mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2024-12-29 10:21:18 -06:00
d99ebc0f37
The UI framework has been extended to include a collection of widgets: - ipa_widget: base class - ipa_text_widget: text field - ipa_radio_widget: radio button - ipa_textarea_widget: textarea - ipa_button_widget: button - ipa_column_widget: column for table - ipa_table_widget: table These widgets can be used to create input controls. They can also be extended to create custom controls. The framework has also been enhanced to support custom layouts. This can be used to change the look of the application without changing the code. Initially this is only available in details section. Layout consists of a collection of HTML templates. Each template is a complete and valid HTML file representing a portion of a page. The template will be loaded and initialized by the code, then filled with the data from the server. The layouts are located in install/static/layouts/<name> folder. By default, if no templates are used, the fields in the details page are rendered vertically using dd/dt/dd tags. For pages that require different layout, a custom UI needs to be developed. There are two ways to do that: - write a custom widget to generate the UI dynamically - create an HTML template and write the initialization code For components that are quite complex or used frequently, it's might be better to use the first method. For simple pages that are used only in one location or need to support customization, the second method might be preferable. Other benefits of templates: - cleaner code and UI separation - more flexibility in customization - new pages can be developed quickly and require less coding - multiple templates can be used with the same initialization code - easier to maintain The HBAC details page has been implemented using both methods. By default it will use custom widgets to generate the page. To use a custom layout, add the following parameter to the URL, then reload the page: &layout=<name> Currently the only available layout is 'default' which produces the same look as the custom widgets. The HBAC details page is usable, but it still needs additional work. The access time is not working yet. There is no undo button, hint, or validation yet. The table in the association facet has also been changed to use ipa_association_widget which is derived from ipa_table_widget. The Makefile has been updated to include the layouts. The unit tests have been updated as well.
141 lines
3.3 KiB
JavaScript
141 lines
3.3 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 = IPA.get_entity(tab.name);
|
|
entity.setup(container2);
|
|
}
|
|
}
|