mirror of https://github.com/zulip/zulip.git
org settings: Refactor the discard changes function.
This extract the logic of resetting the value of a single property element at a time so that we can reuse this for real-time-syncing.
This commit is contained in:
parent
a779fc6095
commit
84a5786b2e
|
@ -492,8 +492,7 @@ function _set_up() {
|
|||
}
|
||||
});
|
||||
|
||||
function discard_subsection_changes(target) {
|
||||
_.each(get_subsection_property_elements(target), function (elem) {
|
||||
function discard_property_element_changes(elem) {
|
||||
elem = $(elem);
|
||||
var property_name = exports.extract_property_name(elem);
|
||||
// Check whether the id refers to a property whose name we can't
|
||||
|
@ -513,13 +512,12 @@ function _set_up() {
|
|||
// Triggering a change event to handle fading and showing of
|
||||
// dependent sub-settings correctly
|
||||
elem.change();
|
||||
});
|
||||
}
|
||||
|
||||
$('.organization').on('click', '.subsection-header .subsection-changes-discard button', function (e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
discard_subsection_changes(e.target);
|
||||
_.each(get_subsection_property_elements(e.target), discard_property_element_changes);
|
||||
var subsection = $(e.target).closest('.org-subsection-parent');
|
||||
var change_process_buttons = subsection.find('.subsection-header .button');
|
||||
change_process_buttons.removeClass('show').addClass('hide');
|
||||
|
|
Loading…
Reference in New Issue