[open-ils-commits] r16226 - trunk/Open-ILS/web/js/dojo/openils/widget (erickson)

svn at svn.open-ils.org svn at svn.open-ils.org
Tue Apr 13 12:18:04 EDT 2010


Author: erickson
Date: 2010-04-13 12:18:00 -0400 (Tue, 13 Apr 2010)
New Revision: 16226

Modified:
   trunk/Open-ILS/web/js/dojo/openils/widget/AutoFieldWidget.js
   trunk/Open-ILS/web/js/dojo/openils/widget/AutoGrid.js
   trunk/Open-ILS/web/js/dojo/openils/widget/EditPane.js
Log:
dijits that are marked as 'required' will show render with the invalid dijit styling when no data is present during page render.  The previous behavior was to only style the invalid widgets after the user had focused the widget and left invalid data in the widget.  this way users can see at page load if a field is required

Modified: trunk/Open-ILS/web/js/dojo/openils/widget/AutoFieldWidget.js
===================================================================
--- trunk/Open-ILS/web/js/dojo/openils/widget/AutoFieldWidget.js	2010-04-13 16:17:59 UTC (rev 16225)
+++ trunk/Open-ILS/web/js/dojo/openils/widget/AutoFieldWidget.js	2010-04-13 16:18:00 UTC (rev 16226)
@@ -501,6 +501,15 @@
             }
             if(this.onload)
                 this.onload(this.widget, this);
+
+            if(this.dijitArgs && this.dijitArgs.required) {
+                // a required dijit is not given any styling to indicate the value
+                // is invalid until the user has focused the widget then left it with
+                // invalid data.  This change tells dojo to pretend this focusing has 
+                // already happened so we can style required widgets during page render.
+                this.widget._hasBeenBlurred = true;
+                this.widget.validate();
+            }
         },
 
         _buildOrgSelector : function() {

Modified: trunk/Open-ILS/web/js/dojo/openils/widget/AutoGrid.js
===================================================================
--- trunk/Open-ILS/web/js/dojo/openils/widget/AutoGrid.js	2010-04-13 16:17:59 UTC (rev 16225)
+++ trunk/Open-ILS/web/js/dojo/openils/widget/AutoGrid.js	2010-04-13 16:18:00 UTC (rev 16226)
@@ -25,6 +25,7 @@
             columnPickerPrefix : null,
             displayLimit : 15,
             displayOffset : 0,
+            requiredFields : null,
             showPaginator : false,
             showLoadFilter : false,
             suppressLinkedFields : null, // list of fields whose linked display data should not be fetched from the server
@@ -379,6 +380,7 @@
                     overrideWidgetClass : this.overrideEditWidgetClass,
                     overrideWidgetArgs : this.overrideWidgetArgs,
                     disableWidgetTest : this.disableWidgetTest,
+                    requiredFields : this.requiredFields,
                     onPostSubmit : function() {
                         for(var i in fmObject._fields) {
                             var field = fmObject._fields[i];
@@ -418,6 +420,7 @@
                     overrideWidgetClass : this.overrideEditWidgetClass,
                     overrideWidgetArgs : this.overrideWidgetArgs,
                     disableWidgetTest : this.disableWidgetTest,
+                    requiredFields : this.requiredFields,
                     onPostSubmit : function(req, cudResults) {
                         var fmObject = cudResults[0];
                         if(grid.onPostCreate)

Modified: trunk/Open-ILS/web/js/dojo/openils/widget/EditPane.js
===================================================================
--- trunk/Open-ILS/web/js/dojo/openils/widget/EditPane.js	2010-04-13 16:17:59 UTC (rev 16225)
+++ trunk/Open-ILS/web/js/dojo/openils/widget/EditPane.js	2010-04-13 16:18:00 UTC (rev 16226)
@@ -19,6 +19,7 @@
             fieldDocs : null,
             existingTable : null,
             suppressFields : null,
+            requiredFields : null,
 
             constructor : function(args) {
                 this.fieldList = [];
@@ -114,6 +115,11 @@
                         }
                     );
 
+                    if(this.requiredFields && this.requiredFields.indexOf(field.name) >= 0) {
+                        if(!args.dijitArgs) args.dijitArgs = {};
+                        args.dijitArgs.required = true;
+                    }
+
                     var widget = new openils.widget.AutoFieldWidget(args);
 
                     widget.build();



More information about the open-ils-commits mailing list