[open-ils-commits] r19373 - in trunk/Open-ILS: src/perlmods/lib/OpenILS/Application xul/staff_client/server/serial (dbwells)
svn at svn.open-ils.org
svn at svn.open-ils.org
Thu Feb 3 11:47:52 EST 2011
Author: dbwells
Date: 2011-02-03 11:47:49 -0500 (Thu, 03 Feb 2011)
New Revision: 19373
Modified:
trunk/Open-ILS/src/perlmods/lib/OpenILS/Application/Serial.pm
trunk/Open-ILS/xul/staff_client/server/serial/manage_items.js
Log:
Two binding fixes for manage items
The first fix is more or less cosmetic. When selecting a target unit, both areas need to refresh in order to not show the selected unit's items in the main list.
The second fix involves handling cases where moving items from one unit to another does not empty the 'donor' unit. In those cases, we need to update the contents of both the new and the old unit.
Modified: trunk/Open-ILS/src/perlmods/lib/OpenILS/Application/Serial.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/lib/OpenILS/Application/Serial.pm 2011-02-03 14:16:25 UTC (rev 19372)
+++ trunk/Open-ILS/src/perlmods/lib/OpenILS/Application/Serial.pm 2011-02-03 16:47:49 UTC (rev 19373)
@@ -1063,6 +1063,11 @@
name => 'call_numbers',
desc => 'hash of item_ids => call_numbers',
type => 'hash'
+ },
+ {
+ name => 'donor_unit_ids',
+ desc => 'hash of unit_ids => 1, keyed with ids of any units giving up items',
+ type => 'hash'
}
],
'return' => {
@@ -1093,6 +1098,11 @@
name => 'call_numbers',
desc => 'hash of item_ids => call_numbers',
type => 'hash'
+ },
+ {
+ name => 'donor_unit_ids',
+ desc => 'hash of unit_ids => 1, keyed with ids of any units giving up items',
+ type => 'hash'
}
],
'return' => {
@@ -1125,7 +1135,7 @@
);
sub unitize_items {
- my ($self, $conn, $auth, $items, $barcodes, $call_numbers) = @_;
+ my ($self, $conn, $auth, $items, $barcodes, $call_numbers, $donor_unit_ids) = @_;
my $editor = new_editor("authtoken" => $auth, "xact" => 1);
return $editor->die_event unless $editor->checkauth;
@@ -1134,6 +1144,9 @@
my $mode = $1;
my %found_unit_ids;
+ if ($donor_unit_ids) { # units giving up items need updating as well
+ %found_unit_ids = %$donor_unit_ids;
+ }
my %found_stream_ids;
my %found_types;
@@ -1262,8 +1275,24 @@
$call_number_string = $call_number_by_unit_id{$unit_id};
$record_id = $sdist->subscription->record_entry;
} else {
+ # XXX: this code assumes you will not have units which mix streams/distributions, but current code does not enforce this
$sunit = $editor->retrieve_serial_unit($unit_id);
- $sdist = $editor->search_serial_distribution([{"+sstr" => {"id" => $stream_ids_by_unit_id{$unit_id}}}, { "join" => {"sstr" => {}} }]);
+ if ($stream_ids_by_unit_id{$unit_id}) {
+ $sdist = $editor->search_serial_distribution([{"+sstr" => {"id" => $stream_ids_by_unit_id{$unit_id}}}, { "join" => {"sstr" => {}}, 'limit' => 1 }]);
+ } else {
+ $sdist = $editor->search_serial_distribution([
+ {'+sunit' => {'id' => $unit_id}},
+ { 'join' =>
+ {'sstr' =>
+ { 'join' =>
+ { 'sitem' =>
+ { 'join' => 'sunit' }
+ }
+ }
+ },
+ 'limit' => 1
+ }]);
+ }
$sdist = $sdist->[0];
}
Modified: trunk/Open-ILS/xul/staff_client/server/serial/manage_items.js
===================================================================
--- trunk/Open-ILS/xul/staff_client/server/serial/manage_items.js 2011-02-03 14:16:25 UTC (rev 19372)
+++ trunk/Open-ILS/xul/staff_client/server/serial/manage_items.js 2011-02-03 16:47:49 UTC (rev 19373)
@@ -304,7 +304,10 @@
var sstr_id = target.getAttribute('sstr_id');
obj.set_sunit(sunit_id, label, sdist_id, sstr_id);
obj.save_sunit(sunit_id, label, sdist_id, sstr_id);
- if (obj.mode == 'bind') obj.refresh_list('workarea');
+ if (obj.mode == 'bind') {
+ obj.refresh_list('main');
+ obj.refresh_list('workarea');
+ }
} catch(E) {
obj.error.standard_unexpected_error_alert('cmd_set_sunit failed!',E);
}
@@ -314,7 +317,10 @@
['command'],
function() {
obj.set_other_sunit();
- if (obj.mode == 'bind') obj.refresh_list('workarea');
+ if (obj.mode == 'bind') {
+ obj.refresh_list('main');
+ obj.refresh_list('workarea');
+ }
}
],
'cmd_predict_items' : [
@@ -328,10 +334,14 @@
function() {
try {
JSAN.use('util.functional');
+ var donor_unit_ids = {};
var list = util.functional.map_list(
obj.retrieve_ids,
function (o) {
var item = obj.list_sitem_map[o.sitem_id];
+ if (item.unit()) {
+ donor_unit_ids[item.unit().id()] = 1;
+ }
item.unit(obj.current_sunit_id);
return item;
}
@@ -439,7 +449,7 @@
var robj = obj.network.request(
'open-ils.serial',
method,
- [ ses(), list, barcodes, call_numbers ]
+ [ ses(), list, barcodes, call_numbers, donor_unit_ids ]
);
if (typeof robj.ilsevent != 'undefined') throw(robj); //TODO: catch for override
More information about the open-ils-commits
mailing list