From 7a01d467e11cd2feec209ea12a7560bfaa80d653 Mon Sep 17 00:00:00 2001
From: Adam Young <ayo...@redhat.com>
Date: Fri, 8 Jul 2011 10:15:16 -0400
Subject: [PATCH] clear errors on reset

https://fedorahosted.org/freeipa/ticket/1446
---
 install/ui/details.js            |    2 +-
 install/ui/test/details_tests.js |    1 +
 install/ui/widget.js             |   16 +++++++++++++++-
 3 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/install/ui/details.js b/install/ui/details.js
index 6a2def7fb5447aba59998876bb6257f2415900c5..85aa9be0b0ae4da3c22964b0ceb380c6ac551404 100644
--- a/install/ui/details.js
+++ b/install/ui/details.js
@@ -164,7 +164,7 @@ IPA.details_section = function(spec) {
         var fields = that.fields.values;
         for (var i=0; i<fields.length; i++) {
             var field = fields[i];
-            var span = $('span[name='+field.name+']', this.container).first();
+//            var span = $('span[name='+field.name+']', this.container).first();
             field.reset();
         }
     };
diff --git a/install/ui/test/details_tests.js b/install/ui/test/details_tests.js
index 71e6bf98eb585b9d5a179842f68fc257dda5aa08..375b8ed1ef977fa7d4f299dfd4842e9a2426a2c6 100644
--- a/install/ui/test/details_tests.js
+++ b/install/ui/test/details_tests.js
@@ -171,6 +171,7 @@ test("Testing details lifecycle: create, setup, load.", function(){
         widget.save = function() {
             save_called = true;
             widget.widget_save();
+            return [];
         };
         return widget;
     }
diff --git a/install/ui/widget.js b/install/ui/widget.js
index 0ec9a968bf5415d3f21fd2d0a2d8cb01eec64797..b2a325f448566b0823744e647cb670ec1c4c7527 100644
--- a/install/ui/widget.js
+++ b/install/ui/widget.js
@@ -140,6 +140,12 @@ IPA.widget = function(spec) {
         that.valid = true;
 
         var values = that.save();
+        if (!values){
+            return;
+        }
+        if (values.length ===0 ){
+            return;
+        }
         var value = values[0];
         if (!value) {
             return;
@@ -202,6 +208,12 @@ IPA.widget = function(spec) {
             return true;
         }
 
+        if ((that.values.length === 0) &&
+            (values.length === 1) &&
+            values[0] === ""){
+            return false;
+        }
+
         if (values.length != that.values.length) {
             return true;
         }
@@ -264,6 +276,7 @@ IPA.widget = function(spec) {
 
     that.reset = function() {
         that.update();
+        that.validate();
         that.set_dirty(false);
     };
 
@@ -1704,11 +1717,12 @@ IPA.entity_select_widget = function(spec) {
 
     that.reset = function() {
         that.entity_filter.val(that.values[0]);
-        that.set_dirty(false);
         populate_select(that.values[0]);
         if (editable){
             that.edit_box.val(that.values[0]);
         }
+        that.validate();
+        that.set_dirty(false);
     };
 
     that.load = function(record) {
-- 
1.7.5.2

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

Reply via email to