[open-ils-commits] r18018 - in branches/rel_2_0/Open-ILS: src/perlmods/OpenILS/Application/Circ web/js/ui/default/conify/global/asset (erickson)
svn at svn.open-ils.org
svn at svn.open-ils.org
Sun Sep 26 19:22:24 EDT 2010
Author: erickson
Date: 2010-09-26 19:22:24 -0400 (Sun, 26 Sep 2010)
New Revision: 18018
Modified:
branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/Application/Circ/CopyLocations.pm
branches/rel_2_0/Open-ILS/web/js/ui/default/conify/global/asset/copy_location_order.js
Log:
backport 18015 : push copy location order update into ML method. return updated orders from method to prevent replication issues. update UI JS to match
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-26 23:20:12 UTC (rev 18017)
+++ branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/Application/Circ/CopyLocations.pm 2010-09-26 23:22:24 UTC (rev 18018)
@@ -182,7 +182,39 @@
return $cl;
}
+__PACKAGE__->register_method(
+ api_name => "open-ils.circ.copy_location_order.update",
+ method => 'update_clo',
+ argc => 2,
+);
+sub update_clo {
+ my($self, $client, $auth, $orders) = @_;
+ return [] unless $orders and @$orders;
+ my $e = new_editor(authtoken => $auth, xact =>1);
+ return $e->die_event unless $e->checkauth;
-23;
+ my $org = $$orders[0]->org;
+ return $e->die_event unless $e->allowed('ADMIN_COPY_LOCATION_ORDER', $org);
+
+ # clear out the previous order entries
+ my $existing = $e->search_asset_copy_location_order({org => $org});
+ $e->delete_asset_copy_location_order($_) or return $e->die_event for @$existing;
+
+ # create the new order entries
+ my $progress = 0;
+ for my $order (@$orders) {
+ return $e->die_event(OpenILS::Event->new('BAD_PARAMS')) unless $order->org == $org;
+ $e->create_asset_copy_location_order($order) or return $e->die_event;
+ $client->respond({maximum => scalar(@$orders), progress => $progress}) unless ($progress++ % 10);
+ }
+
+ # fetch the new entries
+ $orders = $e->search_asset_copy_location_order({org => $org});
+ $e->commit;
+ return {orders => $orders};
+}
+
+
+1;
Modified: branches/rel_2_0/Open-ILS/web/js/ui/default/conify/global/asset/copy_location_order.js
===================================================================
--- branches/rel_2_0/Open-ILS/web/js/ui/default/conify/global/asset/copy_location_order.js 2010-09-26 23:20:12 UTC (rev 18017)
+++ branches/rel_2_0/Open-ILS/web/js/ui/default/conify/global/asset/copy_location_order.js 2010-09-26 23:22:24 UTC (rev 18018)
@@ -34,12 +34,14 @@
function filterGrid(org) {
// fetch the locations and order entries
- var pcrud = new openils.PermaCrud({authtoken : user.authtoken});
- orders = pcrud.search('acplo', {org : org}, {order_by : {acplo : 'position'}});
- locations = pcrud.search('acpl',
- {owning_lib : fieldmapper.aou.orgNodeTrail(fieldmapper.aou.findOrgUnit(org), true)},
- {order_by : {acpl : 'name'}}
- );
+ if(!orders) {
+ var pcrud = new openils.PermaCrud({authtoken : user.authtoken});
+ orders = pcrud.search('acplo', {org : org}, {order_by : {acplo : 'position'}});
+ locations = pcrud.search('acpl',
+ {owning_lib : fieldmapper.aou.orgNodeTrail(fieldmapper.aou.findOrgUnit(org), true)},
+ {order_by : {acpl : 'name'}}
+ );
+ }
// init the DnD environment
source.selectAll();
@@ -80,30 +82,10 @@
}
function applyChanges() {
- progressDialog.show(true);
- if(orders.length)
- deleteOrders(createOrders);
- else
- createOrders();
-}
+ progressDialog.show();
-function deleteOrders(onload) {
- // delete the existing order entries in preparation for new ones
- var pcrud = new openils.PermaCrud({authtoken : user.authtoken});
- pcrud.eliminate(
- orders,
- {
- async : true,
- oncomplete : function() {
- if(onload) onload();
- }
- }
- );
-}
-
-function createOrders() {
-
var newOrders = [];
+ var contextOrg = contextOrgSelector.attr('value');
// pull the locations out of the DnD environment and create order entries for them
dojo.forEach(
@@ -113,21 +95,27 @@
var o = new fieldmapper.acplo();
o.position(newOrders.length + 1);
o.location(item.type[0]); // location.id() is stored in DnD item type
- o.org(contextOrgSelector.attr('value'));
+ o.org(contextOrg);
newOrders.push(o);
}
);
- // send the order entries off to the server
- var pcrud = new openils.PermaCrud({authtoken : user.authtoken});
- pcrud.create(
- newOrders,
+ fieldmapper.standardRequest(
+ ['open-ils.circ', 'open-ils.circ.copy_location_order.update'],
{
async : true,
- oncomplete : function(r) {
- progressDialog.hide();
- filterGrid(contextOrgSelector.attr('value'));
- }
+ params : [openils.User.authtoken, newOrders],
+ onresponse : function(r) {
+ if(r = openils.Util.readResponse(r)) {
+ if(r.orders) {
+ orders = r.order;
+ progressDialog.hide();
+ filterGrid(contextOrg);
+ return;
+ }
+ progressDialog.update(r);
+ }
+ },
}
);
}
More information about the open-ils-commits
mailing list