2021-08-17 14:43:29 +02:00
|
|
|
import $ from "jquery";
|
|
|
|
|
2021-08-30 09:51:38 +02:00
|
|
|
import * as channel from "./channel";
|
2021-09-16 19:18:39 +02:00
|
|
|
import {page_params} from "./page_params";
|
2021-08-17 14:43:29 +02:00
|
|
|
import {realm_user_settings_defaults} from "./realm_user_settings_defaults";
|
|
|
|
import * as settings_display from "./settings_display";
|
2021-08-26 21:03:27 +02:00
|
|
|
import * as settings_notifications from "./settings_notifications";
|
2021-08-30 09:51:38 +02:00
|
|
|
import * as settings_ui from "./settings_ui";
|
2021-08-17 14:43:29 +02:00
|
|
|
|
2021-09-16 19:18:39 +02:00
|
|
|
export function maybe_disable_widgets() {
|
|
|
|
if (!page_params.is_admin) {
|
|
|
|
$(".organization-box [data-name='organization-level-user-defaults']")
|
|
|
|
.find("input, select")
|
|
|
|
.prop("disabled", true);
|
|
|
|
|
|
|
|
$(".organization-box [data-name='organization-level-user-defaults']")
|
|
|
|
.find(".play_notification_sound")
|
|
|
|
.addClass("control-label-disabled");
|
|
|
|
}
|
|
|
|
}
|
2021-08-17 14:43:29 +02:00
|
|
|
export function set_up() {
|
|
|
|
const container = $("#realm-user-default-settings");
|
|
|
|
settings_display.set_up(container, realm_user_settings_defaults, true);
|
2021-08-26 21:03:27 +02:00
|
|
|
settings_notifications.set_up(container, realm_user_settings_defaults, true);
|
2021-08-30 09:51:38 +02:00
|
|
|
|
|
|
|
container.find(".presence_enabled").on("change", (e) => {
|
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
|
|
|
|
|
|
|
const data = {presence_enabled: container.find(".presence_enabled").prop("checked")};
|
|
|
|
settings_ui.do_settings_change(
|
|
|
|
channel.patch,
|
|
|
|
"/json/realm/user_settings_defaults",
|
|
|
|
data,
|
|
|
|
container.find(".privacy-setting-status").expectOne(),
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
2021-09-16 19:18:39 +02:00
|
|
|
maybe_disable_widgets();
|
2021-08-17 14:43:29 +02:00
|
|
|
}
|