Files
freeipa/install/static/navigation.js
T
Endi S. Dewata 65c9442e26 HBAC Services
The HBAC Service search and details pages have been added under the HBAC
tab. This requires some changes to the framework.

Currently the navigation framework doesn't support multiple entities under
one tab. As a temporary solution, an 'entity' URL parameter is used to
determine the entity to be displayed. This parameter is now only used by
HBAC tab, but its use might be expanded later. The navigation framework
needs be redesigned to provide more flexibility.

The search page in all entities except DNS records have been changed to
use the ipa_search_widget. The Select/Unselect All checbox and Delete
button now work correctly and consistently.

The Add dialog has been enhanced to render and work in a more consistent
way while still supporting custom widgets & layouts. For the search page,
the Add button will refresh the search results and clear the fields in
the dialog box.

The framework now provides some extension points which can be overriden
by the subclasses:
 - init(): for initialization and configuration
 - create(): for creating the layout dynamically or from template
 - setup(): for setting the look and feel
 - load(): for loading the data

Entity and facet initialization is now done after IPA.init(). This is to
ensure the metadata is loaded first so the entities and facets can use
localized messages/labels/titles.

The group entity has been partially converted to use the new framework.

The unit tests have been updated accordingly.
2010-11-11 12:23:05 -05:00

146 lines
3.4 KiB
JavaScript

/* Authors:
* Pavel Zuna <pzuna@redhat.com>
*
* Copyright (C) 2010 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; version 2 only
*
* 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, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
var nav_tabs_lists;
var nav_container;
function nav_push_state(params)
{
$.bbq.pushState(params);
}
function nav_get_state(key)
{
return $.bbq.getState(key, true);
}
function nav_remove_state(key)
{
$.bbq.removeState(key);
}
function nav_create(nls, container, tabclass)
{
if (!container)
container = $('#navigation');
if (!tabclass)
tabclass = 'tabs';
nav_tabs_lists = nls;
nav_container = container;
nav_generate_tabs(nls, container, tabclass, 1);
var tabs = $('.' + tabclass);
tabs.tabs({
select: function(event, ui) {
var panel = $(ui.panel);
var parent = panel.parent();
var id = parent.attr('id');
var state = {};
state[id] = ui.index;
nav_push_state(state);
return true;
}
});
nav_update_tabs();
}
function nav_generate_tabs(nls, container, tabclass, depth)
{
container.addClass(tabclass);
container.addClass('tabs'+depth);
var ul = $('<ul/>');
container.append(ul);
for (var i = 0; i < nls.length; ++i) {
var tab = nls[i];
var label = tab.name;
if ((IPA.metadata[tab.name]) && (IPA.metadata[tab.name].label)){
label = IPA.metadata[tab.name].label;
}
var li = nav_create_tab_li(tab.name, label);
ul.append(li);
var div = nav_create_tab_div(tab.name);
container.append(div);
if (tab.children) {
nav_generate_tabs(tab.children, div, tabclass, depth +1 );
} else {
div.addClass('entity-container');
var entity = ipa_get_entity(tab.name);
entity.label = tab.label;
entity.setup = tab.setup;
}
}
}
function nav_create_tab_li(id, name)
{
return $('<li/>').append($('<a/>', {
href: '#'+id,
title: id,
html: name
}));
}
function nav_create_tab_div(id)
{
return $('<div/>', {
id: id
});
}
function nav_update_tabs()
{
_nav_update_tabs(nav_tabs_lists, nav_container);
}
function _nav_update_tabs(nls, container)
{
var id = container.attr('id');
var index = nav_get_state(id);
if (!index || index >= nls.length) index = 0;
container.tabs('select', index);
var tab = nls[index];
var container2 = $('#' + tab.name);
if (tab.children) {
_nav_update_tabs(tab.children, container2);
} else if (tab.setup) {
var entity_name = tab.name;
// TODO: do not hard-code
if (entity_name == 'hbac' && nav_get_state('entity')) entity_name = nav_get_state('entity');
var entity = IPA.get_entity(entity_name);
entity.setup(container2);
}
}