[open-ils-commits] r18774 - in branches/rel_2_0/Open-ILS/web: js/dojo/openils js/dojo/openils/widget js/ui/default/acq/common js/ui/default/acq/lineitem templates/default/acq/common templates/default/conify/global/booking (senator)

svn at svn.open-ils.org svn at svn.open-ils.org
Wed Nov 17 17:41:39 EST 2010


Author: senator
Date: 2010-11-17 17:41:33 -0500 (Wed, 17 Nov 2010)
New Revision: 18774

Added:
   branches/rel_2_0/Open-ILS/web/js/dojo/openils/PermaCrud/
   branches/rel_2_0/Open-ILS/web/js/dojo/openils/widget/PCrudAutocompleteBox.js
Modified:
   branches/rel_2_0/Open-ILS/web/js/ui/default/acq/common/li_table.js
   branches/rel_2_0/Open-ILS/web/js/ui/default/acq/lineitem/related.js
   branches/rel_2_0/Open-ILS/web/templates/default/acq/common/li_table.tt2
   branches/rel_2_0/Open-ILS/web/templates/default/conify/global/booking/resource.tt2
   branches/rel_2_0/Open-ILS/web/templates/default/conify/global/booking/resource_attr.tt2
   branches/rel_2_0/Open-ILS/web/templates/default/conify/global/booking/resource_attr_map.tt2
Log:
Backport r18762 from trunk:

Wonder of wonders, a Dojo data store supporting lazy loading objects via pcrud!

So openils.PermaCrud.Store was dreamt up and directed by Mike Rylander, and
implemented by me.  Right now it gives us a new way to provide widgets for
selecting objects in Dojo-based interfaces.

Where previously we had some dropdowns here and there that really shouldn't
be dropdowns (such as one for selection lists in Acq, and several for resources
and resource types in Booking -- these examples I've replaced, but there are
surely more) because loading a dropdown with potentially zillions of items
to choose from can take forever and break the interface, now we can have
autocompleting textboxes that only load items matching what you type (and
even then with a low-ish default limit so that if you're vague in your input
you still don't get huge unwieldy result sets).

Easiest way to see an example is if you already have any acq selection lists.
Just go to any catalog record, choose Actions for this Record, choose View/Place
orders, then click "Add to Selection List." In the resulting dialog, that
second field used to be a dropdown, but now it's an autocompleting textbox.

Alternatively, you can see these in the affected booking interfaces (see files
modified in this commit) under Admin -> Server Administration -> Booking.

The future promises even better things for this store. When it implements the
Dojo Write API, interfaces using grids can potentially be vastly simplified
by relying on the store to save its own dirty objects. The Notification API
would facilitate easy use of single stores with multiple widgets. All good
things for faster-to-write interfaces.

------------------------------------------------------------------------


Copied: branches/rel_2_0/Open-ILS/web/js/dojo/openils/PermaCrud (from rev 18762, trunk/Open-ILS/web/js/dojo/openils/PermaCrud)

Copied: branches/rel_2_0/Open-ILS/web/js/dojo/openils/widget/PCrudAutocompleteBox.js (from rev 18762, trunk/Open-ILS/web/js/dojo/openils/widget/PCrudAutocompleteBox.js)
===================================================================
--- branches/rel_2_0/Open-ILS/web/js/dojo/openils/widget/PCrudAutocompleteBox.js	                        (rev 0)
+++ branches/rel_2_0/Open-ILS/web/js/dojo/openils/widget/PCrudAutocompleteBox.js	2010-11-17 22:41:33 UTC (rev 18774)
@@ -0,0 +1,49 @@
+if (!dojo._hasResource["openils.widget.PCrudAutocompleteBox"]) {
+    dojo._hasResource["openils.widget.PCrudAutocompleteBox"] = true;
+    dojo.provide("openils.widget.PCrudAutocompleteBox");
+
+    dojo.require("openils.PermaCrud.Store");
+    dojo.require("dijit.form.FilteringSelect");
+
+    dojo.declare(
+        "openils.widget.PCrudAutocompleteBox", [dijit.form.FilteringSelect], {
+        //  summary:
+        //      An autocompleting textbox that uses PermaCrud to fetch
+        //      matches. openils.PermaCrud.Store does the work.
+        //
+        //  description:
+        //      Use just like a dijit.form.FilteringSelect except that there
+        //      are these additional properties supported in the args object:
+        //
+        //      The *fmclass* parameter.
+        //          The class hint for the kind of fieldmapper object you
+        //          want to work with. From the IDL.
+        //
+        //      The *store_options* parameter.
+        //          Another object of options such as you would pass to
+        //          openils.PermaCrud.Store. See the documentation for that
+        //          class (it's more thorough).
+        //
+        //      You should also use the existing *searchAttr* object to
+        //      specify what you want to search for as you type and what
+        //      you see in the box.
+            "store": "",
+            "fmclass": "",
+            "store_options": {},
+
+            "constructor": function(args) {
+                if (!args.hasDownArrow)
+                    args.hasDownArrow = false;
+
+                if (!args.store) {
+                    if (!args.fmclass)
+                        throw new Error("need either store or fmclass");
+                    var store_options = dojo.mixin(
+                        {"fmclass": args.fmclass}, args.store_options
+                    );
+                    args.store = new openils.PermaCrud.Store(store_options);
+                }
+            }
+        }
+    );
+}

Modified: branches/rel_2_0/Open-ILS/web/js/ui/default/acq/common/li_table.js
===================================================================
--- branches/rel_2_0/Open-ILS/web/js/ui/default/acq/common/li_table.js	2010-11-17 22:01:07 UTC (rev 18773)
+++ branches/rel_2_0/Open-ILS/web/js/ui/default/acq/common/li_table.js	2010-11-17 22:41:33 UTC (rev 18774)
@@ -13,6 +13,7 @@
 dojo.require('dojo.data.ItemFileReadStore');
 dojo.require('openils.widget.ProgressDialog');
 dojo.require('openils.PermaCrud');
+dojo.require("openils.widget.PCrudAutocompleteBox");
 
 dojo.requireLocalization('openils.acq', 'acq');
 var localeStrings = dojo.i18n.getLocalization('openils.acq', 'acq');
@@ -1851,7 +1852,6 @@
                 break;
 
             case 'save_picklist':
-                this._loadPLSelect();
                 acqLitSavePlDialog.show();
                 break;
 
@@ -2412,29 +2412,6 @@
         }
     };
 
-    this._loadPLSelect = function(preSel) {
-        if(this._plSelectLoaded) return;
-        var plList = [];
-        function handleResponse(r) {
-            plList.push(r.recv().content());
-        }
-        var method = 'open-ils.acq.picklist.user.retrieve';
-        fieldmapper.standardRequest(
-            ['open-ils.acq', method],
-            {   async: true,
-                params: [this.authtoken],
-                onresponse: handleResponse,
-                oncomplete: function() {
-                    self._plSelectLoaded = true;
-                    acqLitAddExistingSelect.store = 
-                        new dojo.data.ItemFileReadStore({data:acqpl.toStoreData(plList)});
-
-                    acqLitAddExistingSelect.setValue(preSel);
-                }
-            }
-        );
-    }
-
     this.showRealCopyEditUI = function(li) {
         copyList = [];
         var self = this;

Modified: branches/rel_2_0/Open-ILS/web/js/ui/default/acq/lineitem/related.js
===================================================================
--- branches/rel_2_0/Open-ILS/web/js/ui/default/acq/lineitem/related.js	2010-11-17 22:01:07 UTC (rev 18773)
+++ branches/rel_2_0/Open-ILS/web/js/ui/default/acq/lineitem/related.js	2010-11-17 22:41:33 UTC (rev 18774)
@@ -109,7 +109,6 @@
 function prepareButtons() {
     addToPlButton.onClick = createLi(
         function() { /* oncomplete */
-            liTable._loadPLSelect(paramPL);
             acqLitSavePlDialog.show();
         }
     );

Modified: branches/rel_2_0/Open-ILS/web/templates/default/acq/common/li_table.tt2
===================================================================
--- branches/rel_2_0/Open-ILS/web/templates/default/acq/common/li_table.tt2	2010-11-17 22:01:07 UTC (rev 18773)
+++ branches/rel_2_0/Open-ILS/web/templates/default/acq/common/li_table.tt2	2010-11-17 22:41:33 UTC (rev 18774)
@@ -377,8 +377,7 @@
                 <tr>
                     <td><label for="existing_pl">Add to Selection List: </label></td>
                     <td>
-                        <input jsId='acqLitAddExistingSelect' dojoType="dijit.form.FilteringSelect" 
-                            name="existing_pl" searchAttr='name' displayAttr='name'/>
+                        <input jsId="acqLitAddExistingSelect" dojoType="openils.widget.PCrudAutocompleteBox" fmclass="acqpl" searchAttr="name" name="existing_pl" />
                     </td>
                 </tr>
                 <tr>

Modified: branches/rel_2_0/Open-ILS/web/templates/default/conify/global/booking/resource.tt2
===================================================================
--- branches/rel_2_0/Open-ILS/web/templates/default/conify/global/booking/resource.tt2	2010-11-17 22:01:07 UTC (rev 18773)
+++ branches/rel_2_0/Open-ILS/web/templates/default/conify/global/booking/resource.tt2	2010-11-17 22:41:33 UTC (rev 18774)
@@ -1,18 +1,5 @@
 [% WRAPPER default/base.tt2 %]
 [% ctx.page_title = 'Resources' %]
-<script type ="text/javascript">
-    dojo.require('dijit.form.FilteringSelect');
-    dojo.require('openils.widget.AutoGrid');
-
-    openils.Util.addOnLoad(
-        function() {
-            var search = {"id": {"!=": null}};
-            if (xulG && xulG.resultant_brsrc)
-                search = {id: xulG.resultant_brsrc};
-            brsrcGrid.loadAll({order_by:{brsrc : 'barcode'}}, search);
-        }
-    );
-</script>
 <div dojoType="dijit.layout.ContentPane" layoutAlign="client">
     <div dojoType="dijit.layout.ContentPane" layoutAlign="top" class="oils-header-panel">
         <div>Resources</div>
@@ -31,4 +18,24 @@
             editOnEnter='true'>
     </table>
 </div>
+<script type ="text/javascript">
+    dojo.require('dijit.form.FilteringSelect');
+    dojo.require('openils.widget.AutoGrid');
+    dojo.require("openils.widget.PCrudAutocompleteBox");
+
+    openils.Util.addOnLoad(
+        function() {
+            var search = {"id": {"!=": null}};
+            if (xulG && xulG.resultant_brsrc)
+                search = {id: xulG.resultant_brsrc};
+
+            brsrcGrid.overrideEditWidgets.type =
+                new openils.widget.PCrudAutocompleteBox({
+                    "fmclass": "brt", "searchAttr": "name"
+                });
+            brsrcGrid.overrideEditWidgets.type.shove = {"create": ""};
+            brsrcGrid.loadAll({order_by:{brsrc : 'barcode'}}, search);
+        }
+    );
+</script>
 [% END %]

Modified: branches/rel_2_0/Open-ILS/web/templates/default/conify/global/booking/resource_attr.tt2
===================================================================
--- branches/rel_2_0/Open-ILS/web/templates/default/conify/global/booking/resource_attr.tt2	2010-11-17 22:01:07 UTC (rev 18773)
+++ branches/rel_2_0/Open-ILS/web/templates/default/conify/global/booking/resource_attr.tt2	2010-11-17 22:41:33 UTC (rev 18774)
@@ -1,15 +1,5 @@
 [% WRAPPER default/base.tt2 %]
 [% ctx.page_title = 'Resource Attributes' %]
-<script type ="text/javascript">
-    dojo.require('dijit.form.FilteringSelect');
-    dojo.require('openils.widget.AutoGrid');
-
-    openils.Util.addOnLoad(
-        function() {
-            braGrid.loadAll({order_by:{bra : 'name'}}, {"id": {"!=": null}});
-        }
-    );
-</script>
 <div dojoType="dijit.layout.ContentPane" layoutAlign="client">
     <div dojoType="dijit.layout.ContentPane" layoutAlign="top" class="oils-header-panel">
         <div>Resource Attributes</div>
@@ -27,5 +17,19 @@
             editOnEnter='true'>
     </table>
 </div>
+<script type ="text/javascript">
+    dojo.require("openils.widget.PCrudAutocompleteBox");
+    dojo.require('openils.widget.AutoGrid');
 
+    openils.Util.addOnLoad(
+        function() {
+            braGrid.overrideEditWidgets.resource_type =
+                new openils.widget.PCrudAutocompleteBox({
+                    "fmclass": "brt", "searchAttr": "name"
+                });
+            braGrid.overrideEditWidgets.resource_type.shove = {"create": ""};
+            braGrid.loadAll({order_by:{bra : 'name'}}, {"id": {"!=": null}});
+        }
+    );
+</script>
 [% END %]

Modified: branches/rel_2_0/Open-ILS/web/templates/default/conify/global/booking/resource_attr_map.tt2
===================================================================
--- branches/rel_2_0/Open-ILS/web/templates/default/conify/global/booking/resource_attr_map.tt2	2010-11-17 22:01:07 UTC (rev 18773)
+++ branches/rel_2_0/Open-ILS/web/templates/default/conify/global/booking/resource_attr_map.tt2	2010-11-17 22:41:33 UTC (rev 18774)
@@ -1,13 +1,5 @@
 [% WRAPPER default/base.tt2 %]
 [% ctx.page_title = 'Resource Attribute Maps' %]
-<script type ="text/javascript">
-    dojo.require('dijit.form.FilteringSelect');
-    dojo.require('openils.widget.AutoGrid');
-
-    openils.Util.addOnLoad(
-        function() { bramGrid.loadAll({order_by:{bram : 'resource_attr'}}); }
-    );
-</script>
 <div dojoType="dijit.layout.ContentPane" layoutAlign="client">
     <div dojoType="dijit.layout.ContentPane" layoutAlign="top" class='oils-header-panel'>
         <div>Resource Attribute Maps</div>
@@ -25,4 +17,19 @@
             editOnEnter='true'>
     </table>
 </div>
+<script type ="text/javascript">
+    dojo.require("openils.widget.PCrudAutocompleteBox");
+    dojo.require('openils.widget.AutoGrid');
+
+    openils.Util.addOnLoad(
+        function() {
+            bramGrid.overrideEditWidgets.resource =
+                new openils.widget.PCrudAutocompleteBox({
+                    "fmclass": "brsrc", "searchAttr": "barcode"
+                });
+            bramGrid.overrideEditWidgets.resource.shove = {"create": ""};
+            bramGrid.loadAll({"order_by": {"bram": "resource_attr"}});
+        }
+    );
+</script>
 [% END %]



More information about the open-ils-commits mailing list