mirror of https://github.com/zulip/zulip.git
settings_org: Pass subsection elem to get_subsection_property_elements.
We passed subsection elem to get_subsection_property_elements function in all cases except the one when calling from discard button click handler and we passed the input elem instead in that case. This commit changes the code to pass subsection element directly in the discard button click handler as well such that we can use get_subsection_property_elements function for the stream settings code and do not find the subsection element inside the function.
This commit is contained in:
parent
d00c428c88
commit
e9316499cb
|
@ -169,7 +169,6 @@ function test_submit_settings_form(override, submit_form) {
|
||||||
$invite_to_realm_policy_elem.data = () => "number";
|
$invite_to_realm_policy_elem.data = () => "number";
|
||||||
|
|
||||||
let $subsection_elem = $(`#org-${CSS.escape(subsection)}`);
|
let $subsection_elem = $(`#org-${CSS.escape(subsection)}`);
|
||||||
$subsection_elem.closest = () => $subsection_elem;
|
|
||||||
$subsection_elem.set_find_results(".prop-element", [
|
$subsection_elem.set_find_results(".prop-element", [
|
||||||
$bot_creation_policy_elem,
|
$bot_creation_policy_elem,
|
||||||
$email_address_visibility_elem,
|
$email_address_visibility_elem,
|
||||||
|
@ -207,7 +206,6 @@ function test_submit_settings_form(override, submit_form) {
|
||||||
$realm_default_language_elem.data = () => "string";
|
$realm_default_language_elem.data = () => "string";
|
||||||
|
|
||||||
$subsection_elem = $(`#org-${CSS.escape(subsection)}`);
|
$subsection_elem = $(`#org-${CSS.escape(subsection)}`);
|
||||||
$subsection_elem.closest = () => $subsection_elem;
|
|
||||||
$subsection_elem.set_find_results(".prop-element", [$realm_default_language_elem]);
|
$subsection_elem.set_find_results(".prop-element", [$realm_default_language_elem]);
|
||||||
|
|
||||||
submit_form(ev);
|
submit_form(ev);
|
||||||
|
|
|
@ -197,9 +197,8 @@ export function extract_property_name($elem, for_realm_default_settings) {
|
||||||
return /^id_(.*)$/.exec($elem.attr("id").replace(/-/g, "_"))[1];
|
return /^id_(.*)$/.exec($elem.attr("id").replace(/-/g, "_"))[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_subsection_property_elements(element) {
|
function get_subsection_property_elements(subsection) {
|
||||||
const $subsection = $(element).closest(".org-subsection-parent");
|
return Array.from($(subsection).find(".prop-element"));
|
||||||
return Array.from($subsection.find(".prop-element"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const simple_dropdown_properties = [
|
const simple_dropdown_properties = [
|
||||||
|
@ -957,7 +956,8 @@ export function register_save_discard_widget_handlers(
|
||||||
$container.on("click", ".subsection-header .subsection-changes-discard button", (e) => {
|
$container.on("click", ".subsection-header .subsection-changes-discard button", (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
for (const elem of get_subsection_property_elements(e.target)) {
|
const $subsection = $(e.target).closest(".org-subsection-parent");
|
||||||
|
for (const elem of get_subsection_property_elements($subsection)) {
|
||||||
discard_property_element_changes(elem, for_realm_default_settings);
|
discard_property_element_changes(elem, for_realm_default_settings);
|
||||||
}
|
}
|
||||||
const $save_btn_controls = $(e.target).closest(".save-button-controls");
|
const $save_btn_controls = $(e.target).closest(".save-button-controls");
|
||||||
|
|
Loading…
Reference in New Issue