added support for ternary boolean widgets (where null is a valid value) to autowidget...
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 9 Dec 2009 22:44:01 +0000 (22:44 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 9 Dec 2009 22:44:01 +0000 (22:44 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@15131 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/web/css/skin/default.css
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
Open-ILS/web/js/dojo/openils/widget/nls/AutoFieldWidget.js
Open-ILS/web/js/ui/default/conify/global/config/circ_matrix_matchpoint.js

index 87f7757..980907d 100644 (file)
@@ -77,6 +77,14 @@ table { border-collapse: collapse; }
 
 .oils-fm-edit-pane { margin: 5px; }
 .oils-fm-edit-pane td { padding: 5px; }
+.oils-fm-edit-pane-help {  
+    width:10px;
+    padding:0px;
+    margin:0px;
+    border:1px solid #e0e0e0;
+    text-align:center;
+    vertical-align:middle;
+}
 .oils-fm-edit-dialog td { border:1px solid #999;}
 .oils-header-panel {
     width: 100%;
index 9318356..1be08b7 100644 (file)
@@ -79,7 +79,13 @@ 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 '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);
@@ -105,9 +111,13 @@ 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 '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');
@@ -192,9 +202,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':
index e51d621..dd9f114 100644 (file)
@@ -58,6 +58,7 @@ if(!dojo._hasResource['openils.widget.AutoGrid']) {
 
                 this.overrideEditWidgets = {};
                 this.overrideEditWidgetClass = {};
+                this.overrideWidgetArgs = {};
 
                 if(this.editOnEnter) 
                     this._applyEditOnEnter();
@@ -375,6 +376,7 @@ if(!dojo._hasResource['openils.widget.AutoGrid']) {
                     fmObject:fmObject,
                     overrideWidgets : this.overrideEditWidgets,
                     overrideWidgetClass : this.overrideEditWidgetClass,
+                    overrideWidgetArgs : this.overrideWidgetArgs,
                     disableWidgetTest : this.disableWidgetTest,
                     onPostSubmit : function() {
                         for(var i in fmObject._fields) {
@@ -413,6 +415,7 @@ 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);
index 48e5ecf..051fa99 100644 (file)
@@ -16,6 +16,7 @@ if(!dojo._hasResource['openils.widget.EditPane']) {
             onPostSubmit : null, // apply callback
             onCancel : null, // cancel callback
             hideActionButtons : false,
+            fieldDocs : null,
 
             constructor : function(args) {
                 this.fieldList = [];
@@ -33,6 +34,12 @@ if(!dojo._hasResource['openils.widget.EditPane']) {
                 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);
@@ -48,6 +55,9 @@ if(!dojo._hasResource['openils.widget.EditPane']) {
                 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;
@@ -56,29 +66,47 @@ if(!dojo._hasResource['openils.widget.EditPane']) {
                         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});
index a948eee..3fee288 100644 (file)
@@ -1,4 +1,5 @@
 {
     'TRUE' : 'True',
-    'FALSE' : 'False'
+    'FALSE' : 'False',
+    'UNSET' : 'Unset'
 }
index 3004406..f415f56 100644 (file)
@@ -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'));