From 09f3e9869a27adc8c07c305a2aa5107690aa1d04 Mon Sep 17 00:00:00 2001 From: "Endi S. Dewata" Date: Wed, 19 Oct 2011 18:11:09 -0200 Subject: [PATCH] Fixed inconsistent required/optional attributes. The dialogs and details pages have been modified to use the * symbol to mark required fields. The automount map and the DNS zone dialogs have been modified to update the required fields according to the input type. Ticket #1696, #1973 --- install/ui/aci.js | 6 +- install/ui/add.js | 144 +++++++----- install/ui/automount.js | 24 +- install/ui/details.js | 27 +-- install/ui/dns.js | 356 +++++++++++++---------------- install/ui/hbac.js | 3 +- install/ui/host.js | 18 +- install/ui/ipa.css | 7 + install/ui/policy.js | 8 +- install/ui/service.js | 63 ++--- install/ui/sudo.js | 3 +- install/ui/test/data/ipa_init.json | 1 - install/ui/user.js | 5 +- install/ui/widget.js | 56 ++++- ipalib/plugins/internal.py | 1 - 15 files changed, 381 insertions(+), 341 deletions(-) diff --git a/install/ui/aci.js b/install/ui/aci.js index 8dcb540b6..7a331118a 100644 --- a/install/ui/aci.js +++ b/install/ui/aci.js @@ -35,11 +35,7 @@ IPA.entity_factories.permission = function() { { name: 'identity', fields: [ - { - factory: IPA.text_widget, - name: 'cn', - read_only: true - } + 'cn' ] }, { diff --git a/install/ui/add.js b/install/ui/add.js index 17418aaba..fd99b02c5 100644 --- a/install/ui/add.js +++ b/install/ui/add.js @@ -35,7 +35,72 @@ IPA.add_dialog = function (spec) { that.retry = typeof spec.retry !== 'undefined' ? spec.retry : true; that.command = null; - function show_edit_page(entity,result){ + that.show_edit_page = spec.show_edit_page || show_edit_page; + + var init = function() { + that.create_button({ + name: 'add', + label: IPA.messages.buttons.add, + click: function() { + that.hide_message(); + that.add( + function(data, text_status, xhr) { + var facet = IPA.current_entity.get_facet(); + var table = facet.table; + table.refresh(); + that.close(); + }, + that.on_error); + } + }); + + that.create_button({ + name: 'add_and_add_another', + label: IPA.messages.buttons.add_and_add_another, + click: function() { + that.hide_message(); + that.add( + function(data, text_status, xhr) { + var label = that.entity.metadata.label_singular; + var message = IPA.messages.dialogs.add_confirmation; + message = message.replace('${entity}', label); + that.show_message(message); + + var facet = IPA.current_entity.get_facet(); + var table = facet.table; + table.refresh(); + that.reset(); + }, + that.on_error); + } + }); + + that.create_button({ + name: 'add_and_edit', + label: IPA.messages.buttons.add_and_edit, + click: function() { + that.hide_message(); + that.add( + function(data, text_status, xhr) { + that.close(); + var result = data.result.result; + that.show_edit_page(that.entity, result); + }, + that.on_error); + } + }); + + that.create_button({ + name: 'cancel', + label: IPA.messages.buttons.cancel, + click: function() { + that.hide_message(); + that.close(); + } + }); + }; + + function show_edit_page(entity,result) { var pkey_name = entity.metadata.primary_key; var pkey = result[pkey_name]; if (pkey instanceof Array) { @@ -44,8 +109,6 @@ IPA.add_dialog = function (spec) { IPA.nav.show_entity_page(that.entity, 'default', pkey); } - that.show_edit_page = spec.show_edit_page || show_edit_page; - that.add = function(on_success, on_error) { var pkey_name = that.entity.metadata.primary_key; @@ -110,67 +173,28 @@ IPA.add_dialog = function (spec) { command.execute(); }; - /*dialog initialization*/ - that.create_button({ - name: 'add', - label: IPA.messages.buttons.add, - click: function() { - that.hide_message(); - that.add( - function(data, text_status, xhr) { - var facet = IPA.current_entity.get_facet(); - var table = facet.table; - table.refresh(); - that.close(); - }, - that.on_error); - } - }); + that.create = function() { + that.dialog_create(); - that.create_button({ - name: 'add_and_add_another', - label: IPA.messages.buttons.add_and_add_another, - click: function() { - that.hide_message(); - that.add( - function(data, text_status, xhr) { - var label = that.entity.metadata.label_singular; - var message = IPA.messages.dialogs.add_confirmation; - message = message.replace('${entity}', label); - that.show_message(message); + var div = $('
', { + }).appendTo(that.container); - var facet = IPA.current_entity.get_facet(); - var table = facet.table; - table.refresh(); - that.reset(); - }, - that.on_error); - } - }); + $('', { + 'class': 'required-indicator', + text: IPA.required_indicator + }).appendTo(div); - that.create_button({ - name: 'add_and_edit', - label: IPA.messages.buttons.add_and_edit, - click: function() { - that.hide_message(); - that.add( - function(data, text_status, xhr) { - that.close(); - var result = data.result.result; - that.show_edit_page(that.entity, result); - }, - that.on_error); - } - }); + div.append(' '); - that.create_button({ - name: 'cancel', - label: IPA.messages.buttons.cancel, - click: function() { - that.hide_message(); - that.close(); - } - }); + $('', { + text: IPA.messages.widget.validation.required + }).appendTo(div); + }; + + // methods that should be invoked by subclasses + that.add_dialog_create = that.create; + + init(); return that; }; diff --git a/install/ui/automount.js b/install/ui/automount.js index 89b0f6b7e..6b740d8e6 100644 --- a/install/ui/automount.js +++ b/install/ui/automount.js @@ -144,17 +144,17 @@ IPA.entity_factories.automountkey = function() { entity({ name: 'automountkey' }). containing_entity('automountmap'). details_facet({ - sections:[ + sections: [ { name:'identity', label: IPA.messages.details.identity, - fields:[ + fields: [ { - factory: IPA.text_widget, - read_only: true, - name: 'automountkey' + name: 'automountkey', + read_only: true }, - 'automountinformation'] + 'automountinformation' + ] } ], disable_breadcrumb: false, @@ -224,20 +224,26 @@ IPA.automountmap_adder_dialog = function(spec) { var that = IPA.add_dialog(spec); that.create = function() { - that.dialog_create(); + that.add_dialog_create(); var method_field = that.get_field('method'); + var indirect_section = that.get_section('indirect'); + var key_field = that.get_field('key'); var direct_input = $('input[value="add"]', method_field.container); direct_input.change(function() { that.method = 'add'; - that.get_section('indirect').set_visible(false); + + key_field.set_required(false); + indirect_section.set_visible(false); }); var indirect_input = $('input[value="add_indirect"]', method_field.container); indirect_input.change(function() { that.method = 'add_indirect'; - that.get_section('indirect').set_visible(true); + + key_field.set_required(true); + indirect_section.set_visible(true); }); direct_input.click(); diff --git a/install/ui/details.js b/install/ui/details.js index 1e4a9eb5f..5c03de0a3 100644 --- a/install/ui/details.js +++ b/install/ui/details.js @@ -234,44 +234,29 @@ IPA.details_table_section = function(spec) { var tr = $('').appendTo(table); var td = $('', { - 'class': 'section-cell-label' + 'class': 'section-cell-label', + title: field.label }).appendTo(tr); $('