Navigation updates

The entity.default_facet has been removed, instead the first facet
registered to the entity will be considered as the default facet.
So, the 'setup' parameter has been removed from tab definitions
because it's no longer necessary. The ipa_details_only_setup() has
been removed as well.

An 'entity' parameter has been added to tab definitions to specify
which entity corresponds to a tab item. The tab label has been
changed to use entity label if available.

Some hard-coded labels have been removed. The unit tests have been
updated.
This commit is contained in:
Endi S. Dewata 2010-12-07 12:17:12 -06:00 committed by Adam Young
parent 9e5fdcb3a4
commit deb94b150d
8 changed files with 91 additions and 88 deletions

View File

@ -533,10 +533,8 @@ function ipa_details_setup(container) {
function ipa_details_refresh() {
var that = this;
var entity = IPA.get_entity(that.entity_name);
that.pkey = $.bbq.getState(that.entity_name + '-pkey', true) || '';
if (!that.pkey && !entity.default_facet) return;
function on_success(data, text_status, xhr) {
that.load(data.result.result);

View File

@ -189,6 +189,10 @@ function ipa_entity(spec) {
that.init = function() {
if (!that.label) {
that.label = IPA.metadata[that.name].label;
}
if (that.autogenerate_associations) {
that.create_association_facets();
}
@ -332,12 +336,12 @@ function ipa_entity_set_facet_definition(entity_name, list) {
}
}
function ipa_details_only_setup(container){
ipa_entity_setup.call(this, container, 'details');
}
function ipa_current_facet(entity){
return $.bbq.getState(entity.name + '-facet', true) || entity.default_facet || 'search';
var facet_name = $.bbq.getState(entity.name + '-facet', true);
if (!facet_name && entity.facets.length) {
facet_name = entity.facets[0].name;
}
return facet_name;
}
function ipa_entity_setup(container) {

View File

@ -76,8 +76,9 @@ function nav_generate_tabs(nls, container, tabclass, depth)
var tab = nls[i];
var label = tab.name;
if ((IPA.metadata[tab.name]) && (IPA.metadata[tab.name].label)){
label = IPA.metadata[tab.name].label;
if (tab.entity) {
var entity = IPA.get_entity(tab.entity);
label = entity.label;
}
var li = nav_create_tab_li(tab.name, label);
@ -86,14 +87,12 @@ function nav_generate_tabs(nls, container, tabclass, depth)
var div = nav_create_tab_div(tab.name);
container.append(div);
if (tab.entity) {
div.addClass('entity-container');
}
if (tab.children && depth === 1) {
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;
}
}
}
@ -133,8 +132,8 @@ function _nav_update_tabs(nls, container,depth)
if (tab.children && depth === 1 ) {
_nav_update_tabs(tab.children, container2,depth+1);
} else if (tab.setup) {
var entity_name = tab.name;
} else if (tab.entity) {
var entity_name = tab.entity;
var nested_entity = nav_get_state(entity_name+'-entity');

View File

@ -594,7 +594,5 @@ ipa_entity_set_details_definition('krbtpolicy', [
input({name:'krbmaxticketlife'})
]);
IPA.get_entity('krbtpolicy').default_facet = 'details';
ipa_entity_set_association_definition('krbtpolicy', {
});

View File

@ -50,19 +50,17 @@ ipa_entity_set_details_definition('aci', [
/* Configuration */
ipa_entity_set_details_definition('config',[
ipa_stanza({name:'ipaserver', lable:'Configuration'}).
ipa_stanza({name:'ipaserver', label:'Configuration'}).
input({name:'cn', label:'Name'}).
input({name:'description', label:'Description'}).
input({name:'ipacertificatesubjectbase', label:'Certificat Subject Base'}).
input({name: 'ipadefaultloginshell', label:'Default Login Shell'}).
input({name:'ipadefaultprimarygroup', label:'Default Primary Group'}).
input({name:'ipagroupsearchfields', label:'Group Search Fields'}).
input({name:'ipahomesrootdir', label:'Home Root Dir'}).
input({name:'ipamaxusernamelength', label:'Max Username Length'}).
input({name:'ipamigrationenabled', label:'Migration enabled?'}).
input({name:'ipasearchrecordslimit', label:'Search Record Limit'}).
input({name:'ipasearchtimelimit', label:'Search Time Limit'}).
input({name:'ipausersearchfields', label:'User Search Fields'})
input({name:'ipacertificatesubjectbase'}).
input({name:'ipadefaultloginshell'}).
input({name:'ipadefaultprimarygroup'}).
input({name:'ipagroupsearchfields'}).
input({name:'ipahomesrootdir'}).
input({name:'ipamaxusernamelength'}).
input({name:'ipamigrationenabled'}).
input({name:'ipasearchrecordslimit'}).
input({name:'ipasearchtimelimit'}).
input({name:'ipausersearchfields'})
]);
IPA.get_entity('config').default_facet = 'details';

View File

@ -35,9 +35,9 @@ test("Testing ipa_details_section.create().", function() {
);
var section = ipa_details_list_section({name:'IDIDID', label:'NAMENAMENAME'}).
input({name:'cn', label:'Entity Name'}).
input({name:'description', label:'Description'}).
input({name:'number', label:'Entity ID'});
input({name:'cn'}).
input({name:'description'}).
input({name:'number'});
var fields = section.fields;
@ -147,32 +147,32 @@ test("Testing details lifecycle: create, setup, load.", function(){
var obj_name = 'user';
ipa_entity_set_details_definition(obj_name, [
ipa_stanza({name:'identity', label:'Identity Details'}).
input({name:'title', label: 'Title'}).
input({name:'givenname', label:'First Name'}).
input({name:'sn', label:'Last Name'}).
input({name:'cn', label:'Full Name'}).
input({name:'displayname', label:'Dispaly Name'}).
input({name:'initials', label:'Initials'}),
input({name:'title'}).
input({name:'givenname'}).
input({name:'sn'}).
input({name:'cn'}).
input({name:'displayname'}).
input({name:'initials'}),
ipa_stanza({name:'account', label:'Account Details'}).
input({name:'status', label:'Account Status', setup: setup_status}).
input({name:'uid', label:'Login'}).
input({name:'userpassword', label:'Password', save: save_password}).
input({name:'uidnumber', label:'UID'}).
input({name:'gidnumber', label:'GID'}).
input({name:'homedirectory', label:'homedirectory'}),
input({name:'status', setup: setup_status}).
input({name:'uid'}).
input({name:'userpassword', save: save_password}).
input({name:'uidnumber'}).
input({name:'gidnumber'}).
input({name:'homedirectory'}),
ipa_stanza({name:'contact', label:'Contact Details'}).
input({name:'mail', label:'E-mail Address'}).
input({name:'telephonenumber', label:'Numbers'}),
ipa_stanza({name:'address', label:'Mailing Address'}).
input({name:'street', label:'Address'}).
input({name:'location', label:'City'}).
input({name:'state', label:'State', setup: setup_st}).
input({name:'postalcode', label:'ZIP'}),
input({name:'mail'}).
input({name:'telephonenumber'}),
ipa_stanza({name:'address'}).
input({name:'street'}).
input({name:'location'}).
input({name:'state', setup: setup_st}).
input({name:'postalcode'}),
ipa_stanza({name:'employee', label:'Employee Information'}).
input({name:'ou', label:'Org. Unit'}).
input({name:'manager', label:'Manager', load: load_manager}),
input({name:'ou'}).
input({name:'manager', load: load_manager}),
ipa_stanza({name:'misc', label:'Misc. Information'}).
input({name:'carlicense', label:'Car License'})
input({name:'carlicense'})
]);
var entity = ipa_get_entity(obj_name);

View File

@ -26,20 +26,26 @@ test("Testing nav_create().", function() {
var mock_tabs_lists =
[
{ name:'identity', label:'IDENTITY', children: [
{name:'user', label:'Users', setup:mock_setup_user},
{name:'group', label:'Users', setup:mock_setup_group}
{name:'user', entity:'user'},
{name:'group', entity:'group'}
]}];
function mock_setup_user (jobj){
user_mock_called = true;
same(jobj[0].id,'user','user id');
same(jobj[0].nodeName,'DIV','user div');
}
function mock_setup_group (jobj){
group_mock_called = true;
same(jobj[0].id,'group','group id');
same(jobj[0].nodeName,'DIV','group Div');
}
var entity = ipa_entity({name: 'user'});
entity.setup = function(container){
user_mock_called = true;
same(container[0].id,'user','user id');
same(container[0].nodeName,'DIV','user div');
};
IPA.add_entity(entity);
entity = ipa_entity({name: 'group'});
entity.setup = function(container){
group_mock_called = true;
same(container[0].id,'group','group id');
same(container[0].nodeName,'DIV','group Div');
};
IPA.add_entity(entity);
IPA.metadata = {};
var navigation = $('<div id="navigation"/>').appendTo(document.body);
var user_mock_called = false;

View File

@ -25,36 +25,36 @@
var admin_tab_set = [
{name:'identity', children:[
{name:'user', label:'Users', setup: ipa_entity_setup},
{name:'group', label:'Groups', setup: ipa_entity_setup},
{name:'host', label:'Hosts', setup: ipa_entity_setup},
{name:'hostgroup', label:'Hostgroups', setup: ipa_entity_setup},
{name:'netgroup', label:'Netgroups', setup: ipa_entity_setup},
{name:'service', label:'Services', setup: ipa_entity_setup}
{name:'user', entity:'user'},
{name:'group', entity:'group'},
{name:'host', entity:'host'},
{name:'hostgroup', entity:'hostgroup'},
{name:'netgroup', entity:'netgroup'},
{name:'service', entity:'service'}
]},
{name:'policy', children:[
{name:'dnszone', setup: ipa_entity_setup},
{name:'hbac', setup: ipa_entity_setup, children:[
{name:'hbacsvc', setup: ipa_entity_setup},
{name:'hbacsvcgroup', setup: ipa_entity_setup}
{name:'dnszone', entity:'dnszone'},
{name:'hbac', entity:'hbac', children:[
{name:'hbacsvc', entity:'hbacsvc'},
{name:'hbacsvcgroup', entity:'hbacsvcgroup'}
]},
{name:'sudorule', label:'SUDO', setup: ipa_entity_setup,children:[
{name:'sudocmd', setup: ipa_entity_setup},
{name:'sudocmdgroup', setup: ipa_entity_setup}
{name:'sudorule', entity:'sudorule',children:[
{name:'sudocmd', entity:'sudocmd'},
{name:'sudocmdgroup', entity:'sudocmdgroup'}
]},
{name:'automountlocation', setup: ipa_entity_setup},
{name:'pwpolicy', setup: ipa_entity_setup},
{name:'krbtpolicy', setup:ipa_details_only_setup}
{name:'automountlocation', entity:'automountlocation'},
{name:'pwpolicy', entity:'pwpolicy'},
{name:'krbtpolicy', entity:'krbtpolicy'}
]},
{name:'ipaserver', children: [
{name:'config', setup: ipa_details_only_setup}
{name:'config', entity:'config'}
]}
];
var self_serv_tab_set =
[
{ name:'identity', label:'IDENTITY', children: [
{name:'user', label:'Users', setup:ipa_entity_setup}]}];
{ name:'identity', children: [
{name:'user', entity:'user'}]}];
IPA.tab_state = function(entity_name){