Sha256: b554e7c6c4655d3d37cee233ec2db396d55fa947c2691bc81576c332b3221a2e

Contents?: true

Size: 1.09 KB

Versions: 214

Compression:

Stored size: 1.09 KB

Contents

/**
 * @ngdoc service
 * @name  Bastion.menu.service:menuExpander
 *
 * @description
 *   Provides a way to add additional menu items from other modules.
 *
 *   Expects menus to be an array of objects of the form:
 *      {url: 'http://redhat.com', label: 'Red Hat'}
 *
 * @usage
 *   angular.module('SomeOtherModule', ['Bastion.menu']);
 *
 *   angular.module('SomeOtherModule').run(['MenuExpander', function (menuExpander) {
 *       menuExpander.setMenu('system', [{'url': 'http://redhat.com', 'label': 'Red Hat'}]);
 *   }]);
 */
angular.module('Bastion.menu').service('MenuExpander', [function () {
    this.menu = {};

    this.getMenu = function (menuName) {
        if (this.menu.hasOwnProperty(menuName)) {
            return this.menu[menuName];
        }

        return [];
    };

    this.setMenu = function (menuName, items) {
        if (this.menu.hasOwnProperty(menuName)) {
            this.menu[menuName] = _.uniqBy(_.union(this.menu[menuName], items), function (item) {
                return item.url;
            });
        } else {
            this.menu[menuName] = items;
        }
    };
}]);

Version data entries

214 entries across 214 versions & 2 rubygems

Version Path
katello-4.14.2 engines/bastion/app/assets/javascripts/bastion/menu/menu-expander.service.js
katello-4.15.0 engines/bastion/app/assets/javascripts/bastion/menu/menu-expander.service.js
katello-4.15.0.rc2 engines/bastion/app/assets/javascripts/bastion/menu/menu-expander.service.js
katello-4.15.0.rc1 engines/bastion/app/assets/javascripts/bastion/menu/menu-expander.service.js
katello-4.14.1 engines/bastion/app/assets/javascripts/bastion/menu/menu-expander.service.js
katello-4.14.0 engines/bastion/app/assets/javascripts/bastion/menu/menu-expander.service.js
katello-4.14.0.rc3 engines/bastion/app/assets/javascripts/bastion/menu/menu-expander.service.js
katello-4.14.0.rc2 engines/bastion/app/assets/javascripts/bastion/menu/menu-expander.service.js
katello-4.14.0.rc1.1 engines/bastion/app/assets/javascripts/bastion/menu/menu-expander.service.js
katello-4.14.0.rc1 engines/bastion/app/assets/javascripts/bastion/menu/menu-expander.service.js
katello-4.13.1 engines/bastion/app/assets/javascripts/bastion/menu/menu-expander.service.js
katello-4.13.0 engines/bastion/app/assets/javascripts/bastion/menu/menu-expander.service.js
katello-4.12.1 engines/bastion/app/assets/javascripts/bastion/menu/menu-expander.service.js
katello-4.13.0.rc1 engines/bastion/app/assets/javascripts/bastion/menu/menu-expander.service.js
katello-4.12.0 engines/bastion/app/assets/javascripts/bastion/menu/menu-expander.service.js
katello-4.12.0.rc3 engines/bastion/app/assets/javascripts/bastion/menu/menu-expander.service.js
katello-4.12.0.rc2 engines/bastion/app/assets/javascripts/bastion/menu/menu-expander.service.js
katello-4.12.0.rc1 engines/bastion/app/assets/javascripts/bastion/menu/menu-expander.service.js
katello-4.11.1 engines/bastion/app/assets/javascripts/bastion/menu/menu-expander.service.js
katello-4.11.0 engines/bastion/app/assets/javascripts/bastion/menu/menu-expander.service.js