From 1da19c8ca10ec8de81f9864bb26b6135bc7533c7 Mon Sep 17 00:00:00 2001 From: senator Date: Thu, 28 Oct 2010 18:14:06 +0000 Subject: [PATCH] Alternate Serial Control UI misc bugfixes, minor tweaks and improvements. 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 | 2 +- Open-ILS/web/js/ui/default/serial/subscription.js | 9 ++- .../web/templates/default/serial/subscription.tt2 | 1 + .../default/serial/subscription/distribution.tt2 | 13 ++-- .../staff_client/server/serial/batch_receive.js | 69 ++++++++++++++++++++-- 5 files changed, 81 insertions(+), 13 deletions(-) diff --git a/Open-ILS/web/css/skin/default/serial.css b/Open-ILS/web/css/skin/default/serial.css index 1889c8fd61..625ad67fc4 100644 --- a/Open-ILS/web/css/skin/default/serial.css +++ b/Open-ILS/web/css/skin/default/serial.css @@ -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; } diff --git a/Open-ILS/web/js/ui/default/serial/subscription.js b/Open-ILS/web/js/ui/default/serial/subscription.js index 7659e8b34d..7c37a12b7c 100644 --- a/Open-ILS/web/js/ui/default/serial/subscription.js +++ b/Open-ILS/web/js/ui/default/serial/subscription.js @@ -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; } diff --git a/Open-ILS/web/templates/default/serial/subscription.tt2 b/Open-ILS/web/templates/default/serial/subscription.tt2 index a8dc19c256..a147a58436 100644 --- a/Open-ILS/web/templates/default/serial/subscription.tt2 +++ b/Open-ILS/web/templates/default/serial/subscription.tt2 @@ -45,6 +45,7 @@ Bibliographic Record Expected Date Offset + Number of Distributions diff --git a/Open-ILS/web/templates/default/serial/subscription/distribution.tt2 b/Open-ILS/web/templates/default/serial/subscription/distribution.tt2 index 8ad3a61d0d..151a40a11f 100644 --- a/Open-ILS/web/templates/default/serial/subscription/distribution.tt2 +++ b/Open-ILS/web/templates/default/serial/subscription/distribution.tt2 @@ -5,27 +5,30 @@ Refresh Grid New Distribution + onClick="sub_grid._fresh = false; dist_grid.showCreateDialog();"> + New Distribution + Delete Selected + onClick="sub_grid._fresh = false; dist_grid.deleteSelected();"> + Delete Selected +
- diff --git a/Open-ILS/xul/staff_client/server/serial/batch_receive.js b/Open-ILS/xul/staff_client/server/serial/batch_receive.js index eda0c3af5c..83891662dc 100644 --- a/Open-ILS/xul/staff_client/server/serial/batch_receive.js +++ b/Open-ILS/xul/staff_client/server/serial/batch_receive.js @@ -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); -- 2.11.0