Alternate Serial Control UI misc bugfixes, minor tweaks and improvements.
authorsenator <senator@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 28 Oct 2010 18:14:06 +0000 (18:14 +0000)
committersenator <senator@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 28 Oct 2010 18:14:06 +0000 (18:14 +0000)
Still fighting an autogrid that sometimes renders in an imcomplete, cut-off
sort of way in the distributions tab of the subscription details interface.

Add distribution count to summary tab.

The batch receive interface now prepopulates the circ mod, copy location, and
price fields based on each item's stream's distribution's copy template, when it
can.  When users had gone through the steps to create a copy template, it was
confusing not to see that work reflected in the batch receive interface.

git-svn-id: svn://svn.open-ils.org/ILS/trunk@18530 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/web/css/skin/default/serial.css
Open-ILS/web/js/ui/default/serial/subscription.js
Open-ILS/web/templates/default/serial/subscription.tt2
Open-ILS/web/templates/default/serial/subscription/distribution.tt2
Open-ILS/xul/staff_client/server/serial/batch_receive.js

index 1889c8f..625ad67 100644 (file)
@@ -1,5 +1,5 @@
 .oils-serial-header { margin-bottom: 20px; }
-.oils-serial-tab-container { height: 600px; }
+.oils-serial-tab-container { height: 700px; }
 .lesser { margin-top: 2px !important }
 .lesser div:first-child { font-size: 110% !important; }
 .lesser div:last-child { margin-right: 16px; }
index 7659e8b..7c37a12 100644 (file)
@@ -33,15 +33,18 @@ HTMLSelectElement.prototype.setValue = function(s) {
 function load_sub_grid(id, oncomplete) {
     if (!pcrud) return; /* first run, onLoad hasn't fired yet */
     if (!sub_grid._fresh) {
+        var dist_ids = pcrud.search(
+            "sdist", {"subscription": id}, {"id_list": true}
+        );
         pcrud.retrieve(
             "ssub", id, {
                 "onresponse": function(r) {
                     if (r = openils.Util.readResponse(r)) {
                         sub = r;
+                        var data = ssub.toStoreData([r]);
+                        data.items[0].num_dist = dist_ids ? dist_ids.length : 0;
                         sub_grid.setStore(
-                            new dojo.data.ItemFileReadStore(
-                                {"data": ssub.toStoreData([r])}
-                            )
+                            new dojo.data.ItemFileReadStore({"data": data})
                         );
                         sub_grid._fresh = true;
                     }
index a8dc19c..a147a58 100644 (file)
@@ -45,6 +45,7 @@
                         Bibliographic Record
                     </th>
                     <th field="expected_date_offset">Expected Date Offset</th>
+                    <th field="num_dist">Number of Distributions</th>
                 </tr>
             </thead>
         </table>
index 8ad3a61..151a40a 100644 (file)
@@ -5,27 +5,30 @@
         <span dojoType="dijit.form.Button"
             onClick="dist_grid.refresh();">Refresh Grid</span>
         <span dojoType="dijit.form.Button"
-            onClick="dist_grid.showCreateDialog();">New Distribution</span>
+            onClick="sub_grid._fresh = false; dist_grid.showCreateDialog();">
+            New Distribution
+        </span>
         <span dojoType="dijit.form.Button"
-            onClick="dist_grid.deleteSelected();">Delete Selected</span>
+            onClick="sub_grid._fresh = false; dist_grid.deleteSelected();">
+            Delete Selected
+        </span>
     </div>
 </div>
 <div dojoType="dijit.layout.ContentPane" layout="top">
     <table
         jsId="dist_grid"
         dojoType="openils.widget.AutoGrid"
-        autoHeight="true"
+        style="height: 550px;"
         fieldOrder="['subscription','label','holding_lib']"
         suppressFields="['record_entry','subscription','receive_call_number','bind_call_number','bind_unit_template']"
         suppressEditFields="['record_entry','receive_call_number','bind_call_number','bind_unit_template']"
-        defaultCellWidth="'auto'"
         fmClass="sdist"
         query="{id: '*'}"
         editOnEnter="true"
         showPaginator="true">
         <thead>
             <tr>
-                <th field="label"
+                <th field="label" width="35%"
                     get="get_sdist" formatter="format_sdist_label"></th>
             </tr>
         </thead>
index eda0c3a..8389166 100644 (file)
@@ -55,6 +55,7 @@ function BatchReceiver() {
         this._call_number_cache = null;
         this._prepared_call_number_controls = {};
         this._location_by_lib = {};
+        this._copy_template_cache = {};
 
         /* empty the entry receiving table if we're starting over */
         if (this.item_cache) {
@@ -209,6 +210,7 @@ function BatchReceiver() {
             dojo.query("menupopup", control)[0],
             "first"
         );
+        control.value = -1;
         return control;
     };
 
@@ -379,10 +381,18 @@ function BatchReceiver() {
 
         var node = dojo.query("*", node_by_name(field, row))[0];
 
-        if (typeof(value) == "undefined")
+        if (typeof(value) == "undefined") {
             return node.value;
-        else
+        } else {
+            /* XXX The new two lines /should/ each do the same thing, but
+             * apparently they don't.  With only one or the other, I get
+             * skipped fields when this is called by the code that
+             * pre-populates fields based on copy templates.  This may
+             * have something to do with Dojo and XUL not getting along
+             * completely? */
+            dojo.attr(node, "value", value);
             node.value = value;
+        }
     }
 
        this._user_wants_autogen = function() {
@@ -649,6 +659,53 @@ function BatchReceiver() {
 
     };
 
+    this._update_copy_template_cache = function() {
+        var templates_needed = openils.Util.uniqueElements(
+            openils.Util.objectProperties(this.item_cache).map(
+                function(id) {
+                    return self.item_cache[id].stream().distribution().
+                        receive_unit_template();
+                }
+            )
+        ).filter(
+            function(id) { return !self._copy_template_cache[id]; }
+        );
+
+        if (templates_needed.length) {
+            this.pcrud.search("act", {"id": templates_needed}).forEach(
+                function(tmpl) {
+                    self._copy_template_cache[tmpl.id()] = tmpl;
+                }
+            );
+        }
+    }
+
+    this.apply_copy_templates = function() {
+        this._update_copy_template_cache(); /* sync */
+
+        for (var id in this.item_cache) {
+            var item = this.item_cache[id];
+            var template_id =
+                item.stream().distribution().receive_unit_template();
+            var template = this._copy_template_cache[template_id];
+
+            var row = this.rows[id];
+
+            var tmpl_mod = template.circ_modifier();
+            var tmpl_loc = template.location();
+            var tmpl_price = template.price();
+            if (tmpl_mod != null) {
+                this._row_field_value(
+                    row, "circ_modifier", tmpl_mod == "" ? 0 : tmpl_mod
+                );
+            }
+            if (tmpl_loc)
+                this._row_field_value(row, "location", tmpl_loc);
+            if (tmpl_price > 0)
+                this._row_field_value(row, "price", tmpl_price);
+        }
+    };
+
     this.load_entry_form = function(issuance) {
         if (typeof(issuance) == "undefined") {
             var issuance_id = dojo.byId("issuance_chooser").value;
@@ -673,7 +730,6 @@ function BatchReceiver() {
                     busy(false);
 
                     if (list = openils.Util.readResponse(r, false, true)) {
-
                         if (list.length) {
                             busy(true);
                             show("form_holder");
@@ -681,7 +737,12 @@ function BatchReceiver() {
                             list.forEach(function(o) {self.add_entry_row(o);});
 
                             self.build_batch_entry_row();
-                            dojo.byId("batch_receive_with_units").doCommand();
+
+                            var recv_with_units =
+                                dojo.byId("batch_receive_with_units");
+                            recv_with_units.doCommand();
+                            if (recv_with_units.checked)
+                                self.apply_copy_templates();
 
                             show("batch_receive_entry");
                             busy(false);