[Jifty-commit] jifty branch, master, updated. jifty-1.10228-2-g0b722c1

Jifty commits jifty-commit at lists.jifty.org
Mon Feb 28 22:52:07 EST 2011


The branch, master has been updated
       via  0b722c10ea30723eea818a1ffcbe0b0f0a551d18 (commit)
      from  c63d2fa003f848cb57e3f4a5ff9b5f92235ee3cf (commit)

Summary of changes:
 lib/Jifty/View/Declare/CRUD.pm |    3 ---
 share/web/static/js/jifty.js   |    8 ++++++++
 2 files changed, 8 insertions(+), 3 deletions(-)

- Log -----------------------------------------------------------------
commit 0b722c10ea30723eea818a1ffcbe0b0f0a551d18
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Mon Feb 28 22:51:50 2011 -0500

    Close lightboxes automatically and only if there are no validation errors

diff --git a/lib/Jifty/View/Declare/CRUD.pm b/lib/Jifty/View/Declare/CRUD.pm
index cb8de95..4f1a6c0 100644
--- a/lib/Jifty/View/Declare/CRUD.pm
+++ b/lib/Jifty/View/Declare/CRUD.pm
@@ -428,7 +428,6 @@ template 'search' => sub {
             label   => _('Search'),
             onclick => [
                 { submit => $search },
-                "Jifty.closeLightbox();",
                 {
                     refresh => Jifty->web->current_region->parent,
                     args    => { page => 1 },
@@ -543,7 +542,6 @@ private template edit_item_controls => sub {
             label   => _("Save"),
             onclick => [
                 { submit => $update },
-                "Jifty.closeLightbox();",
                 { refresh => $view_region },
             ],
         );
@@ -555,7 +553,6 @@ private template edit_item_controls => sub {
                         submit  => $delete,
                         confirm => _('Really delete?'),
                     },
-                    "Jifty.closeLightbox();",
                     {
                         region => $view_region,
                         replace_with => '/__jifty/empty',
diff --git a/share/web/static/js/jifty.js b/share/web/static/js/jifty.js
index 9e1df0f..6d8529a 100644
--- a/share/web/static/js/jifty.js
+++ b/share/web/static/js/jifty.js
@@ -1394,6 +1394,7 @@ Jifty.update = function () {
         */
 
         // Look through the action results looking for field validation errors
+        var field_errors = 0;
         walk_node(response, {
             result: function(result) {
                 var moniker = result.getAttribute("moniker");
@@ -1407,12 +1408,19 @@ Jifty.update = function () {
                                         : (error.firstChild ? error.firstChild.nodeValue : '');
                             var action = current_actions[moniker];
                             action.result.field_error[field.getAttribute("name")] = text;
+                            field_errors++;
                         }
                     }
                 });
             }
         });
 
+        // If there's a lightbox, close it only if there are no validation
+        // errors
+        if (field_errors == 0) {
+            Jifty.closeLightbox();
+        }
+
         // Re-enable all the controls in the actions we previously disabled
         for ( var i = 0; i < disabled_elements.length; i++ ) {
             disabled_elements[i].disabled = false;

-----------------------------------------------------------------------


More information about the Jifty-commit mailing list