[open-ils-commits] r17432 - in branches/rel_2_0/Open-ILS: src/perlmods/OpenILS/Application xul/staff_client/server/serial (senator)

svn at svn.open-ils.org svn at svn.open-ils.org
Wed Sep 1 18:58:48 EDT 2010


Author: senator
Date: 2010-09-01 18:58:48 -0400 (Wed, 01 Sep 2010)
New Revision: 17432

Modified:
   branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/Application/Serial.pm
   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_overlay.xul
Log:
Backport r17431 from trunk, checkbox to en/disable batch receive w/ units


Modified: branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/Application/Serial.pm
===================================================================
--- branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/Application/Serial.pm	2010-09-01 22:57:49 UTC (rev 17431)
+++ branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/Application/Serial.pm	2010-09-01 22:58:48 UTC (rev 17432)
@@ -877,6 +877,35 @@
     return {'num_items_received' => scalar @$items, 'new_unit_id' => $new_unit_id};
 }
 
+sub _find_or_create_call_number {
+    my ($e, $lib, $cn_string, $record) = @_;
+
+    my $existing = $e->search_asset_call_number({
+        "owning_lib" => $lib,
+        "label" => $cn_string,
+        "record" => $record,
+        "deleted" => "f"
+    }) or return $e->die_event;
+
+    if (@$existing) {
+        return $existing->[0]->id;
+    } else {
+        return $e->die_event unless
+            $e->allowed("CREATE_VOLUME", $lib);
+
+        my $acn = new Fieldmapper::asset::call_number;
+
+        $acn->creator($e->requestor->id);
+        $acn->editor($e->requestor->id);
+        $acn->record($record);
+        $acn->label($cn_string);
+        $acn->owning_lib($lib);
+
+        $e->create_asset_call_number($acn) or return $e->die_event;
+        return $e->data->id;
+    }
+}
+
 __PACKAGE__->register_method(
     "method" => "receive_items_one_unit_per",
     "api_name" => "open-ils.serial.receive_items.one_unit_per",
@@ -959,36 +988,19 @@
                 }
             }
 
+            # Treat call number specially: the provided value from the
+            # user will really be a string.
             if ($user_unit->call_number) {
-                # call_number passed in will actually be a string representing
-                # a call_number label, not an actual acn object or even an ID.
-                # Therefore we must lookup the call_number requested, or
-                # create a new one if it does not exist for the given lib.
+                my $real_cn = _find_or_create_call_number(
+                    $e, $sdist->holding_lib->id,
+                    $user_unit->call_number, $record
+                );
 
-                my $existing = $e->search_asset_call_number({
-                    "owning_lib" => $sdist->holding_lib->id,
-                    "label" => $user_unit->call_number,
-                    "record" => $record,
-                    "deleted" => "f"
-                }) or return $e->die_event;
-
-                if (@$existing) {
-                    $user_unit->call_number($existing->[0]->id);
+                if ($U->event_code($real_cn)) {
+                    $e->rollback;
+                    return $real_cn;
                 } else {
-                    return $e->die_event unless
-                        $e->allowed("CREATE_VOLUME", $sdist->holding_lib->id);
-
-                    my $acn = new Fieldmapper::asset::call_number;
-
-                    $acn->creator($user_id);
-                    $acn->editor($user_id);
-                    $acn->record($record);
-                    $acn->label($user_unit->call_number);
-                    $acn->owning_lib($sdist->holding_lib->id);
-
-                    $e->create_asset_call_number($acn) or return $e->die_event;
-
-                    $user_unit->call_number($e->data->id);
+                    $user_unit->call_number($real_cn);
                 }
             }
 

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-01 22:57:49 UTC (rev 17431)
+++ branches/rel_2_0/Open-ILS/xul/staff_client/server/serial/batch_receive.js	2010-09-01 22:58:48 UTC (rev 17432)
@@ -45,6 +45,19 @@
     openils.Util.removeCSSClass(e, "hideme");
 }
 
+function hide_table_cell(e) {
+    if (typeof(e) == "string") e = dojo.byId(e);
+
+    e.style.display = "none";
+    e.style.visibility = "hidden";
+}
+
+function show_table_cell(e) {
+    if (typeof(e) == "string") e = dojo.byId(e);
+    e.style.display = "table-cell";
+    e.style.visibility = "visible";
+}
+
 function busy(on) {
     if (typeof(busy._window) == "undefined")
         busy._window = dojo.query("window")[0];
@@ -383,11 +396,18 @@
         dojo.query("textbox,menulist", row).forEach(
             function(element) { element.disabled = disabled; }
         );
+        this._row_disabled(row, disabled);
     };
 
-    this._row_disabled = function(row) {
+    this._row_disabled = function(row, disabled) {
         if (typeof(row) == "string") row = this.rows[row];
-        return !dojo.query("checkbox", row)[0].checked;
+
+        var checkbox = dojo.query("checkbox", row)[0];
+
+        if (typeof(disabled) != "undefined")
+            checkbox.checked = !disabled;
+
+        return !checkbox.checked;
     };
 
     this._row_field_value = function(row, field, value) {
@@ -460,11 +480,6 @@
     };
 
     this._call_number_confirm_for_lib = function(lib, value) {
-        /* XXX Right now, this method will ask the user if they're serious if
-         * they apply an _existing_ (somewhere) call number to an item
-         * going to a library where that call number _doesn't_ exist,but it
-         * won't say anything if the user enters a brand new call number.
-         * This may not be ideal, and can be reworked later. */
         if (!this._has_confirmed_cn_for)
             this._has_confirmed_cn_for = {};
 
@@ -678,11 +693,11 @@
                             show("form_holder");
 
                             list.forEach(function(o) {self.add_entry_row(o);});
-                            if (list.length > 1) {
-                                self.build_batch_entry_row();
-                                show("batch_receive_entry");
-                            }
 
+                            self.build_batch_entry_row();
+                            dojo.byId("batch_receive_with_units").doCommand();
+
+                            show("batch_receive_entry");
                             busy(false);
                         } else {
                             alert(S("item_lookup.none"));
@@ -695,9 +710,38 @@
         );
     };
 
+    this.toggle_receive_with_units = function(ev) {
+        var head_row = dojo.byId("batch_receive_entry_thead");
+        var batch_row = dojo.byId("entry_batch_row");
+
+        var fields = [
+            "barcode", "call_number", "price", "location", "circ_modifier"
+        ];
+
+        var table_cell_func = ev.target.checked ?
+            show_table_cell : hide_table_cell;
+        fields.forEach(
+            function(key) {
+                if (batch_row) table_cell_func(node_by_name(key, batch_row));
+                if (head_row) table_cell_func(node_by_name(key, head_row));
+
+                for (var id in self.rows) {
+                    table_cell_func(node_by_name(key, self.rows[id]));
+                }
+            }
+        );
+
+        if (!ev.target.checked) {
+            /* XXX As of the time of this writing, a blank barcode field will
+             * avoid unit creation */
+            this._set_all_enabled_rows("barcode", "");
+        }
+    };
+
     this.toggle_all_receive = function(checked) {
-        for (var id in this.rows)
+        for (var id in this.rows) {
             this._disable_row(id, !checked);
+        }
     };
 
     this.build_batch_entry_row = function() {
@@ -839,7 +883,10 @@
                 alert(S("missing_cn"));
                 return;
             } else if (!confirmed_missing_units) {
-                if (confirm(S("missing_units"))) {
+                if (
+                    (!dojo.byId("batch_receive_with_units").checked) ||
+                    confirm(S("missing_units"))
+                ) {
                     confirmed_missing_units = true;
                 } else {
                     return;

Modified: branches/rel_2_0/Open-ILS/xul/staff_client/server/serial/batch_receive_overlay.xul
===================================================================
--- branches/rel_2_0/Open-ILS/xul/staff_client/server/serial/batch_receive_overlay.xul	2010-09-01 22:57:49 UTC (rev 17431)
+++ branches/rel_2_0/Open-ILS/xul/staff_client/server/serial/batch_receive_overlay.xul	2010-09-01 22:58:48 UTC (rev 17432)
@@ -83,28 +83,28 @@
             <vbox id="batch_receive_entry" class="hideme">
                 <box class="hideme" id="form_holder">
                     <!-- XXX should be a XUL grid instead of an HTML table -->
-                    <h:table>
+                    <h:table id="batch_receive_entry_thead">
                         <h:thead>
                             <h:tr>
                                 <h:th>
                                     &staff.serial.batch_receive.org_unit;
                                 </h:th>
-                                <h:th>
+                                <h:th name="barcode">
                                     &staff.serial.batch_receive.barcode;
                                 </h:th>
-                                <h:th>
+                                <h:th name="circ_modifier">
                                     &staff.serial.batch_receive.circ_modifier;
                                 </h:th>
-                                <h:th>
+                                <h:th name="call_number">
                                     &staff.serial.batch_receive.call_number;
                                 </h:th>
                                 <h:th>
                                     &staff.serial.batch_receive.note;
                                 </h:th>
-                                <h:th>
+                                <h:th name="location">
                                     &staff.serial.batch_receive.location;
                                 </h:th>
-                                <h:th>
+                                <h:th name="price">
                                     &staff.serial.batch_receive.price;
                                 </h:th>
                                 <h:th>
@@ -159,12 +159,13 @@
             <button oncommand="batch_receiver.init();"
                 label="&staff.serial.batch_receive.start_over;"
                 accesskey="&staff.serial.batch_receive.start_over.accesskey;" />
-            <!-- coming soon
             <spacer flex="1" />
-            <checkbox oncommand="batch_receiver.toggle_receive_with_units(event);"
+            <checkbox
+                id="batch_receive_with_units"
+                oils_persist="checked"
+                oncommand="batch_receiver.toggle_receive_with_units(event);"
                 label="&staff.serial.batch_receive.with_units;"
                 accesskey="&staff.serial.batch_receive.with_units.accesskey;" />
-            -->
         </hbox>
     </box>
 </overlay>



More information about the open-ils-commits mailing list