From 68eb69e80578ad94699739dc74ebf1748a98658c Mon Sep 17 00:00:00 2001 From: Mike Rylander Date: Wed, 9 Sep 2015 13:57:41 -0400 Subject: [PATCH] webstaff: Refactor replace-barcode to be reusable, and reuse it in holdings maint Signed-off-by: Mike Rylander Signed-off-by: Galen Charlton Signed-off-by: Jason Stephenson --- .../src/templates/staff/cat/catalog/t_holdings.tt2 | 2 + .../staff/cat/item/replace_barcode/index.tt2 | 36 +------ .../staff/cat/share/t_replace_barcode.tt2 | 45 +++++++++ .../web/js/ui/default/staff/cat/catalog/app.js | 103 +++++++++++++++------ 4 files changed, 123 insertions(+), 63 deletions(-) create mode 100644 Open-ILS/src/templates/staff/cat/share/t_replace_barcode.tt2 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 c7a1142206..6b79312999 100644 --- a/Open-ILS/src/templates/staff/cat/catalog/t_holdings.tt2 +++ b/Open-ILS/src/templates/staff/cat/catalog/t_holdings.tt2 @@ -67,6 +67,8 @@ label="[% l('Copies') %]"> + diff --git a/Open-ILS/src/templates/staff/cat/item/replace_barcode/index.tt2 b/Open-ILS/src/templates/staff/cat/item/replace_barcode/index.tt2 index 6472a4890e..a81f7cd8ba 100644 --- a/Open-ILS/src/templates/staff/cat/item/replace_barcode/index.tt2 +++ b/Open-ILS/src/templates/staff/cat/item/replace_barcode/index.tt2 @@ -10,40 +10,6 @@ [% END %] -

[% l('Replace Item Barcode') %]

+[% INCLUDE 'staff/cat/share/t_replace_barcode.tt2' %] -
-
-
-
- - -
-
- - -
- -
-
-
- -
-
-
- [% l('Copy Not Found') %] -
-
- [% l('Copy Updated') %] - - - [% l('View Item Details') %] - -
-
-
[% END %] diff --git a/Open-ILS/src/templates/staff/cat/share/t_replace_barcode.tt2 b/Open-ILS/src/templates/staff/cat/share/t_replace_barcode.tt2 new file mode 100644 index 0000000000..83702a3179 --- /dev/null +++ b/Open-ILS/src/templates/staff/cat/share/t_replace_barcode.tt2 @@ -0,0 +1,45 @@ +
+
+
+
+

[% l('Replace Item Barcode') %]

+
+
+ +
+
+
+
+
+ + +
+
+ + +
+ + +
+
+
+ +
+
+
+ [% l('Copy Not Found') %] +
+
+ [% l('Copy Updated') %] + + + [% l('View Item Details') %] + +
+
+
+
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 20fe682ec9..8b84e23156 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 @@ -531,6 +531,63 @@ function($scope , $routeParams , $location , $window , $q , egCore , egHolds , e }); } + $scope.replaceBarcodes = function() { + var copy_list = gatherSelectedRawCopies(); + if (copy_list.length == 0) return; + + var holdingsGridDataProviderRef = $scope.holdingsGridDataProvider; + + angular.forEach(copy_list, function (cp) { + $modal.open({ + templateUrl: './cat/share/t_replace_barcode', + animation: true, + controller: + ['$scope','$modalInstance', + function($scope , $modalInstance) { + $scope.isModal = true; + $scope.focusBarcode = false; + $scope.focusBarcode2 = true; + $scope.barcode1 = cp.barcode(); + + $scope.updateBarcode = function() { + $scope.copyNotFound = false; + $scope.updateOK = false; + + egCore.pcrud.search('acp', + {deleted : 'f', barcode : $scope.barcode1}) + .then(function(copy) { + + if (!copy) { + $scope.focusBarcode = true; + $scope.copyNotFound = true; + return; + } + + $scope.copyId = copy.id(); + copy.barcode($scope.barcode2); + + egCore.pcrud.update(copy).then(function(stat) { + $scope.updateOK = stat; + $scope.focusBarcode = true; + holdingsSvc.fetchAgain().then(function (){ + holdingsGridDataProviderRef.refresh(); + }); + }); + + }); + $modalInstance.close(); + } + + $scope.cancel = function($event) { + $modalInstance.dismiss(); + $event.preventDefault(); + } + } + ] + }); + }); + } + // refresh the list of holdings when the record_id is changed. $scope.holdings_record_id_changed = function(id) { if ($scope.record_id != id) $scope.record_id = id; @@ -806,13 +863,7 @@ function($scope , $routeParams , $location , $window , $q , egCore , egHolds , e } ).then(function(success) { if (success) { - holdingsSvc.fetch({ - rid : $scope.record_id, - org : $scope.holdings_ou, - copy: $scope.holdings_show_copies, - vol : $scope.holdings_show_vols, - empty: $scope.holdings_show_empty - }).then(function() { + holdingsSvc.fetchAgain().then(function() { $scope.holdingsGridDataProvider.refresh(); }); } else { @@ -836,13 +887,7 @@ function($scope , $routeParams , $location , $window , $q , egCore , egHolds , e copy_list ).then(function(success) { if (success) { - holdingsSvc.fetch({ - rid : $scope.record_id, - org : $scope.holdings_ou, - copy: $scope.holdings_show_copies, - vol : $scope.holdings_show_vols, - empty: $scope.holdings_show_empty - }).then(function() { + holdingsSvc.fetchAgain().then(function() { $scope.holdingsGridDataProvider.refresh(); }); } else { @@ -877,13 +922,7 @@ function($scope , $routeParams , $location , $window , $q , egCore , egHolds , e $scope.selectedHoldingsDamaged = function () { egCirc.mark_damaged(gatherSelectedHoldingsIds()).then(function() { - holdingsSvc.fetch({ - rid : $scope.record_id, - org : $scope.holdings_ou, - copy: $scope.holdings_show_copies, - vol : $scope.holdings_show_vols, - empty: $scope.holdings_show_empty - }).then(function() { + holdingsSvc.fetchAgain().then(function() { $scope.holdingsGridDataProvider.refresh(); }); }); @@ -891,13 +930,7 @@ function($scope , $routeParams , $location , $window , $q , egCore , egHolds , e $scope.selectedHoldingsMissing = function () { egCirc.mark_missing(gatherSelectedHoldingsIds()).then(function() { - holdingsSvc.fetch({ - rid : $scope.record_id, - org : $scope.holdings_ou, - copy: $scope.holdings_show_copies, - vol : $scope.holdings_show_vols, - empty: $scope.holdings_show_empty - }).then(function() { + holdingsSvc.fetchAgain().then(function() { $scope.holdingsGridDataProvider.refresh(); }); }); @@ -1183,6 +1216,16 @@ function(egCore , $q) { } } + service.fetchAgain = function() { + return service.fetch({ + rid: service.rid, + org: service.org, + copy: service.copy, + vol: service.vol, + empty: service.empty + }) + } + // resolved with the last received copy service.fetch = function(opts) { if (service.ongoing) { @@ -1203,6 +1246,10 @@ function(egCore , $q) { service.rid = rid; service.org = org; + service.copy = opts.copy; + service.vol = opts.vol; + service.empty = opts.empty; + service.copies = []; service.index = 0; -- 2.11.0