Vulcan/packages/telescope-posts/lib/client/templates/views_menu.js

22 lines
792 B
JavaScript
Raw Normal View History

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) {
2015-09-17 14:51:14 +09:00
return (item.adminOnly && !Users.is.admin(Meteor.user())) || (!!Settings.get('postViews') && !_.contains(Settings.get('postViews'), item.label));
2015-06-05 11:17:46 +09:00
});
return viewableItems;
};
2015-08-26 10:43:56 +09:00
Template.views_menu.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 we're on the right pages, and there are at least 2 items
return !!Router.current().showViewsNav && getMenuItems().length >= 2;
2015-03-22 10:55:30 +09:00
}
2015-03-28 18:30:26 +09:00
});