settings_org: Add patch_url parameter to save_organization_settings.

This commit adds patch_url parameter to save_organization_settings
function such that we can use the same function for realm-level
defaults section also as those settings are updated using different
endpoint.
This commit is contained in:
Sahil Batra 2021-09-29 14:55:28 +05:30 committed by Tim Abbott
parent 4e14a98772
commit 774026396b
1 changed files with 3 additions and 3 deletions

View File

@ -560,13 +560,13 @@ export function change_save_button_state($element, state) {
show_hide_element($element, is_show, 800); show_hide_element($element, is_show, 800);
} }
export function save_organization_settings(data, save_button) { export function save_organization_settings(data, save_button, patch_url) {
const subsection_parent = save_button.closest(".org-subsection-parent"); const subsection_parent = save_button.closest(".org-subsection-parent");
const save_btn_container = subsection_parent.find(".save-button-controls"); const save_btn_container = subsection_parent.find(".save-button-controls");
const failed_alert_elem = subsection_parent.find(".subsection-failed-status p"); const failed_alert_elem = subsection_parent.find(".subsection-failed-status p");
change_save_button_state(save_btn_container, "saving"); change_save_button_state(save_btn_container, "saving");
channel.patch({ channel.patch({
url: "/json/realm", url: patch_url,
data, data,
success() { success() {
failed_alert_elem.hide(); failed_alert_elem.hide();
@ -926,7 +926,7 @@ export function build_page() {
...populate_data_for_request(subsection_elem), ...populate_data_for_request(subsection_elem),
...get_complete_data_for_subsection(subsection), ...get_complete_data_for_subsection(subsection),
}; };
save_organization_settings(data, save_button); save_organization_settings(data, save_button, "/json/realm");
}); });
$(".org-subsection-parent").on("keydown", "input", (e) => { $(".org-subsection-parent").on("keydown", "input", (e) => {