<script src="[% ctx.media_prefix %]/js/ui/default/staff/cat/item/replace_barcode/app.js"></script>
[% END %]
-<h2>[% l('Replace Item Barcode') %]</h2>
+[% INCLUDE 'staff/cat/share/t_replace_barcode.tt2' %]
-<div class="row">
- <div class="col-md-6 pad-vert">
- <form role="form" ng-submit="updateBarcode()">
- <div class="form-group">
- <label for="barcode1">[% l('Enter Original Barcode for Item') %]</label>
- <input type="text" class="form-control" id="barcode1" required
- ng-model="barcode1"
- placeholder="[% l('Original Barcode...') %]" select-me="focusBarcode">
- </div>
- <div class="form-group">
- <label for="barcode2">[% l('Enter New Barcode for Item') %]</label>
- <input type="text" class="form-control" id="barcode2"
- ng-model="barcode2"
- required placeholder="[% l('New Barcode...') %]">
- </div>
- <button type="submit" class="btn btn-default">[% l('Submit') %]</button>
- </form>
- </div>
-</div>
-
-<div class="row pad-vert">
- <div class="col-md-6">
- <div class="alert alert-danger" ng-if="copyNotFound">
- [% l('Copy Not Found') %]
- </div>
- <div class="alert alert-success" ng-if="updateOK">
- <span>[% l('Copy Updated') %]</span>
- <span class="horiz-pad" ng-if="copyId">
- <a href="./cat/item/{{copyId}}/summary" target="_self">
- [% l('View Item Details') %]
- </a>
- </div>
- </div>
-</div>
[% END %]
--- /dev/null
+<div>
+<div class="row ">
+ <div class="col-md-1"></div>
+ <div class="col-md-6">
+ <h2 class="center-block">[% l('Replace Item Barcode') %]</h2>
+ </div>
+</div>
+
+<div class="row pad-vert">
+ <div class="col-md-1"></div>
+ <div ng-class="{'col-md-6': !isModal, 'col-md-10': isModal}">
+ <form role="form" ng-submit="updateBarcode()">
+ <div class="form-group">
+ <label for="barcode1">[% l('Enter Original Barcode for Item') %]</label>
+ <input type="text" class="form-control" id="barcode1" required
+ ng-model="barcode1"
+ placeholder="[% l('Original Barcode...') %]" select-me="focusBarcode">
+ </div>
+ <div class="form-group">
+ <label for="barcode2">[% l('Enter New Barcode for Item') %]</label>
+ <input type="text" class="form-control" id="barcode2" select-me="focusBarcode2"
+ ng-model="barcode2"
+ required placeholder="[% l('New Barcode...') %]">
+ </div>
+ <button type="submit" class="btn btn-default">[% l('Submit') %]</button>
+ <button ng-if="isModal" class="btn btn-warning" ng-click="cancel($event)">[% l('Cancel') %]</button>
+ </form>
+ </div>
+</div>
+
+<div class="row pad-vert">
+ <div class="col-md-6">
+ <div class="alert alert-danger" ng-if="copyNotFound">
+ [% l('Copy Not Found') %]
+ </div>
+ <div class="alert alert-success" ng-if="updateOK">
+ <span>[% l('Copy Updated') %]</span>
+ <span class="horiz-pad" ng-if="copyId">
+ <a href="./cat/item/{{copyId}}/summary" target="_self">
+ [% l('View Item Details') %]
+ </a>
+ </div>
+ </div>
+</div>
+</div>
});
}
+ $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;
}
).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 {
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 {
$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();
});
});
$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();
});
});
}
}
+ 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) {
service.rid = rid;
service.org = org;
+ service.copy = opts.copy;
+ service.vol = opts.vol;
+ service.empty = opts.empty;
+
service.copies = [];
service.index = 0;