added send to user mode

This commit is contained in:
Luke Pulverenti 2014-04-27 13:54:43 -04:00
parent a59b0ce027
commit b44c10384c
2 changed files with 40 additions and 10 deletions

View File

@ -38,8 +38,19 @@
</div>
<div>
<label>${LabelSendNotificationToUsers}</label>
<div class="sendToUsersList">
<div>
<label for="selectUsers">${LabelSendNotificationToUsers}</label>
<select id="selectUsers" data-mini="true">
<option value="All">${OptionAllUsers}</option>
<option value="Admins">${OptionAdminUsers}</option>
<option value="Custom">${OptionCustomUsers}</option>
</select>
</div>
<div class="selectCustomUsers" style="display: none;">
<br />
<label>${LabelSelectUsers}</label>
<div class="sendToUsersList">
</div>
</div>
<br />
<br />
@ -57,7 +68,7 @@
<ul data-role="listview" class="ulForm">
<li>
<label for="txtTitle">${LabelMessageTitle}</label>
<input id="txtTitle" type="text" data-mini="true" />
<input id="txtTitle" type="text" data-mini="true" required="required" />
<div class="fieldDescription tokenHelp">
<div>${LabelAvailableTokens}</div>
<div class="tokenList" style="margin-top: .5em;"></div>

View File

@ -1,6 +1,6 @@
(function () {
function fillItems(elem, items, cssClass, idPrefix, disabledList) {
function fillItems(elem, items, cssClass, idPrefix, currentList, isEnabledList) {
var html = '<div data-role="controlgroup">';
@ -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 '<label for="' + id + '">' + u.Name + '</label><input class="' + cssClass + '" type="checkbox" data-itemid="' + u.Id + '" data-mini="true" id="' + id + '"' + checkedHtml + ' />';
@ -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;