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

svn at svn.open-ils.org svn at svn.open-ils.org
Fri Feb 13 17:10:13 EST 2009


Author: erickson
Date: 2009-02-13 17:10:08 -0500 (Fri, 13 Feb 2009)
New Revision: 12179

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:
can now override any given auto-widget with a locally defined widget

Modified: trunk/Open-ILS/web/js/dojo/openils/widget/AutoFieldWidget.js
===================================================================
--- trunk/Open-ILS/web/js/dojo/openils/widget/AutoFieldWidget.js	2009-02-13 20:08:30 UTC (rev 12178)
+++ trunk/Open-ILS/web/js/dojo/openils/widget/AutoFieldWidget.js	2009-02-13 22:10:08 UTC (rev 12179)
@@ -85,6 +85,13 @@
         },
 
         build : function(onload) {
+
+            if(this.widget) {
+                // core widget provided for us, attach and move on
+                this.parentNode.appendChild(this.widget.domNode);
+                return;
+            }
+
             this.onload = onload;
             if(this.widgetValue == null)
                 this.widgetValue = (this.fmObject) ? this.fmObject[this.idlField.name]() : null;

Modified: trunk/Open-ILS/web/js/dojo/openils/widget/AutoGrid.js
===================================================================
--- trunk/Open-ILS/web/js/dojo/openils/widget/AutoGrid.js	2009-02-13 20:08:30 UTC (rev 12178)
+++ trunk/Open-ILS/web/js/dojo/openils/widget/AutoGrid.js	2009-02-13 22:10:08 UTC (rev 12179)
@@ -24,8 +24,11 @@
                 this.initAutoEnv();
                 this.setStructure(this._compileStructure());
                 this.setStore(this.buildAutoStore());
+                this.overrideEditWidgets = {};
                 if(this.editOnEnter) 
                     this._applyEditOnEnter();
+                else if(this.singleEditStyle) 
+                    this._applySingleEditStyle();
             },
 
             _compileStructure : function() {
@@ -73,17 +76,19 @@
                 return [{cells: [fields]}];
             },
 
-
-            /* capture keydown and launch edit dialog on enter */
-            _applyEditOnEnter : function() {
-
+            _applySingleEditStyle : function() {
                 this.onMouseOverRow = function(e) {};
                 this.onMouseOutRow = function(e) {};
                 this.onCellFocus = function(cell, rowIndex) { 
                     this.selection.deselectAll();
                     this.selection.select(this.focus.rowIndex);
                 };
+            },
 
+            /* capture keydown and launch edit dialog on enter */
+            _applyEditOnEnter : function() {
+                this._applySingleEditStyle();
+
                 dojo.connect(this, 'onRowDblClick',
                     function(e) {
                         this._drawEditDialog(this.selection.getFirstSelected(), this.focus.rowIndex);
@@ -107,6 +112,7 @@
                 var idents = grid.store.getIdentityAttributes();
                 var dialog = new openils.widget.EditDialog({
                     fmObject:fmObject,
+                    overrideWidgets : this.overrideEditWidgets,
                     onPostSubmit : function() {
                         for(var i in fmObject._fields) {
                             var field = fmObject._fields[i];
@@ -142,6 +148,7 @@
                 var grid = this;
                 var dialog = new openils.widget.EditDialog({
                     fmClass : this.fmClass,
+                    overrideWidgets : this.overrideEditWidgets,
                     onPostSubmit : function(r) {
                         var fmObject = openils.Util.readResponse(r);
                         if(fmObject) 
@@ -163,7 +170,7 @@
                 dialog.show();
             },
 
-            loadAll : function(opts) {
+            loadAll : function(opts, search) {
                 dojo.require('openils.PermaCrud');
                 if(!opts) opts = {};
                 var self = this;
@@ -175,7 +182,10 @@
                         self.store.newItem(item.toStoreItem());
                     }
                 });
-                new openils.PermaCrud().retrieveAll(this.fmClass, opts);
+                if(search)
+                    new openils.PermaCrud().search(this.fmClass, search, opts);
+                else
+                    new openils.PermaCrud().retrieveAll(this.fmClass, opts);
             }
         } 
     );

Modified: trunk/Open-ILS/web/js/dojo/openils/widget/EditPane.js
===================================================================
--- trunk/Open-ILS/web/js/dojo/openils/widget/EditPane.js	2009-02-13 20:08:30 UTC (rev 12178)
+++ trunk/Open-ILS/web/js/dojo/openils/widget/EditPane.js	2009-02-13 22:10:08 UTC (rev 12179)
@@ -40,6 +40,9 @@
                 if(this.fmIDL.permacrud && this.fmIDL.permacrud[this.mode])
                     this.limitPerms = this.fmIDL.permacrud[this.mode].perms;
 
+                if(!this.overrideWidgets)
+                    this.overrideWidgets = {};
+
                 for(var f in this.sortedFieldList) {
                     var field = this.sortedFieldList[f];
                     if(!field || field.virtual) continue;
@@ -64,7 +67,8 @@
                         fmClass : this.fmClass,
                         parentNode : valSpan,
                         orgLimitPerms : this.limitPerms,
-                        readOnly : this.readOnly
+                        readOnly : this.readOnly,
+                        widget : this.overrideWidgets[field.name]
                     });
 
                     widget.build();



More information about the open-ils-commits mailing list