|
|
|
@ -1,29 +1,30 @@
|
|
|
|
|
"use strict";
|
|
|
|
|
import pygments_data from "../generated/pygments_data.json";
|
|
|
|
|
import render_settings_admin_auth_methods_list from "../templates/settings/admin_auth_methods_list.hbs";
|
|
|
|
|
import render_settings_admin_realm_domains_list from "../templates/settings/admin_realm_domains_list.hbs";
|
|
|
|
|
|
|
|
|
|
const pygments_data = require("../generated/pygments_data.json");
|
|
|
|
|
const render_settings_admin_auth_methods_list = require("../templates/settings/admin_auth_methods_list.hbs");
|
|
|
|
|
const render_settings_admin_realm_domains_list = require("../templates/settings/admin_realm_domains_list.hbs");
|
|
|
|
|
import * as channel from "./channel";
|
|
|
|
|
import * as loading from "./loading";
|
|
|
|
|
import * as overlays from "./overlays";
|
|
|
|
|
import * as realm_icon from "./realm_icon";
|
|
|
|
|
import * as realm_logo from "./realm_logo";
|
|
|
|
|
import * as settings_config from "./settings_config";
|
|
|
|
|
import * as settings_notifications from "./settings_notifications";
|
|
|
|
|
import * as settings_ui from "./settings_ui";
|
|
|
|
|
import * as stream_data from "./stream_data";
|
|
|
|
|
import * as ui_report from "./ui_report";
|
|
|
|
|
|
|
|
|
|
const channel = require("./channel");
|
|
|
|
|
const loading = require("./loading");
|
|
|
|
|
const overlays = require("./overlays");
|
|
|
|
|
const realm_icon = require("./realm_icon");
|
|
|
|
|
const realm_logo = require("./realm_logo");
|
|
|
|
|
const settings_config = require("./settings_config");
|
|
|
|
|
const settings_notifications = require("./settings_notifications");
|
|
|
|
|
const settings_ui = require("./settings_ui");
|
|
|
|
|
const stream_data = require("./stream_data");
|
|
|
|
|
const ui_report = require("./ui_report");
|
|
|
|
|
export let parse_time_limit;
|
|
|
|
|
export let save_organization_settings;
|
|
|
|
|
|
|
|
|
|
const meta = {
|
|
|
|
|
loaded: false,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
exports.reset = function () {
|
|
|
|
|
export function reset() {
|
|
|
|
|
meta.loaded = false;
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
exports.maybe_disable_widgets = function () {
|
|
|
|
|
export function maybe_disable_widgets() {
|
|
|
|
|
if (page_params.is_owner) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
@ -57,9 +58,9 @@ exports.maybe_disable_widgets = function () {
|
|
|
|
|
$(".organization-box [data-name='organization-permissions']")
|
|
|
|
|
.find(".control-label-disabled")
|
|
|
|
|
.addClass("enabled");
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
exports.get_sorted_options_list = function (option_values_object) {
|
|
|
|
|
export function get_sorted_options_list(option_values_object) {
|
|
|
|
|
const options_list = Object.keys(option_values_object).map((key) => ({
|
|
|
|
|
...option_values_object[key],
|
|
|
|
|
key,
|
|
|
|
@ -80,45 +81,43 @@ exports.get_sorted_options_list = function (option_values_object) {
|
|
|
|
|
}
|
|
|
|
|
options_list.sort(comparator);
|
|
|
|
|
return options_list;
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
exports.get_organization_settings_options = () => {
|
|
|
|
|
export function get_organization_settings_options() {
|
|
|
|
|
const options = {};
|
|
|
|
|
options.create_stream_policy_values = exports.get_sorted_options_list(
|
|
|
|
|
options.create_stream_policy_values = get_sorted_options_list(
|
|
|
|
|
settings_config.create_stream_policy_values,
|
|
|
|
|
);
|
|
|
|
|
options.invite_to_stream_policy_values = exports.get_sorted_options_list(
|
|
|
|
|
options.invite_to_stream_policy_values = get_sorted_options_list(
|
|
|
|
|
settings_config.invite_to_stream_policy_values,
|
|
|
|
|
);
|
|
|
|
|
options.user_group_edit_policy_values = exports.get_sorted_options_list(
|
|
|
|
|
options.user_group_edit_policy_values = get_sorted_options_list(
|
|
|
|
|
settings_config.user_group_edit_policy_values,
|
|
|
|
|
);
|
|
|
|
|
options.private_message_policy_values = exports.get_sorted_options_list(
|
|
|
|
|
options.private_message_policy_values = get_sorted_options_list(
|
|
|
|
|
settings_config.private_message_policy_values,
|
|
|
|
|
);
|
|
|
|
|
options.wildcard_mention_policy_values = exports.get_sorted_options_list(
|
|
|
|
|
options.wildcard_mention_policy_values = get_sorted_options_list(
|
|
|
|
|
settings_config.wildcard_mention_policy_values,
|
|
|
|
|
);
|
|
|
|
|
return options;
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
exports.get_realm_time_limits_in_minutes = function (property) {
|
|
|
|
|
export function get_realm_time_limits_in_minutes(property) {
|
|
|
|
|
let val = (page_params[property] / 60).toFixed(1);
|
|
|
|
|
if (Number.parseFloat(val, 10) === Number.parseInt(val, 10)) {
|
|
|
|
|
val = Number.parseInt(val, 10);
|
|
|
|
|
}
|
|
|
|
|
return val.toString();
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function get_property_value(property_name) {
|
|
|
|
|
if (property_name === "realm_message_content_edit_limit_minutes") {
|
|
|
|
|
return exports.get_realm_time_limits_in_minutes("realm_message_content_edit_limit_seconds");
|
|
|
|
|
return get_realm_time_limits_in_minutes("realm_message_content_edit_limit_seconds");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (property_name === "realm_message_content_delete_limit_minutes") {
|
|
|
|
|
return exports.get_realm_time_limits_in_minutes(
|
|
|
|
|
"realm_message_content_delete_limit_seconds",
|
|
|
|
|
);
|
|
|
|
|
return get_realm_time_limits_in_minutes("realm_message_content_delete_limit_seconds");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (property_name === "realm_waiting_period_setting") {
|
|
|
|
@ -199,9 +198,9 @@ function get_property_value(property_name) {
|
|
|
|
|
return page_params[property_name];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
exports.extract_property_name = function (elem) {
|
|
|
|
|
export function extract_property_name(elem) {
|
|
|
|
|
return elem.attr("id").split("-").join("_").replace("id_", "");
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function get_subsection_property_elements(element) {
|
|
|
|
|
const subsection = $(element).closest(".org-subsection-parent");
|
|
|
|
@ -306,7 +305,7 @@ function set_digest_emails_weekday_visibility() {
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
exports.populate_realm_domains = function (realm_domains) {
|
|
|
|
|
export function populate_realm_domains(realm_domains) {
|
|
|
|
|
if (!meta.loaded) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
@ -330,7 +329,8 @@ exports.populate_realm_domains = function (realm_domains) {
|
|
|
|
|
}),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function sort_object_by_key(obj) {
|
|
|
|
|
const keys = Object.keys(obj).sort();
|
|
|
|
|
const new_obj = {};
|
|
|
|
@ -341,7 +341,8 @@ function sort_object_by_key(obj) {
|
|
|
|
|
|
|
|
|
|
return new_obj;
|
|
|
|
|
}
|
|
|
|
|
exports.populate_auth_methods = function (auth_methods) {
|
|
|
|
|
|
|
|
|
|
export function populate_auth_methods(auth_methods) {
|
|
|
|
|
if (!meta.loaded) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
@ -356,7 +357,7 @@ exports.populate_auth_methods = function (auth_methods) {
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
auth_methods_table.html(rendered_auth_method_rows);
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function update_dependent_subsettings(property_name) {
|
|
|
|
|
if (simple_dropdown_properties.includes(property_name)) {
|
|
|
|
@ -390,25 +391,25 @@ function update_dependent_subsettings(property_name) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
exports.default_code_language_widget = null;
|
|
|
|
|
exports.notifications_stream_widget = null;
|
|
|
|
|
exports.signup_notifications_stream_widget = null;
|
|
|
|
|
export let default_code_language_widget = null;
|
|
|
|
|
export let notifications_stream_widget = null;
|
|
|
|
|
export let signup_notifications_stream_widget = null;
|
|
|
|
|
|
|
|
|
|
function discard_property_element_changes(elem) {
|
|
|
|
|
elem = $(elem);
|
|
|
|
|
const property_name = exports.extract_property_name(elem);
|
|
|
|
|
const property_name = extract_property_name(elem);
|
|
|
|
|
const property_value = get_property_value(property_name);
|
|
|
|
|
|
|
|
|
|
if (property_name === "realm_authentication_methods") {
|
|
|
|
|
exports.populate_auth_methods(property_value);
|
|
|
|
|
populate_auth_methods(property_value);
|
|
|
|
|
} else if (property_name === "realm_notifications_stream_id") {
|
|
|
|
|
exports.notifications_stream_widget.render(property_value);
|
|
|
|
|
notifications_stream_widget.render(property_value);
|
|
|
|
|
} else if (property_name === "realm_signup_notifications_stream_id") {
|
|
|
|
|
exports.signup_notifications_stream_widget.render(property_value);
|
|
|
|
|
signup_notifications_stream_widget.render(property_value);
|
|
|
|
|
} else if (property_name === "realm_default_code_block_language") {
|
|
|
|
|
exports.default_code_language_widget.render(property_value);
|
|
|
|
|
default_code_language_widget.render(property_value);
|
|
|
|
|
} else if (property_value !== undefined) {
|
|
|
|
|
exports.set_input_element_value(elem, property_value);
|
|
|
|
|
set_input_element_value(elem, property_value);
|
|
|
|
|
} else {
|
|
|
|
|
blueslip.error("Element refers to unknown property " + property_name);
|
|
|
|
|
}
|
|
|
|
@ -416,18 +417,18 @@ function discard_property_element_changes(elem) {
|
|
|
|
|
update_dependent_subsettings(property_name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
exports.sync_realm_settings = function (property) {
|
|
|
|
|
export function sync_realm_settings(property) {
|
|
|
|
|
if (!overlays.settings_open()) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const value = page_params[`realm_${property}`];
|
|
|
|
|
if (property === "notifications_stream_id") {
|
|
|
|
|
exports.notifications_stream_widget.render(value);
|
|
|
|
|
notifications_stream_widget.render(value);
|
|
|
|
|
} else if (property === "signup_notifications_stream_id") {
|
|
|
|
|
exports.signup_notifications_stream_widget.render(value);
|
|
|
|
|
signup_notifications_stream_widget.render(value);
|
|
|
|
|
} else if (property === "default_code_block_language") {
|
|
|
|
|
exports.default_code_language_widget.render(value);
|
|
|
|
|
default_code_language_widget.render(value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (property === "message_content_edit_limit_seconds") {
|
|
|
|
@ -450,9 +451,9 @@ exports.sync_realm_settings = function (property) {
|
|
|
|
|
if (element.length) {
|
|
|
|
|
discard_property_element_changes(element);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
exports.change_save_button_state = function ($element, state) {
|
|
|
|
|
export function change_save_button_state($element, state) {
|
|
|
|
|
function show_hide_element($element, show, fadeout_delay) {
|
|
|
|
|
if (show) {
|
|
|
|
|
$element.removeClass("hide").addClass(".show").fadeIn(300);
|
|
|
|
@ -508,7 +509,7 @@ exports.change_save_button_state = function ($element, state) {
|
|
|
|
|
$textEl.text(button_text);
|
|
|
|
|
$saveBtn.attr("data-status", data_status);
|
|
|
|
|
show_hide_element($element, is_show, 800);
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function get_input_type(input_elem, input_type) {
|
|
|
|
|
if (["boolean", "string", "number"].includes(input_type)) {
|
|
|
|
@ -517,7 +518,7 @@ function get_input_type(input_elem, input_type) {
|
|
|
|
|
return input_elem.data("setting-widget-type");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
exports.get_input_element_value = function (input_elem, input_type) {
|
|
|
|
|
export function get_input_element_value(input_elem, input_type) {
|
|
|
|
|
input_elem = $(input_elem);
|
|
|
|
|
input_type = get_input_type(input_elem, input_type);
|
|
|
|
|
if (input_type) {
|
|
|
|
@ -532,9 +533,9 @@ exports.get_input_element_value = function (input_elem, input_type) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return undefined;
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
exports.set_input_element_value = function (input_elem, value) {
|
|
|
|
|
export function set_input_element_value(input_elem, value) {
|
|
|
|
|
const input_type = get_input_type(input_elem, typeof value);
|
|
|
|
|
if (input_type) {
|
|
|
|
|
if (input_type === "boolean") {
|
|
|
|
@ -544,14 +545,14 @@ exports.set_input_element_value = function (input_elem, value) {
|
|
|
|
|
return input_elem.val(value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
blueslip.error(`Failed to set value of property ${exports.extract_property_name(input_elem)}`);
|
|
|
|
|
blueslip.error(`Failed to set value of property ${extract_property_name(input_elem)}`);
|
|
|
|
|
return undefined;
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
exports.set_up = function () {
|
|
|
|
|
exports.build_page();
|
|
|
|
|
exports.maybe_disable_widgets();
|
|
|
|
|
};
|
|
|
|
|
export function set_up() {
|
|
|
|
|
build_page();
|
|
|
|
|
maybe_disable_widgets();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function get_auth_method_table_data() {
|
|
|
|
|
const new_auth_methods = {};
|
|
|
|
@ -568,7 +569,7 @@ function get_auth_method_table_data() {
|
|
|
|
|
|
|
|
|
|
function check_property_changed(elem) {
|
|
|
|
|
elem = $(elem);
|
|
|
|
|
const property_name = exports.extract_property_name(elem);
|
|
|
|
|
const property_name = extract_property_name(elem);
|
|
|
|
|
let current_val = get_property_value(property_name);
|
|
|
|
|
let changed_val;
|
|
|
|
|
|
|
|
|
@ -578,20 +579,20 @@ function check_property_changed(elem) {
|
|
|
|
|
changed_val = get_auth_method_table_data();
|
|
|
|
|
changed_val = JSON.stringify(changed_val);
|
|
|
|
|
} else if (property_name === "realm_notifications_stream_id") {
|
|
|
|
|
changed_val = Number.parseInt(exports.notifications_stream_widget.value(), 10);
|
|
|
|
|
changed_val = Number.parseInt(notifications_stream_widget.value(), 10);
|
|
|
|
|
} else if (property_name === "realm_signup_notifications_stream_id") {
|
|
|
|
|
changed_val = Number.parseInt(exports.signup_notifications_stream_widget.value(), 10);
|
|
|
|
|
changed_val = Number.parseInt(signup_notifications_stream_widget.value(), 10);
|
|
|
|
|
} else if (property_name === "realm_default_code_block_language") {
|
|
|
|
|
changed_val = exports.default_code_language_widget.value();
|
|
|
|
|
changed_val = default_code_language_widget.value();
|
|
|
|
|
} else if (current_val !== undefined) {
|
|
|
|
|
changed_val = exports.get_input_element_value(elem, typeof current_val);
|
|
|
|
|
changed_val = get_input_element_value(elem, typeof current_val);
|
|
|
|
|
} else {
|
|
|
|
|
blueslip.error("Element refers to unknown property " + property_name);
|
|
|
|
|
}
|
|
|
|
|
return current_val !== changed_val;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
exports.save_discard_widget_status_handler = (subsection) => {
|
|
|
|
|
export function save_discard_widget_status_handler(subsection) {
|
|
|
|
|
subsection.find(".subsection-failed-status p").hide();
|
|
|
|
|
subsection.find(".save-button").show();
|
|
|
|
|
const properties_elements = get_subsection_property_elements(subsection);
|
|
|
|
@ -601,10 +602,10 @@ exports.save_discard_widget_status_handler = (subsection) => {
|
|
|
|
|
|
|
|
|
|
const save_btn_controls = subsection.find(".subsection-header .save-button-controls");
|
|
|
|
|
const button_state = show_change_process_button ? "unsaved" : "discarded";
|
|
|
|
|
exports.change_save_button_state(save_btn_controls, button_state);
|
|
|
|
|
};
|
|
|
|
|
change_save_button_state(save_btn_controls, button_state);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
exports.init_dropdown_widgets = () => {
|
|
|
|
|
export function init_dropdown_widgets() {
|
|
|
|
|
const streams = stream_data.get_streams_for_settings_page();
|
|
|
|
|
const notification_stream_options = {
|
|
|
|
|
data: streams.map((x) => ({
|
|
|
|
@ -612,23 +613,23 @@ exports.init_dropdown_widgets = () => {
|
|
|
|
|
value: x.stream_id.toString(),
|
|
|
|
|
})),
|
|
|
|
|
on_update: () => {
|
|
|
|
|
exports.save_discard_widget_status_handler($("#org-notifications"));
|
|
|
|
|
save_discard_widget_status_handler($("#org-notifications"));
|
|
|
|
|
},
|
|
|
|
|
default_text: i18n.t("Disabled"),
|
|
|
|
|
render_text: (x) => `#${x}`,
|
|
|
|
|
null_value: -1,
|
|
|
|
|
};
|
|
|
|
|
exports.notifications_stream_widget = dropdown_list_widget({
|
|
|
|
|
notifications_stream_widget = dropdown_list_widget({
|
|
|
|
|
widget_name: "realm_notifications_stream_id",
|
|
|
|
|
value: page_params.realm_notifications_stream_id,
|
|
|
|
|
...notification_stream_options,
|
|
|
|
|
});
|
|
|
|
|
exports.signup_notifications_stream_widget = dropdown_list_widget({
|
|
|
|
|
signup_notifications_stream_widget = dropdown_list_widget({
|
|
|
|
|
widget_name: "realm_signup_notifications_stream_id",
|
|
|
|
|
value: page_params.realm_signup_notifications_stream_id,
|
|
|
|
|
...notification_stream_options,
|
|
|
|
|
});
|
|
|
|
|
exports.default_code_language_widget = dropdown_list_widget({
|
|
|
|
|
default_code_language_widget = dropdown_list_widget({
|
|
|
|
|
widget_name: "realm_default_code_block_language",
|
|
|
|
|
data: Object.keys(pygments_data.langs).map((x) => ({
|
|
|
|
|
name: x,
|
|
|
|
@ -636,24 +637,24 @@ exports.init_dropdown_widgets = () => {
|
|
|
|
|
})),
|
|
|
|
|
value: page_params.realm_default_code_block_language,
|
|
|
|
|
on_update: () => {
|
|
|
|
|
exports.save_discard_widget_status_handler($("#org-other-settings"));
|
|
|
|
|
save_discard_widget_status_handler($("#org-other-settings"));
|
|
|
|
|
},
|
|
|
|
|
default_text: i18n.t("No language set"),
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
exports.build_page = function () {
|
|
|
|
|
export function build_page() {
|
|
|
|
|
meta.loaded = true;
|
|
|
|
|
|
|
|
|
|
loading.make_indicator($("#admin_page_auth_methods_loading_indicator"));
|
|
|
|
|
|
|
|
|
|
// Initialize all the dropdown list widgets.
|
|
|
|
|
exports.init_dropdown_widgets();
|
|
|
|
|
init_dropdown_widgets();
|
|
|
|
|
// Populate realm domains
|
|
|
|
|
exports.populate_realm_domains(page_params.realm_domains);
|
|
|
|
|
populate_realm_domains(page_params.realm_domains);
|
|
|
|
|
|
|
|
|
|
// Populate authentication methods table
|
|
|
|
|
exports.populate_auth_methods(page_params.realm_authentication_methods);
|
|
|
|
|
populate_auth_methods(page_params.realm_authentication_methods);
|
|
|
|
|
|
|
|
|
|
for (const property_name of simple_dropdown_properties) {
|
|
|
|
|
set_property_dropdown_value(property_name);
|
|
|
|
@ -687,7 +688,7 @@ exports.build_page = function () {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const subsection = $(e.target).closest(".org-subsection-parent");
|
|
|
|
|
exports.save_discard_widget_status_handler(subsection);
|
|
|
|
|
save_discard_widget_status_handler(subsection);
|
|
|
|
|
return undefined;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
@ -701,31 +702,31 @@ exports.build_page = function () {
|
|
|
|
|
discard_property_element_changes(elem);
|
|
|
|
|
}
|
|
|
|
|
const save_btn_controls = $(e.target).closest(".save-button-controls");
|
|
|
|
|
exports.change_save_button_state(save_btn_controls, "discarded");
|
|
|
|
|
change_save_button_state(save_btn_controls, "discarded");
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
exports.save_organization_settings = function (data, save_button) {
|
|
|
|
|
save_organization_settings = function (data, save_button) {
|
|
|
|
|
const subsection_parent = save_button.closest(".org-subsection-parent");
|
|
|
|
|
const save_btn_container = subsection_parent.find(".save-button-controls");
|
|
|
|
|
const failed_alert_elem = subsection_parent.find(".subsection-failed-status p");
|
|
|
|
|
exports.change_save_button_state(save_btn_container, "saving");
|
|
|
|
|
change_save_button_state(save_btn_container, "saving");
|
|
|
|
|
channel.patch({
|
|
|
|
|
url: "/json/realm",
|
|
|
|
|
data,
|
|
|
|
|
success() {
|
|
|
|
|
failed_alert_elem.hide();
|
|
|
|
|
exports.change_save_button_state(save_btn_container, "succeeded");
|
|
|
|
|
change_save_button_state(save_btn_container, "succeeded");
|
|
|
|
|
},
|
|
|
|
|
error(xhr) {
|
|
|
|
|
exports.change_save_button_state(save_btn_container, "failed");
|
|
|
|
|
change_save_button_state(save_btn_container, "failed");
|
|
|
|
|
save_button.hide();
|
|
|
|
|
ui_report.error(i18n.t("Save failed"), xhr, failed_alert_elem);
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
exports.parse_time_limit = function parse_time_limit(elem) {
|
|
|
|
|
parse_time_limit = function parse_time_limit(elem) {
|
|
|
|
|
return Math.floor(Number.parseFloat(elem.val(), 10).toFixed(1) * 60);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
@ -737,7 +738,7 @@ exports.build_page = function () {
|
|
|
|
|
if (edit_limit_setting_value === "never") {
|
|
|
|
|
data.allow_message_editing = false;
|
|
|
|
|
} else if (edit_limit_setting_value === "custom_limit") {
|
|
|
|
|
data.message_content_edit_limit_seconds = exports.parse_time_limit(
|
|
|
|
|
data.message_content_edit_limit_seconds = parse_time_limit(
|
|
|
|
|
$("#id_realm_message_content_edit_limit_minutes"),
|
|
|
|
|
);
|
|
|
|
|
// Disable editing if the parsed time limit is 0 seconds
|
|
|
|
@ -752,7 +753,7 @@ exports.build_page = function () {
|
|
|
|
|
if (delete_limit_setting_value === "never") {
|
|
|
|
|
data.allow_message_deleting = false;
|
|
|
|
|
} else if (delete_limit_setting_value === "custom_limit") {
|
|
|
|
|
data.message_content_delete_limit_seconds = exports.parse_time_limit(
|
|
|
|
|
data.message_content_delete_limit_seconds = parse_time_limit(
|
|
|
|
|
$("#id_realm_message_content_delete_limit_minutes"),
|
|
|
|
|
);
|
|
|
|
|
// Disable deleting if the parsed time limit is 0 seconds
|
|
|
|
@ -765,10 +766,10 @@ exports.build_page = function () {
|
|
|
|
|
}
|
|
|
|
|
} else if (subsection === "notifications") {
|
|
|
|
|
data.notifications_stream_id = JSON.stringify(
|
|
|
|
|
Number.parseInt(exports.notifications_stream_widget.value(), 10),
|
|
|
|
|
Number.parseInt(notifications_stream_widget.value(), 10),
|
|
|
|
|
);
|
|
|
|
|
data.signup_notifications_stream_id = JSON.stringify(
|
|
|
|
|
Number.parseInt(exports.signup_notifications_stream_widget.value(), 10),
|
|
|
|
|
Number.parseInt(signup_notifications_stream_widget.value(), 10),
|
|
|
|
|
);
|
|
|
|
|
} else if (subsection === "message_retention") {
|
|
|
|
|
const message_retention_setting_value = $("#id_realm_message_retention_setting").val();
|
|
|
|
@ -776,11 +777,11 @@ exports.build_page = function () {
|
|
|
|
|
data.message_retention_days = JSON.stringify("forever");
|
|
|
|
|
} else {
|
|
|
|
|
data.message_retention_days = JSON.stringify(
|
|
|
|
|
exports.get_input_element_value($("#id_realm_message_retention_days")),
|
|
|
|
|
get_input_element_value($("#id_realm_message_retention_days")),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
} else if (subsection === "other_settings") {
|
|
|
|
|
const code_block_language_value = exports.default_code_language_widget.value();
|
|
|
|
|
const code_block_language_value = default_code_language_widget.value();
|
|
|
|
|
data.default_code_block_language = JSON.stringify(code_block_language_value);
|
|
|
|
|
} else if (subsection === "other_permissions") {
|
|
|
|
|
const add_emoji_permission = $("#id_realm_add_emoji_by_admins_only").val();
|
|
|
|
@ -845,7 +846,7 @@ exports.build_page = function () {
|
|
|
|
|
for (let input_elem of properties_elements) {
|
|
|
|
|
input_elem = $(input_elem);
|
|
|
|
|
if (check_property_changed(input_elem)) {
|
|
|
|
|
const input_value = exports.get_input_element_value(input_elem);
|
|
|
|
|
const input_value = get_input_element_value(input_elem);
|
|
|
|
|
if (input_value !== undefined) {
|
|
|
|
|
const property_name = input_elem.attr("id").replace("id_realm_", "");
|
|
|
|
|
data[property_name] = JSON.stringify(input_value);
|
|
|
|
@ -868,7 +869,7 @@ exports.build_page = function () {
|
|
|
|
|
...populate_data_for_request(subsection_elem),
|
|
|
|
|
...get_complete_data_for_subsection(subsection),
|
|
|
|
|
};
|
|
|
|
|
exports.save_organization_settings(data, save_button);
|
|
|
|
|
save_organization_settings(data, save_button);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$(".org-subsection-parent").on("keydown", "input", (e) => {
|
|
|
|
@ -1109,6 +1110,4 @@ exports.build_page = function () {
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
window.settings_org = exports;
|
|
|
|
|
}
|
|
|
|
|