From 92ec34f83523787ffe61771c1760105febded8e7 Mon Sep 17 00:00:00 2001 From: senator Date: Sat, 18 Sep 2010 00:24:41 +0000 Subject: [PATCH] Serials batch receive: usability improvements s/fundamental periodicity/frequency/ Smart copy location batch applicator Dedup call numbers with same label in batch applicator Tooltips on the holding lib column to show dist label and stream routing label git-svn-id: svn://svn.open-ils.org/ILS/trunk@17796 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../OpenILS/Application/Circ/CopyLocations.pm | 24 ++++++ Open-ILS/web/js/dojo/openils/Util.js | 10 +++ .../staff_client/server/serial/batch_receive.js | 97 +++++++++++++++++----- .../server/serial/pattern_wizard_overlay.xul | 2 +- 4 files changed, 110 insertions(+), 23 deletions(-) diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Circ/CopyLocations.pm b/Open-ILS/src/perlmods/OpenILS/Application/Circ/CopyLocations.pm index 3930641b95..5ace445bfa 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Circ/CopyLocations.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Circ/CopyLocations.pm @@ -44,6 +44,30 @@ sub cl_retrieve_all { } __PACKAGE__->register_method( + "api_name" => "open-ils.circ.copy_location.retrieve.distinct", + "method" => "cl_retrieve_distinct", + "stream" => 1, + "argc" => 0, + "signature" => q/Retrieve copy locations with distinct names globally/ +); + +sub cl_retrieve_distinct { + my ($self, $client) = @_; + + my $e = new_editor(); + my $names = $e->json_query({ + "select" => { + "acpl" => [{"transform" => "distinct", "column" => "name"}] + }, + "from" => {"acpl" => {}} + }) or return $e->die_event; + $e->disconnect; + + $client->respond($_->{"name"}) for @$names; + undef; +} + +__PACKAGE__->register_method( api_name => 'open-ils.circ.copy_location.create', method => 'cl_create', argc => 2, diff --git a/Open-ILS/web/js/dojo/openils/Util.js b/Open-ILS/web/js/dojo/openils/Util.js index ebe5cc36c5..f670b696f5 100644 --- a/Open-ILS/web/js/dojo/openils/Util.js +++ b/Open-ILS/web/js/dojo/openils/Util.js @@ -324,6 +324,16 @@ if(!dojo._hasResource["openils.Util"]) { return openils.Util.objectProperties(o); } + openils.Util.uniqueObjects = function(list, field) { + var sorted = openils.Util.objectSort(list, field); + var results = []; + for (var i = 0; i < sorted.length; i++) { + if (!i || (sorted[i][field]() != sorted[i-1][field]())) + results.push(sorted[i]); + } + return results; + }; + /** * Highlight instances of each pattern in the given DOM node * Inspired by the jquery plugin 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 3fbf35046a..553f76ae35 100644 --- a/Open-ILS/xul/staff_client/server/serial/batch_receive.js +++ b/Open-ILS/xul/staff_client/server/serial/batch_receive.js @@ -226,9 +226,7 @@ function BatchReceiver() { function(loc) { dojo.create( "menuitem", { - "value": loc.id(), - "label": "(" + loc.owning_lib().shortname() + ") " + - loc.name() /* XXX i18n */ + "value": loc.id(), "label": loc.name() }, menupopup, "last" ); } @@ -277,15 +275,18 @@ function BatchReceiver() { "editable": "true", "className": "cn" }); var menupopup = dojo.create("menupopup", null, menulist, "only"); - this._call_number_cache.forEach( - function(cn) { - dojo.create( - "menuitem", { - "value": cn.id(), "label": cn.label() - }, menupopup, "last" - ); - } - ); + + openils.Util.uniqueObjects(this._call_number_cache, "label"). + forEach( + function(cn) { + dojo.create( + "menuitem", { + "value": cn.label(), "label": cn.label() + }, menupopup, "last" + ); + } + ); + return menulist; } else { /* In this case, limit call numbers by owning_lib matching @@ -303,7 +304,7 @@ function BatchReceiver() { function(cn) { dojo.create( "menuitem", { - "value": cn.id(), "label": cn.label() + "value": cn.label(), "label": cn.label() }, menupopup, "last" ); } @@ -314,6 +315,35 @@ function BatchReceiver() { } }; + this._build_batch_location_dropdown = function() { + var menulist = dojo.create("menulist"); + var menupopup = dojo.create("menupopup",null,menulist); + dojo.create("menuitem", {"value": -1, "label": "---"}, menupopup); + + fieldmapper.standardRequest( + ["open-ils.circ", + "open-ils.circ.copy_location.retrieve.distinct.atomic"],{ + "params": [], + "async": false, + "onresponse": function(r) { + if (list = openils.Util.readResponse(r)) { + list.forEach( + function(locname) { + dojo.create( + "menuitem", { + "value": locname, "label": locname + }, menupopup + ); + } + ); + } + } + } + ); + + return menulist; + }; + this._build_receive_toggle = function(item) { return dojo.create( "checkbox", { @@ -442,12 +472,30 @@ function BatchReceiver() { } }; + this._location_by_name = function(id, value) { + var lib = this.item_cache[id].stream().distribution(). + holding_lib().id(); + var winners = this._location_by_lib[lib].filter( + function(loc) { return loc.name() == value; } + ); + if (winners.length) { + return winners[0].id(); + } else { + return null; + } + }; + this._set_all_enabled_rows = function(key, value) { /* do NOT do trimming here, set whitespace as is. */ for (var id in this.rows) { if (!this._row_disabled(id)) { if (this._confirm_row_field_application(id, key, value)) { - this._row_field_value(id, key, value); + if (key == "location") /* kludge for this field */ { + if (actual = this._location_by_name(id, value)) + this._row_field_value(id, key, actual); + } else { + this._row_field_value(id, key, value); + } } } } @@ -692,13 +740,8 @@ function BatchReceiver() { ); node_by_name("location", row).appendChild( - this.batch_controls.location = this._build_location_dropdown( - /* XXX TODO build a smarter list. rather than all copy locs - * under OU #1, try building a list of copy locs available to - * all OUs represented in actual items */ - this._get_locations_for_lib(1), - true /* add_unset_value */ - ) + this.batch_controls.location = + this._build_batch_location_dropdown() ); node_by_name("circ_modifier", row).appendChild( @@ -754,8 +797,18 @@ function BatchReceiver() { function n(s) { return node_by_name(s, row); } /* typing saver */ + var stream_dist_label = item.stream().distribution().label(); + if (item.stream().routing_label()) + stream_dist_label += " / " + item.stream().routing_label(); + n("holding_lib").appendChild( - T(item.stream().distribution().holding_lib().shortname()) + dojo.create( + "description", { + "value": item.stream().distribution(). + holding_lib().shortname(), + "tooltiptext": stream_dist_label + } + ) ); n("barcode").appendChild( diff --git a/Open-ILS/xul/staff_client/server/serial/pattern_wizard_overlay.xul b/Open-ILS/xul/staff_client/server/serial/pattern_wizard_overlay.xul index 141bbb3366..76686f78d6 100644 --- a/Open-ILS/xul/staff_client/server/serial/pattern_wizard_overlay.xul +++ b/Open-ILS/xul/staff_client/server/serial/pattern_wizard_overlay.xul @@ -238,7 +238,7 @@ -- 2.11.0