From 98a2ff8c5c279bb361690426abd5922fe55e9e12 Mon Sep 17 00:00:00 2001 From: Dan Wells Date: Wed, 30 May 2018 12:43:08 -0400 Subject: [PATCH] LP#1773417 Improve empty volume handling The crux of this patch is to rethink how we handle the volume-only editing interface. Previously, we were attempting to distinguish between when the volume was the only thing *showing* and when it was actually the only thing *existing*. We have now removed that distinction, so the volume-only interface only cares about the volume regardless of the possible presence of a copy. This simplifies the interface logic, and reduces or eliminates the chance of the hidden copy editor interfering with the volume adding/editing functions. Other smaller changes here include: - Teach the edit function to pick up copy-less "empty" call numbers - Reduce and clarify the arguments to spawnHoldingsAdd We had three arguments, but two were simply inversions of one another in every case. Reduce to two arguments and give them more meaningful labels - Fix typo ("emtpy") preventing proper button disabling for blank call numbers - Move call number emptiness check from updateLabel() function to value watch instead. This ensure that any updates to that value (even those not using the update function) will flip the flag appropriately. This fixes a timing bug which prevented call numbers from being saved without further edits in some cases. Ultimately, as J. Boyer suggests, we would be better off not generating the copy editor at all (rather than just hiding it), but we're a few steps off from that yet. Signed-off-by: Dan Wells Signed-off-by: Mike Rylander --- .../js/ui/default/staff/cat/catalog/app.js | 20 ++++++++-------- .../js/ui/default/staff/cat/volcopy/app.js | 23 ++++++++----------- 2 files changed, 21 insertions(+), 22 deletions(-) diff --git a/Open-ILS/web/js/ui/default/staff/cat/catalog/app.js b/Open-ILS/web/js/ui/default/staff/cat/catalog/app.js index f9ba1e7fcc..c3505ab1f7 100644 --- a/Open-ILS/web/js/ui/default/staff/cat/catalog/app.js +++ b/Open-ILS/web/js/ui/default/staff/cat/catalog/app.js @@ -1143,7 +1143,10 @@ function($scope , $routeParams , $location , $window , $q , egCore , egHolds , e angular.forEach( $scope.holdingsGridControls.selectedItems(), function (item) { - if (item.copy_count == 0) + if (item.copy_count == 0 || (!item.id && item.call_number)) + // we are in a compressed row with no copies, or we are in a single + // call number row with no copy (testing for presence of 'id') + // In either case, the call number is 'empty' cn_id_list.push(item.call_number.id) } ); @@ -1233,13 +1236,13 @@ function($scope , $routeParams , $location , $window , $q , egCore , egHolds , e $scope.selectedHoldingsVolCopyDelete = function () { $scope.selectedHoldingsDelete(true,true) } $scope.selectedHoldingsEmptyVolCopyDelete = function () { $scope.selectedHoldingsDelete(true,false) } - spawnHoldingsAdd = function (vols,copies,only_add_vol){ + spawnHoldingsAdd = function (add_vols,add_copies){ var raw = []; - if (copies) { // just a copy on existing volumes + if (!add_vols && add_copies) { // just a copy on existing volumes angular.forEach(gatherSelectedVolumeIds(), function (v) { raw.push( {callnumber : v} ); }); - } else if (vols) { + } else if (add_vols) { if (typeof $scope.holdingsGridControls.selectedItems == "function" && $scope.holdingsGridControls.selectedItems().length > 0) { angular.forEach($scope.holdingsGridControls.selectedItems(), @@ -1265,8 +1268,7 @@ function($scope , $routeParams , $location , $window , $q , egCore , egHolds , e record_id: $scope.record_id, raw: raw, hide_vols : false, - hide_copies : ((only_add_vol) ? true : false), - only_add_vol : only_add_vol + hide_copies : !add_copies } ).then(function(key) { if (key) { @@ -1277,9 +1279,9 @@ function($scope , $routeParams , $location , $window , $q , egCore , egHolds , e } }); } - $scope.selectedHoldingsVolCopyAdd = function () { spawnHoldingsAdd(true,false,false) } - $scope.selectedHoldingsCopyAdd = function () { spawnHoldingsAdd(false,true,false) } - $scope.selectedHoldingsVolAdd = function () { spawnHoldingsAdd(true,false,true) } + $scope.selectedHoldingsVolCopyAdd = function () { spawnHoldingsAdd(true,true) } + $scope.selectedHoldingsCopyAdd = function () { spawnHoldingsAdd(false,true) } + $scope.selectedHoldingsVolAdd = function () { spawnHoldingsAdd(true,false) } spawnHoldingsEdit = function (hide_vols,hide_copies){ egCore.net.request( diff --git a/Open-ILS/web/js/ui/default/staff/cat/volcopy/app.js b/Open-ILS/web/js/ui/default/staff/cat/volcopy/app.js index 82e888dab2..c5e929b9b9 100644 --- a/Open-ILS/web/js/ui/default/staff/cat/volcopy/app.js +++ b/Open-ILS/web/js/ui/default/staff/cat/volcopy/app.js @@ -592,7 +592,7 @@ function(egCore , $q) { controller : ['$scope','itemSvc','egCore', function ( $scope , itemSvc , egCore ) { $scope.callNumber = $scope.copies[0].call_number(); - if (!$scope.callNumber.label()) $scope.callNumber.emtpy_label = true; + if (!$scope.callNumber.label()) $scope.callNumber.empty_label = true; $scope.empty_label = false; $scope.empty_label_string = window.empty_label_string; @@ -722,11 +722,6 @@ function(egCore , $q) { } $scope.updateLabel = function () { - if ($scope.label == '') { - $scope.callNumber.empty_label = $scope.empty_label = true; - } else { - $scope.callNumber.empty_label = $scope.empty_label = false; - } angular.forEach($scope.copies, function(cp) { cp.call_number().label($scope.label); cp.call_number().ischanged(1); @@ -735,6 +730,11 @@ function(egCore , $q) { $scope.$watch('callNumber.label()', function (v) { $scope.label = v; + if ($scope.label == '') { + $scope.callNumber.empty_label = $scope.empty_label = true; + } else { + $scope.callNumber.empty_label = $scope.empty_label = false; + } }); $scope.prefix = $scope.callNumber.prefix(); @@ -1372,9 +1372,6 @@ function($scope , $q , $window , $routeParams , $location , $timeout , egCore , $scope.show_copies = false; $scope.only_vols = true; } - if (data.only_add_vol) { - $scope.only_add_vol = true; - } $scope.record_id = data.record_id; @@ -1477,7 +1474,7 @@ function($scope , $q , $window , $routeParams , $location , $timeout , egCore , return itemSvc.copies; } - if (!$scope.only_add_vol && data.copies && data.copies.length) + if (data.copies && data.copies.length) return itemSvc.fetchIds(data.copies).then(fetchRaw); return fetchRaw(); @@ -1496,7 +1493,7 @@ function($scope , $q , $window , $routeParams , $location , $timeout , egCore , angular.forEach( itemSvc.copies, function (i) { - if (!$scope.only_add_vol) { + if (!$scope.only_vols) { if (i.duplicate_barcode || i.empty_barcode || i.call_number().empty_label) { can_save = false; } @@ -1506,7 +1503,7 @@ function($scope , $q , $window , $routeParams , $location , $timeout , egCore , } ); - if ($scope.forms.myForm && $scope.forms.myForm.$invalid) { + if (!$scope.only_vols && $scope.forms.myForm && $scope.forms.myForm.$invalid) { can_save = false; } @@ -1796,7 +1793,7 @@ function($scope , $q , $window , $routeParams , $location , $timeout , egCore , cnHash[cn_id].suffix(cnHash[cn_id].suffix().id()); // un-object-ize some fields }); - if ($scope.only_add_vol) { // strip off copies when we're in add-empty-vol mode + if ($scope.only_vols) { // strip off copies when we're in vol-only mode angular.forEach(cnHash, function (v, k) { cnHash[k].copies([]); }); -- 2.43.2