dijits that are marked as 'required' will show render with the invalid dijit styling...
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 13 Apr 2010 16:18:00 +0000 (16:18 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 13 Apr 2010 16:18:00 +0000 (16:18 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@16226 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/web/js/dojo/openils/widget/AutoFieldWidget.js
Open-ILS/web/js/dojo/openils/widget/AutoGrid.js
Open-ILS/web/js/dojo/openils/widget/EditPane.js

index 838872b..bfd3828 100644 (file)
@@ -501,6 +501,15 @@ if(!dojo._hasResource['openils.widget.AutoFieldWidget']) {
             }
             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() {
index d3147bb..34ac133 100644 (file)
@@ -25,6 +25,7 @@ if(!dojo._hasResource['openils.widget.AutoGrid']) {
             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 @@ if(!dojo._hasResource['openils.widget.AutoGrid']) {
                     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 @@ if(!dojo._hasResource['openils.widget.AutoGrid']) {
                     overrideWidgetClass : this.overrideEditWidgetClass,
                     overrideWidgetArgs : this.overrideWidgetArgs,
                     disableWidgetTest : this.disableWidgetTest,
+                    requiredFields : this.requiredFields,
                     onPostSubmit : function(req, cudResults) {
                         var fmObject = cudResults[0];
                         if(grid.onPostCreate)
index 2e2cefe..7c166ca 100644 (file)
@@ -19,6 +19,7 @@ if(!dojo._hasResource['openils.widget.EditPane']) {
             fieldDocs : null,
             existingTable : null,
             suppressFields : null,
+            requiredFields : null,
 
             constructor : function(args) {
                 this.fieldList = [];
@@ -114,6 +115,11 @@ if(!dojo._hasResource['openils.widget.EditPane']) {
                         }
                     );
 
+                    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();