stream settings: Make deactivate stream handler global.

Configure the click event handler for #do_deactivate_stream_button
once to avoid adding click handlers for it more than once.

Fixes #8979
This commit is contained in:
Aastha Gupta 2018-04-06 22:54:14 +05:30 committed by Tim Abbott
parent d1c57df0ca
commit c852185e9d
1 changed files with 17 additions and 15 deletions

View File

@ -183,21 +183,6 @@ exports.set_up = function () {
}); });
}); });
$("#settings_content").on("click", "#do_deactivate_stream_button", function () {
if ($("#deactivation_stream_modal .stream_name").text() !== $(".active_stream_row").find('.stream_name').text()) {
blueslip.error("Stream deactivation canceled due to non-matching fields.");
ui_report.message(i18n.t("Deactivation encountered an error. Please reload and try again."),
$("#home-error"), 'alert-error');
}
overlays.close_modal('deactivation_stream_modal');
$("#deactivation_stream_modal").remove();
$(".active_stream_row button").prop("disabled", true).text(i18n.t("Working…"));
var stream_name = $(".active_stream_row").find('.stream_name').text();
var stream_id = stream_data.get_sub(stream_name).stream_id;
var row = $(".active_stream_row");
exports.delete_stream(stream_id, $("#organization-status"), row);
});
$("#settings_content").on("hide.bs.modal", "#deactivation_stream_modal", function () { $("#settings_content").on("hide.bs.modal", "#deactivation_stream_modal", function () {
$("#deactivation_stream_modal").remove(); $("#deactivation_stream_modal").remove();
}); });
@ -215,6 +200,23 @@ exports.delete_stream = function (stream_id, alert_element, stream_row) {
}); });
}; };
$(function () {
$("#settings_overlay_container").on("click", "#do_deactivate_stream_button", function () {
if ($("#deactivation_stream_modal .stream_name").text() !== $(".active_stream_row").find('.stream_name').text()) {
blueslip.error("Stream deactivation canceled due to non-matching fields.");
ui_report.message(i18n.t("Deactivation encountered an error. Please reload and try again."),
$("#home-error"), 'alert-error');
}
overlays.close_modal('deactivation_stream_modal');
$("#deactivation_stream_modal").remove();
$(".active_stream_row button").prop("disabled", true).text(i18n.t("Working…"));
var stream_name = $(".active_stream_row").find('.stream_name').text();
var stream_id = stream_data.get_sub(stream_name).stream_id;
var row = $(".active_stream_row");
exports.delete_stream(stream_id, $("#organization-status"), row);
});
});
return exports; return exports;
}()); }());