mirror of https://github.com/zulip/zulip.git
settings: Modify update_save_button_state to use it for other settings.
This commit modifies update_save_button_state such that it can be used for other time-limit settings too.
This commit is contained in:
parent
34f5218cc8
commit
2933f079b8
|
@ -1164,32 +1164,24 @@ 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) {
|
function update_save_button_state(e) {
|
||||||
const edit_limit_value = Number.parseInt(
|
const $subsection_elem = $(e.target).closest(".org-subsection-parent");
|
||||||
$("#id_realm_message_content_edit_limit_minutes").val(),
|
const time_limit_settings = Array.from($subsection_elem.find(".time-limit-setting"));
|
||||||
10,
|
let disable_save_btn = false;
|
||||||
);
|
for (const setting_elem of time_limit_settings) {
|
||||||
const delete_limit_value = Number.parseInt(
|
const dropdown_elem_val = $(setting_elem).find("select").val();
|
||||||
$("#id_realm_message_content_delete_limit_minutes").val(),
|
const custom_input_elem_val = Number.parseInt(
|
||||||
10,
|
$(setting_elem).find(".admin-realm-time-limit-input").val(),
|
||||||
);
|
10,
|
||||||
|
);
|
||||||
|
|
||||||
const msg_edit_limit_dropdown_value = $("#id_realm_msg_edit_limit_setting").val();
|
disable_save_btn =
|
||||||
const edit_limit_custom_value_invalid =
|
dropdown_elem_val === "custom_limit" &&
|
||||||
msg_edit_limit_dropdown_value === "custom_limit" &&
|
(custom_input_elem_val <= 0 || Number.isNaN(custom_input_elem_val));
|
||||||
(edit_limit_value <= 0 || Number.isNaN(edit_limit_value));
|
if (disable_save_btn) {
|
||||||
|
break;
|
||||||
const msg_delete_limit_dropdown_value = $("#id_realm_msg_delete_limit_setting").val();
|
}
|
||||||
const delete_limit_custom_value_invalid =
|
}
|
||||||
msg_delete_limit_dropdown_value === "custom_limit" &&
|
$subsection_elem.find(".subsection-changes-save button").prop("disabled", disable_save_btn);
|
||||||
(delete_limit_value <= 0 || Number.isNaN(delete_limit_value));
|
|
||||||
|
|
||||||
const disable_save_btn =
|
|
||||||
edit_limit_custom_value_invalid || delete_limit_custom_value_invalid;
|
|
||||||
|
|
||||||
$(e.target)
|
|
||||||
.closest(".org-subsection-parent")
|
|
||||||
.find(".subsection-changes-save button")
|
|
||||||
.prop("disabled", disable_save_btn);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$(".org-subsection-parent").on("keydown", "input", (e) => {
|
$(".org-subsection-parent").on("keydown", "input", (e) => {
|
||||||
|
|
|
@ -154,7 +154,7 @@
|
||||||
is_checked=realm_allow_message_editing
|
is_checked=realm_allow_message_editing
|
||||||
label=admin_settings_label.realm_allow_message_editing}}
|
label=admin_settings_label.realm_allow_message_editing}}
|
||||||
|
|
||||||
<div class="input-group">
|
<div class="input-group time-limit-setting">
|
||||||
<label for="realm_msg_edit_limit_setting" class="dropdown-title">{{t "Time limit for editing messages" }}</label>
|
<label for="realm_msg_edit_limit_setting" class="dropdown-title">{{t "Time limit for editing messages" }}</label>
|
||||||
<select name="realm_msg_edit_limit_setting" id="id_realm_msg_edit_limit_setting" class="prop-element" {{#unless realm_allow_message_editing}}disabled{{/unless}}>
|
<select name="realm_msg_edit_limit_setting" id="id_realm_msg_edit_limit_setting" class="prop-element" {{#unless realm_allow_message_editing}}disabled{{/unless}}>
|
||||||
{{#each msg_edit_limit_dropdown_values}}
|
{{#each msg_edit_limit_dropdown_values}}
|
||||||
|
@ -197,7 +197,7 @@
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="input-group">
|
<div class="input-group time-limit-setting">
|
||||||
<label for="realm_msg_delete_limit_setting" class="dropdown-title">
|
<label for="realm_msg_delete_limit_setting" class="dropdown-title">
|
||||||
{{t "Time limit for deleting messages" }}
|
{{t "Time limit for deleting messages" }}
|
||||||
<i class="fa fa-info-circle settings-info-icon tippy-zulip-tooltip"
|
<i class="fa fa-info-circle settings-info-icon tippy-zulip-tooltip"
|
||||||
|
|
Loading…
Reference in New Issue