From 66dbe6e4769460a50fdeed50e2d604bf3d11a8e1 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Wed, 2 Jul 2014 16:12:20 -0400 Subject: [PATCH] patron holds; view canceled; cancel Signed-off-by: Bill Erickson --- Open-ILS/src/templates/staff/circ/patron/index.tt2 | 17 ++--- .../src/templates/staff/circ/patron/t_holds.tt2 | 44 +++++++++---- .../templates/staff/circ/share/hold_strings.tt2 | 16 +++++ .../staff/circ/share/t_cancel_hold_dialog.tt2 | 38 +++++++++++ .../web/js/ui/default/staff/circ/patron/app.js | 19 ++++++ .../web/js/ui/default/staff/circ/patron/holds.js | 57 +++++++++++++--- .../js/ui/default/staff/circ/patron/items_out.js | 1 + .../web/js/ui/default/staff/circ/services/holds.js | 77 ++++++++++++++++++++++ 8 files changed, 240 insertions(+), 29 deletions(-) create mode 100644 Open-ILS/src/templates/staff/circ/share/hold_strings.tt2 create mode 100644 Open-ILS/src/templates/staff/circ/share/t_cancel_hold_dialog.tt2 create mode 100644 Open-ILS/web/js/ui/default/staff/circ/services/holds.js diff --git a/Open-ILS/src/templates/staff/circ/patron/index.tt2 b/Open-ILS/src/templates/staff/circ/patron/index.tt2 index 54258a0815..1956411d3d 100644 --- a/Open-ILS/src/templates/staff/circ/patron/index.tt2 +++ b/Open-ILS/src/templates/staff/circ/patron/index.tt2 @@ -12,6 +12,8 @@ [% INCLUDE 'staff/circ/share/circ_strings.tt2' %] + +[% INCLUDE 'staff/circ/share/hold_strings.tt2' %] @@ -43,7 +45,6 @@ angular.module('egCoreMod').run(['egStrings', function(s) { [% END %] -
@@ -55,15 +56,15 @@ angular.module('egCoreMod').run(['egStrings', function(s) { '{{patron().first_given_name()}}', '{{patron().second_given_name()}}') %]
-
- + + ng-hide="collapse_summary()"> - + ng-show="collapse_summary()">
@@ -147,10 +148,10 @@ angular.module('egCoreMod').run(['egStrings', function(s) {
-
+
[% INCLUDE 'staff/circ/patron/t_summary.tt2' %]
-
+
diff --git a/Open-ILS/src/templates/staff/circ/patron/t_holds.tt2 b/Open-ILS/src/templates/staff/circ/patron/t_holds.tt2 index 983f566b12..cce13f5d0b 100644 --- a/Open-ILS/src/templates/staff/circ/patron/t_holds.tt2 +++ b/Open-ILS/src/templates/staff/circ/patron/t_holds.tt2 @@ -1,19 +1,41 @@ + + +
+ - - - - - - - - - + + + + + + + + + + + + + + + + + + + + diff --git a/Open-ILS/src/templates/staff/circ/share/hold_strings.tt2 b/Open-ILS/src/templates/staff/circ/share/hold_strings.tt2 new file mode 100644 index 0000000000..41718f85ae --- /dev/null +++ b/Open-ILS/src/templates/staff/circ/share/hold_strings.tt2 @@ -0,0 +1,16 @@ +[%# Strings for circ/services/circ.js %] + + + + diff --git a/Open-ILS/src/templates/staff/circ/share/t_cancel_hold_dialog.tt2 b/Open-ILS/src/templates/staff/circ/share/t_cancel_hold_dialog.tt2 new file mode 100644 index 0000000000..81417f2029 --- /dev/null +++ b/Open-ILS/src/templates/staff/circ/share/t_cancel_hold_dialog.tt2 @@ -0,0 +1,38 @@ +
+ +
+ diff --git a/Open-ILS/web/js/ui/default/staff/circ/patron/app.js b/Open-ILS/web/js/ui/default/staff/circ/patron/app.js index 2b04291d08..ad53b2af00 100644 --- a/Open-ILS/web/js/ui/default/staff/circ/patron/app.js +++ b/Open-ILS/web/js/ui/default/staff/circ/patron/app.js @@ -539,6 +539,25 @@ function($scope, $q, $location , $filter, egCore, egUser, patronSvc) { } }); } + + $scope.toggle_expand_summary = function() { + if ($scope.collapsePatronSummary) { + $scope.collapsePatronSummary = false; + egCore.hatch.removeItem('eg.circ.patron.summary.collapse'); + } else { + $scope.collapsePatronSummary = true; + egCore.hatch.setItem('eg.circ.patron.summary.collapse', true); + } + } + + // always expand the patron summary in the search UI, regardless + // of stored preference. + $scope.collapse_summary = function() { + return $scope.tab != 'search' && $scope.collapsePatronSummary; + } + + egCore.hatch.getItem('eg.circ.patron.summary.collapse') + .then(function(val) {$scope.collapsePatronSummary = Boolean(val)}); }]) .controller('PatronBarcodeSearchCtrl', diff --git a/Open-ILS/web/js/ui/default/staff/circ/patron/holds.js b/Open-ILS/web/js/ui/default/staff/circ/patron/holds.js index 78031e1a79..da66ef80ff 100644 --- a/Open-ILS/web/js/ui/default/staff/circ/patron/holds.js +++ b/Open-ILS/web/js/ui/default/staff/circ/patron/holds.js @@ -4,9 +4,33 @@ angular.module('egPatronApp').controller('PatronHoldsCtrl', - ['$scope','$q','$routeParams','egCore','egUser','patronSvc','egGridDataProvider', -function($scope, $q, $routeParams, egCore, egUser, patronSvc, egGridDataProvider) { + ['$scope','$q','$routeParams','egCore','egUser','patronSvc','egGridDataProvider','egHolds', +function($scope, $q, $routeParams, egCore, egUser, patronSvc, egGridDataProvider , egHolds) { $scope.initTab('holds', $routeParams.id); + $scope.holds_display = 'main'; + + function refresh_all() { + patronSvc.refreshPrimary(); + patronSvc.holds = []; + patronSvc.hold_ids = []; + provider.refresh() + } + + $scope.show_main_list = function() { + // don't need a full reset_page() to swap tabs + $scope.holds_display = 'main'; + patronSvc.holds = []; + patronSvc.hold_ids = []; + provider.refresh(); + } + + $scope.show_alt_list = function() { + // don't need a full reset_page() to swap tabs + $scope.holds_display = 'alt'; + patronSvc.holds = []; + patronSvc.hold_ids = []; + provider.refresh(); + } var provider = egGridDataProvider.instance({}); $scope.gridDataProvider = provider; @@ -22,6 +46,11 @@ function($scope, $q, $routeParams, egCore, egUser, patronSvc, egGridDataPr ).then(null, null, function(hold_data) { $scope.loading = false; + + hold_data.status_string = + egCore.strings['HOLD_STATUS_' + hold_data.status] + || hold_data.status; + var hold = hold_data.hold; hold_data.id = hold.id(); hold.pickup_lib(egCore.org.get(hold.pickup_lib())); // flesh @@ -34,9 +63,7 @@ function($scope, $q, $routeParams, egCore, egUser, patronSvc, egGridDataPr // see if we have the requested range cached if (patronSvc.holds[offset]) { - return provider.arrayNotifier( - patronSvc.holds, offset, count - ); + return provider.arrayNotifier(patronSvc.holds, offset, count); } // see if we have the holds IDs for this range already loaded @@ -47,22 +74,32 @@ function($scope, $q, $routeParams, egCore, egUser, patronSvc, egGridDataPr var deferred = $q.defer(); patronSvc.hold_ids = []; + var method = 'open-ils.circ.holds.id_list.retrieve.authoritative'; + if ($scope.holds_display == 'alt') + method = 'open-ils.circ.holds.canceled.id_list.retrieve.authoritative'; + egCore.net.request( - 'open-ils.circ', - 'open-ils.circ.holds.id_list.retrieve.authoritative', + 'open-ils.circ', method, egCore.auth.token(), $scope.patron_id ).then(function(hold_ids) { - console.log('fetched hold ids ' + hold_ids); - if (!hold_ids.length) { deferred.resolve(); return; } patronSvc.hold_ids = hold_ids; - fetchHolds(offset, count).then(null, null, deferred.notify); + fetchHolds(offset, count) + .then(deferred.resolve, null, deferred.notify); }); return deferred.promise; } + + $scope.cancel_hold = function(items) { + var hold_ids = items.filter(function(item) { + return !item.hold.cancel_time(); + }).map(function(item) {return item.hold.id()}); + + return egHolds.cancel_holds(hold_ids).then(refresh_all); + } }]) diff --git a/Open-ILS/web/js/ui/default/staff/circ/patron/items_out.js b/Open-ILS/web/js/ui/default/staff/circ/patron/items_out.js index 297f2d22fd..fa68501ddb 100644 --- a/Open-ILS/web/js/ui/default/staff/circ/patron/items_out.js +++ b/Open-ILS/web/js/ui/default/staff/circ/patron/items_out.js @@ -75,6 +75,7 @@ function($scope, $q, $routeParams, egCore , egUser, patronSvc , $scope.gridDataProvider = provider; function fetch_circs(id_list, offset, count) { + if (!id_list.length) return $q.when(); // fetch the lot of circs and stream the results back via notify return egCore.pcrud.search('circ', {id : id_list}, diff --git a/Open-ILS/web/js/ui/default/staff/circ/services/holds.js b/Open-ILS/web/js/ui/default/staff/circ/services/holds.js new file mode 100644 index 0000000000..e9535ef5d5 --- /dev/null +++ b/Open-ILS/web/js/ui/default/staff/circ/services/holds.js @@ -0,0 +1,77 @@ +/** + * Holds, yo + */ + +angular.module('egCoreMod') + +.factory('egHolds', + + ['$modal','$q','egCore','egAlertDialog','egConfirmDialog', +function($modal , $q , egCore , egAlertDialog , egConfirmDialog) { + + var service = {}; + + service.cancel_holds = function(hold_ids) { + + return $modal.open({ + templateUrl : './circ/share/t_cancel_hold_dialog', + controller : + ['$scope', '$modalInstance', 'cancel_reasons', + function($scope, $modalInstance, cancel_reasons) { + $scope.args = { + cancel_reasons : cancel_reasons, + num_holds : hold_ids.length + }; + + $scope.cancel = function($event) { + $modalInstance.dismiss(); + $event.preventDefault(); + } + + $scope.ok = function() { + + function cancel_one() { + var hold_id = hold_ids.pop(); + if (!hold_id) { + $modalInstance.close(); + return; + } + egCore.net.request( + 'open-ils.circ', 'open-ils.circ.hold.cancel', + egCore.auth.token(), hold_id, + $scope.args.cancel_reason.id(), + $scope.args.note + ).then(function(resp) { + if (evt = egCore.evt.parse(resp)) { + console.error('unable to cancel hold: ' + + evt.toString()); + } + cancel_one(); + }); + } + + cancel_one(); + } + } + ], + resolve : { + cancel_reasons : function() { + return service.get_cancel_reasons(); + } + } + }).result; + } + + service.get_cancel_reasons = function() { + if (egCore.env.ahrcc) return $q.when(egCore.env.ahrcc.list); + return egCore.pcrud.retrieveAll('ahrcc', {}, {atomic : true}) + .then(function(list) { + egCore.env.absorbList(list, 'ahrcc') + return list; + }); + } + + return service; +}]) + + -- 2.11.0