2015-04-22 07:50:11 +09:00
|
|
|
Template.notificationsMenu.helpers({
|
|
|
|
menuLabel: function () {
|
|
|
|
var notificationsCount;
|
|
|
|
var notifications=Herald.collection.find({userId: Meteor.userId(), read: false}, {sort: {timestamp: -1}}).fetch();
|
|
|
|
|
2015-05-01 18:22:00 +02:00
|
|
|
if(notifications.length === 0){
|
2015-04-22 07:50:11 +09:00
|
|
|
notificationsCount = __('no_notifications');
|
2015-05-01 18:22:00 +02:00
|
|
|
}else if(notifications.length === 1){
|
2015-04-22 07:50:11 +09:00
|
|
|
notificationsCount = __('1_notification');
|
|
|
|
}else{
|
2015-05-01 18:22:00 +02:00
|
|
|
notificationsCount = notifications.length+' '+ __('notifications');
|
2015-04-22 07:50:11 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
return notificationsCount;
|
|
|
|
},
|
|
|
|
menuItems: function () {
|
|
|
|
var notifications=Herald.collection.find({userId: Meteor.userId(), read: false}, {sort: {timestamp: -1}}).fetch();
|
|
|
|
var markAllAsRead = [{
|
|
|
|
template: 'notificationsMarkAsRead'
|
|
|
|
}];
|
2015-05-01 18:22:00 +02:00
|
|
|
var menuItems;
|
2015-04-22 07:50:11 +09:00
|
|
|
if (notifications.length) {
|
2015-05-01 18:22:00 +02:00
|
|
|
menuItems = markAllAsRead.concat(_.map(notifications, function (notification) {
|
2015-04-22 07:50:11 +09:00
|
|
|
return {
|
|
|
|
template: "notificationItem",
|
|
|
|
data: notification
|
2015-05-01 18:22:00 +02:00
|
|
|
};
|
2015-04-22 07:50:11 +09:00
|
|
|
}));
|
|
|
|
} else {
|
2015-05-01 18:22:00 +02:00
|
|
|
menuItems = [];
|
2015-04-22 07:50:11 +09:00
|
|
|
}
|
|
|
|
return menuItems;
|
|
|
|
},
|
|
|
|
menuMode: function () {
|
|
|
|
if (!!this.mobile) {
|
|
|
|
return 'list';
|
|
|
|
} else if (Settings.get('navLayout', 'top-nav') === 'top-nav') {
|
|
|
|
return 'dropdown';
|
|
|
|
} else {
|
|
|
|
return 'accordion';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|