[open-ils-commits] r17797 - in branches/rel_2_0/Open-ILS: src/perlmods/OpenILS/Application/Circ web/js/dojo/openils xul/staff_client/server/serial (senator)

svn at svn.open-ils.org svn at svn.open-ils.org
Fri Sep 17 20:25:14 EDT 2010


Author: senator
Date: 2010-09-17 20:25:13 -0400 (Fri, 17 Sep 2010)
New Revision: 17797

Modified:
   branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/Application/Circ/CopyLocations.pm
   branches/rel_2_0/Open-ILS/web/js/dojo/openils/Util.js
   branches/rel_2_0/Open-ILS/xul/staff_client/server/serial/batch_receive.js
   branches/rel_2_0/Open-ILS/xul/staff_client/server/serial/pattern_wizard_overlay.xul
Log:
Backport r17796 from trunk: serials batch receive improvements


Modified: branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/Application/Circ/CopyLocations.pm
===================================================================
--- branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/Application/Circ/CopyLocations.pm	2010-09-18 00:24:41 UTC (rev 17796)
+++ branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/Application/Circ/CopyLocations.pm	2010-09-18 00:25:13 UTC (rev 17797)
@@ -44,6 +44,30 @@
 }
 
 __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,

Modified: branches/rel_2_0/Open-ILS/web/js/dojo/openils/Util.js
===================================================================
--- branches/rel_2_0/Open-ILS/web/js/dojo/openils/Util.js	2010-09-18 00:24:41 UTC (rev 17796)
+++ branches/rel_2_0/Open-ILS/web/js/dojo/openils/Util.js	2010-09-18 00:25:13 UTC (rev 17797)
@@ -324,6 +324,16 @@
         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

Modified: branches/rel_2_0/Open-ILS/xul/staff_client/server/serial/batch_receive.js
===================================================================
--- branches/rel_2_0/Open-ILS/xul/staff_client/server/serial/batch_receive.js	2010-09-18 00:24:41 UTC (rev 17796)
+++ branches/rel_2_0/Open-ILS/xul/staff_client/server/serial/batch_receive.js	2010-09-18 00:25:13 UTC (rev 17797)
@@ -226,9 +226,7 @@
             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 @@
                 "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(cn) {
                         dojo.create(
                             "menuitem", {
-                                "value": cn.id(), "label": cn.label()
+                                "value": cn.label(), "label": cn.label()
                             }, menupopup, "last"
                         );
                     }
@@ -314,6 +315,35 @@
         }
     };
 
+    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 @@
         }
     };
 
+    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 @@
         );
 
         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 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(

Modified: branches/rel_2_0/Open-ILS/xul/staff_client/server/serial/pattern_wizard_overlay.xul
===================================================================
--- branches/rel_2_0/Open-ILS/xul/staff_client/server/serial/pattern_wizard_overlay.xul	2010-09-18 00:24:41 UTC (rev 17796)
+++ branches/rel_2_0/Open-ILS/xul/staff_client/server/serial/pattern_wizard_overlay.xul	2010-09-18 00:25:13 UTC (rev 17797)
@@ -238,7 +238,7 @@
                         <rows>
                             <row>
                                 <radio
-                                    label="Select fundamental periodicity:"
+                                    label="Select frequency:"
                                     accesskey="F" selected="true"
                                     value="hard_w" />
                                 <menulist id="hard_w">



More information about the open-ils-commits mailing list