2021-08-17 14:43:29 +02:00
|
|
|
import $ from "jquery";
|
|
|
|
|
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-09-28 09:09:52 +02:00
|
|
|
import * as settings_org from "./settings_org";
|
2021-08-17 14:43:29 +02:00
|
|
|
|
2021-09-20 13:38:38 +02:00
|
|
|
export const realm_default_settings_panel = {};
|
|
|
|
|
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() {
|
2021-09-20 13:38:38 +02:00
|
|
|
const container = $(realm_default_settings_panel.container);
|
|
|
|
settings_display.set_up(realm_default_settings_panel);
|
2021-09-20 15:56:32 +02:00
|
|
|
settings_notifications.set_up(realm_default_settings_panel);
|
2021-08-30 09:51:38 +02:00
|
|
|
|
2021-09-28 09:09:52 +02:00
|
|
|
settings_org.register_save_discard_widget_handlers(
|
|
|
|
container,
|
|
|
|
"/json/realm/user_settings_defaults",
|
|
|
|
true,
|
|
|
|
);
|
2021-09-17 12:51:31 +02:00
|
|
|
|
2021-09-16 19:18:39 +02:00
|
|
|
maybe_disable_widgets();
|
2021-08-17 14:43:29 +02:00
|
|
|
}
|
2021-09-20 13:38:38 +02:00
|
|
|
|
|
|
|
export function initialize() {
|
|
|
|
realm_default_settings_panel.container = "#realm-user-default-settings";
|
|
|
|
realm_default_settings_panel.settings_object = realm_user_settings_defaults;
|
|
|
|
realm_default_settings_panel.patch_url = "/json/realm/user_settings_defaults";
|
2021-09-20 15:56:32 +02:00
|
|
|
realm_default_settings_panel.notification_sound_elem =
|
|
|
|
"#realm-default-notification-sound-audio";
|
2021-09-20 13:38:38 +02:00
|
|
|
realm_default_settings_panel.for_realm_settings = true;
|
|
|
|
}
|