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/widget.js | 244 +++++++++++++++++++++++++++++++++++------------ 1 file changed, 184 insertions(+), 60 deletions(-) (limited to 'install/static/widget.js') diff --git a/install/static/widget.js b/install/static/widget.js index b4f52b1a..281370ca 100755 --- a/install/static/widget.js +++ b/install/static/widget.js @@ -32,10 +32,12 @@ function ipa_widget(spec) { that.read_only = spec.read_only; that._entity_name = spec.entity_name; + that.init = spec.init || init; that.create = spec.create || create; that.setup = spec.setup || setup; that.load = spec.load || load; that.save = spec.save || save; + that.clear = spec.clear || clear; that.super = function(name) { var method = that[name]; @@ -52,6 +54,9 @@ function ipa_widget(spec) { that._entity_name = entity_name; }); + function init() { + } + function create(container) { } @@ -65,6 +70,9 @@ function ipa_widget(spec) { return []; } + function clear(container) { + } + return that; } @@ -74,6 +82,16 @@ function ipa_text_widget(spec) { var that = ipa_widget(spec); + that.size = spec.size || 30; + + that.create = function(container) { + $('', { + 'type': 'text', + 'name': that.name, + 'size': that.size + }).appendTo(container); + }; + that.load = function(container, result) { that.value = result[that.name] || ''; var input = $('input[name="'+that.name+'"]', container); @@ -101,35 +119,68 @@ function ipa_text_widget(spec) { return values; }; + that.clear = function(container) { + var input = $('input[name="'+that.name+'"]', container); + input.val(''); + }; + return that; } -function ipa_radio_widget(spec) { +function ipa_checkbox_widget(spec) { spec = spec || {}; - spec.setup = spec.setup || setup; - spec.load = spec.load || load; - spec.save = spec.save || save; - var that = ipa_widget(spec); - function setup(container) { - } + that.create = function(container) { + $('', { + 'type': 'checkbox', + 'name': that.name + }).appendTo(container); + }; - function load(container, result) { + that.load = function(container, result) { var value = result[that.name] || ''; $('input[name="'+that.name+'"][value="'+value+'"]', container).attr('checked', 'checked'); - } + }; - function save(container) { + that.save = function(container) { + var values = []; + + var value = $('input[name="'+that.name+'"]', container).is(':checked'); + values.push(value); + + return values; + }; + + that.clear = function(container) { + var input = $('input[name="'+that.name+'"]', container).get(0); + input.checked = false; + }; + + return that; +} + +function ipa_radio_widget(spec) { + + spec = spec || {}; + + var that = ipa_widget(spec); + + that.load = function(container, result) { + var value = result[that.name] || ''; + $('input[name="'+that.name+'"][value="'+value+'"]', container).attr('checked', 'checked'); + }; + + that.save = function(container) { var values = []; var value = $('input[name="'+that.name+'"]:checked', container).val(); values.push(value); return values; - } + }; return that; } @@ -138,28 +189,37 @@ function ipa_textarea_widget(spec) { spec = spec || {}; - spec.setup = spec.setup || setup; - spec.load = spec.load || load; - spec.save = spec.save || save; - var that = ipa_widget(spec); - function setup(container) { - } + that.rows = spec.rows || 5; + that.cols = spec.cols || 40; - function load(container, result) { + that.create = function(container) { + $('