From 5da2dcc549d8937306b8d2ff875f83db54e0ef0b Mon Sep 17 00:00:00 2001 From: Mike Rylander Date: Wed, 23 Nov 2016 12:37:39 -0500 Subject: [PATCH] webstaff: honor sticky-setting org by calling onchange handler; have newer holdings service requests cancel ongoing older ones Signed-off-by: Mike Rylander Signed-off-by: Kathy Lussier --- Open-ILS/web/js/ui/default/staff/cat/services/holdings.js | 14 ++++++++++---- Open-ILS/web/js/ui/default/staff/services/ui.js | 2 ++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/Open-ILS/web/js/ui/default/staff/cat/services/holdings.js b/Open-ILS/web/js/ui/default/staff/cat/services/holdings.js index 71255a4551..3f4ec7d3af 100644 --- a/Open-ILS/web/js/ui/default/staff/cat/services/holdings.js +++ b/Open-ILS/web/js/ui/default/staff/cat/services/holdings.js @@ -33,9 +33,11 @@ function(egCore , $q) { // resolved with the last received copy service.prototype.fetch = function(opts) { var svc = this; - if (svc.ongoing) { - console.log('Skipping fetch, ongoing = true'); - return $q.when(); + + if (svc.ongoing && svc.p) { + svc.p.cancel = true; + console.log('Canceling fetch for org '+ svc.org.id()); + if (svc.p.reject) svc.p.reject(); } var rid = opts.rid; @@ -61,12 +63,13 @@ function(egCore , $q) { var org_list = egCore.org.descendants(org.id(), true); console.log('Holdings fetch with: rid='+rid+' org='+org_list+' copy='+copy+' vol='+vol+' empty='+empty); - return egCore.pcrud.search( + var p = egCore.pcrud.search( 'acn', {record : rid, owning_lib : org_list, deleted : 'f'}, svc.flesh ).then( function() { // finished + if (p.cancel) return; svc.copies = svc.copies.sort( function (a, b) { function compare_array (x, y, i) { @@ -236,6 +239,7 @@ function(egCore , $q) { // notify reads the stream of copies, one at a time. function(cn) { + if (p.cancel) return; var copies = cn.copies().filter(function(cp){ return cp.deleted() == 'f' }); cn.copies([]); @@ -278,6 +282,8 @@ function(egCore , $q) { return cn; } ); + + return svc.p = p; }; return service; diff --git a/Open-ILS/web/js/ui/default/staff/services/ui.js b/Open-ILS/web/js/ui/default/staff/services/ui.js index 86268d7757..0925dd486d 100644 --- a/Open-ILS/web/js/ui/default/staff/services/ui.js +++ b/Open-ILS/web/js/ui/default/staff/services/ui.js @@ -493,6 +493,8 @@ function($window , egStrings) { var orgId = scope.hatch.getLocalItem(scope.stickySetting); if (orgId) { scope.selected = scope.egOrg.get(orgId); + if (scope.onchange) + scope.onchange(scope.selected); } } -- 2.11.0