From d064e75fa506783c6e7e260b19c059ed1ca31f41 Mon Sep 17 00:00:00 2001 From: erickson Date: Fri, 21 May 2010 20:03:20 +0000 Subject: [PATCH] back-porting a number of local dojo library fixes and enhancements. of note, autogrid caching and paging for faster paged grid display. (turning on the pager in some config interfaces to follow). git-svn-id: svn://svn.open-ils.org/ILS/branches/rel_1_6@16482 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/web/js/dojo/openils/Event.js | 3 + Open-ILS/web/js/dojo/openils/PermaCrud.js | 14 +- .../web/js/dojo/openils/widget/AutoFieldWidget.js | 220 +++++++++++++++++---- Open-ILS/web/js/dojo/openils/widget/AutoGrid.js | 16 +- Open-ILS/web/js/dojo/openils/widget/AutoWidget.js | 2 +- Open-ILS/web/js/dojo/openils/widget/EditDialog.js | 4 +- Open-ILS/web/js/dojo/openils/widget/EditPane.js | 105 +++++++--- .../js/dojo/openils/widget/nls/AutoFieldWidget.js | 3 +- .../js/ui/default/conify/global/action/survey.js | 4 +- .../ui/default/conify/global/action/survey/edit.js | 4 +- .../conify/global/config/circ_matrix_matchpoint.js | 13 +- 11 files changed, 309 insertions(+), 79 deletions(-) diff --git a/Open-ILS/web/js/dojo/openils/Event.js b/Open-ILS/web/js/dojo/openils/Event.js index a37f6ff066..b2bf745682 100644 --- a/Open-ILS/web/js/dojo/openils/Event.js +++ b/Open-ILS/web/js/dojo/openils/Event.js @@ -29,12 +29,15 @@ if(!dojo._hasResource["openils.Event"]) { this.servertime = kwargs.servertime; this.ilsperm = kwargs.ilsperm; this.ilspermloc = kwargs.ilspermloc; + this.note = kwargs.note; }, toString : function() { var s = 'Event: ' + (this.code || '') + ':' + this.textcode + ' -> ' + new String(this.desc); if(this.ilsperm) s += ' ' + this.ilsperm + '@' + this.ilspermloc; + if(this.note) + s += '\n' + this.note; return s; } }); diff --git a/Open-ILS/web/js/dojo/openils/PermaCrud.js b/Open-ILS/web/js/dojo/openils/PermaCrud.js index 5dbc8137e9..6213c8f67d 100644 --- a/Open-ILS/web/js/dojo/openils/PermaCrud.js +++ b/Open-ILS/web/js/dojo/openils/PermaCrud.js @@ -111,6 +111,7 @@ if(!dojo._hasResource["openils.PermaCrud"]) { if (opts.select) order_by.select = opts.select; if (opts.limit) order_by.limit = opts.limit; if (opts.offset) order_by.offset = opts.offset; + if (opts.join) order_by.join = opts.join; var method = 'open-ils.pcrud.search.' + fm_class; if(!opts.streaming) method += '.atomic'; @@ -151,14 +152,17 @@ if(!dojo._hasResource["openils.PermaCrud"]) { }, search : function ( fm_class /* Fieldmapper class hint */, search /* Fieldmapper query object */, opts /* Option hash */) { + var return_type = 'search'; if(!opts) opts = {}; var order_by = {}; if (opts.order_by) order_by.order_by = opts.order_by; if (opts.select) order_by.select = opts.select; if (opts.limit) order_by.limit = opts.limit; if (opts.offset) order_by.offset = opts.offset; + if (opts.join) order_by.join = opts.join; + if (opts.id_list) return_type = 'id_list'; - var method = 'open-ils.pcrud.search.' + fm_class; + var method = 'open-ils.pcrud.' + return_type + '.' + fm_class; if(!opts.streaming) method += '.atomic'; var req_hash = dojo.mixin( @@ -323,13 +327,15 @@ if(!dojo._hasResource["openils.PermaCrud"]) { return obj_list; }, + /* + * 'delete' is a reserved keyword in JavaScript and can't be used + * in browsers like IE or Chrome, so we define a safe synonym + * NOTE: delete() is now removed -- use eliminate instead + delete : function ( list, opts ) { return this._CUD( 'delete', list, opts ); }, - /* - * 'delete' is a reserved keyword in JavaScript and can't be used - * in browsers like IE or Chrome, so we define a safe synonym */ eliminate: function ( list, opts ) { return this._CUD( 'delete', list, opts ); diff --git a/Open-ILS/web/js/dojo/openils/widget/AutoFieldWidget.js b/Open-ILS/web/js/dojo/openils/widget/AutoFieldWidget.js index 1e2d6ba1e1..d6a108c9b9 100644 --- a/Open-ILS/web/js/dojo/openils/widget/AutoFieldWidget.js +++ b/Open-ILS/web/js/dojo/openils/widget/AutoFieldWidget.js @@ -22,6 +22,28 @@ if(!dojo._hasResource['openils.widget.AutoFieldWidget']) { * orgLimitPerms -- If this field defines a set of org units and an orgLimitPerms * is defined, the code will limit the org units in the set to those * allowed by the permission + * orgDefaultsToWs -- If this is an org unit field and the widget has no value, + * set the value equal to the users's workstation org unit. Othwerwise, leave it null + * selfReference -- The primary purpose of an AutoFieldWidget is to render the value + * or widget for a field on an object (that may or may not link to another object). + * selfReference allows you to sidestep the indirection and create a selector widget + * based purely on an fmClass. To get a dropdown of all of the 'abc' + * objects, pass in {selfReference : true, fmClass : 'abc'}. + * labelFormat -- For widgets that are displayed as remote object filtering selects, + * this provides a mechanism for overriding the label format in the filtering select. + * It must be an array, whose first value is a format string, compliant with + * dojo.string.substitute. The remaining array items are the arguments to the format + * represented as field names on the remote linked object. + * E.g. + * labelFormat : [ '${0} (${1})', 'obj_field_1', 'obj_field_2' ] + * Note: this does not control the final display value. Only values in the drop-down. + * See searchFormat for controlling the display value + * searchFormat -- This format controls the structure of the search attribute which + * controls the text used during type-ahead searching and the displayed value in + * the filtering select. See labelFormat for the structure. + * dataLoader : Bypass the default PermaCrud linked data fetcher and use this function instead. + * Function arguments are (link class name, search filter, callback) + * The fetched objects should be passed to the callback as an array */ constructor : function(args) { for(var k in args) @@ -33,16 +55,32 @@ if(!dojo._hasResource['openils.widget.AutoFieldWidget']) { this.fmIDL = fieldmapper.IDL.fmclasses[this.fmClass]; this.suppressLinkedFields = args.suppressLinkedFields || []; - if(!this.idlField) { - this.fmIDL = fieldmapper.IDL.fmclasses[this.fmClass]; - var fields = this.fmIDL.fields; - for(var f in fields) - if(fields[f].name == this.fmField) - this.idlField = fields[f]; + if(this.selfReference) { + this.fmField = fieldmapper.IDL.fmclasses[this.fmClass].pkey; + + // create a mock-up of the idlField object. + this.idlField = { + datatype : 'link', + 'class' : this.fmClass, + reltype : 'has_a', + key : this.fmField, + name : this.fmField + }; + + } else { + + if(!this.idlField) { + this.fmIDL = fieldmapper.IDL.fmclasses[this.fmClass]; + var fields = this.fmIDL.fields; + for(var f in fields) + if(fields[f].name == this.fmField) + this.idlField = fields[f]; + } } if(!this.idlField) - throw new Error("AutoFieldWidget could not determine which field to render. We need more information. fmClass=" + + throw new Error("AutoFieldWidget could not determine which " + + "field to render. We need more information. fmClass=" + this.fmClass + ' fmField=' + this.fmField + ' fmObject=' + js2JSON(this.fmObject)); this.auth = openils.User.authtoken; @@ -59,14 +97,21 @@ if(!dojo._hasResource['openils.widget.AutoFieldWidget']) { var value = this.baseWidgetValue(); switch(this.idlField.datatype) { case 'bool': - return (value) ? 't' : 'f' + switch(value) { + case 'true': return 't'; + case 'on': return 't'; + case 'false' : return 'f'; + case 'unset' : return null; + case true : return 't'; + default: return 'f'; + } case 'timestamp': if(!value) return null; return dojo.date.stamp.toISOString(value); case 'int': case 'float': case 'money': - if(isNaN(value)) value = 0; + if(isNaN(value)) value = null; default: return (value === '') ? null : value; } @@ -85,9 +130,17 @@ if(!dojo._hasResource['openils.widget.AutoFieldWidget']) { var value = this.widgetValue; switch(this.idlField.datatype) { case 'bool': - return (openils.Util.isTrue(value)) ? - openils.widget.AutoFieldWidget.localeStrings.TRUE : - openils.widget.AutoFieldWidget.localeStrings.FALSE; + switch(value) { + case 't': + case 'true': + return openils.widget.AutoFieldWidget.localeStrings.TRUE; + case 'f' : + case 'false' : + return openils.widget.AutoFieldWidget.localeStrings.FALSE; + case 'unset' : return openils.widget.AutoFieldWidget.localeStrings.UNSET; + case true : return openils.widget.AutoFieldWidget.localeStrings.TRUE; + default: return openils.widget.AutoFieldWidget.localeStrings.FALSE; + } case 'timestamp': if (!value) return ''; dojo.require('dojo.date.locale'); @@ -109,10 +162,15 @@ if(!dojo._hasResource['openils.widget.AutoFieldWidget']) { build : function(onload) { + if(this.widgetValue == null) + this.widgetValue = (this.fmObject) ? this.fmObject[this.idlField.name]() : null; + if(this.widget) { // core widget provided for us, attach and move on if(this.parentNode) // may already be in the "right" place this.parentNode.appendChild(this.widget.domNode); + if(this.widget.attr('value') == null) + this._widgetLoaded(); return; } @@ -120,8 +178,6 @@ if(!dojo._hasResource['openils.widget.AutoFieldWidget']) { this.parentNode = dojo.create('div'); this.onload = onload; - if(this.widgetValue == null) - this.widgetValue = (this.fmObject) ? this.fmObject[this.idlField.name]() : null; if(this.readOnly) { dojo.require('dijit.layout.ContentPane'); @@ -171,9 +227,30 @@ if(!dojo._hasResource['openils.widget.AutoFieldWidget']) { break; case 'bool': - dojo.require('dijit.form.CheckBox'); - this.widget = new dijit.form.CheckBox(this.dijitArgs, this.parentNode); - this.widgetValue = openils.Util.isTrue(this.widgetValue); + if(this.ternary) { + dojo.require('dijit.form.FilteringSelect'); + var store = new dojo.data.ItemFileReadStore({ + data:{ + identifier : 'value', + items:[ + {label : openils.widget.AutoFieldWidget.localeStrings.UNSET, value : 'unset'}, + {label : openils.widget.AutoFieldWidget.localeStrings.TRUE, value : 'true'}, + {label : openils.widget.AutoFieldWidget.localeStrings.FALSE, value : 'false'} + ] + } + }); + this.widget = new dijit.form.FilteringSelect(this.dijitArgs, this.parentNode); + this.widget.searchAttr = this.widget.labelAttr = 'label'; + this.widget.valueAttr = 'value'; + this.widget.store = store; + this.widget.startup(); + this.widgetValue = (this.widgetValue === null) ? 'unset' : + (openils.Util.isTrue(this.widgetValue)) ? 'true' : 'false'; + } else { + dojo.require('dijit.form.CheckBox'); + this.widget = new dijit.form.CheckBox(this.dijitArgs, this.parentNode); + this.widgetValue = openils.Util.isTrue(this.widgetValue); + } break; case 'link': @@ -211,10 +288,8 @@ if(!dojo._hasResource['openils.widget.AutoFieldWidget']) { return false; var lclass = linkInfo.linkClass; - if(lclass == 'aou') { - this.widgetValue = fieldmapper.aou.findOrgUnit(this.widgetValue).shortname(); - return; - } + if(lclass == 'aou') + return false; // first try the store cache var self = this; @@ -222,12 +297,17 @@ if(!dojo._hasResource['openils.widget.AutoFieldWidget']) { var store = this.cache[this.auth].list[lclass]; var query = {}; query[linkInfo.vfield.name] = ''+this.widgetValue; + var found = false; store.fetch({query:query, onComplete: function(list) { - self.widgetValue = store.getValue(list[0], linkInfo.vfield.selector); + if(list[0]) { + self.widgetValue = store.getValue(list[0], linkInfo.vfield.selector); + found = true; + } } }); - return; + + if(found) return; } // then try the single object cache @@ -284,6 +364,7 @@ if(!dojo._hasResource['openils.widget.AutoFieldWidget']) { }, _buildLinkSelector : function() { + var self = this; var selectorInfo = this._getLinkSelector(); if(!selectorInfo) return false; @@ -307,30 +388,90 @@ if(!dojo._hasResource['openils.widget.AutoFieldWidget']) { this.widget.searchAttr = this.widget.labelAttr = vfield.selector || vfield.name; this.widget.valueAttr = vfield.name; - var self = this; var oncomplete = function(list) { + + if(self.labelFormat) + self.widget.labelAttr = '_label'; + + if(self.searchFormat) + self.widget.searchAttr = '_search'; + + function formatString(item, formatList) { + + try { + + // formatList[1..*] are names of fields. Pull the field + // values from each object to determine the values for string substitution + var values = []; + var format = formatList[0]; + for(var i = 1; i< formatList.length; i++) + values.push(item[formatList[i]]); + + return dojo.string.substitute(format, values); + + } catch(E) { + throw new Error( + "openils.widget.AutoFieldWidget: Invalid formatList ["+formatList+"] : "+E); + } + + } + if(list) { - self.widget.store = - new dojo.data.ItemFileReadStore({data:fieldmapper[linkClass].toStoreData(list)}); + var storeData = {data:fieldmapper[linkClass].toStoreData(list)}; + + if(self.labelFormat) { + dojo.forEach(storeData.data.items, + function(item) { + item._label = formatString(item, self.labelFormat); + } + ); + } + + if(self.searchFormat) { + dojo.forEach(storeData.data.items, + function(item) { + item._search = formatString(item, self.searchFormat); + } + ); + } + + self.widget.store = new dojo.data.ItemFileReadStore(storeData); self.cache[self.auth].list[linkClass] = self.widget.store; + } else { self.widget.store = self.cache[self.auth].list[linkClass]; } + self.widget.startup(); self._widgetLoaded(); }; - if(this.cache[self.auth].list[linkClass]) { + if(!this.noCache && this.cache[self.auth].list[linkClass]) { oncomplete(); } else { - new openils.PermaCrud().retrieveAll(linkClass, { - async : !this.forceSync, - oncomplete : function(r) { - var list = openils.Util.readResponse(r, false, true); - oncomplete(list); + + if(this.dataLoader) { + + // caller provided an external function for retrieving the data + this.dataLoader(linkClass, this.searchFilter, oncomplete); + + } else { + + var _cb = function(r) { + oncomplete(openils.Util.readResponse(r, false, true)); + }; + + if (this.searchFilter) { + new openils.PermaCrud().search(linkClass, this.searchFilter, { + async : !this.forceSync, oncomplete : _cb + }); + } else { + new openils.PermaCrud().retrieveAll(linkClass, { + async : !this.forceSync, oncomplete : _cb + }); } - }); + } } return true; @@ -356,13 +497,22 @@ if(!dojo._hasResource['openils.widget.AutoFieldWidget']) { } else { this.baseWidgetValue(this.widgetValue); - if(this.idlField.name == this.fmIDL.pkey && this.fmIDL.pkey_sequence) + if(this.idlField.name == this.fmIDL.pkey && this.fmIDL.pkey_sequence && (!this.selfReference && !this.noDisablePkey)) this.widget.attr('disabled', true); if(this.disableWidgetTest && this.disableWidgetTest(this.idlField.name, this.fmObject)) this.widget.attr('disabled', true); } if(this.onload) this.onload(this.widget, this); + + if(!this.readOnly && 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() { @@ -374,7 +524,7 @@ if(!dojo._hasResource['openils.widget.AutoFieldWidget']) { this.widget.parentField = 'parent_ou'; var user = new openils.User(); - if(this.widgetValue == null) + if(this.widgetValue == null && this.orgDefaultsToWs) this.widgetValue = user.user.ws_ou(); // if we have a limit perm, find the relevent orgs (async) diff --git a/Open-ILS/web/js/dojo/openils/widget/AutoGrid.js b/Open-ILS/web/js/dojo/openils/widget/AutoGrid.js index e51d6215ed..0ff2d87771 100644 --- a/Open-ILS/web/js/dojo/openils/widget/AutoGrid.js +++ b/Open-ILS/web/js/dojo/openils/widget/AutoGrid.js @@ -18,6 +18,7 @@ if(!dojo._hasResource['openils.widget.AutoGrid']) { editOnEnter : false, defaultCellWidth : null, editStyle : 'dialog', + editReadOnly : false, suppressFields : null, hideSelector : false, selectorWidth : '1.5', @@ -25,6 +26,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 @@ -58,6 +60,7 @@ if(!dojo._hasResource['openils.widget.AutoGrid']) { this.overrideEditWidgets = {}; this.overrideEditWidgetClass = {}; + this.overrideWidgetArgs = {}; if(this.editOnEnter) this._applyEditOnEnter(); @@ -317,7 +320,7 @@ if(!dojo._hasResource['openils.widget.AutoGrid']) { dojo.forEach(items, function(item) { var fmObject = new fieldmapper[self.fmClass]().fromStoreItem(item); - new openils.PermaCrud()['delete'](fmObject, {oncomplete : function(r) { self.store.deleteItem(item) }}); + new openils.PermaCrud()['eliminate'](fmObject, {oncomplete : function(r) { self.store.deleteItem(item) }}); } ); }, @@ -370,12 +373,17 @@ if(!dojo._hasResource['openils.widget.AutoGrid']) { var grid = this; var fmObject = new fieldmapper[this.fmClass]().fromStoreItem(storeItem); var idents = grid.store.getIdentityAttributes(); + var self = this; var pane = new openils.widget.EditPane({ fmObject:fmObject, + hideSaveButton : this.editReadOnly, + readOnly : this.editReadOnly, overrideWidgets : this.overrideEditWidgets, 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]; @@ -413,9 +421,11 @@ if(!dojo._hasResource['openils.widget.AutoGrid']) { fmClass : this.fmClass, overrideWidgets : this.overrideEditWidgets, overrideWidgetClass : this.overrideEditWidgetClass, + overrideWidgetArgs : this.overrideWidgetArgs, disableWidgetTest : this.disableWidgetTest, - onPostSubmit : function(r) { - var fmObject = openils.Util.readResponse(r); + requiredFields : this.requiredFields, + onPostSubmit : function(req, cudResults) { + var fmObject = cudResults[0]; if(grid.onPostCreate) grid.onPostCreate(fmObject); if(fmObject) diff --git a/Open-ILS/web/js/dojo/openils/widget/AutoWidget.js b/Open-ILS/web/js/dojo/openils/widget/AutoWidget.js index f8bb0984fd..e4f11ab20c 100644 --- a/Open-ILS/web/js/dojo/openils/widget/AutoWidget.js +++ b/Open-ILS/web/js/dojo/openils/widget/AutoWidget.js @@ -48,7 +48,7 @@ if(!dojo._hasResource['openils.widget.AutoWidget']) { self.sortedFieldList.push(field) } else { // non-IDL field - self.sortedFieldList.push({name : name, virtual:true}); + self.sortedFieldList.push({name : name, nonIdl:true}); } } ); diff --git a/Open-ILS/web/js/dojo/openils/widget/EditDialog.js b/Open-ILS/web/js/dojo/openils/widget/EditDialog.js index 6bb66bdfed..08a22dece5 100644 --- a/Open-ILS/web/js/dojo/openils/widget/EditDialog.js +++ b/Open-ILS/web/js/dojo/openils/widget/EditDialog.js @@ -38,9 +38,9 @@ if(!dojo._hasResource['openils.widget.EditDialog']) { self.hide(); } - this.editPane.onPostSubmit = function(r) { + this.editPane.onPostSubmit = function(r, cudResults) { self.hide(); - if(onSubmit) onSubmit(r); + if(onSubmit) onSubmit(r, cudResults); } }, diff --git a/Open-ILS/web/js/dojo/openils/widget/EditPane.js b/Open-ILS/web/js/dojo/openils/widget/EditPane.js index 48e5ecfcc9..760eca80d4 100644 --- a/Open-ILS/web/js/dojo/openils/widget/EditPane.js +++ b/Open-ILS/web/js/dojo/openils/widget/EditPane.js @@ -16,6 +16,11 @@ if(!dojo._hasResource['openils.widget.EditPane']) { onPostSubmit : null, // apply callback onCancel : null, // cancel callback hideActionButtons : false, + fieldDocs : null, + existingTable : null, + suppressFields : null, + requiredFields : null, + paneStackCount : 1, // how many fields to add to each row, for compressing display constructor : function(args) { this.fieldList = []; @@ -31,11 +36,20 @@ if(!dojo._hasResource['openils.widget.EditPane']) { this.inherited(arguments); this.initAutoEnv(); if(this.readOnly) - this.hideActionButtons = true; + this.hideSaveButton = true; - var table = this.table = document.createElement('table'); + // grab any field-level docs + /* + var pcrud = new openils.PermaCrud(); + this.fieldDocs = pcrud.search('fdoc', {fm_class:this.fmClass}); + */ + + var table = this.existingTable; + if(!table) { + var table = this.table = document.createElement('table'); + this.domNode.appendChild(table); + } var tbody = document.createElement('tbody'); - this.domNode.appendChild(table); table.appendChild(tbody); this.limitPerms = []; @@ -48,37 +62,80 @@ if(!dojo._hasResource['openils.widget.EditPane']) { if(!this.overrideWidgetClass) this.overrideWidgetClass = {}; + if(!this.overrideWidgetArgs) + this.overrideWidgetArgs = {}; + + var idx = 0; + var currentRow; for(var f in this.sortedFieldList) { var field = this.sortedFieldList[f]; - if(!field || field.virtual) continue; + if(!field || field.virtual || field.nonIdl) continue; + + if(this.suppressFields && this.suppressFields.indexOf(field.name) > -1) + continue; if(field.name == this.fmIDL.pkey && this.mode == 'create' && this.fmIDL.pkey_sequence) continue; /* don't show auto-generated fields on create */ - var row = document.createElement('tr'); + if((idx++ % this.paneStackCount) == 0 || !currentRow) { + // time to start a new row + currentRow = document.createElement('tr'); + tbody.appendChild(currentRow); + } + + //var docTd = document.createElement('td'); var nameTd = document.createElement('td'); var valTd = document.createElement('td'); var valSpan = document.createElement('span'); valTd.appendChild(valSpan); + dojo.addClass(nameTd, 'openils-widget-editpane-name-cell'); + dojo.addClass(valTd, 'openils-widget-editpane-value-cell'); + if(this.readOnly) { + dojo.addClass(nameTd, 'openils-widget-editpane-ro-name-cell'); + dojo.addClass(valTd, 'openils-widget-editpane-ro-value-cell'); + } + + + /* + if(this.fieldDocs[field]) { + var helpLink = dojo.create('a'); + var helpImg = dojo.create('img', {src:'/opac/images/advancedsearch-icon.png'}); // TODO Config + helpLink.appendChild(helpImg); + docTd.appendChild(helpLink); + } + */ nameTd.appendChild(document.createTextNode(field.label)); - row.setAttribute('fmfield', field.name); - row.appendChild(nameTd); - row.appendChild(valTd); - tbody.appendChild(row); - - var widget = new openils.widget.AutoFieldWidget({ - idlField : field, - fmObject : this.fmObject, - fmClass : this.fmClass, - parentNode : valSpan, - orgLimitPerms : this.limitPerms, - readOnly : this.readOnly, - widget : this.overrideWidgets[field.name], - widgetClass : this.overrideWidgetClass[field.name], - disableWidgetTest : this.disableWidgetTest - }); + currentRow.setAttribute('fmfield', field.name); + //currentRow.appendChild(docTd); + currentRow.appendChild(nameTd); + currentRow.appendChild(valTd); + //dojo.addClass(docTd, 'oils-fm-edit-pane-help'); + + if(!this.overrideWidgetArgs[field.name]) + this.overrideWidgetArgs[field.name] = {}; + + var args = dojo.mixin( + this.overrideWidgetArgs[field.name], { + idlField : field, + fmObject : this.fmObject, + fmClass : this.fmClass, + parentNode : valSpan, + orgLimitPerms : this.limitPerms, + readOnly : this.readOnly, + widget : this.overrideWidgets[field.name], + widgetClass : this.overrideWidgetClass[field.name], + disableWidgetTest : this.disableWidgetTest + } + ); + + 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(); this.fieldList.push({name:field.name, widget:widget}); @@ -117,6 +174,8 @@ if(!dojo._hasResource['openils.widget.EditPane']) { onClick : this.onCancel }, cancelSpan); + if(this.hideSaveButton) return; + new dijit.form.Button({ label:'Save', // XXX onClick: function() {self.performAutoEditAction();} @@ -137,9 +196,9 @@ if(!dojo._hasResource['openils.widget.EditPane']) { performAutoEditAction : function() { var self = this; self.performEditAction({ - oncomplete:function(r) { + oncomplete:function(req, cudResults) { if(self.onPostSubmit) - self.onPostSubmit(r); + self.onPostSubmit(req, cudResults); } }); }, diff --git a/Open-ILS/web/js/dojo/openils/widget/nls/AutoFieldWidget.js b/Open-ILS/web/js/dojo/openils/widget/nls/AutoFieldWidget.js index a948eee61c..3fee288dbd 100644 --- a/Open-ILS/web/js/dojo/openils/widget/nls/AutoFieldWidget.js +++ b/Open-ILS/web/js/dojo/openils/widget/nls/AutoFieldWidget.js @@ -1,4 +1,5 @@ { 'TRUE' : 'True', - 'FALSE' : 'False' + 'FALSE' : 'False', + 'UNSET' : 'Unset' } diff --git a/Open-ILS/web/js/ui/default/conify/global/action/survey.js b/Open-ILS/web/js/ui/default/conify/global/action/survey.js index 5fb779bc2e..c9809653d4 100644 --- a/Open-ILS/web/js/ui/default/conify/global/action/survey.js +++ b/Open-ILS/web/js/ui/default/conify/global/action/survey.js @@ -145,8 +145,8 @@ function svCreate(args) { var pcrud = new openils.PermaCrud(); pcrud.create(sv, { - oncomplete: function(r) { - var obj = openils.Util.readResponse(r); + oncomplete: function(r, objs) { + var obj = objs[0]; if(!obj) return ''; svGrid.store.newItem(asv.toStoreItem(obj)); svSurveyDialog.hide(); diff --git a/Open-ILS/web/js/ui/default/conify/global/action/survey/edit.js b/Open-ILS/web/js/ui/default/conify/global/action/survey/edit.js index 2c2b8ed67b..132c3fcfdf 100644 --- a/Open-ILS/web/js/ui/default/conify/global/action/survey/edit.js +++ b/Open-ILS/web/js/ui/default/conify/global/action/survey/edit.js @@ -123,8 +123,8 @@ function newQuestion(svyId, questionText, questionRow) { question.question(questionText); question.isnew(true); pcrud.create(question, - {oncomplete: function(r) - { var q = openils.Util.readResponse(r); + {oncomplete: function(r, qs) + { var q = qs[0]; questionRow.parentNode.removeChild(questionRow); drawQuestionBody(q, null); newQuestionBody(svyId); diff --git a/Open-ILS/web/js/ui/default/conify/global/config/circ_matrix_matchpoint.js b/Open-ILS/web/js/ui/default/conify/global/config/circ_matrix_matchpoint.js index 3004406519..7fdae7b166 100644 --- a/Open-ILS/web/js/ui/default/conify/global/config/circ_matrix_matchpoint.js +++ b/Open-ILS/web/js/ui/default/conify/global/config/circ_matrix_matchpoint.js @@ -12,6 +12,7 @@ var circModEntryCache = {}; var matchPoint; function load(){ + cmGrid.overrideWidgetArgs.is_renewal = {ternary : true}; cmGrid.loadAll({order_by:{ccmm:'circ_modifier'}}); cmGrid.onEditPane = buildEditPaneAdditions; circModEditor = dojo.byId('circ-mod-editor').parentNode.removeChild(dojo.byId('circ-mod-editor')); @@ -22,6 +23,7 @@ function byName(name, ctxt) { } function buildEditPaneAdditions(editPane) { + if(!editPane.fmObject) return; var node = circModEditor.cloneNode(true); var tableTmpl = node.removeChild(byName('circ-mod-group-table', node)); circModGroupTables = []; @@ -143,8 +145,8 @@ function applyCircModChanges() { if(group.isnew()) { pcrud.create(group, { - oncomplete : function(r) { - var group = openils.Util.readResponse(r); + oncomplete : function(r, cudResults) { + var group = cudResults[0]; dojo.forEach(entries, function(e) { e.circ_mod_test(group.id()) } ); pcrud.create(entries, { oncomplete : function() { @@ -157,8 +159,7 @@ function applyCircModChanges() { } else { pcrud.update(group, { - oncomplete : function(r) { - openils.Util.readResponse(r); + oncomplete : function(r, cudResults) { var newOnes = entries.filter(function(e) { return e.isnew() }); var delOnes = entries.filter(function(e) { return e.isdeleted() }); if(!delOnes.length && !newOnes.length) { @@ -169,7 +170,7 @@ function applyCircModChanges() { pcrud.create(newOnes, { oncomplete : function() { if(delOnes.length) { - pcrud.delete(delOnes, { + pcrud.eliminate(delOnes, { oncomplete : function() { progressDialog.hide(); } @@ -180,7 +181,7 @@ function applyCircModChanges() { } }); } else { - pcrud.delete(delOnes, { + pcrud.eliminate(delOnes, { oncomplete : function() { progressDialog.hide(); } -- 2.11.0