can now override any given auto-widget with a locally defined widget
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 13 Feb 2009 22:10:08 +0000 (22:10 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 13 Feb 2009 22:10:08 +0000 (22:10 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@12179 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 a7f967d..5122af2 100644 (file)
@@ -85,6 +85,13 @@ if(!dojo._hasResource['openils.widget.AutoFieldWidget']) {
         },
 
         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;
index 7607726..8a760b3 100644 (file)
@@ -24,8 +24,11 @@ if(!dojo._hasResource['openils.widget.AutoGrid']) {
                 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,16 +76,18 @@ if(!dojo._hasResource['openils.widget.AutoGrid']) {
                 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) {
@@ -107,6 +112,7 @@ if(!dojo._hasResource['openils.widget.AutoGrid']) {
                 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 @@ if(!dojo._hasResource['openils.widget.AutoGrid']) {
                 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 @@ if(!dojo._hasResource['openils.widget.AutoGrid']) {
                 dialog.show();
             },
 
-            loadAll : function(opts) {
+            loadAll : function(opts, search) {
                 dojo.require('openils.PermaCrud');
                 if(!opts) opts = {};
                 var self = this;
@@ -175,7 +182,10 @@ if(!dojo._hasResource['openils.widget.AutoGrid']) {
                         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);
             }
         } 
     );
index 745edb5..b2ea34e 100644 (file)
@@ -40,6 +40,9 @@ if(!dojo._hasResource['openils.widget.EditPane']) {
                 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 @@ if(!dojo._hasResource['openils.widget.EditPane']) {
                         fmClass : this.fmClass,
                         parentNode : valSpan,
                         orgLimitPerms : this.limitPerms,
-                        readOnly : this.readOnly
+                        readOnly : this.readOnly,
+                        widget : this.overrideWidgets[field.name]
                     });
 
                     widget.build();