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