From 65c9442e2697f9e5d8b6cc2b7c22a6b8da426247 Mon Sep 17 00:00:00 2001 From: "Endi S. Dewata" Date: Tue, 9 Nov 2010 14:22:31 -0600 Subject: 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. --- install/static/details.js | 235 ++++++++++++++++++++++++++-------------------- 1 file changed, 134 insertions(+), 101 deletions(-) (limited to 'install/static/details.js') diff --git a/install/static/details.js b/install/static/details.js index 9301f310..efb896a6 100644 --- a/install/static/details.js +++ b/install/static/details.js @@ -31,23 +31,20 @@ IPA.is_field_writable = function(rights){ alert('no right'); } return rights.indexOf('w') > -1; -} +}; function ipa_details_field(spec) { spec = spec || {}; - spec.create = spec.create || create; - spec.setup = spec.setup || setup; - spec.load = spec.load || load; - spec.save = spec.save || save; - var that = ipa_widget(spec); - function create(container) { - } + that.create = spec.create || create; + that.setup = spec.setup || setup; + that.load = spec.load || load; + that.save = spec.save || save; - function setup(container) { + function create(container) { var dl = $('dl', container); @@ -65,6 +62,9 @@ function ipa_details_field(spec) { }).appendTo(dl); } + function setup(container) { + } + function load(container, result) { var multivalue = false; @@ -187,10 +187,6 @@ function ipa_details_section(spec){ } }); - that.get_fields = function() { - return that.fields; - }; - that.get_field = function(name) { return that.fields_by_name[name]; }; @@ -231,6 +227,13 @@ function ipa_details_section(spec){ return field; }; + that.init = function() { + for (var i=0; iError: '+error_thrown.name+'

'); - details.append('

'+error_thrown.title+'

'); - details.append('

'+error_thrown.message+'

'); - } - - var params = []; - if (facet.pkey) params.push(facet.pkey); - - ipa_cmd( - 'show', params, {all: true, rights: true}, on_success, on_failure, facet.entity_name - ); -} - -function ipa_details_create(container, result) +function ipa_details_create(container) { var facet = this; @@ -364,6 +339,8 @@ function ipa_details_create(container, result) var entity_name = container.attr('id'); container.attr('title', entity_name); + facet.setup_views(container); + var details = $('
', { 'class': 'details' }).appendTo(container); @@ -377,7 +354,7 @@ function ipa_details_create(container, result) 'icon': 'ui-icon-refresh', 'class': 'details-reset', 'click': function() { - ipa_details_reset(container); + facet.reset(container); return false; } })); @@ -389,7 +366,7 @@ function ipa_details_create(container, result) 'icon': 'ui-icon-check', 'class': 'details-update', 'click': function() { - ipa_details_update(container, ipa_details_cache[facet.entity_name][pkey_name][0]); + facet.update(container, ipa_details_cache[facet.entity_name][pkey_name][0]); return false; } })); @@ -410,52 +387,111 @@ function ipa_details_create(container, result) 'class': 'details-section' }).appendTo(details); - section.setup(div, result); + section.create(div); details.append('
'); } } +function ipa_details_setup(container, unspecified) { + var that = this; -function ipa_details_section_setup(container, result) { - var section = this; - var fields = section.get_fields(); + for (var i = 0; i < that.sections.length; ++i) { + var section = that.sections[i]; - if (section.template) { - var template = IPA.get_template(section.template); - container.load(template, function(data, text_status, xhr) { - for (var i = 0; i < fields.length; ++i) { - var field = fields[i]; - field.create(container); - field.setup(container); - field.load(container, result); - } - }); - return; + var div = $( + '#'+that.entity_name+'-'+that.name+'-'+section.name, + container + ); + + section.setup(div, unspecified); } +} - section.create(container); +function ipa_details_load(container, unspecified) { - for (var i = 0; i < fields.length; ++i) { - var field = fields[i]; - field.create(container); - field.setup(container); - field.load(container, result); + var that = this; + + that.pkey = $.bbq.getState(that.entity_name + '-pkey', true) || ''; + if (!that.pkey && !unspecified) return; + + function on_success(data, text_status, xhr) { + var result = data.result.result; + + ipa_details_cache[that.entity_name] = $.extend(true, {}, result); + for (var i = 0; i < that.sections.length; ++i) { + var section = that.sections[i]; + + var div = $( + '#'+that.entity_name+'-'+that.name+'-'+section.name, + container + ); + + section.load(div, result); + } } + + function on_failure(xhr, text_status, error_thrown) { + var details = $('.details', container).empty(); + details.append('

Error: '+error_thrown.name+'

'); + details.append('

'+error_thrown.title+'

'); + details.append('

'+error_thrown.message+'

'); + } + + var params = []; + if (that.pkey) params.push(that.pkey); + + ipa_cmd( + 'show', params, {all: true, rights: true}, on_success, on_failure, that.entity_name + ); } -function ipa_details_section_create(container, result) { - var section = this; +function ipa_details_section_create(container) { + + var that = this; + if (that.template) return; var dl = $('
', { - 'id': section.name, + 'id': that.name, 'class': 'entryattrs' }).appendTo(container); + + var fields = that.fields; + for (var i = 0; i < fields.length; ++i) { + var field = fields[i]; + field.create(container); + } +} + +function ipa_details_section_setup(container, unspecified) { + var that = this; + if (that.template) return; + + var fields = that.fields; + for (var i = 0; i < fields.length; ++i) { + var field = fields[i]; + field.setup(container); + } } function ipa_details_section_load(container, result) { - var section = this; - var fields = section.get_fields(); + var that = this; + var fields = that.fields; + + if (that.template) { + var template = IPA.get_template(that.template); + container.load( + template, + function(data, text_status, xhr) { + for (var i = 0; i < fields.length; ++i) { + var field = fields[i]; + field.setup(container); + field.load(container, result); + } + } + ); + return; + } for (var j=0; j tags i.e. all attribute values */ $('dd', container).remove(); /* go through all
tags and pair them with newly created
s */ - var facet = ipa_entity_get_details_facet(entity_name); - var sections = facet.get_sections(); - for (var i=0; i