2016-08-05 12:34:10 -07:00
|
|
|
|
define(['jQuery', 'listViewStyle'], function ($) {
|
2014-04-25 13:47:56 -07:00
|
|
|
|
|
|
|
|
|
function reload(page) {
|
|
|
|
|
|
2014-04-26 20:42:05 -07:00
|
|
|
|
Dashboard.showLoadingMsg();
|
2014-04-25 13:47:56 -07:00
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
ApiClient.getJSON(ApiClient.getUrl("Notifications/Types")).then(function (list) {
|
2014-04-25 19:55:07 -07:00
|
|
|
|
|
2015-09-22 10:09:29 -07:00
|
|
|
|
var html = '';
|
2014-04-25 13:47:56 -07:00
|
|
|
|
|
2014-04-26 20:42:05 -07:00
|
|
|
|
var lastCategory = "";
|
2014-04-25 13:47:56 -07:00
|
|
|
|
|
2014-04-26 20:42:05 -07:00
|
|
|
|
html += list.map(function (i) {
|
2014-04-25 13:47:56 -07:00
|
|
|
|
|
2014-04-26 20:42:05 -07:00
|
|
|
|
var itemHtml = '';
|
2014-04-25 13:47:56 -07:00
|
|
|
|
|
2014-04-26 20:42:05 -07:00
|
|
|
|
if (i.Category != lastCategory) {
|
|
|
|
|
lastCategory = i.Category;
|
2015-09-22 10:09:29 -07:00
|
|
|
|
|
|
|
|
|
if (lastCategory) {
|
|
|
|
|
itemHtml += '</div>';
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
itemHtml += '<h1>';
|
2014-04-26 20:42:05 -07:00
|
|
|
|
itemHtml += i.Category;
|
2015-09-22 10:09:29 -07:00
|
|
|
|
itemHtml += '</h1>';
|
|
|
|
|
|
|
|
|
|
itemHtml += '<div class="paperList" style="margin-bottom:2em;">';
|
2014-04-26 20:42:05 -07:00
|
|
|
|
}
|
2014-04-25 13:47:56 -07:00
|
|
|
|
|
2015-09-22 10:09:29 -07:00
|
|
|
|
itemHtml += '<a class="clearLink" href="notificationsetting.html?type=' + i.Type + '">';
|
2016-08-05 12:34:10 -07:00
|
|
|
|
itemHtml += '<div class="listItem">';
|
2014-04-25 19:55:07 -07:00
|
|
|
|
|
2014-04-26 20:42:05 -07:00
|
|
|
|
if (i.Enabled) {
|
2016-08-05 12:34:10 -07:00
|
|
|
|
itemHtml += '<i class="listItemIcon md-icon">notifications_active</i>';
|
2015-09-22 10:09:29 -07:00
|
|
|
|
}
|
|
|
|
|
else {
|
2016-08-05 12:34:10 -07:00
|
|
|
|
itemHtml += '<i class="listItemIcon md-icon" style="background-color:#999;">notifications_off</i>';
|
2014-04-26 20:42:05 -07:00
|
|
|
|
}
|
2014-04-25 13:47:56 -07:00
|
|
|
|
|
2016-10-02 23:28:45 -07:00
|
|
|
|
itemHtml += '<div class="listItemBody">';
|
2016-08-05 12:34:10 -07:00
|
|
|
|
itemHtml += '<div class="listItemBodyText">' + i.Name + '</div>';
|
2015-09-22 10:09:29 -07:00
|
|
|
|
|
2016-08-05 12:34:10 -07:00
|
|
|
|
itemHtml += '</div>';
|
2015-09-22 10:09:29 -07:00
|
|
|
|
|
2016-08-05 12:34:10 -07:00
|
|
|
|
itemHtml += '<button type="button" is="paper-icon-button-light"><i class="md-icon">mode_edit</i></button>';
|
2015-09-22 10:09:29 -07:00
|
|
|
|
|
2016-08-05 12:34:10 -07:00
|
|
|
|
itemHtml += '</div>';
|
2014-04-26 20:42:05 -07:00
|
|
|
|
itemHtml += '</a>';
|
|
|
|
|
|
|
|
|
|
return itemHtml;
|
|
|
|
|
|
|
|
|
|
}).join('');
|
|
|
|
|
|
2015-10-12 12:09:56 -07:00
|
|
|
|
if (list.length) {
|
|
|
|
|
html += '</div>';
|
|
|
|
|
}
|
2014-04-25 13:47:56 -07:00
|
|
|
|
|
2014-04-26 20:42:05 -07:00
|
|
|
|
$('.notificationList', page).html(html).trigger('create');
|
|
|
|
|
|
|
|
|
|
Dashboard.hideLoadingMsg();
|
|
|
|
|
});
|
2014-04-25 13:47:56 -07:00
|
|
|
|
}
|
|
|
|
|
|
2016-04-12 22:28:45 -07:00
|
|
|
|
function getTabs() {
|
|
|
|
|
return [
|
|
|
|
|
{
|
|
|
|
|
href: 'notificationsettings.html',
|
|
|
|
|
name: Globalize.translate('TabNotifications')
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
href: 'appservices.html?context=notifications',
|
|
|
|
|
name: Globalize.translate('TabServices')
|
|
|
|
|
}];
|
|
|
|
|
}
|
2014-04-25 13:47:56 -07:00
|
|
|
|
|
2016-04-12 22:28:45 -07:00
|
|
|
|
return function (view, params) {
|
2014-04-25 13:47:56 -07:00
|
|
|
|
|
2016-04-12 22:28:45 -07:00
|
|
|
|
view.addEventListener('viewshow', function () {
|
2014-04-25 13:47:56 -07:00
|
|
|
|
|
2016-04-12 22:28:45 -07:00
|
|
|
|
LibraryMenu.setTabs('notifications', 0, getTabs);
|
|
|
|
|
|
2016-08-05 12:34:10 -07:00
|
|
|
|
reload(view);
|
2016-04-12 22:28:45 -07:00
|
|
|
|
});
|
|
|
|
|
};
|
2016-03-18 21:26:17 -07:00
|
|
|
|
});
|