diff options
author | Endi S. Dewata <edewata@redhat.com> | 2011-09-10 11:54:02 -0500 |
---|---|---|
committer | Endi S. Dewata <edewata@redhat.com> | 2011-09-23 13:13:10 +0000 |
commit | 390d017e321fd5ed56af094cf1f1c74f64e95735 (patch) | |
tree | ea90b38f292170059dd757f59ef6b757c5b9b5a5 /install | |
parent | a90e50cdf759a1b436381f0e9e91caf2d4288636 (diff) | |
download | freeipa-390d017e321fd5ed56af094cf1f1c74f64e95735.tar.gz freeipa-390d017e321fd5ed56af094cf1f1c74f64e95735.tar.xz freeipa-390d017e321fd5ed56af094cf1f1c74f64e95735.zip |
Modified dialog to use sections.
The IPA.dialog has been modified to store sections instead of fields.
If there is no sections specified, it will create a default section.
The adder dialog for automount map has been modified such that the
fields related to indirect map are stored in a section which will
only be visible when the map type is set to indirect.
The adder dialog for host has been modified such that it uses a
custom section for hostname and DNS zone and standard section for
the other fields.
Ticket #1394
Diffstat (limited to 'install')
-rw-r--r-- | install/ui/aci.js | 41 | ||||
-rw-r--r-- | install/ui/add.js | 69 | ||||
-rw-r--r-- | install/ui/association.js | 2 | ||||
-rw-r--r-- | install/ui/automount.js | 106 | ||||
-rw-r--r-- | install/ui/details.js | 90 | ||||
-rw-r--r-- | install/ui/dialog.js | 211 | ||||
-rw-r--r-- | install/ui/dns.js | 3 | ||||
-rw-r--r-- | install/ui/entitle.js | 8 | ||||
-rw-r--r-- | install/ui/entity.js | 19 | ||||
-rw-r--r-- | install/ui/host.js | 158 | ||||
-rw-r--r-- | install/ui/ipa.css | 14 | ||||
-rw-r--r-- | install/ui/ipa.js | 4 | ||||
-rw-r--r-- | install/ui/service.js | 22 | ||||
-rw-r--r-- | install/ui/test/aci_tests.js | 4 | ||||
-rw-r--r-- | install/ui/user.js | 4 | ||||
-rw-r--r-- | install/ui/widget.js | 30 |
16 files changed, 378 insertions, 407 deletions
diff --git a/install/ui/aci.js b/install/ui/aci.js index 5dcd69d44..13fbc7d13 100644 --- a/install/ui/aci.js +++ b/install/ui/aci.js @@ -65,12 +65,20 @@ IPA.entity_factories.permission = function() { adder_dialog({ width: 500, height: 400, - fields: [ - 'cn', + sections: [ { - factory: IPA.rights_widget, - name: 'permissions', - join: true, undo: false + name: 'general', + fields: [ + { + name: 'cn', + undo: false + }, + { + factory: IPA.rights_widget, + name: 'permissions', + join: true, undo: false + } + ] }, { factory: IPA.target_section, @@ -274,7 +282,7 @@ IPA.attributes_widget = function(spec) { } if (that.object_type){ - that.populate (that.object_type); + that.populate(that.object_type); } }; @@ -392,7 +400,6 @@ IPA.target_section = function(spec) { spec = spec || {}; var that = IPA.details_section(spec); - that.section = true; that.undo = typeof spec.undo == 'undefined' ? true : spec.undo; var target_types = [ @@ -406,7 +413,7 @@ IPA.target_section = function(spec) { that.filter_text.load(record); }, save: function(record) { - record.filter = that.filter_text.save()[0]; + record.filter = that.filter_text.save(); } }, { @@ -419,7 +426,7 @@ IPA.target_section = function(spec) { that.subtree_textarea.load(record); }, save: function(record) { - record.subtree = that.subtree_textarea.save()[0]; + record.subtree = that.subtree_textarea.save(); } }, { @@ -432,7 +439,7 @@ IPA.target_section = function(spec) { that.group_select.list.val(record.targetgroup); }, save: function(record) { - record.targetgroup = that.group_select.save()[0]; + record.targetgroup = that.group_select.save(); } }, { @@ -478,17 +485,17 @@ IPA.target_section = function(spec) { that.type_select.select_update(); that.attribute_table.object_type = that.type_select.save()[0]; - that.attribute_table.reset(); - }; + that.attribute_table.reset(); + }; }, - load: function(record){ + load: function(record) { that.type_select.load(record); that.attribute_table.object_type = record.type; that.attribute_table.reset(); }, - save: function(record){ - record.type = that.type_select.save()[0]; - record.attrs = that.attribute_table.save().join(','); + save: function(record) { + record.type = that.type_select.save(); + record.attrs = that.attribute_table.save(); } }] ; @@ -507,12 +514,14 @@ IPA.target_section = function(spec) { undo: that.undo }); that.group_select = IPA.entity_select_widget({ + entity: spec.entity, name: 'targetgroup', other_entity: 'group', other_field: 'cn', undo: that.undo }); that.type_select = IPA.select_widget({ + entity: spec.entity, name: 'type', undo: that.undo }); diff --git a/install/ui/add.js b/install/ui/add.js index b4f1228f0..21707df13 100644 --- a/install/ui/add.js +++ b/install/ui/add.js @@ -46,9 +46,8 @@ IPA.add_dialog = function (spec) { that.show_edit_page = spec.show_edit_page || show_edit_page; - that.add = function(record, on_success, on_error) { + that.add = function(on_success, on_error) { - var field, value, pkey_prefix; var pkey_name = that.entity.metadata.primary_key; var command = IPA.command({ @@ -60,46 +59,36 @@ IPA.add_dialog = function (spec) { }); that.command = command; - pkey_prefix = that.entity.get_primary_key_prefix(); + command.add_args(that.entity.get_primary_key_prefix()); - for (var h=0; h<pkey_prefix.length; h++) { - command.add_arg(pkey_prefix[h]); - } + var record = {}; + that.save(record); - var fields = that.fields.values; + var fields = that.get_fields(); for (var i=0; i<fields.length; i++) { fields[i].validate(); } - var required_fields_filled = true; - for (i=0; i<fields.length; i++) { - field = fields[i]; - if (!field.valid) return; - required_fields_filled = field.check_required() && - required_fields_filled; + var valid = true; - value = record[field.name]; - if (!value) continue; + var sections = that.sections.values; + for (i=0; i<sections.length; i++) { + var section = sections[i]; - if (field.name == pkey_name) { - command.add_arg(value); - } else { - command.set_option(field.name, value); + if (!section.is_valid() || !valid) { + valid = false; + continue; } - } - - var sections = that.sections.values; - for (var j=0; j<sections.length; j++) { - var section = sections[j]; var section_fields = section.fields.values; - for (var k=0; k<section_fields.length; k++) { - field = section_fields[k]; - if (!field.valid) return; - required_fields_filled = field.check_required() && - required_fields_filled; + for (var j=0; j<section_fields.length; j++) { + var field = section_fields[j]; - value = record[field.name]; + var values = record[field.name]; + if (!values) continue; + + // TODO: Handle multi-valued attributes like in detail facet's update() + var value = values.join(','); if (!value) continue; if (field.name == pkey_name) { @@ -110,23 +99,20 @@ IPA.add_dialog = function (spec) { } } + if (!valid) return; + //alert(JSON.stringify(command.to_json())); - if (that.pre_execute_hook){ + if (that.pre_execute_hook) { that.pre_execute_hook(command); } - if (required_fields_filled){ - command.execute(); - } + command.execute(); }; /*dialog initialization*/ that.add_button(IPA.messages.buttons.add, function() { - var record = {}; - that.save(record); that.add( - record, function(data, text_status, xhr) { var facet = IPA.current_entity.get_facet(); var table = facet.table; @@ -137,10 +123,7 @@ IPA.add_dialog = function (spec) { }); that.add_button(IPA.messages.buttons.add_and_add_another, function() { - var record = {}; - that.save(record); that.add( - record, function(data, text_status, xhr) { var facet = IPA.current_entity.get_facet(); var table = facet.table; @@ -151,14 +134,11 @@ IPA.add_dialog = function (spec) { }); that.add_button(IPA.messages.buttons.add_and_edit, function() { - var record = {}; - that.save(record); that.add( - record, function(data, text_status, xhr) { that.close(); var result = data.result.result; - that.show_edit_page(that.entity,result); + that.show_edit_page(that.entity, result); }, that.on_error); }); @@ -167,7 +147,6 @@ IPA.add_dialog = function (spec) { that.close(); }); - return that; }; diff --git a/install/ui/association.js b/install/ui/association.js index 664c80e21..3d75072ae 100644 --- a/install/ui/association.js +++ b/install/ui/association.js @@ -650,7 +650,7 @@ IPA.association_table_widget = function (spec) { entity: that.entity.name, method: 'show', args: [pkey], - options: {'all': true, 'rights': true}, + options: { all: true, rights: true }, on_success: on_success, on_error: on_error }).execute(); diff --git a/install/ui/automount.js b/install/ui/automount.js index eeff8a048..8be2b6574 100644 --- a/install/ui/automount.js +++ b/install/ui/automount.js @@ -36,25 +36,26 @@ IPA.entity_factories.automountlocation = function() { }). nested_search_facet({ facet_group: 'automountmap', - nested_entity : 'automountmap', - label : IPA.metadata.objects.automountmap.label, + nested_entity: 'automountmap', + label: IPA.metadata.objects.automountmap.label, name: 'maps', - columns:['automountmapname'] + columns: [ 'automountmapname' ] }). details_facet({ sections:[ { - name:'identity', + name: 'identity', label: IPA.messages.details.identity, - fields:['cn'] + fields: [ 'cn' ] } ] }). adder_dialog({ - fields:['cn'] + fields: [ 'cn' ] }). build(); }; + IPA.entity_factories.automountmap = function() { return IPA.entity_builder(). entity({ name: 'automountmap' }). @@ -62,63 +63,78 @@ IPA.entity_factories.automountmap = function() { facet_groups([ 'automountkey', 'settings' ]). nested_search_facet({ facet_group: 'automountkey', - nested_entity : 'automountkey', - label : IPA.metadata.objects.automountkey.label, + nested_entity: 'automountkey', + label: IPA.metadata.objects.automountkey.label, name: 'keys', get_values: IPA.get_option_values, - columns:[ + columns: [ { factory: IPA.automount_key_column, - name:'automountkey', - label:IPA.get_entity_param('automountkey', 'automountkey'). - label + name: 'automountkey', + label: IPA.get_entity_param('automountkey', 'automountkey').label }, - 'automountinformation'] + 'automountinformation' + ] }). details_facet({ - sections:[ + sections: [ { - name:'identity', + name: 'identity', label: IPA.messages.details.identity, - fields:['automountmapname','description'] + fields: [ 'automountmapname', 'description' ] } ] }). adder_dialog({ factory: IPA.automountmap_adder_dialog, - fields: [ + sections: [ { - factory: IPA.radio_widget, - name: 'method', - undo: false, - label: IPA.messages.objects.automountmap.map_type, - options: [ + name: 'general', + fields: [ { - value: 'add', - label: IPA.messages.objects.automountmap.direct + factory: IPA.radio_widget, + name: 'method', + label: IPA.messages.objects.automountmap.map_type, + options: [ + { + value: 'add', + label: IPA.messages.objects.automountmap.direct + }, + { + value: 'add_indirect', + label: IPA.messages.objects.automountmap.indirect + } + ], + undo: false }, { - value: 'add_indirect', - label: IPA.messages.objects.automountmap.indirect + name: 'automountmapname', + undo: false + }, + { + name: 'description', + undo: false } ] }, - 'automountmapname', - 'description', - { - name: 'key', - label: IPA.get_method_option( - 'automountmap_add_indirect', 'key').label, - conditional: true, - undo: false - }, { - name: 'parentmap', - label: IPA.get_method_option( - 'automountmap_add_indirect', 'parentmap').label, - conditional: true, - undo: false - }] + name: 'indirect', + fields: [ + { + name: 'key', + label: IPA.get_method_option( + 'automountmap_add_indirect', 'key').label, + undo: false + }, + { + name: 'parentmap', + label: IPA.get_method_option( + 'automountmap_add_indirect', 'parentmap').label, + undo: false + } + ] + } + ] }). build(); }; @@ -202,7 +218,6 @@ IPA.automount_key_column = function(spec){ return that; }; - IPA.automountmap_adder_dialog = function(spec) { var that = IPA.add_dialog(spec); @@ -214,12 +229,14 @@ IPA.automountmap_adder_dialog = function(spec) { var direct_input = $('input[value="add"]', method_field.container); direct_input.change(function() { - that.disable_conditional_fields(); + that.method = 'add'; + that.get_section('indirect').set_visible(false); }); var indirect_input = $('input[value="add_indirect"]', method_field.container); indirect_input.change(function() { - that.enable_conditional_fields(); + that.method = 'add_indirect'; + that.get_section('indirect').set_visible(true); }); direct_input.click(); @@ -237,7 +254,6 @@ IPA.automountmap_adder_dialog = function(spec) { return that; }; - IPA.get_option_values = function(){ var values = []; diff --git a/install/ui/details.js b/install/ui/details.js index f7831114d..cecf97a61 100644 --- a/install/ui/details.js +++ b/install/ui/details.js @@ -43,17 +43,42 @@ IPA.details_section = function(spec) { that.dirty = false; that.dirty_changed = IPA.observer(); + that.undo = typeof spec.undo == 'undefined' ? true : spec.undo; + + var init = function() { + var fields = spec.fields || []; + that.add_fields(fields); + }; + that.get_field = function(name) { return that.fields.get(name); }; that.add_field = function(field) { field.entity = that.entity; + field.undo = that.undo; that.fields.put(field.name, field); field.dirty_changed.attach(that.field_dirty_changed); return field; }; + that.add_fields = function(fields) { + for (var i=0; i<fields.length; i++) { + var field_spec = fields[i]; + var field; + + if (field_spec instanceof Object) { + var factory = field_spec.factory || IPA.text_widget; + field_spec.entity = that.entity; + field = factory(field_spec); + that.add_field(field); + + } else { + that.text({ name: field_spec }); + } + } + }; + that.field = function(field) { that.add_field(field); return that; @@ -93,6 +118,8 @@ IPA.details_section = function(spec) { var fields = that.fields.values; for (var i=0; i<fields.length; i++) { var field = fields[i]; + if (field.hidden) continue; + var field_container = $('<div/>', { name: field.name, title: field.label, @@ -102,7 +129,6 @@ IPA.details_section = function(spec) { } }; - that.load = function(record) { that.record = record; @@ -114,6 +140,14 @@ IPA.details_section = function(spec) { } }; + that.save = function(record) { + var fields = that.fields.values; + for (var i=0; i<fields.length; i++) { + var field = fields[i]; + record[field.name] = field.save(); + } + }; + that.reset = function() { var fields = that.fields.values; for (var i=0; i<fields.length; i++) { @@ -159,6 +193,16 @@ IPA.details_section = function(spec) { return valid; }; + that.set_visible = function(visible) { + if (visible) { + that.container.show(); + } else { + that.container.hide(); + } + }; + + init(); + // methods that should be invoked by subclasses that.section_create = that.create; that.section_setup = that.setup; @@ -272,6 +316,15 @@ IPA.details_facet = function(spec) { return section; }; + that.get_fields = function() { + var fields = []; + for (var i=0; i<that.sections.length; i++) { + var section = that.sections.values[i]; + $.merge(fields, section.fields.values); + } + return fields; + }; + /* the primary key used for show and update is built as an array. for most entities, this will be a single element long, but for some it requires the containing entities primary keys as well.*/ @@ -509,6 +562,14 @@ IPA.details_facet = function(spec) { that.enable_update(false); }; + that.save = function(record) { + var sections = that.sections.values; + for (var i=0; i<sections.length; i++) { + var section = sections[i]; + section.save(record); + } + }; + that.reset = function() { var sections = that.sections.values; for (var i=0; i<sections.length; i++) { @@ -554,31 +615,34 @@ IPA.details_facet = function(spec) { on_error: on_error }); - var values; + var record = {}; + that.save(record); + + var fields = that.get_fields(); + for (var i=0; i<fields.length; i++) { + fields[i].validate(); + } + var valid = true; var sections = that.sections.values; - for (var i=0; i<sections.length; i++) { + for (i=0; i<sections.length; i++) { var section = sections[i]; - if(!section.is_valid() || !valid) { + if (!section.is_valid() || !valid) { valid = false; continue; } - if (section.save) { - section.save(command.options); - continue; - } - var section_fields = section.fields.values; for (var j=0; j<section_fields.length; j++) { var field = section_fields[j]; if (!field.is_dirty()) continue; - values = field.save(); + var values = record[field.name]; if (!values) continue; - var param_info = field.param_info; + + var param_info = field.param_info; if (param_info) { if (param_info.primary_key) continue; if (values.length === 1) { @@ -588,7 +652,7 @@ IPA.details_facet = function(spec) { } else { command.set_option(field.name, values); } - } else { + } else { if (values.length) { command.add_option('setattr', field.name+'='+values[0]); } else { @@ -601,7 +665,7 @@ IPA.details_facet = function(spec) { } } - if(!valid) { + if (!valid) { var dialog = IPA.message_dialog({ title: IPA.messages.dialogs.validation_title, message: IPA.messages.dialogs.validation_message diff --git a/install/ui/dialog.js b/install/ui/dialog.js index eb1bbd1d9..e533e4af8 100644 --- a/install/ui/dialog.js +++ b/install/ui/dialog.js @@ -39,32 +39,22 @@ IPA.dialog = function(spec) { that.buttons = {}; - that.fields = $.ordered_map(); that.sections = $.ordered_map(); - that.conditional_fields = []; + var init = function() { + + var sections = spec.sections || []; - that.enable_conditional_fields = function(){ - for (var i =0; i < that.conditional_fields.length; i+=1) { - $('label[id='+ - that.conditional_fields[i] +'-label]', - that.container).css('visibility','visible'); - $('input[name='+ - that.conditional_fields[i] + - ']',that.container).css('visibility','visible'); + for (var i=0; i<sections.length; i++) { + var section_spec = sections[i]; + that.create_section(section_spec); } - }; - that.disable_conditional_fields = function(){ - for (var i =0; i < that.conditional_fields.length; i+=1) { - $('label[id='+ - that.conditional_fields[i] +'-label]', - that.container).css('visibility','hidden'); + var fields = spec.fields || []; - $('input[name='+ - that.conditional_fields[i] + - ']',that.container).css('visibility','hidden'); - } + // add fields to the default section + var section = that.get_section(); + section.add_fields(fields); }; that.add_button = function(name, handler) { @@ -72,15 +62,29 @@ IPA.dialog = function(spec) { }; that.get_field = function(name) { - return that.fields.get(name); + for (var i=0; i<that.sections.length; i++) { + var section = that.sections.values[i]; + var field = section.fields.get(name); + if (field) return field; + } + return null; + }; + + that.get_fields = function() { + var fields = []; + for (var i=0; i<that.sections.length; i++) { + var section = that.sections.values[i]; + $.merge(fields, section.fields.values); + } + return fields; }; that.add_field = function(field) { field.dialog = that; - that.fields.put(field.name, field); - if (field.conditional){ - that.conditional_fields.push(field.name); - } + + var section = that.get_section(); + section.add_field(field); + return field; }; @@ -90,23 +94,13 @@ IPA.dialog = function(spec) { }; that.is_valid = function() { - var fields = that.fields.values; - for (var i=0; i<fields.length; i++) { - var field = fields[i]; - if (!field.valid) return false; + for (var i=0; i<that.sections.length; i++) { + var section = that.sections.values[i]; + if (!section.is_valid()) return false; } return true; }; - that.text = function(name){ - that.field(IPA.text_widget({ - name: name, - undo: false, - entity : that.entity - })); - return that; - }; - that.add_section = function(section) { that.sections.put(section.name, section); return that; @@ -118,72 +112,42 @@ IPA.dialog = function(spec) { }; that.create_section = function(spec) { - var section = IPA.details_section(spec); + + var factory = spec.factory || IPA.details_table_section; + spec.entity = that.entity; + spec.undo = false; + + var section = factory(spec); that.add_section(section); + return section; }; - /** - * Create content layout - */ - that.create = function() { + that.get_section = function(name) { - var table = $('<table/>', { - 'class': 'section-table' - }).appendTo(that.container); + if (name) { + return that.sections.get(name); - var fields = that.fields.values; - for (var i=0; i<fields.length; i++) { - var field = fields[i]; - if (field.hidden) continue; - - var tr = $('<tr/>').appendTo(table); - - var td = $('<td/>', { - 'class': 'section-cell-label' - }).appendTo(tr); - - $('<label/>', { - name: field.name, - title: field.label, - 'class': 'field-label', - text: field.label+':' - }).appendTo(td); - - td = $('<td/>', { - 'class': 'section-cell-field' - }).appendTo(tr); - - var field_container = $('<div/>', { - name: field.name, - title: field.label, - 'class': 'field' - }).appendTo(td); - - field.create(field_container); - - if (field.optional) { - field_container.css('display', 'none'); - - var link = $('<a/>', { - text: IPA.messages.widget.optional, - href: '' - }).appendTo(td); - - link.click(function(field_container, link) { - return function() { - field_container.css('display', 'inline'); - link.css('display', 'none'); - return false; - }; - }(field_container, link)); + } else { + var length = that.sections.length; + if (length) { + // get the last section + return that.sections.values[length-1]; + } else { + // create a default section + return that.create_section({ name: 'general' }); } - } + }; + + /** + * Create content layout + */ + that.create = function() { var sections = that.sections.values; - for (var j=0; j<sections.length; j++) { - var section = sections[j]; + for (var i=0; i<sections.length; i++) { + var section = sections[i]; var div = $('<div/>', { name: section.name, @@ -228,20 +192,10 @@ IPA.dialog = function(spec) { }; that.save = function(record) { - var fields = that.fields.values; - for (var i=0; i<fields.length; i++) { - var field = fields[i]; - var values = field.save(); - record[field.name] = values.join(','); - } - var sections = that.sections.values; - for (var j=0; j<sections.length; j++) { - var section = sections[j]; - - if (section.save) { - section.save(record); - } + for (var i=0; i<sections.length; i++) { + var section = sections[i]; + section.save(record); } }; @@ -251,55 +205,20 @@ IPA.dialog = function(spec) { }; that.reset = function() { - var fields = that.fields.values; - for (var i=0; i<fields.length; i++) { - var field = fields[i]; - field.reset(); - } - var sections = that.sections.values; - for (var j=0; j<sections.length; j++) { - sections[j].reset(); + for (var i=0; i<sections.length; i++) { + sections[i].reset(); } }; + init(); + that.dialog_create = that.create; that.dialog_open = that.open; that.dialog_close = that.close; that.dialog_save = that.save; that.dialog_reset = that.reset; - var fields = spec.fields || []; - for (var i=0; i<fields.length; i++) { - var field_spec = fields[i]; - var field; - - 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 - permissions. The target section is a group of several - widgets together. It makes more sense to do them as a - section than as a widget. However, since they can be mixed - into the flow with the other widgets, the section needs to - be defined here with the fields to get the order correct.*/ - if (field.section) { - that.add_section(field); - } else { - that.add_field(field); - } - - } else { - field = IPA.text_widget({ - name: field_spec, - entity:that.entity, - undo: false }); - that.add_field(field); - } - } - return that; }; diff --git a/install/ui/dns.js b/install/ui/dns.js index e01e28f68..da00a0495 100644 --- a/install/ui/dns.js +++ b/install/ui/dns.js @@ -105,7 +105,8 @@ IPA.entity_factories.dnszone = function() { }, { factory: IPA.force_dnszone_add_checkbox_widget, - name: 'force' + name: 'force', + param_info: IPA.get_method_option('dnszone_add', 'force') } ] }). diff --git a/install/ui/entitle.js b/install/ui/entitle.js index 2687f6f95..693206cb0 100644 --- a/install/ui/entitle.js +++ b/install/ui/entitle.js @@ -580,9 +580,9 @@ IPA.entitle.register_online_dialog = function(spec) { that.save(record); that.entity.register_online( - record.username, - record.password, - record.ipaentitlementid, + record.username[0], + record.password[0], + record.ipaentitlementid[0], function() { var facet = that.entity.get_facet(); facet.refresh(); @@ -638,7 +638,7 @@ IPA.entitle.consume_dialog = function(spec) { that.save(record); that.entity.consume( - record.quantity, + record.quantity[0], function() { var facet = that.entity.get_facet(); facet.refresh(); diff --git a/install/ui/entity.js b/install/ui/entity.js index 15e45aad9..1ae233fe4 100644 --- a/install/ui/entity.js +++ b/install/ui/entity.js @@ -885,25 +885,6 @@ IPA.entity_builder = function(){ section = IPA.details_table_section(spec); } facet.add_section(section); - var fields = spec.fields; - if (fields) { - for (var i=0; i<fields.length; i++) { - var field_spec = fields[i]; - var field; - - if (field_spec instanceof Object) { - field_spec.entity = entity; - var factory = field_spec.factory || IPA.text_widget; - field = factory(field_spec); - } else { - field = IPA.text_widget({ - name: field_spec, - entity: entity - }); - } - section.add_field(field); - } - } }; function add_redirect_info(facet_name){ diff --git a/install/ui/host.js b/install/ui/host.js index 2b0a5a4ed..1a3ccadc6 100644 --- a/install/ui/host.js +++ b/install/ui/host.js @@ -119,37 +119,50 @@ IPA.entity_factories.host = function () { factory: IPA.host_adder_dialog, width: 400, height: 250, - fields: [ + sections: [ { - factory: IPA.widget, + factory: IPA.host_fqdn_section, name: 'fqdn', - optional: true, - hidden: true - }, - { - factory: IPA.text_widget, - name: 'hostname', - label: IPA.messages.objects.service.host, - undo: false - }, - { - factory: IPA.dnszone_select_widget, - name: 'dnszone', - label: IPA.metadata.objects.dnszone.label_singular, - editable: true, - empty_option: false, - undo: false - }, - { - factory: IPA.force_host_add_checkbox_widget, - name: 'force' + fields: [ + { + factory: IPA.widget, + name: 'fqdn', + optional: true, + hidden: true + }, + { + factory: IPA.text_widget, + name: 'hostname', + label: IPA.messages.objects.service.host, + param_info: { required: true }, + undo: false + }, + { + factory: IPA.dnszone_select_widget, + name: 'dnszone', + label: IPA.metadata.objects.dnszone.label_singular, + editable: true, + empty_option: false, + param_info: { required: true }, + undo: false + } + ] }, { - factory: IPA.text_widget, - name: 'ip_address', - label: IPA.get_method_option('host_add','ip_address')['label'], - tooltip: IPA.get_method_option('host_add','ip_address')['doc'], - undo: false + name: 'other', + fields: [ + { + factory: IPA.text_widget, + name: 'ip_address', + param_info: IPA.get_method_option('host_add', 'ip_address'), + undo: false + }, + { + factory: IPA.force_host_add_checkbox_widget, + name: 'force', + param_info: IPA.get_method_option('host_add', 'force') + } + ] } ] }). @@ -159,91 +172,55 @@ IPA.entity_factories.host = function () { build(); }; -IPA.host_adder_dialog = function(spec) { +IPA.host_fqdn_section = function(spec) { spec = spec || {}; - spec.retry = typeof spec.retry !== 'undefined' ? spec.retry : false; - var that = IPA.add_dialog(spec); - - that.create = function() { + var that = IPA.details_section(spec); - that.container.addClass('host-adder-dialog'); + that.create = function(container) { + that.container = container; var hostname = that.get_field('hostname'); var dnszone = that.get_field('dnszone'); var table = $('<table/>', { - name: 'fqdn' + 'class': 'fqdn' }).appendTo(that.container); var tr = $('<tr/>').appendTo(table); - var td = $('<td/>', { - name: hostname.name, + var th = $('<th/>', { + 'class': 'hostname', title: hostname.label, text: hostname.label }).appendTo(tr); - td = $('<td/>', { - name: dnszone.name, + th = $('<th/>', { + 'class': 'dnszone', title: dnszone.label, text: dnszone.label }).appendTo(tr); tr = $('<tr/>').appendTo(table); - td = $('<td/>').appendTo(tr); + var td = $('<td/>', { + 'class': 'hostname' + }).appendTo(tr); + var span = $('<span/>', { name: hostname.name }).appendTo(td); hostname.create(span); - td = $('<td/>').appendTo(tr); - span = $('<span/>', { - name: dnszone.name - }).appendTo(td); - dnszone.create(span); - - table = $('<table/>', { - name: 'other' - }).appendTo(that.container); - - var force = that.get_field('force'); - - tr = $('<tr/>').appendTo(table); - - td = $('<td/>', { - title: force.label, - text: force.label+':' - }).appendTo(tr); - - td = $('<td/>', { - title: force.label - }).appendTo(tr); - - span = $('<span/>', { - name: force.name - }).appendTo(td); - force.create(span); - - var ip_address = that.get_field('ip_address'); - - tr = $('<tr/>').appendTo(table); - td = $('<td/>', { - title: ip_address.label, - text: ip_address.label+':' - }).appendTo(tr); - - td = $('<td/>', { - title: ip_address.label + 'class': 'dnszone' }).appendTo(tr); span = $('<span/>', { - name: ip_address.name + name: dnszone.name }).appendTo(td); - ip_address.create(span); + dnszone.create(span); var hostname_input = $('input', hostname.container); var dnszone_input = $('input', dnszone.container); @@ -271,13 +248,22 @@ IPA.host_adder_dialog = function(spec) { field = that.get_field('dnszone'); var dnszone = field.save()[0]; - record.fqdn = hostname && dnszone ? hostname+'.'+dnszone : null; + record.fqdn = hostname && dnszone ? [ hostname+'.'+dnszone ] : []; + }; + + return that; +}; + +IPA.host_adder_dialog = function(spec) { - field = that.get_field('force'); - record.force = field.save()[0]; + spec = spec || {}; + spec.retry = typeof spec.retry !== 'undefined' ? spec.retry : false; - field = that.get_field('ip_address'); - record.ip_address = field.save()[0]; + var that = IPA.add_dialog(spec); + + that.create = function() { + that.dialog_create(); + that.container.addClass('host-adder-dialog'); }; that.on_error = function(xhr, text_status, error_thrown) { @@ -660,8 +646,8 @@ IPA.host_password_widget = function(spec) { var record = {}; dialog.save(record); - var new_password = record.password1; - var repeat_password = record.password2; + var new_password = record.password1[0]; + var repeat_password = record.password2[0]; if (new_password != repeat_password) { alert(IPA.messages.password.password_must_match); diff --git a/install/ui/ipa.css b/install/ui/ipa.css index 826126065..7876da355 100644 --- a/install/ui/ipa.css +++ b/install/ui/ipa.css @@ -807,7 +807,7 @@ hr { } .dialog-section { - margin-top: 10px; + margin-bottom: 10px; } .section-table { @@ -1231,14 +1231,22 @@ table.scrollable tbody { margin-right: 3px; } -.host-adder-dialog table[name=fqdn] { +.host-adder-dialog table.fqdn { width: 100%; } -.host-adder-dialog td[name=hostname] { +.host-adder-dialog th.hostname { width: 110px; } +.host-adder-dialog td.hostname { + vertical-align: top; +} + +.host-adder-dialog td.dnszone { + vertical-align: top; +} + .host-adder-dialog input[name=hostname] { width: 100%; } diff --git a/install/ui/ipa.js b/install/ui/ipa.js index f71de82a5..ca081dc0d 100644 --- a/install/ui/ipa.js +++ b/install/ui/ipa.js @@ -281,6 +281,10 @@ IPA.command = function(spec) { that.args.push(arg); }; + that.add_args = function(args) { + $.merge(that.args, args); + }; + that.set_option = function(name, value) { that.options[name] = value; }; diff --git a/install/ui/service.js b/install/ui/service.js index 0bb15cba8..7ff1ba711 100644 --- a/install/ui/service.js +++ b/install/ui/service.js @@ -110,31 +110,31 @@ IPA.service_add_dialog = function(spec) { var that = IPA.add_dialog(spec). field(IPA.widget({ name: 'krbprincipalname', - optional:true, - entity:spec.entity, + optional: true, + entity: spec.entity, hidden: true })). field(IPA.service_select_widget({ name: 'service', label: IPA.messages.objects.service.service, size: 20, - entity:spec.entity, + entity: spec.entity, + param_info: { required: true }, undo: false })). field(IPA.entity_select_widget({ name: 'host', other_entity: 'host', other_field: 'fqdn', - entity:spec.entity, + entity: spec.entity, label: IPA.messages.objects.service.host, + param_info: { required: true }, undo: false })). - field( - IPA.checkbox_widget({ + field(IPA.checkbox_widget({ name: 'force', - entity:spec.entity, - label: IPA.get_method_option('service_add', 'force').label, - tooltip: IPA.get_method_option('service_add', 'force').doc, + entity: spec.entity, + param_info: IPA.get_method_option('service_add', 'force'), undo: false })); @@ -147,10 +147,10 @@ IPA.service_add_dialog = function(spec) { field = that.get_field('host'); var host = field.save()[0]; - record['krbprincipalname'] = service+'/'+host; + record['krbprincipalname'] = [ service+'/'+host ]; field = that.get_field('force'); - record['force'] = field.save()[0]; + record['force'] = field.save(); }; return that; diff --git a/install/ui/test/aci_tests.js b/install/ui/test/aci_tests.js index acb4e7dab..10b76aefc 100644 --- a/install/ui/test/aci_tests.js +++ b/install/ui/test/aci_tests.js @@ -152,7 +152,7 @@ test("Testing type target.", function() { $("input[type=checkbox]").attr("checked",true); var response_record = {}; target_section.save(response_record); - same(response_record.type, sample_data_filter_only.type, + same(response_record.type[0], sample_data_filter_only.type, "saved type matches sample data"); ok((response_record.attrs.length > 10), "response length shows some attrs set"); @@ -180,7 +180,7 @@ test("Testing subtree target.", function() { target_section.load(sample_data); var record = {}; target_section.save(record); - same(record.subtree, sample_data.subtree, 'subtree set correctly'); + same(record.subtree[0], sample_data.subtree, 'subtree set correctly'); }); diff --git a/install/ui/user.js b/install/ui/user.js index d390d1906..6243cd2d6 100644 --- a/install/ui/user.js +++ b/install/ui/user.js @@ -340,8 +340,8 @@ IPA.user_password_widget = function(spec) { var record = {}; dialog.save(record); - var new_password = record.password1; - var repeat_password = record.password2; + var new_password = record.password1[0]; + var repeat_password = record.password2[0]; if (new_password != repeat_password) { alert(IPA.messages.password.password_must_match); diff --git a/install/ui/widget.js b/install/ui/widget.js index 5438c8157..4a02cb7d8 100644 --- a/install/ui/widget.js +++ b/install/ui/widget.js @@ -40,7 +40,6 @@ IPA.widget = function(spec) { that.disabled = spec.disabled; that.hidden = spec.hidden; - that.conditional = spec.conditional; that.optional = spec.optional || false; // read_only is set when widget is created @@ -65,8 +64,8 @@ IPA.widget = function(spec) { that.dirty_changed = IPA.observer(); - function set_param_info(){ - if (!that.param_info && that.entity){ + function set_param_info() { + if (!that.param_info && that.entity) { that.param_info = IPA.get_entity_param(that.entity.name, that.name); } @@ -88,7 +87,7 @@ IPA.widget = function(spec) { if (!value.match(/^-?\d+$/)) { that.valid = false; that.show_error(IPA.messages.widget.validation.integer); - return; + return that.valid; } if (meta.minvalue !== undefined && value < meta.minvalue) { @@ -96,7 +95,7 @@ IPA.widget = function(spec) { message = IPA.messages.widget.validation.min_value; message = message.replace('${value}', meta.minvalue); that.show_error(message); - return; + return that.valid; } if (meta.maxvalue !== undefined && value > meta.maxvalue) { @@ -104,7 +103,7 @@ IPA.widget = function(spec) { message = IPA.messages.widget.validation.max_value; message = message.replace('${value}', meta.maxvalue); that.show_error(message); - return; + return that.valid; } } if (meta.pattern) { @@ -112,11 +111,13 @@ IPA.widget = function(spec) { if (!value.match(regex)) { that.valid = false; that.show_error(meta.pattern_errmsg); - return; + return that.valid; } } + return that.valid; } + that.create_error_link = function(container){ container.append(' '); @@ -153,22 +154,25 @@ IPA.widget = function(spec) { var values = that.save(); if (!values) { - return; + return that.valid; } if (values.length === 0) { - return; + return that.valid; } var value = values[0]; if (!value) { - return; + return that.valid; } if (that.metadata) { - meta_validate(that.metadata,value); + meta_validate(that.metadata, value); } - if (that.param_info) { - meta_validate(that.param_info,value); + + if (that.valid && that.param_info) { + meta_validate(that.param_info, value); } + + return that.valid; }; |