2013-08-12 23:31:23 +02:00
|
|
|
var admin = (function () {
|
|
|
|
|
|
|
|
var exports = {};
|
|
|
|
|
2014-01-22 01:43:11 +01:00
|
|
|
exports.show_or_hide_menu_item = function () {
|
|
|
|
var item = $('.admin-menu-item').expectOne();
|
|
|
|
if (page_params.is_admin) {
|
2017-04-10 23:17:31 +02:00
|
|
|
item.find("span").text(i18n.t("Manage organization"));
|
2014-01-22 01:43:11 +01:00
|
|
|
} else {
|
2017-04-10 23:17:31 +02:00
|
|
|
item.find("span").text(i18n.t("Organization settings"));
|
2017-04-07 21:39:58 +02:00
|
|
|
$(".organization-box [data-name='organization-settings']")
|
2017-05-12 23:03:47 +02:00
|
|
|
.find("input, textarea, button, select").attr("disabled", true);
|
2017-05-18 14:06:57 +02:00
|
|
|
$(".organization-box [data-name='organization-permissions']")
|
|
|
|
.find("input, textarea, button, select").attr("disabled", true);
|
2017-04-08 23:16:25 +02:00
|
|
|
$(".organization-box [data-name='auth-methods']")
|
|
|
|
.find("input, button, select, checked").attr("disabled", true);
|
2017-04-14 23:08:22 +02:00
|
|
|
$(".organization-box [data-name='default-streams-list']")
|
2017-05-15 19:12:04 +02:00
|
|
|
.find("input:not(.search), button, select").attr("disabled", true);
|
2017-04-14 23:56:33 +02:00
|
|
|
$(".organization-box [data-name='filter-settings']")
|
|
|
|
.find("input, button, select").attr("disabled", true);
|
2017-05-15 19:12:04 +02:00
|
|
|
$(".control-label-disabled").css("color", "#333333");
|
2014-01-22 01:43:11 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2016-06-10 09:03:36 +02:00
|
|
|
function _setup_page() {
|
2015-08-20 02:38:32 +02:00
|
|
|
var options = {
|
2016-07-28 06:17:31 +02:00
|
|
|
realm_name: page_params.realm_name,
|
2017-03-18 20:19:44 +01:00
|
|
|
realm_description: page_params.realm_description,
|
2015-08-20 02:38:32 +02:00
|
|
|
realm_restricted_to_domain: page_params.realm_restricted_to_domain,
|
2016-07-28 06:17:31 +02:00
|
|
|
realm_invite_required: page_params.realm_invite_required,
|
2016-05-12 10:28:00 +02:00
|
|
|
realm_invite_by_admins_only: page_params.realm_invite_by_admins_only,
|
2017-03-13 14:42:03 +01:00
|
|
|
realm_inline_image_preview: page_params.realm_inline_image_preview,
|
|
|
|
server_inline_image_preview: page_params.server_inline_image_preview,
|
|
|
|
realm_inline_url_embed_preview: page_params.realm_inline_url_embed_preview,
|
|
|
|
server_inline_url_embed_preview: page_params.server_inline_url_embed_preview,
|
2016-11-02 21:51:56 +01:00
|
|
|
realm_authentication_methods: page_params.realm_authentication_methods,
|
2016-06-21 21:34:41 +02:00
|
|
|
realm_create_stream_by_admins_only: page_params.realm_create_stream_by_admins_only,
|
2017-03-13 18:33:49 +01:00
|
|
|
realm_name_changes_disabled: page_params.realm_name_changes_disabled,
|
2017-03-04 06:39:45 +01:00
|
|
|
realm_email_changes_disabled: page_params.realm_email_changes_disabled,
|
2016-12-20 15:41:30 +01:00
|
|
|
realm_add_emoji_by_admins_only: page_params.realm_add_emoji_by_admins_only,
|
2016-07-08 02:25:55 +02:00
|
|
|
realm_allow_message_editing: page_params.realm_allow_message_editing,
|
2016-12-02 15:16:33 +01:00
|
|
|
realm_message_content_edit_limit_minutes:
|
|
|
|
Math.ceil(page_params.realm_message_content_edit_limit_seconds / 60),
|
2016-11-30 10:42:58 +01:00
|
|
|
realm_message_retention_days: page_params.realm_message_retention_days,
|
2016-08-04 17:32:41 +02:00
|
|
|
language_list: page_params.language_list,
|
2016-11-29 08:57:35 +01:00
|
|
|
realm_default_language: page_params.realm_default_language,
|
2017-01-12 00:17:43 +01:00
|
|
|
realm_waiting_period_threshold: page_params.realm_waiting_period_threshold,
|
2017-06-10 07:03:53 +02:00
|
|
|
realm_notifications_stream_id: page_params.realm_notifications_stream_id,
|
2017-02-21 21:34:13 +01:00
|
|
|
is_admin: page_params.is_admin,
|
2017-02-21 03:41:20 +01:00
|
|
|
realm_icon_source: page_params.realm_icon_source,
|
2017-02-26 20:35:23 +01:00
|
|
|
realm_icon_url: page_params.realm_icon_url,
|
2017-07-04 20:04:27 +02:00
|
|
|
realm_mandatory_topics: page_params.realm_mandatory_topics,
|
2015-08-20 02:38:32 +02:00
|
|
|
};
|
2016-12-03 01:12:52 +01:00
|
|
|
|
2015-08-20 02:38:32 +02:00
|
|
|
var admin_tab = templates.render('admin_tab', options);
|
2017-04-07 21:39:58 +02:00
|
|
|
$("#settings_content .organization-box").html(admin_tab);
|
2017-03-23 20:37:08 +01:00
|
|
|
$("#settings_content .alert").removeClass("show");
|
2014-01-27 21:48:23 +01:00
|
|
|
|
2017-04-17 16:51:27 +02:00
|
|
|
// Since we just swapped in a whole new page, we need to
|
|
|
|
// tell admin_sections nothing is loaded.
|
|
|
|
admin_sections.reset_sections();
|
|
|
|
|
2016-12-03 01:12:52 +01:00
|
|
|
var tab = (function () {
|
|
|
|
var tab = false;
|
|
|
|
var hash_sequence = window.location.hash.split(/\//);
|
2017-04-07 21:39:58 +02:00
|
|
|
if (/#*(organization)/.test(hash_sequence[0])) {
|
2016-12-03 01:12:52 +01:00
|
|
|
tab = hash_sequence[1];
|
|
|
|
return tab || "organization-settings";
|
|
|
|
}
|
|
|
|
return tab;
|
|
|
|
}());
|
|
|
|
|
|
|
|
if (tab) {
|
|
|
|
exports.launch_page(tab);
|
|
|
|
}
|
|
|
|
|
2016-08-04 17:32:41 +02:00
|
|
|
$("#id_realm_default_language").val(page_params.realm_default_language);
|
|
|
|
|
2017-04-15 17:07:57 +02:00
|
|
|
// Do this after calling the setup_up methods, so that we can
|
|
|
|
// disable any dynamically rendered elements.
|
|
|
|
exports.show_or_hide_menu_item();
|
2016-06-10 09:03:36 +02:00
|
|
|
}
|
|
|
|
|
2016-12-03 01:12:52 +01:00
|
|
|
exports.launch_page = function (tab) {
|
|
|
|
var $active_tab = $("#settings_overlay_container li[data-section='" + tab + "']");
|
|
|
|
|
|
|
|
if ($active_tab.hasClass("admin")) {
|
2017-04-07 21:39:58 +02:00
|
|
|
$(".sidebar .ind-tab[data-tab-key='organization']").click();
|
2016-12-03 01:12:52 +01:00
|
|
|
}
|
|
|
|
|
2017-05-27 15:40:54 +02:00
|
|
|
overlays.open_settings();
|
2016-12-03 01:12:52 +01:00
|
|
|
$active_tab.click();
|
|
|
|
};
|
|
|
|
|
2016-06-10 09:03:36 +02:00
|
|
|
exports.setup_page = function () {
|
|
|
|
i18n.ensure_i18n(_setup_page);
|
2013-08-12 23:31:23 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
return exports;
|
|
|
|
|
|
|
|
}());
|
2016-12-04 08:59:56 +01:00
|
|
|
|
|
|
|
if (typeof module !== 'undefined') {
|
|
|
|
module.exports = admin;
|
|
|
|
}
|