mirror of https://github.com/zulip/zulip.git
org settings: Add real-time syncing for property changes.
This commit is contained in:
parent
315058498b
commit
3e47a9fe22
|
@ -49,6 +49,7 @@ set_global('settings_org', {
|
||||||
reset_realm_default_language: noop,
|
reset_realm_default_language: noop,
|
||||||
update_message_retention_days: noop,
|
update_message_retention_days: noop,
|
||||||
update_realm_description: noop,
|
update_realm_description: noop,
|
||||||
|
sync_realm_settings: noop,
|
||||||
});
|
});
|
||||||
|
|
||||||
set_global('message_edit', {
|
set_global('message_edit', {
|
||||||
|
|
|
@ -67,6 +67,7 @@ exports.dispatch_normal_event = function dispatch_normal_event(event) {
|
||||||
invite_by_admins_only: noop,
|
invite_by_admins_only: noop,
|
||||||
invite_required: noop,
|
invite_required: noop,
|
||||||
mandatory_topics: noop,
|
mandatory_topics: noop,
|
||||||
|
message_content_edit_limit_seconds: noop,
|
||||||
message_retention_days: settings_org.update_message_retention_days,
|
message_retention_days: settings_org.update_message_retention_days,
|
||||||
name: notifications.redraw_title,
|
name: notifications.redraw_title,
|
||||||
name_changes_disabled: settings_account.update_name_change_display,
|
name_changes_disabled: settings_account.update_name_change_display,
|
||||||
|
@ -79,6 +80,7 @@ exports.dispatch_normal_event = function dispatch_normal_event(event) {
|
||||||
if (event.op === 'update' && _.has(realm_settings, event.property)) {
|
if (event.op === 'update' && _.has(realm_settings, event.property)) {
|
||||||
page_params['realm_' + event.property] = event.value;
|
page_params['realm_' + event.property] = event.value;
|
||||||
realm_settings[event.property]();
|
realm_settings[event.property]();
|
||||||
|
settings_org.sync_realm_settings(event.property);
|
||||||
if (event.property === 'create_stream_by_admins_only') {
|
if (event.property === 'create_stream_by_admins_only') {
|
||||||
if (!page_params.is_admin) {
|
if (!page_params.is_admin) {
|
||||||
page_params.can_create_streams = (!page_params.
|
page_params.can_create_streams = (!page_params.
|
||||||
|
@ -101,6 +103,9 @@ exports.dispatch_normal_event = function dispatch_normal_event(event) {
|
||||||
if (key === 'allow_message_editing') {
|
if (key === 'allow_message_editing') {
|
||||||
message_edit.update_message_topic_editing_pencil();
|
message_edit.update_message_topic_editing_pencil();
|
||||||
}
|
}
|
||||||
|
if (_.has(realm_settings, key)) {
|
||||||
|
settings_org.sync_realm_settings(key);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
if (event.data.authentication_methods !== undefined) {
|
if (event.data.authentication_methods !== undefined) {
|
||||||
settings_org.populate_auth_methods(event.data.authentication_methods);
|
settings_org.populate_auth_methods(event.data.authentication_methods);
|
||||||
|
|
|
@ -679,6 +679,25 @@ function _set_up() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
exports.sync_realm_settings = function (property) {
|
||||||
|
if (!overlays.settings_open()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (property === 'message_content_edit_limit_seconds') {
|
||||||
|
property = 'message_content_edit_limit_minutes';
|
||||||
|
} else if (property === 'create_stream_by_admins_only' || property === 'waiting_period_threshold') {
|
||||||
|
// We use this path for `waiting_period_threshold` property because we
|
||||||
|
// don't get both 'create_stream_by_admins_only' and 'waiting_period_threshold'
|
||||||
|
// in the same event to determine the value of dropdown.
|
||||||
|
property = 'create_stream_permission';
|
||||||
|
}
|
||||||
|
var element = $('#id_realm_'+property);
|
||||||
|
if (element.length) {
|
||||||
|
discard_property_element_changes(element);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
$(".organization form.org-profile-form").off('submit').on('submit', function (e) {
|
$(".organization form.org-profile-form").off('submit').on('submit', function (e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
|
|
Loading…
Reference in New Issue