The details facet validation has been moved out of update() such
that all subclasses perform consistent validation.

Ticket #1455

--
Endi S. Dewata
From 620dd687f887fafc2057d979c056fa379e0408ff Mon Sep 17 00:00:00 2001
From: Endi S. Dewata <edew...@redhat.com>
Date: Wed, 26 Oct 2011 18:21:11 -0500
Subject: [PATCH] Fixed inconsistent details facet validation.

The details facet validation has been moved out of update() such
that all subclasses perform consistent validation.

Ticket #1455
---
 install/ui/details.js |   25 +++++++++++++------------
 install/ui/dns.js     |    5 ++++-
 install/ui/hbac.js    |    5 ++++-
 install/ui/sudo.js    |    5 ++++-
 4 files changed, 25 insertions(+), 15 deletions(-)

diff --git a/install/ui/details.js b/install/ui/details.js
index 022b005bc42a6fad744eecddbf92439a99da7785..98f48d0f9f02f323fd1b1ef206f2ece198d87c90 100644
--- a/install/ui/details.js
+++ b/install/ui/details.js
@@ -374,7 +374,7 @@ IPA.details_facet = function(spec) {
             icon: 'reset-icon',
             'class': 'details-reset action-button-disabled',
             click: function() {
-                if(!that.update_button.hasClass('action-button-disabled')) {
+                if (!that.update_button.hasClass('action-button-disabled')) {
                     that.reset();
                 }
                 return false;
@@ -387,9 +387,19 @@ IPA.details_facet = function(spec) {
             icon: 'update-icon',
             'class': 'details-update action-button-disabled',
             click: function() {
-                if(!that.update_button.hasClass('action-button-disabled')) {
-                    that.update();
+                if (that.update_button.hasClass('action-button-disabled')) return false;
+
+                if (!that.validate()) {
+                    var dialog = IPA.message_dialog({
+                        title: IPA.messages.dialogs.validation_title,
+                        message: IPA.messages.dialogs.validation_message
+                    });
+                    dialog.open();
+                    return false;
                 }
+
+                that.update();
+
                 return false;
             }
         }).appendTo(that.controls);
@@ -628,15 +638,6 @@ IPA.details_facet = function(spec) {
             on_error: on_error
         });
 
-        if (!that.validate()) {
-            var dialog = IPA.message_dialog({
-                title: IPA.messages.dialogs.validation_title,
-                message: IPA.messages.dialogs.validation_message
-            });
-            dialog.open();
-            return;
-        }
-
         var record = {};
         that.save(record);
 
diff --git a/install/ui/dns.js b/install/ui/dns.js
index a73d4b2051ce60a589576229cb8932d3cdcf4caf..4dbf3e0d26699330b18285306ae7f6ee2c377324 100644
--- a/install/ui/dns.js
+++ b/install/ui/dns.js
@@ -168,6 +168,9 @@ IPA.dnszone_details_facet = function(spec) {
             })
         };
 
+        var record = {};
+        that.save(record);
+
         var sections = that.sections.values;
         for (var i=0; i<sections.length; i++) {
             var section = sections[i];
@@ -177,7 +180,7 @@ IPA.dnszone_details_facet = function(spec) {
                 var field = section_fields[j];
                 if (!field.is_dirty()) continue;
 
-                var values = field.save();
+                var values = record[field.name];
                 if (!values) continue;
 
                 var metadata = field.metadata;
diff --git a/install/ui/hbac.js b/install/ui/hbac.js
index b5c223614f52c0213d8b15fa05148712e673f7de..e8c106ac70c33a2ac04373c610ae00a2e7a8b38a 100644
--- a/install/ui/hbac.js
+++ b/install/ui/hbac.js
@@ -440,6 +440,9 @@ IPA.hbacrule_details_facet = function(spec) {
             })
         };
 
+        var record = {};
+        that.save(record);
+
         var sections = that.sections.values;
         for (var i=0; i<sections.length; i++) {
             var section = sections[i];
@@ -451,7 +454,7 @@ IPA.hbacrule_details_facet = function(spec) {
                 // association tables are never dirty, so call
                 // is_dirty() after checking table values
 
-                var values = field.save();
+                var values = record[field.name];
                 if (!values) continue;
 
                 var metadata = field.metadata;
diff --git a/install/ui/sudo.js b/install/ui/sudo.js
index f2dd646edd5f53cce765a46c7dc0ac16ceb7ab17..3c581387e6cfbe9c3ee903360fb4e1111b6cf4ab 100644
--- a/install/ui/sudo.js
+++ b/install/ui/sudo.js
@@ -389,6 +389,9 @@ IPA.sudorule_details_facet = function(spec) {
             })
         };
 
+        var record = {};
+        that.save(record);
+
         var sections = that.sections.values;
         for (var i=0; i<sections.length; i++) {
             var section = sections[i];
@@ -400,7 +403,7 @@ IPA.sudorule_details_facet = function(spec) {
                 // association tables are never dirty, so call
                 // is_dirty() after checking table values
 
-                var values = field.save();
+                var values = record[field.name];
                 if (!values) continue;
 
                 var metadata = field.metadata;
-- 
1.7.5.1

_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Reply via email to