diff options
author | Adam Young <ayoung@redhat.com> | 2011-05-06 17:04:09 -0400 |
---|---|---|
committer | Adam Young <ayoung@redhat.com> | 2011-05-26 14:53:40 -0400 |
commit | 1636d649264348526012b1f699284ad728e8a43d (patch) | |
tree | d65f7427070871b8a50ab3dbf4b8bfab65530da6 /install/ui/entity.js | |
parent | 5288bdb79ae7602cb72a735fad0c8b6e62a48df0 (diff) | |
download | freeipa-1636d649264348526012b1f699284ad728e8a43d.tar.gz freeipa-1636d649264348526012b1f699284ad728e8a43d.tar.xz freeipa-1636d649264348526012b1f699284ad728e8a43d.zip |
automount UI
automount implemented using standard facets and containing_entity pkey generation
sample data fixtures for automount.
messages for automount and HBAC.
modified form of the search facet used to nest the automount entities
Add works for nested entities. Delete works for all but keys. Since the API for this is going to change, I'm not going to fix it pre-checkin.
All the places the PKEY prefix is needed uses a single function. Added breadcrumb trail into title.
update ipa_init sample data
add redirect logic for pages without pkeys.
add and delete link to appropriate entities for nested search facet.
Using on demand entities. Fixed breadcrumbs.
Diffstat (limited to 'install/ui/entity.js')
-rw-r--r-- | install/ui/entity.js | 145 |
1 files changed, 114 insertions, 31 deletions
diff --git a/install/ui/entity.js b/install/ui/entity.js index 8af4af968..889b6be38 100644 --- a/install/ui/entity.js +++ b/install/ui/entity.js @@ -147,20 +147,9 @@ IPA.table_facet = function(spec) { var that = IPA.facet(spec); - that.columns = $.ordered_map(); - - that.__defineGetter__('entity_name', function() { - return that._entity_name; - }); - - that.__defineSetter__('entity_name', function(entity_name) { - that._entity_name = entity_name; + that.managed_entity_name = spec.managed_entity_name || that.entity_name; - var columns = that.columns.values; - for (var i=0; i<columns.length; i++) { - columns[i].entity_name = entity_name; - } - }); + that.columns = $.ordered_map(); that.get_columns = function() { return that.columns.values; @@ -171,7 +160,7 @@ IPA.table_facet = function(spec) { }; that.add_column = function(column) { - column.entity_name = that.entity_name; + column.entity_name = that.managed_entity_name; that.columns.put(column.name, column); }; @@ -233,6 +222,7 @@ IPA.entity = function (spec) { that.metadata = spec.metadata; that.name = spec.name; that.label = spec.label || spec.metadata.label || spec.name; + that.title = spec.title || that.label; that.header = spec.header || IPA.entity_header({entity: that}); @@ -244,6 +234,8 @@ IPA.entity = function (spec) { // current facet that.facet_name = null; + that.redirect_facet = spec.redirect_facet; + that.containing_entity = null; that.get_dialog = function(name) { return that.dialogs.get(name); }; @@ -367,6 +359,28 @@ IPA.entity = function (spec) { that.facet.refresh(); }; + that.get_primary_key_prefix = function() { + var pkey = []; + var current_entity = that; + current_entity = current_entity.containing_entity; + while(current_entity !== null){ + pkey.unshift( + $.bbq.getState(current_entity.name + '-pkey', true) || ''); + current_entity = current_entity.containing_entity; + } + return pkey; + }; + + /*gets the primary key for trhe current entity out of the URL parameters */ + that.get_primary_key = function() { + var pkey = that.get_primary_key_prefix(); + var current_entity = that; + pkey.unshift( + $.bbq.getState(current_entity.name + '-pkey', true) || ''); + return pkey; + }; + + that.entity_init = that.init; return that; @@ -375,7 +389,7 @@ IPA.entity = function (spec) { IPA.current_facet = function (entity){ var facet_name = $.bbq.getState(entity.name + '-facet', true); var facets = entity.facets.values; - if (!facet_name && facets.length) { + if (!facet_name && facets.length) { facet_name = facets[0].name; } return facet_name; @@ -471,12 +485,47 @@ IPA.entity_header = function(spec) { that.set_pkey = function(value) { if (value) { - var span = $('.entity-pkey', that.pkey); - span.text(value); - that.pkey.css('display', 'inline'); + var breadcrumb = []; + var current_entity = IPA.current_entity.containing_entity; + + while(current_entity){ + breadcrumb.unshift($('<a/>',{ + text:$.bbq.getState(current_entity.name + '-pkey', true) || + '', + title: current_entity.name, + click: function() { + var entity = IPA.get_entity((this.title)); + IPA.nav.show_page(entity.name, 'default'); + $('a', that.facet_tabs).removeClass('selected'); + return false; + } + })); + + current_entity = current_entity.containing_entity; + } + + that.title_container.empty(); + var h3 = $('<h3/>').appendTo(that.title_container); + + h3.empty(); + h3.append(IPA.current_entity.title); + h3.append(': '); + + for (var i = 0; i < breadcrumb.length; i+=1){ + h3.append(breadcrumb[i]); + h3.append(' > '); + } + h3.append( + $('<span/>', { + 'class': 'entity-pkey', + text:value + })); } else { - that.pkey.css('display', 'none'); + that.title_container.empty(); + var span = $('<h3/>',{ + text:IPA.current_entity.metadata.label + }).appendTo(that.title_container); } }; @@ -554,7 +603,12 @@ IPA.entity_header = function(spec) { return false; } - IPA.nav.show_page(that.entity.name, 'search'); + var current_entity = that.entity; + while(current_entity.containing_entity){ + current_entity = current_entity.containing_entity; + } + + IPA.nav.show_page(current_entity.name, 'search'); $('a', that.facet_tabs).removeClass('selected'); return false; } @@ -655,12 +709,9 @@ IPA.entity_builder = function(){ }; that.facet = function(spec) { - spec.entity_name = entity.name; - facet = spec.factory(spec); entity.add_facet(facet); - return that; }; @@ -672,6 +723,19 @@ IPA.entity_builder = function(){ var factory = spec.factory || IPA.search_facet; facet = factory(spec); entity.add_facet(facet); + add_redirect_info(); + + return that; + }; + + that.nested_search_facet = function(spec) { + + spec.entity_name = entity.name; + spec.label = spec.label || IPA.messages.facets.search; + + var factory = spec.factory || IPA.nested_search_facet; + facet = factory(spec); + entity.add_facet(facet); return that; }; @@ -701,22 +765,29 @@ IPA.entity_builder = function(){ spec.entity_name = entity.name; var index = spec.name.indexOf('_'); - spec.attribute_member = spec.attribute_member || spec.name.substring(0, index); - spec.other_entity = spec.other_entity || spec.name.substring(index+1); + spec.attribute_member = spec.attribute_member || + spec.name.substring(0, index); + spec.other_entity = spec.other_entity || + spec.name.substring(index+1); - spec.facet_group = spec.facet_group || spec.attribute_member; + spec.facet_group = spec.facet_group || + spec.attribute_member; - if (spec.facet_group == 'memberindirect' || spec.facet_group == 'memberofindirect') { + if (spec.facet_group == 'memberindirect' || + spec.facet_group == 'memberofindirect') { spec.read_only = true; } - spec.label = spec.label || (IPA.metadata.objects[spec.other_entity] ? IPA.metadata.objects[spec.other_entity].label : spec.other_entity); + spec.label = spec.label || + (IPA.metadata.objects[spec.other_entity] ? + IPA.metadata.objects[spec.other_entity].label : spec.other_entity); if (!spec.title) { - if (spec.facet_group == 'member' || spec.facet_group == 'memberindirect') { + if (spec.facet_group == 'member' || + spec.facet_group == 'memberindirect') { spec.title = IPA.messages.association.member; - - } else if (spec.facet_group == 'memberof' || spec.facet_group == 'memberofindirect') { + } else if (spec.facet_group == 'memberof' || + spec.facet_group == 'memberofindirect') { spec.title = IPA.messages.association.memberof; } } @@ -794,6 +865,18 @@ IPA.entity_builder = function(){ } }; + function add_redirect_info(facet_name){ + if (!entity.redirect_facet){ + entity.redirect_facet = 'search'; + } + } + + that.containing_entity = function(entity_name) { + add_redirect_info(); + entity.containing_entity = IPA.get_entity(entity_name); + return that; + }; + that.dialog = function(spec) { var dialog; if (spec instanceof Object){ |