From e0a5438ea0237a80bfa9bccd69a3ac1353cfcbcb Mon Sep 17 00:00:00 2001 From: Mike Rylander Date: Wed, 24 May 2017 20:39:52 -0400 Subject: [PATCH] webstaff: Add routing list printing on receive/bind and directly from the action menu Signed-off-by: Mike Rylander --- Open-ILS/src/templates/staff/serials/index.tt2 | 1 + .../templates/staff/serials/t_batch_receive.tt2 | 12 ++ .../staff/serials/t_print_routing_list.tt2 | 15 ++ .../templates/staff/serials/t_view_items_grid.tt2 | 14 +- .../staff/serials/directives/view-items-grid.js | 181 +++++++++++++++++---- .../js/ui/default/staff/serials/services/core.js | 8 +- 6 files changed, 191 insertions(+), 40 deletions(-) create mode 100644 Open-ILS/src/templates/staff/serials/t_print_routing_list.tt2 diff --git a/Open-ILS/src/templates/staff/serials/index.tt2 b/Open-ILS/src/templates/staff/serials/index.tt2 index 2944abe032..920686b365 100644 --- a/Open-ILS/src/templates/staff/serials/index.tt2 +++ b/Open-ILS/src/templates/staff/serials/index.tt2 @@ -6,6 +6,7 @@ [% BLOCK APP_JS %] + diff --git a/Open-ILS/src/templates/staff/serials/t_batch_receive.tt2 b/Open-ILS/src/templates/staff/serials/t_batch_receive.tt2 index 9beaf9c089..60c55bd5c4 100644 --- a/Open-ILS/src/templates/staff/serials/t_batch_receive.tt2 +++ b/Open-ILS/src/templates/staff/serials/t_batch_receive.tt2 @@ -18,6 +18,11 @@
+ +
+
@@ -44,6 +49,10 @@
[% l('Circulation modifier') %]
+
+
+ [% l('Routing List') %] +
@@ -115,6 +124,9 @@ ng-model="item._barcode" type="text" id="item_barcode_{{$index}}" eg-enter="focus_next_barcode($index)"/>
+
+ +
diff --git a/Open-ILS/src/templates/staff/serials/t_print_routing_list.tt2 b/Open-ILS/src/templates/staff/serials/t_print_routing_list.tt2 new file mode 100644 index 0000000000..e5da6f1c37 --- /dev/null +++ b/Open-ILS/src/templates/staff/serials/t_print_routing_list.tt2 @@ -0,0 +1,15 @@ +
+ + + +
diff --git a/Open-ILS/src/templates/staff/serials/t_view_items_grid.tt2 b/Open-ILS/src/templates/staff/serials/t_view_items_grid.tt2 index fb0309fd0c..2f91d61179 100644 --- a/Open-ILS/src/templates/staff/serials/t_view_items_grid.tt2 +++ b/Open-ILS/src/templates/staff/serials/t_view_items_grid.tt2 @@ -4,7 +4,7 @@ features="-display,-sort,-multisort" items-provider="itemGridProvider" grid-controls="itemGridControls" - menu-label="[% l('Filter items') %]" + menu-label="[% l('Filter items... ') %]" persist-key="serials.view_item_grid"> - + + + + diff --git a/Open-ILS/web/js/ui/default/staff/serials/directives/view-items-grid.js b/Open-ILS/web/js/ui/default/staff/serials/directives/view-items-grid.js index 3ad5e348a2..26e76c8e90 100644 --- a/Open-ILS/web/js/ui/default/staff/serials/directives/view-items-grid.js +++ b/Open-ILS/web/js/ui/default/staff/serials/directives/view-items-grid.js @@ -10,9 +10,9 @@ angular.module('egSerialsAppDep') }, templateUrl: './serials/t_view_items_grid', controller: - ['$scope','$q','egSerialsCoreSvc','egCore','egGridDataProvider', + ['$scope','$q','egSerialsCoreSvc','egCore','egGridDataProvider','orderByFilter', '$uibModal','ngToast','egConfirmDialog','egPromptDialog','$timeout', -function($scope , $q , egSerialsCoreSvc , egCore , egGridDataProvider , +function($scope , $q , egSerialsCoreSvc , egCore , egGridDataProvider , orderByFilter , $uibModal , ngToast , egConfirmDialog , egPromptDialog , $timeout) { $scope.svc = egSerialsCoreSvc; @@ -225,9 +225,19 @@ function($scope , $q , egSerialsCoreSvc , egCore , egGridDataProvider , }); } + $scope.do_print_routing_lists = false; + egCore.hatch.getItem('eg.serials.items.do_print_routing_lists').then(function(val) { + $scope.do_print_routing_lists = val; + }); + $scope.receive_and_barcode = false; - $scope.receive_barcode_checkbox_handler = function(item) { + egCore.hatch.getItem('eg.serials.items.receive_and_barcode').then(function(val) { + $scope.receive_and_barcode = val; + }); + + $scope.checkbox_handler = function(item) { $scope[item.checkbox] = item.checked; + egCore.hatch.setItem('eg.serials.items.'+item.checkbox, item.checked); } $scope.receive_next = function () { @@ -279,8 +289,9 @@ function($scope , $q , egSerialsCoreSvc , egCore , egGridDataProvider , var deferred = $q.defer(); var current_promise = deferred.promise; var last_promise; - if (do_barcode || bind) { // supplying a barcode (unit) to new items + if (do_barcode || bind) { + var print_routing_lists = $scope.do_print_routing_lists; last_promise = current_promise.then(function(){ return $uibModal.open({ templateUrl: './serials/t_batch_receive', size: 'lg', @@ -289,6 +300,7 @@ function($scope , $q , egSerialsCoreSvc , egCore , egGridDataProvider , controller: ['$scope', '$uibModalInstance', function($scope, $uibModalInstance) { + $scope.print_routing_lists = print_routing_lists; $scope.barcode_items = do_barcode; $scope.force_bind = bind; $scope.bind = bind; @@ -296,9 +308,43 @@ function($scope , $q , egSerialsCoreSvc , egCore , egGridDataProvider , $scope.acn_list = []; $scope.acpl_list = []; + $scope.cannot_print = function (index) { + return $scope.items[index].stream().routing_list_users().length == 0 || ($scope.bind && index > 0); + } + + $scope.bind_or_none = function (index) { + return !$scope.barcode_items || ($scope.bind && index > 0); + } + + $scope.focus_next_barcode = function (index) { + index++; + $('#item_barcode_'+index).focus().select(); + } + + $scope.apply_template_overrides = function (e) { + if ($scope.selected_call_number) { + angular.forEach($scope.items, function (i) { + i._call_number = $scope.selected_call_number; + }); + } + if ($scope.selected_circ_mod) { + angular.forEach($scope.items, function (i) { + i._circ_mod = $scope.selected_circ_mod; + }); + } + if ($scope.selected_copy_location) { + angular.forEach($scope.items, function (i) { + i._copy_location = $scope.selected_copy_location; + }); + } + } + + $scope.ok = function(items) { $uibModalInstance.close(items) } + $scope.cancel = function () { $uibModalInstance.dismiss() } + var pile_o_promises = [$q.when()]; // let's gather what we need... - angular.forEach(list, function (i) { + angular.forEach(list, function (i, index) { if (i.unit()) { i._barcode = i.unit().barcode(); pile_o_promises.push( @@ -322,6 +368,9 @@ function($scope , $q , egSerialsCoreSvc , egCore , egGridDataProvider , i._copy_location = i.stream().distribution()[mode + '_unit_template']().location(); i._circ_mod = i.stream().distribution()[mode + '_unit_template']().circ_modifier(); } + + if ($scope.print_routing_lists && !$scope.cannot_print(index)) + i._print_routing_list = true; }); pile_o_promises.push(egCore.pcrud.search( @@ -353,33 +402,6 @@ function($scope , $q , egSerialsCoreSvc , egCore , egGridDataProvider , console.log('receive data collected'); }); - $scope.bind_or_none = function (index) { - return !$scope.barcode_items || ($scope.bind && index > 0); - } - - $scope.focus_next_barcode = function (index) { - index++; - $('#item_barcode_'+index).focus().select(); - } - - $scope.apply_template_overrides = function (e) { - if ($scope.selected_call_number) { - angular.forEach($scope.items, function (i) { - i._call_number = $scope.selected_call_number; - }); - } - if ($scope.selected_circ_mod) { - angular.forEach($scope.items, function (i) { - i._circ_mod = $scope.selected_circ_mod; - }); - } - if ($scope.selected_copy_location) { - angular.forEach($scope.items, function (i) { - i._copy_location = $scope.selected_copy_location; - }); - } - } - $scope.$watch('barcode_items', function (n,o) { if (n === undefined || n == o) return; do_barcode = n; @@ -388,6 +410,11 @@ function($scope , $q , egSerialsCoreSvc , egCore , egGridDataProvider , $scope.$watch('bind', function (n,o) { if (n === undefined || n == o) return; bind = n; + if (bind) { + angular.forEach($scope.items, function (i,index) { + if (index > 0) i._print_routing_list = false; + }); + } }); $scope.$watch('auto_barcodes', function (n,o) { @@ -403,8 +430,17 @@ function($scope , $q , egSerialsCoreSvc , egCore , egGridDataProvider , }); }); - $scope.ok = function(items) { $uibModalInstance.close(items) } - $scope.cancel = function () { $uibModalInstance.dismiss() } + $scope.$watch('print_routing_lists', function (n,o) { + if (n === undefined || n == o) return; + + angular.forEach($scope.items, function(i, index) { + if (!$scope.cannot_print(index)) { + i._print_routing_list = n; + } else { + i._print_routing_list = false; + } + }); + }); }] }).result}); } else { @@ -453,7 +489,8 @@ function($scope , $q , egSerialsCoreSvc , egCore , egGridDataProvider , ngToast.danger(egCore.strings.SERIALS_ISSUANCE_FAIL_SAVE); } else { ngToast.success(egCore.strings.SERIALS_ISSUANCE_SUCCESS_SAVE); - return reload($scope.ssubId,_paging_filter); + return $scope.print_routing_lists_impl(items, do_barcode || bind) + .finally(function(){reload($scope.ssubId,_paging_filter)}); } }, function(resp) { @@ -465,6 +502,80 @@ function($scope , $q , egSerialsCoreSvc , egCore , egGridDataProvider , return deferred.resolve(); } + $scope.menu_print_routing_lists = function (items) { + items = items.map(function(item) { + return egCore.idl.Clone(egSerialsCoreSvc.itemMap[item.id]); + }); + return $scope.print_routing_lists_impl(items, false, true); + } + + $scope.print_routing_lists_impl = function (items, check, force) { + if (!check && !$scope.do_print_routing_lists && !force) return $q.when(); + + return egCore.net.request( + 'open-ils.search', + 'open-ils.search.biblio.record.mods_slim.retrieve', + $scope.bibId + ).then(function(mvr) { + + var by_issuance = {}; + angular.forEach(items, function (i) { + if (check && !i._print_routing_list) return; + if (!by_issuance[i.issuance().id()]) + by_issuance[i.issuance().id()] = []; + by_issuance[i.issuance().id()].push(i); + }); + + var issuance_matrix = []; + angular.forEach(by_issuance, function (list) { + issuance_matrix.push(list); + }); + + var deferred = $q.defer(); + var promise = deferred.promise; + + angular.forEach(issuance_matrix, function(item_list, index) { + + promise = promise.then(function(){ + return $uibModal.open({ + templateUrl: './serials/t_print_routing_list', + size: 'lg', + windowClass: 'eg-wide-modal', + backdrop: 'static', + controller: + ['$scope', '$uibModalInstance', function($scope, $uibModalInstance) { + var all_users = []; + var all_streams = []; + + angular.forEach(item_list, function(i){ + all_streams.push(i.stream()); + all_users = all_users.concat(i.stream().routing_list_users()); + }); + + $scope.xulg = { + show_print_button: true, + routing_list_data: { + streams : all_streams, + mvr : mvr, + issuance: item_list[0].issuance(), + users : orderByFilter(all_users, 'pos') + } + }; + + $scope.url = '/eg/serial/print_routing_list_users?ses=' + egCore.auth.token(); + $scope.last = index == issuance_matrix.length - 1 ? true : false; + $scope.ok = function() { $uibModalInstance.close() } + }] + }).result; + }); + + }); + + return deferred.resolve(); + }); + + } + $scope.add_issuances = function () { var lastItem = egSerialsCoreSvc.itemList[egSerialsCoreSvc.itemList.length - 1]; diff --git a/Open-ILS/web/js/ui/default/staff/serials/services/core.js b/Open-ILS/web/js/ui/default/staff/serials/services/core.js index db707a5a24..77e4acd58e 100644 --- a/Open-ILS/web/js/ui/default/staff/serials/services/core.js +++ b/Open-ILS/web/js/ui/default/staff/serials/services/core.js @@ -128,7 +128,7 @@ function(egCore , orderByFilter , $q , $filter , $uibModal) { return egCore.pcrud.search('ssub', { record_entry : bibId }, { - flesh : 3, + flesh : 5, flesh_fields : { 'ssub' : ['owning_lib','distributions', 'scaps', 'notes'], 'sdist' : [ 'record_entry','holding_lib', @@ -137,7 +137,9 @@ function(egCore , orderByFilter , $q , $filter , $uibModal) { 'bind_call_number', 'bind_unit_template', 'streams','notes'], - 'sstr' : ['routing_list_users'] + 'sstr' : ['routing_list_users'], + 'srlu' : ['reader'], + 'au' : ['card','home_ou','mailing_address','billing_address'] } }, { atomic : true } @@ -229,7 +231,9 @@ function(egCore , orderByFilter , $q , $filter , $uibModal) { angular.forEach(sub.distributions(), function(dist) { angular.forEach(dist.streams(), function(stream) { angular.forEach(tmp[stream.id()], function (item) { + var routing_list = egCore.idl.Clone(stream.routing_list_users()); var st = egCore.idl.Clone(stream,1); + st.routing_list_users(routing_list); var d = egCore.idl.Clone(dist,1); var ss = egCore.idl.Clone(sub,1); ss.distributions([]); -- 2.11.0