From 1636d649264348526012b1f699284ad728e8a43d Mon Sep 17 00:00:00 2001 From: Adam Young Date: Fri, 6 May 2011 17:04:09 -0400 Subject: 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. --- install/ui/search.js | 145 +++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 112 insertions(+), 33 deletions(-) (limited to 'install/ui/search.js') diff --git a/install/ui/search.js b/install/ui/search.js index 8e64adff9..450b8a655 100644 --- a/install/ui/search.js +++ b/install/ui/search.js @@ -30,40 +30,47 @@ IPA.search_facet = function(spec) { spec.name = spec.name || 'search'; spec.display_class = 'search-facet'; + spec.managed_entity_name = spec.managed_entity_name || spec.entity_name; var that = IPA.table_facet(spec); that.search_all = spec.search_all || false; - that.setup_column = function(column) { - column.setup = function(container, record) { - container.empty(); - - var value = record[column.name]; - value = value ? value.toString() : ''; - - $('', { - 'href': '#'+value, - 'html': value, - 'click': function (value) { - return function() { - IPA.nav.show_page(that.entity_name, 'default', value); - return false; - }; - }(value) - }).appendTo(container); - }; - }; that.init = function() { - that.facet_init(); + that.managed_entity = IPA.get_entity(that.managed_entity_name); + that.init_table(that.managed_entity); + }; + + that.init_table = function(entity){ + + function setup_column(column,entity) { + column.setup = function(container, record) { + container.empty(); + + var value = record[column.name]; + value = value ? value.toString() : ''; + + $('', { + 'href': '#'+value, + 'html': value, + 'click': function (value) { + return function() { + IPA.nav.show_page(entity.name, 'default', value); + return false; + }; + }(value) + }).appendTo(container); + }; + } + that.table = IPA.table_widget({ - id: that.entity_name+'-search', + id: entity.name+'-search', name: 'search', - label: IPA.metadata.objects[that.entity_name].label, - entity_name: that.entity_name, + label: IPA.metadata.objects[entity.name].label, + entity_name: entity.name, search_all: that.search_all }); @@ -71,11 +78,11 @@ IPA.search_facet = function(spec) { for (var i=0; i'+error_thrown.message+'

'); } - var filter = $.bbq.getState(that.entity_name + '-filter', true) || ''; + var filter = []; + var current_entity = entity; + filter.unshift($.bbq.getState(current_entity.name + '-filter', true) || ''); + current_entity = current_entity.containing_entity; + while(current_entity !== null){ + filter.unshift( + $.bbq.getState(current_entity.name + '-pkey', true) || ''); + current_entity = current_entity.containing_entity; + } + var command = IPA.command({ - entity: that.entity_name, + entity: entity.name, method: 'find', - args: [filter], + args: filter, options: { all: that.search_all }, @@ -294,3 +327,49 @@ IPA.search_facet = function(spec) { return that; }; + + +/*TODO. this has much copied code from above. Refactor the search_facet +To either be nested or not nested. */ +IPA.nested_search_facet = function(spec){ + spec.managed_entity_name = spec.nested_entity; + var that = IPA.search_facet(spec); + + that.show = function() { + that.facet_show(); + + //that.entity.header.set_pkey(null); + that.entity.header.back_link.css('visibility', 'visible'); + that.entity.header.facet_tabs.css('visibility', 'visible'); + + that.entity.header.set_pkey( + $.bbq.getState(IPA.current_entity.name + '-pkey', true) || ''); + if (that.filter) { + var filter = + $.bbq.getState(that.managed_entity_name + '-filter', true) || ''; + that.filter.val(filter); + } + }; + + that.refresh = function(){ + + var pkey = $.bbq.getState(that.entity.name + '-pkey', true) || ''; + + if ((!pkey) && (that.entity.redirect_facet)) { + + var current_entity = that.entity; + while (current_entity.containing_entity){ + current_entity = current_entity.containing_entity; + } + + IPA.nav.show_page( + current_entity.name, + that.entity.redirect_facet); + return; + } + + that.search_refresh(that.managed_entity); + }; + + return that; +}; -- cgit