Forgot to update tests - to address newly added validation row in table_widget.

--
Petr Vobornik
From 40382df3620607760e8a6033b93b178d149f9ed4 Mon Sep 17 00:00:00 2001
From: Petr Vobornik <pvobo...@redhat.com>
Date: Wed, 14 Sep 2011 13:01:25 +0200
Subject: [PATCH] Fixed: Some widgets do not have space for validation error
 message

https://fedorahosted.org/freeipa/ticket/1454

The following widgets should call create_error_link() to create a space to show validation error messages:

  IPA.checkbox_widget
  IPA.checkboxes_widget
  IPA.radio_widget
  IPA.select_widget
  IPA.table_widget
  IPA.attributes_widget
  IPA.rights_widget
  IPA.target_section (it's a widget)

Solution:
 * added call to checkbox, checkboxes, radio, select, table, attributes widget
 * rights_widget inherits it from checkboxes_widget.
 * target_section IS NOT a widget as it doesn't inherit from widget. It's still a section, which shows different widgets based on its state.
 * table_widget displays error_link above pagination. It looks better than under the table.
---
 install/ui/aci.js               |    2 +
 install/ui/test/widget_tests.js |    2 +-
 install/ui/widget.js            |   43 +++++++++++++++++++++++++++++++++-----
 3 files changed, 40 insertions(+), 7 deletions(-)

diff --git a/install/ui/aci.js b/install/ui/aci.js
index 5dcd69d447521ff5ed80088be1bd19bb3b851ba8..3be9953ae782320bace7bbc51e74d908b1c409d4 100644
--- a/install/ui/aci.js
+++ b/install/ui/aci.js
@@ -276,6 +276,8 @@ IPA.attributes_widget = function(spec) {
         if (that.object_type){
             that.populate (that.object_type);
         }
+
+        that.create_error_link(container);
     };
 
     that.load = function(record) {
diff --git a/install/ui/test/widget_tests.js b/install/ui/test/widget_tests.js
index 9f0f6f0b59660a9c0648680ac94302ecf4d84aa5..141a0659e65ac01e781cad7f5ab5f3410fd1dc11 100644
--- a/install/ui/test/widget_tests.js
+++ b/install/ui/test/widget_tests.js
@@ -190,7 +190,7 @@ test("IPA.table_widget" ,function(){
 
     widget.load(mock_results);
 
-    same ($('tr' ,widget_container).length, 4, 'four rows after load');
+    same ($('tr' ,widget_container).length, 5, 'five rows after load');
 
 
 });
diff --git a/install/ui/widget.js b/install/ui/widget.js
index 58698486894ce9e72842ea1cf011a5fb75286421..e71cc22c1f660815afae0398f0bea0b8346d7a83 100644
--- a/install/ui/widget.js
+++ b/install/ui/widget.js
@@ -148,7 +148,7 @@ IPA.widget = function(spec) {
       the validation pattern.  If the field value does not pass validation,
       displays the error message and returns false. */
     that.validate = function() {
-        hide_error();
+        that.hide_error();
         that.valid = true;
 
         var values = that.save();
@@ -353,10 +353,10 @@ IPA.widget = function(spec) {
         error_link.css('display', 'block');
     };
 
-    function hide_error() {
+    that.hide_error = function() {
         var error_link = that.get_error_link();
         error_link.css('display', 'none');
-    }
+    };
 
     that.set_enabled = function() {
     };
@@ -370,10 +370,12 @@ IPA.widget = function(spec) {
 
     // methods that should be invoked by subclasses
     that.widget_create = that.create;
+    that.widget_hide_error = that.hide_error;
     that.widget_load = that.load;
     that.widget_reset = that.reset;
     that.widget_save = that.save;
     that.widget_set_dirty = that.set_dirty;
+    that.widget_show_error = that.show_error;
     that.widget_test_dirty = that.test_dirty;
 
     return that;
@@ -783,6 +785,8 @@ IPA.checkbox_widget = function (spec) {
         if (that.undo) {
             that.create_undo(container);
         }
+
+        that.create_error_link(container);
     };
 
     that.load = function(record) {
@@ -858,6 +862,8 @@ IPA.checkboxes_widget = function (spec) {
         input.change(function() {
             that.set_dirty(that.test_dirty());
         });
+
+        that.create_error_link(container);
     };
 
 
@@ -928,6 +934,8 @@ IPA.radio_widget = function(spec) {
         input.change(function() {
             that.set_dirty(that.test_dirty());
         });
+
+        that.create_error_link(container);
     };
 
     that.load = function(record) {
@@ -1000,6 +1008,8 @@ IPA.select_widget = function(spec) {
         that.select.change(function() {
             that.set_dirty(that.test_dirty());
         });
+
+        that.create_error_link(container);
     };
 
     that.load = function(record) {
@@ -1336,10 +1346,20 @@ IPA.table_widget = function (spec) {
 
         that.tfoot = $('<tfoot/>').appendTo(that.table);
 
+        var columns_count = columns.length + (that.selectable ? 1 : 0);
+
+        that.error_link_row = $('<tr/>').appendTo(that.tfoot);
+
+        td = $('<td/>', {
+            colspan: columns_count
+        }).appendTo(that.error_link_row);
+
+        that.create_error_link(td);
+
         tr = $('<tr/>').appendTo(that.tfoot);
 
         td = $('<td/>', {
-            colspan: columns.length + (that.selectable ? 1 : 0)
+            colspan: columns_count
         }).appendTo(tr);
 
         that.summary = $('<span/>', {
@@ -1549,6 +1569,15 @@ IPA.table_widget = function (spec) {
         return rows;
     };
 
+    that.show_error = function(message) {
+        that.widget_show_error(message);
+        that.error_link_row.css('display', 'table-row');
+    };
+
+    that.hide_error = function() {
+        that.error_link_row.css('display', 'none');
+    };
+
     that.set_enabled = function(enabled) {
         if (enabled) {
             $('input[name="select"]', that.table).attr('disabled', false);
@@ -1565,10 +1594,12 @@ IPA.table_widget = function (spec) {
 
     // methods that should be invoked by subclasses
     that.table_create = that.create;
-    that.table_set_enabled = that.set_enabled;
-    that.table_prev_page = that.prev_page;
+    that.table_hide_error = that.hide_error;
     that.table_next_page = that.next_page;
+    that.table_prev_page = that.prev_page;
+    that.table_set_enabled = that.set_enabled;
     that.table_set_page = that.set_page;
+    that.table_show_error = that.show_error;
 
     return that;
 };
-- 
1.7.6

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

Reply via email to