var value = this.baseWidgetValue();
switch(this.idlField.datatype) {
case 'bool':
- return (value) ? 't' : 'f'
+ switch(value) {
+ case 'true': 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);
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 'true': return openils.widget.AutoFieldWidget.localeStrings.TRUE;
+ 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':
dojo.require('dojo.date.locale');
dojo.require('dojo.date.stamp');
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':
this.overrideEditWidgets = {};
this.overrideEditWidgetClass = {};
+ this.overrideWidgetArgs = {};
if(this.editOnEnter)
this._applyEditOnEnter();
fmObject:fmObject,
overrideWidgets : this.overrideEditWidgets,
overrideWidgetClass : this.overrideEditWidgetClass,
+ overrideWidgetArgs : this.overrideWidgetArgs,
disableWidgetTest : this.disableWidgetTest,
onPostSubmit : function() {
for(var i in fmObject._fields) {
fmClass : this.fmClass,
overrideWidgets : this.overrideEditWidgets,
overrideWidgetClass : this.overrideEditWidgetClass,
+ overrideWidgetArgs : this.overrideWidgetArgs,
disableWidgetTest : this.disableWidgetTest,
onPostSubmit : function(r) {
var fmObject = openils.Util.readResponse(r);
onPostSubmit : null, // apply callback
onCancel : null, // cancel callback
hideActionButtons : false,
+ fieldDocs : null,
constructor : function(args) {
this.fieldList = [];
if(this.readOnly)
this.hideActionButtons = true;
+ // grab any field-level docs
+ /*
+ var pcrud = new openils.PermaCrud();
+ this.fieldDocs = pcrud.search('fdoc', {fm_class:this.fmClass});
+ */
+
var table = this.table = document.createElement('table');
var tbody = document.createElement('tbody');
this.domNode.appendChild(table);
if(!this.overrideWidgetClass)
this.overrideWidgetClass = {};
+ if(!this.overrideWidgetArgs)
+ this.overrideWidgetArgs = {};
+
for(var f in this.sortedFieldList) {
var field = this.sortedFieldList[f];
if(!field || field.virtual) continue;
continue; /* don't show auto-generated fields on create */
var row = document.createElement('tr');
+ //var docTd = document.createElement('td');
var nameTd = document.createElement('td');
var valTd = document.createElement('td');
var valSpan = document.createElement('span');
valTd.appendChild(valSpan);
+ /*
+ 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(docTd);
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
- });
+ //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
+ }
+ );
+
+ var widget = new openils.widget.AutoFieldWidget(args);
widget.build();
this.fieldList.push({name:field.name, widget:widget});