diff options
author | Adam Young <ayoung@redhat.com> | 2011-07-25 12:15:14 -0400 |
---|---|---|
committer | Adam Young <ayoung@redhat.com> | 2011-07-28 14:17:25 -0400 |
commit | b36df6e9b9c1104d37fe14782a7e21e57097a7c0 (patch) | |
tree | 1eca6d4b0f7127b01f2e366919981ed90090ee95 /install/ui/dialog.js | |
parent | 264ed38fa206537d7b160ea5d7586d071575c610 (diff) | |
download | freeipa-b36df6e9b9c1104d37fe14782a7e21e57097a7c0.tar.gz freeipa-b36df6e9b9c1104d37fe14782a7e21e57097a7c0.tar.xz freeipa-b36df6e9b9c1104d37fe14782a7e21e57097a7c0.zip |
removing setters setup and init
change widget and widget unit tests to hold on to entity, not entity name.
Replacing entity_name with entity.name in most places.
The one exception is columns for table_widget.
Widgets that refer to other entities have to have late resolution of the entity object, due to circular dependencies.
cleanup entity assignment.
removed template and layout,
merged setup into create
adder dialogs adjust height for external
removed init from widget, isection, association, facet, host and service
Make unit tests use factory.
fix functional tests to click find link correctly.
tweak to activation test, but still broken.
moved initialization code to the end
use --all for hbacrule find, so the type shows up now
fixed dns exception code and exception handling for get_entity
replace metadata look up with value from entity.
fixed author lines
removed duplicate columns in managed by facets.
tweak to nav fix in order to initialize tab.
more defensive code
update metadata for true false
one line init for entity_name in widget
move init code to end of constructor functions
moved constants to start of function for adder_dialog
external fields for dialogs initialized at dialog creation
sudo sections: move add fields and columns to widget definition.
The parameter validation in IPA.column ...This is precondition checking. Note that it merely throws an exception if the entity_name is not set. I want this stuff at the top of the function so that it is obvious to people looking to use them what is required. I added a comment to make this clear, but I'd like to keep precondition checking at the top of the function.
decreased the scope of the pkey_name and moved the initiailzation fof columns into the setup_column function for association_tables
return false at the end of click handler
removed blank labels in sudo command section
fix radio buttons for sudo category
fixed table side for adder dialogs with external fields
comments for future direction with add_columns
https://fedorahosted.org/freeipa/ticket/1451
https://fedorahosted.org/freeipa/ticket/1462
https://fedorahosted.org/freeipa/ticket/1493
https://fedorahosted.org/freeipa/ticket/1497
https://fedorahosted.org/freeipa/ticket/1532
https://fedorahosted.org/freeipa/ticket/1534
Diffstat (limited to 'install/ui/dialog.js')
-rw-r--r-- | install/ui/dialog.js | 168 |
1 files changed, 74 insertions, 94 deletions
diff --git a/install/ui/dialog.js b/install/ui/dialog.js index 513a5b9f2..f4a8293bc 100644 --- a/install/ui/dialog.js +++ b/install/ui/dialog.js @@ -30,10 +30,9 @@ IPA.dialog = function(spec) { var that = {}; + that.entity = spec.entity; that.name = spec.name; that.title = spec.title; - that._entity_name = spec.entity_name; - that.width = spec.width || 400; that.height = spec.height; @@ -67,24 +66,6 @@ IPA.dialog = function(spec) { } }; - that.__defineGetter__("entity_name", function(){ - return that._entity_name; - }); - - that.__defineSetter__("entity_name", function(entity_name){ - that._entity_name = entity_name; - - var fields = that.fields.values; - for (var i=0; i<fields.length; i++) { - fields[i].entity_name = entity_name; - } - - var sections = that.sections.values; - for (var j=0; j<sections.length; j++) { - sections[j].entity_name = entity_name; - } - }); - that.add_button = function(name, handler) { that.buttons[name] = handler; }; @@ -120,7 +101,7 @@ IPA.dialog = function(spec) { that.field(IPA.text_widget({ name: name, undo: false, - entity_name : that.entity_name + entity : that.entity })); return that; }; @@ -141,25 +122,6 @@ IPA.dialog = function(spec) { return section; }; - that.init = function() { - - that.entity = IPA.get_entity(that.entity_name); - - var fields = that.fields.values; - for (var i=0; i<fields.length; i++) { - var field = fields[i]; - field.entity_name = that.entity_name; - field.init(); - } - - var sections = that.sections.values; - for (var j=0; j<sections.length; j++) { - var section = sections[j]; - section.entity_name = that.entity_name; - section.init(); - } - }; - /** * Create content layout */ @@ -178,8 +140,14 @@ IPA.dialog = function(spec) { style: 'vertical-align: top;', title: field.label }).appendTo(tr); + var label_text = field.label; + if (label_text !== null){ + label_text += ': '; + }else{ + label_text = ''; + } td.append($('<label />',{id: field.name+'-label', - text:field.label+': '})); + text: label_text})); td = $('<td/>', { style: 'vertical-align: top;' @@ -217,44 +185,21 @@ IPA.dialog = function(spec) { section.create(div); } - }; - - /** - * Setup behavior - */ - that.setup = function() { - var fields = that.fields.values; - for (var i=0; i<fields.length; i++) { - var field = fields[i]; - - var span = $('span[name="'+field.name+'"]', that.container); - field.setup(span); - } - - var sections = that.sections.values; - for (var j=0; j<sections.length; j++) { - var section = sections[j]; - - var div = $('div.details-section[name='+section.name+']', - that.container); - section.setup(div); - } }; + /** * Open dialog */ that.open = function(container) { that.container = $('<div/>'); - if (container) { container.append(that.container); } that.create(); - that.setup(); that.container.dialog({ 'title': that.title, @@ -308,9 +253,7 @@ IPA.dialog = function(spec) { } }; - that.dialog_init = that.init; that.dialog_create = that.create; - that.dialog_setup = that.setup; that.dialog_open = that.open; var fields = spec.fields || []; @@ -320,6 +263,7 @@ IPA.dialog = function(spec) { if (field_spec instanceof Object) { var factory = field_spec.factory || IPA.text_widget; + field_spec.entity = that.entity; field = factory(field_spec); /* This is a bit of a hack, and is here to support ACI @@ -335,7 +279,10 @@ IPA.dialog = function(spec) { } } else { - field = IPA.text_widget({ name: field_spec, undo: false }); + field = IPA.text_widget({ + name: field_spec, + entity:that.entity, + undo: false }); that.add_field(field); } } @@ -348,16 +295,27 @@ IPA.dialog = function(spec) { * values from the available results. */ IPA.adder_dialog = function (spec) { + var NORMAL_HEIGHT = '151px'; + var EXTERNAL_HEIGHT = '119px'; spec = spec || {}; var that = IPA.dialog(spec); - + that.external = spec.external; that.width = spec.width || 600; that.height = spec.height || 360; + if (!that.entity){ + var except = { + expected: false, + message:'Adder dialog created without entity.' + }; + throw except; + } + that.columns = $.ordered_map(); + that.get_column = function(name) { return that.columns.get(name); }; @@ -378,38 +336,40 @@ IPA.adder_dialog = function (spec) { }; that.create_column = function(spec) { + spec.entity = that.entity; var column = IPA.column(spec); that.add_column(column); return column; }; - that.init = function() { + function initialize_table(){ + var table_height = NORMAL_HEIGHT; + if (that.external){ + table_height = EXTERNAL_HEIGHT; + } + that.available_table = IPA.table_widget({ + entity: that.entity, name: 'available', scrollable: true, - height: '151px' + height: table_height }); var columns = that.columns.values; that.available_table.set_columns(columns); - that.available_table.init(); - that.selected_table = IPA.table_widget({ + entity: that.entity, name: 'selected', scrollable: true, - height: '151px' + height: NORMAL_HEIGHT }); that.selected_table.set_columns(columns); - - that.selected_table.init(); - - that.dialog_init(); - }; - + } that.create = function() { + // do not call that.dialog_create(); var search_panel = $('<div/>', { @@ -465,6 +425,7 @@ IPA.adder_dialog = function (spec) { that.available_table.create(available_panel); + var buttons_panel = $('<div/>', { name: 'buttons', 'class': 'adder-dialog-buttons' @@ -495,17 +456,6 @@ IPA.adder_dialog = function (spec) { }).appendTo(selected_panel); that.selected_table.create(selected_panel); - }; - - that.setup = function() { - - // do not call that.dialog_setup(); - - var available_panel = $('div[name=available]', that.container); - that.available_table.setup(available_panel); - - var selected_panel = $('div[name=selected]', that.container); - that.selected_table.setup(selected_panel); that.filter_field = $('input[name=filter]', that.container); @@ -513,7 +463,10 @@ IPA.adder_dialog = function (spec) { that.find_button = IPA.button({ name: 'find', 'label': button.val(), - 'click': function() { that.search(); } + 'click': function() { + that.search(); + return false; + } }); button.replaceWith(that.find_button); @@ -539,9 +492,29 @@ IPA.adder_dialog = function (spec) { }); button.replaceWith(that.add_button); + if (that.external) { + var external_panel = $('<div/>', { + name: 'external', + 'class': 'adder-dialog-external' + }).appendTo(results_panel); + + $('<div/>', { + html: IPA.messages.objects.sudorule.external, + 'class': 'ui-widget-header' + }).appendTo(external_panel); + + that.external_field = $('<input/>', { + type: 'text', + name: 'external', + style: 'width: 244px' + }).appendTo(external_panel); + + } + that.search(); }; + that.open = function(container) { that.buttons[IPA.messages.buttons.enroll] = that.execute; @@ -584,9 +557,16 @@ IPA.adder_dialog = function (spec) { return that.selected_table.save(); }; - that.adder_dialog_init = that.init; + /*dialog initialization */ + if (spec.columns){ + for (var i =0; i < spec.columns.length; i +=1){ + that.create_column(spec.columns[i]); + } + } + + initialize_table(); + that.adder_dialog_create = that.create; - that.adder_dialog_setup = that.setup; return that; }; |