2015-06-05 11:17:46 +09:00
|
|
|
var getMenuItems = function () {
|
|
|
|
var defaultItems = Telescope.menuItems.get("viewsMenu");
|
|
|
|
|
|
|
|
// reject an item if the item is admin only and the current user is not an admin
|
|
|
|
// or if views have been configured in the settings and the item is not part of them
|
|
|
|
var viewableItems = _.reject(defaultItems, function (item) {
|
|
|
|
return (item.adminOnly && !Users.is.admin(Meteor.user())) || (!!Settings.get('postViews') && !_.contains(Settings.get('postViews'), item.route));
|
|
|
|
});
|
|
|
|
|
|
|
|
return viewableItems;
|
|
|
|
};
|
|
|
|
|
2015-05-18 10:30:08 +09:00
|
|
|
Template.posts_views_nav.helpers({
|
2015-03-28 10:54:41 +09:00
|
|
|
menuItems: function () {
|
2015-06-05 11:17:46 +09:00
|
|
|
return getMenuItems();
|
|
|
|
},
|
|
|
|
showNav: function () {
|
|
|
|
// only show menu when there are at least 2 items
|
|
|
|
return getMenuItems().length >= 2;
|
2015-03-22 10:55:30 +09:00
|
|
|
}
|
2015-03-28 18:30:26 +09:00
|
|
|
});
|