mirror of https://github.com/zulip/zulip.git
settings_org: Move update_save_button_state function to module level.
We would use update_save_button_state for realm-level default of notification batching setting also in further commits.
This commit is contained in:
parent
2933f079b8
commit
25223539d1
|
@ -888,6 +888,27 @@ export function init_dropdown_widgets() {
|
||||||
default_code_language_widget.setup();
|
default_code_language_widget.setup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function update_save_button_state(e) {
|
||||||
|
const $subsection_elem = $(e.target).closest(".org-subsection-parent");
|
||||||
|
const time_limit_settings = Array.from($subsection_elem.find(".time-limit-setting"));
|
||||||
|
let disable_save_btn = false;
|
||||||
|
for (const setting_elem of time_limit_settings) {
|
||||||
|
const dropdown_elem_val = $(setting_elem).find("select").val();
|
||||||
|
const custom_input_elem_val = Number.parseInt(
|
||||||
|
$(setting_elem).find(".admin-realm-time-limit-input").val(),
|
||||||
|
10,
|
||||||
|
);
|
||||||
|
|
||||||
|
disable_save_btn =
|
||||||
|
dropdown_elem_val === "custom_limit" &&
|
||||||
|
(custom_input_elem_val <= 0 || Number.isNaN(custom_input_elem_val));
|
||||||
|
if (disable_save_btn) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$subsection_elem.find(".subsection-changes-save button").prop("disabled", disable_save_btn);
|
||||||
|
}
|
||||||
|
|
||||||
export function register_save_discard_widget_handlers(
|
export function register_save_discard_widget_handlers(
|
||||||
$container,
|
$container,
|
||||||
patch_url,
|
patch_url,
|
||||||
|
@ -1163,27 +1184,6 @@ export function build_page() {
|
||||||
|
|
||||||
register_save_discard_widget_handlers($(".admin-realm-form"), "/json/realm", false);
|
register_save_discard_widget_handlers($(".admin-realm-form"), "/json/realm", false);
|
||||||
|
|
||||||
function update_save_button_state(e) {
|
|
||||||
const $subsection_elem = $(e.target).closest(".org-subsection-parent");
|
|
||||||
const time_limit_settings = Array.from($subsection_elem.find(".time-limit-setting"));
|
|
||||||
let disable_save_btn = false;
|
|
||||||
for (const setting_elem of time_limit_settings) {
|
|
||||||
const dropdown_elem_val = $(setting_elem).find("select").val();
|
|
||||||
const custom_input_elem_val = Number.parseInt(
|
|
||||||
$(setting_elem).find(".admin-realm-time-limit-input").val(),
|
|
||||||
10,
|
|
||||||
);
|
|
||||||
|
|
||||||
disable_save_btn =
|
|
||||||
dropdown_elem_val === "custom_limit" &&
|
|
||||||
(custom_input_elem_val <= 0 || Number.isNaN(custom_input_elem_val));
|
|
||||||
if (disable_save_btn) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$subsection_elem.find(".subsection-changes-save button").prop("disabled", disable_save_btn);
|
|
||||||
}
|
|
||||||
|
|
||||||
$(".org-subsection-parent").on("keydown", "input", (e) => {
|
$(".org-subsection-parent").on("keydown", "input", (e) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
if (e.key === "Enter") {
|
if (e.key === "Enter") {
|
||||||
|
|
Loading…
Reference in New Issue