From 90757fb620c361fc7b4b1e7acbd53f09a533eaf0 Mon Sep 17 00:00:00 2001 From: erickson Date: Tue, 13 Apr 2010 16:18:00 +0000 Subject: [PATCH] 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 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 | 9 +++++++++ Open-ILS/web/js/dojo/openils/widget/AutoGrid.js | 3 +++ Open-ILS/web/js/dojo/openils/widget/EditPane.js | 6 ++++++ 3 files changed, 18 insertions(+) diff --git a/Open-ILS/web/js/dojo/openils/widget/AutoFieldWidget.js b/Open-ILS/web/js/dojo/openils/widget/AutoFieldWidget.js index 838872bcb..bfd3828b8 100644 --- a/Open-ILS/web/js/dojo/openils/widget/AutoFieldWidget.js +++ b/Open-ILS/web/js/dojo/openils/widget/AutoFieldWidget.js @@ -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() { diff --git a/Open-ILS/web/js/dojo/openils/widget/AutoGrid.js b/Open-ILS/web/js/dojo/openils/widget/AutoGrid.js index d3147bbf4..34ac133bc 100644 --- a/Open-ILS/web/js/dojo/openils/widget/AutoGrid.js +++ b/Open-ILS/web/js/dojo/openils/widget/AutoGrid.js @@ -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) diff --git a/Open-ILS/web/js/dojo/openils/widget/EditPane.js b/Open-ILS/web/js/dojo/openils/widget/EditPane.js index 2e2cefedb..7c166caff 100644 --- a/Open-ILS/web/js/dojo/openils/widget/EditPane.js +++ b/Open-ILS/web/js/dojo/openils/widget/EditPane.js @@ -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(); -- 2.11.0