working org selector, working call number prefix/suffix. crushing it!
authorLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Mon, 2 Apr 2012 16:34:47 +0000 (12:34 -0400)
committerLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Mon, 2 Apr 2012 16:34:47 +0000 (12:34 -0400)
Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Open-ILS/src/templates/circ/hold_pull_list.tt2
Open-ILS/web/js/dojo/openils/widget/FlattenerGrid.js

index aef4e4f..09fd3d9 100644 (file)
@@ -2,7 +2,74 @@
 [% ctx.page_title = 'Hold Pull List' %]
 <script type="text/javascript">
     dojo.require("dijit.form.Button");
+    dojo.require("openils.widget.OrgUnitFilteringSelect");
     dojo.require("openils.widget.FlattenerGrid");
+
+    var map_extras = {
+        "call_number_prefix": {
+            "path": "current_copy.call_number.prefix.label",
+            "display": true
+        },
+        "call_number_suffix": {
+            "path": "current_copy.call_number.suffix.label",
+            "display": true
+        },
+        "copy_circ_lib": {
+            "path": "current_copy.circ_lib",
+            "filter": true
+        },
+        "call_number_sort_key": {
+            "path": "current_copy.call_number.label_sortkey",
+            "filter" :true
+        }
+    };
+
+    function get_cn_extras(rowIndex, item) {
+        if (!item)
+            return null;
+        var store = this.grid.store;
+        var result = [];
+        dojo.forEach(
+            ["call_number_prefix", "call_number", "call_number_suffix"],
+            function(attr) {
+                var v = store.getValue(item, attr);
+                if (v)
+                    result.push(v);
+            }
+        );
+
+        return result;
+    }
+
+    function format_cn_extras(result) {
+        return result ? result.join(" ") : "";
+    }
+
+    function set_grid_query_from_org_selector() {
+        grid.query = {
+            "copy_circ_lib": org_selector.attr("value")
+        };
+        grid.refresh();
+    }
+
+    function prepare_org_selector(perm) {
+        new openils.User().buildPermOrgSelector(
+            perm, org_selector, null,
+            function() {
+                dojo.connect(
+                    org_selector, "onChange", set_grid_query_from_org_selector
+                );
+                set_grid_query_from_org_selector();
+            }
+        );
+    }
+
+    openils.Util.addOnLoad(
+        function() {
+            prepare_org_selector("VIEW_HOLD");
+        }
+    );
+
 </script>
 <div dojoType="dijit.layout.ContentPane" layoutAlign="client">
     <div dojoType="dijit.layout.ContentPane"
                 onClick="print_pull_list()">Print Pull List</button>
         </div>
     </div>
-    <!-- <div class="oils-acq-basic-roomy">
-        blah, a dropdown or something here (optional; typical interfaces might
-        have a filtering org select here. Then again, why not use
-        showLoadFilter on the Grid instead?)
-    </div> -->
+    <div class="oils-acq-basic-roomy">
+        <label for="org_selector">Show the pull list for:</label>
+        <select
+            id="org_selector" jsId="org_selector"
+            dojoType="openils.widget.OrgUnitFilteringSelect"
+            searchAttr="shortname" labelAttr="shortname">
+        </select>
+    </div>
     <table
         id="gridNode"
         jsid="grid"
         showLoadFilter="true"
         fmClass="'ahopl'"
         baseSort="['copy_location_sort_order','call_number']"
-        mapExtras="{copy_circ_lib:{path:'current_copy.circ_lib',filter:true}}"
-        query="{copy_circ_lib: 4}">
+        mapExtras="map_extras"
+        deferInitialFetch="true"
+        query="{}">
         <thead>
             <tr>
                 <th field="barcode" fpath="current_copy.barcode">Barcode</th>
                 <th field="title" fpath="current_copy.call_number.record.simple_record.title"></th>
                 <th field="author" fpath="current_copy.call_number.record.simple_record.author"></th>
-                <th field="call_number" fpath="current_copy.call_number.label" ffilter="true"></th><!-- FIXME: prefix & suffix -->
+                <th field="call_number" fpath="current_copy.call_number.label" ffilter="true" get="get_cn_extras" formatter="format_cn_extras"></th>
                 <th field="shelving_loc" fpath="current_copy.location.name" ffilter="true">Shelving Location</th>
             </tr>
         </thead>
index 230974d..e86460d 100644 (file)
@@ -17,6 +17,7 @@ if (!dojo._hasResource["openils.widget.FlattenerGrid"]) {
             "columnReordering": true,
             "columnPersistKey": null,
             "showLoadFilter": false,    /* use FlattenerFilterDialog */
+            "deferInitialFetch": false,
 
             /* These potential constructor arguments maybe useful to
              * FlattenerGrid in their own right, and are passed to
@@ -294,7 +295,7 @@ if (!dojo._hasResource["openils.widget.FlattenerGrid"]) {
 
             "_finishStartup": function(sortFields) {
 
-                this.setStore(
+                this._setStore( /* Seriously, let's leave this as _setStore. */
                     new openils.FlattenerStore({
                         "fmClass": this.fmClass,
                         "fmIdentifier": this.fmIdentifier,
@@ -305,6 +306,10 @@ if (!dojo._hasResource["openils.widget.FlattenerGrid"]) {
                     }), this.query
                 );
 
+                if (!this.deferInitialFetch) {
+                    this._refresh(true);
+                }
+
                 // pick up any column label changes
                 this.columnPicker.reloadStructure();
 
@@ -359,6 +364,23 @@ if (!dojo._hasResource["openils.widget.FlattenerGrid"]) {
                 }
             },
 
+            "refresh": function() {
+                /* We may never need additional logic here, but I don't
+                 * want callers to make a habit of calling _ methods directly.
+                 */
+                console.log("here (no surprise)");
+                this._refresh(/* isRender */ true);
+            },
+
+            "_render": function() {
+                if(this.domNode.parentNode){
+                    this.scroller.init(this.attr('rowCount'), this.keepRows, this.rowsPerPage);
+                    this.prerender();
+                    if (!this.deferInitialFetch)
+                        this._fetch(0, true);
+                }
+            },
+
             /* ******** below are methods mostly copied but
              * slightly changed from AutoGrid ******** */