From b44c10384c5103e1dcd20e3af8c586a3f0f9cb84 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 27 Apr 2014 13:54:43 -0400 Subject: [PATCH] added send to user mode --- dashboard-ui/notificationsetting.html | 17 +++++++++-- dashboard-ui/scripts/notificationsetting.js | 33 ++++++++++++++++----- 2 files changed, 40 insertions(+), 10 deletions(-) diff --git a/dashboard-ui/notificationsetting.html b/dashboard-ui/notificationsetting.html index 84f1cde6f..706aa9d93 100644 --- a/dashboard-ui/notificationsetting.html +++ b/dashboard-ui/notificationsetting.html @@ -38,8 +38,19 @@
- -
+
+ + +
+

@@ -57,7 +68,7 @@
  • - +
    ${LabelAvailableTokens}
    diff --git a/dashboard-ui/scripts/notificationsetting.js b/dashboard-ui/scripts/notificationsetting.js index a935f360a..e5910e5c1 100644 --- a/dashboard-ui/scripts/notificationsetting.js +++ b/dashboard-ui/scripts/notificationsetting.js @@ -1,6 +1,6 @@ (function () { - function fillItems(elem, items, cssClass, idPrefix, disabledList) { + function fillItems(elem, items, cssClass, idPrefix, currentList, isEnabledList) { var html = '
    '; @@ -8,7 +8,9 @@ var id = idPrefix + u.Id; - var checkedHtml = disabledList.indexOf(u.Id) != -1 ? '' : ' checked="checked"'; + var isChecked = isEnabledList ? currentList.indexOf(u.Id) != -1 : currentList.indexOf(u.Id) == -1; + + var checkedHtml = isChecked ? ' checked="checked"' : ''; return ''; @@ -72,19 +74,21 @@ notificationConfig = { DisabledMonitorUsers: [], - DisabledSendToUsers: [], + SendToUsers: [], DisabledServices: [] }; } fillItems($('.monitorUsersList', page), users, 'chkMonitor', 'chkMonitor', notificationConfig.DisabledMonitorUsers); - fillItems($('.sendToUsersList', page), users, 'chkSendTo', 'chkSendTo', notificationConfig.DisabledSendToUsers); + fillItems($('.sendToUsersList', page), users, 'chkSendTo', 'chkSendTo', notificationConfig.SendToUsers, true); fillItems($('.servicesList', page), services, 'chkService', 'chkService', notificationConfig.DisabledServices); $('#chkEnabled', page).checked(notificationConfig.Enabled || false).checkboxradio('refresh'); $('#txtTitle', page).val(notificationConfig.Title || typeInfo.DefaultTitle); + $('#selectUsers', page).val(notificationConfig.SendToUserMode).selectmenu('refresh').trigger('change'); + }); } @@ -123,6 +127,7 @@ notificationConfig.Enabled = $('#chkEnabled', page).checked(); notificationConfig.Title = $('#txtTitle', page).val(); + notificationConfig.SendToUserMode = $('#selectUsers', page).val(); // Don't persist if it's just the default if (notificationConfig.Title == typeInfo.DefaultTitle) { @@ -133,7 +138,7 @@ return c.getAttribute('data-itemid'); }); - notificationConfig.DisabledSendToUsers = $('.chkSendTo:not(:checked)', page).get().map(function (c) { + notificationConfig.SendToUsers = $('.chkSendTo:checked', page).get().map(function (c) { return c.getAttribute('data-itemid'); }); @@ -141,7 +146,7 @@ return c.getAttribute('data-itemid'); }); - ApiClient.updateServerConfiguration(config).done(function(r) { + ApiClient.updateServerConfiguration(config).done(function (r) { Dashboard.navigate('notificationsettings.html'); }); @@ -149,7 +154,21 @@ }); } - $(document).on('pageshow', "#notificationSettingPage", function () { + $(document).on('pageinit', "#notificationSettingPage", function () { + + var page = this; + + $('#selectUsers', page).on('change', function () { + + if (this.value == 'Custom') { + $('.selectCustomUsers', page).show(); + } else { + $('.selectCustomUsers', page).hide(); + } + + }); + + }).on('pageshow', "#notificationSettingPage", function () { var page = this;