From: erickson Date: Fri, 13 Feb 2009 22:10:08 +0000 (+0000) Subject: can now override any given auto-widget with a locally defined widget X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=d417da2ad6b100cc6b033ccbac44c739cf7e2c19;p=evergreen%2Ftadl.git can now override any given auto-widget with a locally defined widget git-svn-id: svn://svn.open-ils.org/ILS/trunk@12179 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/web/js/dojo/openils/widget/AutoFieldWidget.js b/Open-ILS/web/js/dojo/openils/widget/AutoFieldWidget.js index a7f967d21d..5122af2006 100644 --- a/Open-ILS/web/js/dojo/openils/widget/AutoFieldWidget.js +++ b/Open-ILS/web/js/dojo/openils/widget/AutoFieldWidget.js @@ -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; diff --git a/Open-ILS/web/js/dojo/openils/widget/AutoGrid.js b/Open-ILS/web/js/dojo/openils/widget/AutoGrid.js index 7607726e9f..8a760b3178 100644 --- a/Open-ILS/web/js/dojo/openils/widget/AutoGrid.js +++ b/Open-ILS/web/js/dojo/openils/widget/AutoGrid.js @@ -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); } } ); diff --git a/Open-ILS/web/js/dojo/openils/widget/EditPane.js b/Open-ILS/web/js/dojo/openils/widget/EditPane.js index 745edb563c..b2ea34e851 100644 --- a/Open-ILS/web/js/dojo/openils/widget/EditPane.js +++ b/Open-ILS/web/js/dojo/openils/widget/EditPane.js @@ -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();