From 77b784dd8fe189aeb3ae7e0ddaf4c434c057087c Mon Sep 17 00:00:00 2001 From: Mike Rylander Date: Wed, 25 Apr 2018 12:32:15 -0400 Subject: [PATCH] LP#1715697: Ability to add empty volumes Staff can add volumes to any library that is allowed to have holdings. Signed-off-by: Mike Rylander Signed-off-by: Jason Stephenson Signed-off-by: Dan Wells --- .../staff/cat/catalog/t_holdings.tt2 | 2 + .../js/ui/default/staff/cat/catalog/app.js | 31 ++++- .../ui/default/staff/cat/services/holdings.js | 22 +++- .../js/ui/default/staff/cat/volcopy/app.js | 123 +++++++++++------- 4 files changed, 119 insertions(+), 59 deletions(-) diff --git a/Open-ILS/src/templates/staff/cat/catalog/t_holdings.tt2 b/Open-ILS/src/templates/staff/cat/catalog/t_holdings.tt2 index 222ea20365..545374fc9b 100644 --- a/Open-ILS/src/templates/staff/cat/catalog/t_holdings.tt2 +++ b/Open-ILS/src/templates/staff/cat/catalog/t_holdings.tt2 @@ -72,6 +72,8 @@ + 0) { - for (var field in cn_array[0]) { - cn.label( cn_array[0][field] ); - break; + angular.forEach(owners, function(owner) { + var cn = new egCore.idl.acn(); + cn.id( --itemSvc.new_cn_id ); + cn.isnew( true ); + cn.prefix( $scope.defaults.prefix || -1 ); + cn.suffix( $scope.defaults.suffix || -1 ); + cn.owning_lib( owner ); + cn.record( $scope.record_id ); + egCore.org.settings( + ['cat.default_classification_scheme'], + cn.owning_lib() + ).then(function (val) { + cn.label_class( + $scope.defaults.classification || + val['cat.default_classification_scheme'] || + 1 + ); + if (proto.label) { + cn.label( proto.label ); + } else { + egCore.net.request( + 'open-ils.cat', + 'open-ils.cat.biblio.record.marc_cn.retrieve', + $scope.record_id, + cn.label_class() + ).then(function(cn_array) { + if (cn_array.length > 0) { + for (var field in cn_array[0]) { + cn.label( cn_array[0][field] ); + break; + } } - } - }); - } - }); + }); + } + }); - var cp = new itemSvc.generateNewCopy( - cn, - proto.owner || egCore.auth.user().ws_ou(), - $scope.is_fast_add, - true - ); + var cp = new itemSvc.generateNewCopy( + cn, + proto.owner || egCore.auth.user().ws_ou(), + $scope.is_fast_add, + true + ); - if (proto.barcode) { - cp.barcode( proto.barcode ); - cp.empty_barcode = false; - } + if (proto.barcode) { + cp.barcode( proto.barcode ); + cp.empty_barcode = false; + } - itemSvc.addCopy(cp) + itemSvc.addCopy(cp) + }); } - } ); return itemSvc.copies; } - if (data.copies && data.copies.length) + if (!$scope.only_add_vol && data.copies && data.copies.length) return itemSvc.fetchIds(data.copies).then(fetchRaw); return fetchRaw(); @@ -1485,16 +1494,24 @@ function($scope , $q , $window , $routeParams , $location , $timeout , egCore , $scope.can_save = false; function check_saveable () { var can_save = true; + angular.forEach( itemSvc.copies, function (i) { - if (i.duplicate_barcode || i.empty_barcode || i.call_number().empty_label) + if (!$scope.only_add_vol) { + if (i.duplicate_barcode || i.empty_barcode || i.call_number().empty_label) { + can_save = false; + } + } else if (i.call_number().empty_label) { can_save = false; + } } ); + if ($scope.forms.myForm && $scope.forms.myForm.$invalid) { can_save = false; } + $scope.can_save = can_save; } @@ -1781,9 +1798,15 @@ function($scope , $q , $window , $routeParams , $location , $timeout , egCore , cnHash[cn_id].suffix(cnHash[cn_id].suffix().id()); // un-object-ize some fields }); - angular.forEach(perCnCopies, function (v, k) { - cnHash[k].copies(v); - }); + if ($scope.only_add_vol) { // strip off copies when we're in add-empty-vol mode + angular.forEach(cnHash, function (v, k) { + cnHash[k].copies([]); + }); + } else { + angular.forEach(perCnCopies, function (v, k) { + cnHash[k].copies(v); + }); + } cnList = []; angular.forEach(cnHash, function (v, k) { -- 2.43.2