mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
100
install/ui/src/freeipa/menu.js
Normal file
100
install/ui/src/freeipa/menu.js
Normal file
@@ -0,0 +1,100 @@
|
||||
/* Authors:
|
||||
* Petr Vobornik <pvoborni@redhat.com>
|
||||
*
|
||||
* Copyright (C) 2013 Red Hat
|
||||
* see file 'COPYING' for use and warranty information
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Menu proxy.
|
||||
*
|
||||
* Exports public interface for dealing with menu items.
|
||||
*/
|
||||
define([
|
||||
'dojo/_base/lang',
|
||||
'./app', // creates circular dependency
|
||||
'./ipa',
|
||||
'exports' // for handling circular dependency
|
||||
],
|
||||
function(lang, app, IPA, exports) {
|
||||
|
||||
|
||||
var get_menu = function() {
|
||||
return app.app.menu;
|
||||
},
|
||||
|
||||
/**
|
||||
* Adds menu item.
|
||||
* Takes a spec of menu item.
|
||||
* Normalizes item's name, parent, adds children if specified
|
||||
*
|
||||
* @param {menu_item} items
|
||||
* @param {String|menu_item} parent
|
||||
* @param {Object} options
|
||||
*/
|
||||
add_item = function(item, parent, options) {
|
||||
var menu = get_menu();
|
||||
return menu.add_item(item, parent, options);
|
||||
},
|
||||
|
||||
/**
|
||||
* Removes menu item
|
||||
*
|
||||
* @param {String|menu_item} name or menu item to remove
|
||||
*
|
||||
*/
|
||||
remove_item = function(item) {
|
||||
|
||||
var menu = get_menu();
|
||||
return menu.items.remove(item);
|
||||
},
|
||||
|
||||
/**
|
||||
* Query internal data store by using default search options or supplied
|
||||
* search options.
|
||||
*
|
||||
* @param Object Query filter
|
||||
* @param ?Object Search options, overrides default
|
||||
* @return QueryResult
|
||||
*/
|
||||
query = function(query, search_options) {
|
||||
|
||||
var menu = get_menu();
|
||||
|
||||
if (search_options) {
|
||||
return menu.items.query(query, search_options);
|
||||
} else {
|
||||
return menu.query(query);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Get current instance of menu
|
||||
*/
|
||||
get = function() {
|
||||
return get_menu();
|
||||
};
|
||||
|
||||
// Module export
|
||||
exports = {
|
||||
add_item: add_item,
|
||||
remove_item: remove_item,
|
||||
query: query,
|
||||
get: get
|
||||
};
|
||||
|
||||
return exports;
|
||||
});
|
||||
@@ -21,7 +21,7 @@
|
||||
/**
|
||||
* Navigation tells application to show certain facet.
|
||||
*
|
||||
* It's proxy for navigation/Router instace in current running
|
||||
* It's proxy for navigation/Router instance in current running
|
||||
* application.
|
||||
*
|
||||
* Modules just use the interface, they don't have to care about the logic in
|
||||
@@ -29,9 +29,9 @@
|
||||
*/
|
||||
define([
|
||||
'dojo/_base/lang',
|
||||
'./app', // creates circullar dependency
|
||||
'./app', // creates circular dependency
|
||||
'./ipa',
|
||||
'exports' // for handling circullar dependency
|
||||
'exports' // for handling circular dependency
|
||||
],
|
||||
function(lang, app, IPA, exports) {
|
||||
|
||||
|
||||
@@ -101,7 +101,7 @@ return declare([Evented], {
|
||||
* @param {String|menu_item} parent
|
||||
* @param {Object} options
|
||||
*/
|
||||
add_item: function(item, parent, options ) {
|
||||
add_item: function(item, parent, options) {
|
||||
|
||||
item = lang.clone(item); //don't modify original spec
|
||||
|
||||
@@ -115,7 +115,9 @@ return declare([Evented], {
|
||||
if (item.entity) {
|
||||
// FIXME: replace with 'entities' module in future
|
||||
var entity = IPA.get_entity(item.entity);
|
||||
if (!entity) return; //quit
|
||||
if (!entity) {
|
||||
return false; //quit
|
||||
}
|
||||
//item.name = entity.name;
|
||||
if (!item.label) item.label = entity.label;
|
||||
if (!item.title) item.title = entity.title;
|
||||
@@ -163,6 +165,7 @@ return declare([Evented], {
|
||||
this.add_item(child, item);
|
||||
}, this);
|
||||
}
|
||||
return true;
|
||||
},
|
||||
|
||||
add_items: function(/* Array */ items) {
|
||||
|
||||
Reference in New Issue
Block a user