[open-ils-commits] r15131 - in trunk/Open-ILS/web: css/skin js/dojo/openils/widget js/dojo/openils/widget/nls js/ui/default/conify/global/config (erickson)

svn at svn.open-ils.org svn at svn.open-ils.org
Wed Dec 9 17:44:07 EST 2009


Author: erickson
Date: 2009-12-09 17:44:01 -0500 (Wed, 09 Dec 2009)
New Revision: 15131

Modified:
   trunk/Open-ILS/web/css/skin/default.css
   trunk/Open-ILS/web/js/dojo/openils/widget/AutoFieldWidget.js
   trunk/Open-ILS/web/js/dojo/openils/widget/AutoGrid.js
   trunk/Open-ILS/web/js/dojo/openils/widget/EditPane.js
   trunk/Open-ILS/web/js/dojo/openils/widget/nls/AutoFieldWidget.js
   trunk/Open-ILS/web/js/ui/default/conify/global/config/circ_matrix_matchpoint.js
Log:
added support for ternary boolean widgets (where null is a valid value) to autowidgets plus a more generic way to pass that flag through autogrid/editpane.  made is_renewal a ternary widget for circ matrix matchpoint.  partial (commented out until complete) implementation of field-level documentation widgets (a la the new user editor) for EditPane's

Modified: trunk/Open-ILS/web/css/skin/default.css
===================================================================
--- trunk/Open-ILS/web/css/skin/default.css	2009-12-09 22:14:39 UTC (rev 15130)
+++ trunk/Open-ILS/web/css/skin/default.css	2009-12-09 22:44:01 UTC (rev 15131)
@@ -77,6 +77,14 @@
 
 .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%;

Modified: trunk/Open-ILS/web/js/dojo/openils/widget/AutoFieldWidget.js
===================================================================
--- trunk/Open-ILS/web/js/dojo/openils/widget/AutoFieldWidget.js	2009-12-09 22:14:39 UTC (rev 15130)
+++ trunk/Open-ILS/web/js/dojo/openils/widget/AutoFieldWidget.js	2009-12-09 22:44:01 UTC (rev 15131)
@@ -79,7 +79,13 @@
             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 @@
             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 @@
                         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':

Modified: trunk/Open-ILS/web/js/dojo/openils/widget/AutoGrid.js
===================================================================
--- trunk/Open-ILS/web/js/dojo/openils/widget/AutoGrid.js	2009-12-09 22:14:39 UTC (rev 15130)
+++ trunk/Open-ILS/web/js/dojo/openils/widget/AutoGrid.js	2009-12-09 22:44:01 UTC (rev 15131)
@@ -58,6 +58,7 @@
 
                 this.overrideEditWidgets = {};
                 this.overrideEditWidgetClass = {};
+                this.overrideWidgetArgs = {};
 
                 if(this.editOnEnter) 
                     this._applyEditOnEnter();
@@ -375,6 +376,7 @@
                     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 @@
                     fmClass : this.fmClass,
                     overrideWidgets : this.overrideEditWidgets,
                     overrideWidgetClass : this.overrideEditWidgetClass,
+                    overrideWidgetArgs : this.overrideWidgetArgs,
                     disableWidgetTest : this.disableWidgetTest,
                     onPostSubmit : function(r) {
                         var fmObject = openils.Util.readResponse(r);

Modified: trunk/Open-ILS/web/js/dojo/openils/widget/EditPane.js
===================================================================
--- trunk/Open-ILS/web/js/dojo/openils/widget/EditPane.js	2009-12-09 22:14:39 UTC (rev 15130)
+++ trunk/Open-ILS/web/js/dojo/openils/widget/EditPane.js	2009-12-09 22:44:01 UTC (rev 15131)
@@ -16,6 +16,7 @@
             onPostSubmit : null, // apply callback
             onCancel : null, // cancel callback
             hideActionButtons : false,
+            fieldDocs : null,
 
             constructor : function(args) {
                 this.fieldList = [];
@@ -33,6 +34,12 @@
                 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(!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,30 +66,48 @@
                         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);
+                    //dojo.addClass(docTd, 'oils-fm-edit-pane-help');
 
-                    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
-                    });
+                    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});
                 }

Modified: trunk/Open-ILS/web/js/dojo/openils/widget/nls/AutoFieldWidget.js
===================================================================
--- trunk/Open-ILS/web/js/dojo/openils/widget/nls/AutoFieldWidget.js	2009-12-09 22:14:39 UTC (rev 15130)
+++ trunk/Open-ILS/web/js/dojo/openils/widget/nls/AutoFieldWidget.js	2009-12-09 22:44:01 UTC (rev 15131)
@@ -1,4 +1,5 @@
 {
     'TRUE' : 'True',
-    'FALSE' : 'False'
+    'FALSE' : 'False',
+    'UNSET' : 'Unset'
 }

Modified: trunk/Open-ILS/web/js/ui/default/conify/global/config/circ_matrix_matchpoint.js
===================================================================
--- trunk/Open-ILS/web/js/ui/default/conify/global/config/circ_matrix_matchpoint.js	2009-12-09 22:14:39 UTC (rev 15130)
+++ trunk/Open-ILS/web/js/ui/default/conify/global/config/circ_matrix_matchpoint.js	2009-12-09 22:44:01 UTC (rev 15131)
@@ -12,6 +12,7 @@
 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'));



More information about the open-ils-commits mailing list