})
.factory('itemSvc',
- ['egCore',
-function(egCore) {
+ ['egCore','egCirc','$uibModal','$q','$timeout','$window','egConfirmDialog',
+function(egCore , egCirc , $uibModal , $q , $timeout , $window , egConfirmDialog ) {
var service = {
copies : [], // copy barcode search results
}
- return service;
-}])
-
-/**
- * Search bar along the top of the page.
- * Parent scope for list and detail views
- */
-.controller('SearchCtrl',
- ['$scope','$location','egCore','egGridDataProvider','itemSvc',
-function($scope , $location , egCore , egGridDataProvider , itemSvc) {
- $scope.args = {}; // search args
-
- // sub-scopes (search / detail-view) apply their version
- // of retrieval function to $scope.context.search
- // and display toggling via $scope.context.toggleDisplay
- $scope.context = {
- selectBarcode : true
- };
-
- $scope.toggleView = function($event) {
- $scope.context.toggleDisplay();
- $event.preventDefault(); // avoid form submission
- }
-}])
-
-/**
- * List view - grid stuff
- */
-.controller('ListCtrl',
- ['$scope','$q','$routeParams','$location','$timeout','$window','egCore','egGridDataProvider','itemSvc','egUser','$uibModal','egCirc','egConfirmDialog',
-function($scope , $q , $routeParams , $location , $timeout , $window , egCore , egGridDataProvider , itemSvc , egUser , $uibModal , egCirc , egConfirmDialog) {
- var copyId = [];
- var cp_list = $routeParams.idList;
- if (cp_list) {
- copyId = cp_list.split(',');
- }
-
- $scope.context.page = 'list';
-
- /*
- var provider = egGridDataProvider.instance();
- provider.get = function(offset, count) {
- }
- */
-
- $scope.gridDataProvider = egGridDataProvider.instance({
- get : function(offset, count) {
- //return provider.arrayNotifier(itemSvc.copies, offset, count);
- return this.arrayNotifier(itemSvc.copies, offset, count);
- }
- });
-
- // If a copy was just displayed in the detail view, ensure it's
- // focused in the list view.
- var selected = false;
- var copyGrid = $scope.gridControls = {
- itemRetrieved : function(item) {
- if (selected || !itemSvc.copy) return;
- if (itemSvc.copy.id() == item.id) {
- copyGrid.selectItems([item.index]);
- selected = true;
- }
- }
- };
-
- $scope.$watch('barcodesFromFile', function(newVal, oldVal) {
- if (newVal && newVal != oldVal) {
- $scope.args.barcode = '';
- var barcodes = [];
-
- angular.forEach(newVal.split(/\n/), function(line) {
- if (!line) return;
- // scrub any trailing spaces or commas from the barcode
- line = line.replace(/(.*?)($|\s.*|,.*)/,'$1');
- barcodes.push(line);
- });
-
- itemSvc.fetch(barcodes).then(
- function() {
- copyGrid.refresh();
- copyGrid.selectItems([itemSvc.copies[0].index]);
- }
- );
- }
- });
-
- $scope.context.search = function(args) {
- if (!args.barcode) return;
- $scope.context.itemNotFound = false;
- itemSvc.fetch(args.barcode).then(function(res) {
- if (res) {
- copyGrid.refresh();
- copyGrid.selectItems([res.index]);
- $scope.args.barcode = '';
- } else {
- $scope.context.itemNotFound = true;
- egCore.audio.play('warning.item_status.itemNotFound');
- }
- $scope.context.selectBarcode = true;
- })
- }
-
- var add_barcode_to_list = function (b) {
- $scope.context.search({barcode:b});
- }
-
- $scope.context.toggleDisplay = function() {
- var item = copyGrid.selectedItems()[0];
- if (item)
- $location.path('/cat/item/' + item.id);
- }
-
- $scope.context.show_triggered_events = function() {
- var item = copyGrid.selectedItems()[0];
- if (item)
- $location.path('/cat/item/' + item.id + '/triggered_events');
- }
-
- function gatherSelectedRecordIds () {
- var rid_list = [];
- angular.forEach(
- copyGrid.selectedItems(),
- function (item) {
- if (rid_list.indexOf(item['call_number.record.id']) == -1)
- rid_list.push(item['call_number.record.id'])
- }
- );
- return rid_list;
- }
-
- function gatherSelectedVolumeIds (rid) {
- var cn_id_list = [];
- angular.forEach(
- copyGrid.selectedItems(),
- function (item) {
- if (rid && item['call_number.record.id'] != rid) return;
- if (cn_id_list.indexOf(item['call_number.id']) == -1)
- cn_id_list.push(item['call_number.id'])
- }
- );
- return cn_id_list;
- }
-
- function gatherSelectedHoldingsIds (rid) {
- var cp_id_list = [];
- angular.forEach(
- copyGrid.selectedItems(),
- function (item) {
- if (rid && item['call_number.record.id'] != rid) return;
- cp_id_list.push(item.id)
- }
- );
- return cp_id_list;
- }
-
- $scope.add_copies_to_bucket = function() {
- var copy_list = gatherSelectedHoldingsIds();
+ service.add_copies_to_bucket = function(copy_list) {
if (copy_list.length == 0) return;
return $uibModal.open({
});
}
- $scope.need_one_selected = function() {
- var items = $scope.gridControls.selectedItems();
- if (items.length == 1) return false;
- return true;
- };
-
- $scope.make_copies_bookable = function() {
+ service.make_copies_bookable = function(items) {
var copies_by_record = {};
var record_list = [];
angular.forEach(
- copyGrid.selectedItems(),
+ items,
function (item) {
var record_id = item['call_number.record.id'];
if (typeof copies_by_record[ record_id ] == 'undefined') {
});
}
- $scope.book_copies_now = function() {
+ service.book_copies_now = function(items) {
var copies_by_record = {};
var record_list = [];
angular.forEach(
- copyGrid.selectedItems(),
+ items,
function (item) {
var record_id = item['call_number.record.id'];
if (typeof copies_by_record[ record_id ] == 'undefined') {
});
}
- $scope.requestItems = function() {
- var copy_list = gatherSelectedHoldingsIds();
+ service.requestItems = function(copy_list) {
if (copy_list.length == 0) return;
return $uibModal.open({
});
}
- $scope.replaceBarcodes = function() {
- angular.forEach(copyGrid.selectedItems(), function (cp) {
- $uibModal.open({
- templateUrl: './cat/share/t_replace_barcode',
- animation: true,
- controller:
- ['$scope','$uibModalInstance',
- function($scope , $uibModalInstance) {
- $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;
- if (stat) add_barcode_to_list(copy.barcode());
- });
-
- });
- $uibModalInstance.close();
- }
-
- $scope.cancel = function($event) {
- $uibModalInstance.dismiss();
- $event.preventDefault();
- }
- }
- ]
- });
- });
- }
-
- $scope.attach_to_peer_bib = function() {
- if (copyGrid.selectedItems().length == 0) return;
+ service.attach_to_peer_bib = function(items) {
+ if (items.length == 0) return;
egCore.hatch.getItem('eg.cat.marked_conjoined_record').then(function(target_record) {
if (!target_record) return;
$scope.ok = function(type) {
var promises = [];
- angular.forEach(copyGrid.selectedItems(), function (cp) {
+ angular.forEach(items, function (cp) {
var n = new egCore.idl.bpbcm();
n.isnew(true);
n.peer_record(target_record);
n.target_copy(cp.id);
n.peer_type(type);
- promises.push(egCore.pcrud.create(n).then(function(){add_barcode_to_list(cp.barcode)}));
+ promises.push(egCore.pcrud.create(n).then(function(){service.add_barcode_to_list(cp.barcode)}));
});
return $q.all(promises).then(function(){$uibModalInstance.close()});
});
}
- $scope.selectedHoldingsCopyDelete = function () {
- var copy_list = gatherSelectedHoldingsIds();
- if (copy_list.length == 0) return;
+ service.selectedHoldingsCopyDelete = function (items) {
+ if (items.length == 0) return;
var copy_objects = [];
egCore.pcrud.search('acp',
- {deleted : 'f', id : copy_list},
+ {deleted : 'f', id : items.map(function(el){return el.id;}) },
{ flesh : 1, flesh_fields : { acp : ['call_number'] } }
).then(function(copy) {
copy_objects.push(copy);
'open-ils.cat.asset.volume.fleshed.batch.update.override',
egCore.auth.token(), cnList, 1, flags
).then(function(){
- angular.forEach(copyGrid.selectedItems(), function(cp){add_barcode_to_list(cp.barcode)});
+ angular.forEach(items, function(cp){service.add_barcode_to_list(cp.barcode)});
});
});
});
}
- $scope.selectedHoldingsItemStatusTgrEvt= function() {
- var item = copyGrid.selectedItems()[0];
- if (item)
- $location.path('/cat/item/' + item.id + '/triggered_events');
+ service.checkin = function (items) {
+ angular.forEach(items, function (cp) {
+ egCirc.checkin({copy_barcode:cp.barcode}).then(
+ function() { service.add_barcode_to_list(cp.barcode) }
+ );
+ });
}
- $scope.selectedHoldingsItemStatusHolds= function() {
- var item = copyGrid.selectedItems()[0];
- if (item)
- $location.path('/cat/item/' + item.id + '/holds');
+ service.renew = function (items) {
+ angular.forEach(items, function (cp) {
+ egCirc.renew({copy_barcode:cp.barcode}).then(
+ function() { service.add_barcode_to_list(cp.barcode) }
+ );
+ });
}
- $scope.cancel_transit = function () {
- var initial_list = copyGrid.selectedItems();
- angular.forEach(copyGrid.selectedItems(), function(cp) {
+ service.cancel_transit = function (items) {
+ angular.forEach(items, function(cp) {
egCirc.find_copy_transit(null, {copy_barcode:cp.barcode})
.then(function(t) { return egCirc.abort_transit(t.id()) })
- .then(function() { return add_barcode_to_list(cp.barcode) });
- });
- }
-
- $scope.selectedHoldingsDamaged = function () {
- var initial_list = copyGrid.selectedItems();
- egCirc.mark_damaged(gatherSelectedHoldingsIds()).then(function(){
- angular.forEach(initial_list, function(cp){add_barcode_to_list(cp.barcode)});
+ .then(function() { return service.add_barcode_to_list(cp.barcode) });
});
}
- $scope.selectedHoldingsMissing = function () {
- var initial_list = copyGrid.selectedItems();
- egCirc.mark_missing(gatherSelectedHoldingsIds()).then(function(){
- angular.forEach(initial_list, function(cp){add_barcode_to_list(cp.barcode)});
+ service.selectedHoldingsDamaged = function (items) {
+ egCirc.mark_damaged(items.map(function(el){return el.id;})).then(function(){
+ angular.forEach(items, function(cp){service.add_barcode_to_list(cp.barcode)});
});
}
- $scope.checkin = function () {
- angular.forEach(copyGrid.selectedItems(), function (cp) {
- egCirc.checkin({copy_barcode:cp.barcode}).then(
- function() { add_barcode_to_list(cp.barcode) }
- );
+ service.selectedHoldingsMissing = function (items) {
+ egCirc.mark_missing(items.map(function(el){return el.id;})).then(function(){
+ angular.forEach(items, function(cp){service.add_barcode_to_list(cp.barcode)});
});
}
- $scope.renew = function () {
- angular.forEach(copyGrid.selectedItems(), function (cp) {
- egCirc.renew({copy_barcode:cp.barcode}).then(
- function() { add_barcode_to_list(cp.barcode) }
- );
- });
+ service.gatherSelectedRecordIds = function (items) {
+ var rid_list = [];
+ angular.forEach(
+ items,
+ function (item) {
+ if (rid_list.indexOf(item['call_number.record.id']) == -1)
+ rid_list.push(item['call_number.record.id'])
+ }
+ );
+ return rid_list;
}
-
- var spawnHoldingsAdd = function (vols,copies){
- angular.forEach(gatherSelectedRecordIds(), function (r) {
+ service.gatherSelectedVolumeIds = function (items,rid) {
+ var cn_id_list = [];
+ angular.forEach(
+ items,
+ function (item) {
+ if (rid && item['call_number.record.id'] != rid) return;
+ if (cn_id_list.indexOf(item['call_number.id']) == -1)
+ cn_id_list.push(item['call_number.id'])
+ }
+ );
+ return cn_id_list;
+ }
+
+ service.gatherSelectedHoldingsIds = function (items,rid) {
+ var cp_id_list = [];
+ angular.forEach(
+ items,
+ function (item) {
+ if (rid && item['call_number.record.id'] != rid) return;
+ cp_id_list.push(item.id)
+ }
+ );
+ return cp_id_list;
+ }
+
+ service.spawnHoldingsAdd = function (items,use_vols,use_copies){
+ angular.forEach(service.gatherSelectedRecordIds(items), function (r) {
var raw = [];
- if (copies) { // just a copy on existing volumes
- angular.forEach(gatherSelectedVolumeIds(r), function (v) {
+ if (use_copies) { // just a copy on existing volumes
+ angular.forEach(service.gatherSelectedVolumeIds(items,r), function (v) {
raw.push( {callnumber : v} );
});
- } else if (vols) {
+ } else if (use_vols) {
angular.forEach(
- gatherSelectedHoldingsIds(r),
+ service.gatherSelectedHoldingsIds(items,r),
function (i) {
- angular.forEach(copyGrid.selectedItems(), function(item) {
+ angular.forEach(items, function(item) {
if (i == item.id) raw.push({owner : item['call_number.owning_lib']});
});
}
});
});
}
- $scope.selectedHoldingsVolCopyAdd = function () { spawnHoldingsAdd(true,false) }
- $scope.selectedHoldingsCopyAdd = function () { spawnHoldingsAdd(false,true) }
-
- $scope.showBibHolds = function () {
- angular.forEach(gatherSelectedRecordIds(), function (r) {
- var url = egCore.env.basePath + 'cat/catalog/record/' + r + '/holds';
- $timeout(function() { $window.open(url, '_blank') });
- });
- }
- var spawnHoldingsEdit = function (hide_vols,hide_copies){
- angular.forEach(gatherSelectedRecordIds(), function (r) {
+ service.spawnHoldingsEdit = function (items,hide_vols,hide_copies){
+ angular.forEach(service.gatherSelectedRecordIds(items), function (r) {
egCore.net.request(
'open-ils.actor',
'open-ils.actor.anon_cache.set_value',
null, 'edit-these-copies', {
record_id: r,
- copies: gatherSelectedHoldingsIds(r),
+ copies: service.gatherSelectedHoldingsIds(items,r),
raw: {},
hide_vols : hide_vols,
hide_copies : hide_copies
});
});
}
- $scope.selectedHoldingsVolCopyEdit = function () { spawnHoldingsEdit(false,false) }
- $scope.selectedHoldingsVolEdit = function () { spawnHoldingsEdit(false,true) }
- $scope.selectedHoldingsCopyEdit = function () { spawnHoldingsEdit(true,false) }
+
+ service.replaceBarcodes = function(items) {
+ angular.forEach(items, function (cp) {
+ $uibModal.open({
+ templateUrl: './cat/share/t_replace_barcode',
+ animation: true,
+ controller:
+ ['$scope','$uibModalInstance',
+ function($scope , $uibModalInstance) {
+ $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;
+ if (stat) service.add_barcode_to_list(copy.barcode());
+ });
+
+ });
+ $uibModalInstance.close();
+ }
+
+ $scope.cancel = function($event) {
+ $uibModalInstance.dismiss();
+ $event.preventDefault();
+ }
+ }
+ ]
+ });
+ });
+ }
// this "transfers" selected copies to a new owning library,
// auto-creating volumes and deleting unused volumes as required.
- $scope.changeItemOwningLib = function() {
+ service.changeItemOwningLib = function(items) {
var xfer_target = egCore.hatch.getLocalItem('eg.cat.volume_transfer_target');
- var items = copyGrid.selectedItems();
if (!xfer_target || !items.length) {
return;
}
});
angular.forEach(
- copyGrid.selectedItems(),
+ items,
function(cp){
promises.push(
- function(){ add_barcode_to_list(cp.barcode) }
+ function(){ service.add_barcode_to_list(cp.barcode) }
)
}
);
$q.all(promises);
}
- $scope.transferItems = function (){
+ service.transferItems = function (items){
var xfer_target = egCore.hatch.getLocalItem('eg.cat.item_transfer_target');
- var copy_ids = gatherSelectedHoldingsIds();
+ var copy_ids = service.gatherSelectedHoldingsIds(items);
if (xfer_target && copy_ids.length > 0) {
egCore.net.request(
'open-ils.cat',
egConfirmDialog.open(
egCore.strings.OVERRIDE_TRANSFER_COPIES_TO_MARKED_VOLUME_TITLE,
egCore.strings.OVERRIDE_TRANSFER_COPIES_TO_MARKED_VOLUME_BODY,
- {'evt_desc': evt.desc}
+ {'evt_desc': evt}
).result.then(function() {
egCore.net.request(
'open-ils.cat',
null, // onerror
null // onprogress
).then(function() {
- angular.forEach(copyGrid.selectedItems(), function(cp){add_barcode_to_list(cp.barcode)});
+ angular.forEach(items, function(cp){service.add_barcode_to_list(cp.barcode)});
});
}
}
+ return service;
+}])
+
+/**
+ * Search bar along the top of the page.
+ * Parent scope for list and detail views
+ */
+.controller('SearchCtrl',
+ ['$scope','$location','$timeout','egCore','egGridDataProvider','itemSvc',
+function($scope , $location , $timeout , egCore , egGridDataProvider , itemSvc) {
+ $scope.args = {}; // search args
+
+ // sub-scopes (search / detail-view) apply their version
+ // of retrieval function to $scope.context.search
+ // and display toggling via $scope.context.toggleDisplay
+ $scope.context = {
+ selectBarcode : true
+ };
+
+ $scope.toggleView = function($event) {
+ $scope.context.toggleDisplay();
+ $event.preventDefault(); // avoid form submission
+ }
+
+ // The functions that follow in this controller are never called
+ // when the List View is active, only the Detail View.
+
+ // In this context, we're only ever dealing with 1 item, so
+ // we can simply refresh the page. These various itemSvc
+ // functions used to live in the ListCtrl, but they're now
+ // shared between SearchCtrl (for Actions for the Detail View)
+ // and ListCtrl (Actions in the egGrid)
+ itemSvc.add_barcode_to_list = function(b) {
+ //console.log('SearchCtrl: add_barcode_to_list',b);
+ // timeout so audible can happen upon checkin
+ $timeout(function() { location.href = location.href; }, 1000);
+ }
+
+ $scope.add_copies_to_bucket = function() {
+ itemSvc.add_copies_to_bucket([$scope.args.copyId]);
+ }
+
+ $scope.make_copies_bookable = function() {
+ itemSvc.make_copies_bookable([{
+ id : $scope.args.copyId,
+ 'call_number.record.id' : $scope.args.recordId
+ }]);
+ }
+
+ $scope.book_copies_now = function() {
+ itemSvc.book_copies_now([{
+ id : $scope.args.copyId,
+ 'call_number.record.id' : $scope.args.recordId
+ }]);
+ }
+
+ $scope.requestItems = function() {
+ itemSvc.requestItems([$scope.args.copyId]);
+ }
+
+ $scope.attach_to_peer_bib = function() {
+ itemSvc.attach_to_peer_bib([{
+ id : $scope.args.copyId,
+ barcode : $scope.args.copyBarcode
+ }]);
+ }
+
+ $scope.selectedHoldingsCopyDelete = function () {
+ itemSvc.selectedHoldingsCopyDelete([{
+ id : $scope.args.copyId,
+ barcode : $scope.args.copyBarcode
+ }]);
+ }
+
+ $scope.checkin = function () {
+ itemSvc.checkin([{
+ id : $scope.args.copyId,
+ barcode : $scope.args.copyBarcode
+ }]);
+ }
+
+ $scope.renew = function () {
+ itemSvc.renew([{
+ id : $scope.args.copyId,
+ barcode : $scope.args.copyBarcode
+ }]);
+ }
+
+ $scope.cancel_transit = function () {
+ itemSvc.cancel_transit([{
+ id : $scope.args.copyId,
+ barcode : $scope.args.copyBarcode
+ }]);
+ }
+
+ $scope.selectedHoldingsDamaged = function () {
+ itemSvc.selectedHoldingsDamaged([{
+ id : $scope.args.copyId,
+ barcode : $scope.args.copyBarcode
+ }]);
+ }
+
+ $scope.selectedHoldingsMissing = function () {
+ itemSvc.selectedHoldingsMissing([{
+ id : $scope.args.copyId,
+ barcode : $scope.args.copyBarcode
+ }]);
+ }
+
+ $scope.selectedHoldingsVolCopyAdd = function () {
+ itemSvc.spawnHoldingsAdd([{
+ id : $scope.args.copyId,
+ 'call_number.owning_lib' : $scope.args.cnOwningLib,
+ 'call_number.record.id' : $scope.args.recordId,
+ barcode : $scope.args.copyBarcode
+ }],true,false);
+ }
+ $scope.selectedHoldingsCopyAdd = function () {
+ itemSvc.spawnHoldingsAdd([{
+ id : $scope.args.copyId,
+ 'call_number.id' : $scope.args.cnId,
+ 'call_number.owning_lib' : $scope.args.cnOwningLib,
+ 'call_number.record.id' : $scope.args.recordId,
+ barcode : $scope.args.copyBarcode
+ }],false,true);
+ }
+
+ $scope.selectedHoldingsVolCopyEdit = function () {
+ itemSvc.spawnHoldingsEdit([{
+ id : $scope.args.copyId,
+ 'call_number.id' : $scope.args.cnId,
+ 'call_number.owning_lib' : $scope.args.cnOwningLib,
+ 'call_number.record.id' : $scope.args.recordId,
+ barcode : $scope.args.copyBarcode
+ }],false,false);
+ }
+ $scope.selectedHoldingsVolEdit = function () {
+ itemSvc.spawnHoldingsEdit([{
+ id : $scope.args.copyId,
+ 'call_number.id' : $scope.args.cnId,
+ 'call_number.owning_lib' : $scope.args.cnOwningLib,
+ 'call_number.record.id' : $scope.args.recordId,
+ barcode : $scope.args.copyBarcode
+ }],false,true);
+ }
+ $scope.selectedHoldingsCopyEdit = function () {
+ itemSvc.spawnHoldingsEdit([{
+ id : $scope.args.copyId,
+ 'call_number.id' : $scope.args.cnId,
+ 'call_number.owning_lib' : $scope.args.cnOwningLib,
+ 'call_number.record.id' : $scope.args.recordId,
+ barcode : $scope.args.copyBarcode
+ }],true,false);
+ }
+
+ $scope.replaceBarcodes = function() {
+ itemSvc.replaceBarcodes([{
+ id : $scope.args.copyId,
+ barcode : $scope.args.copyBarcode
+ }]);
+ }
+
+ $scope.changeItemOwningLib = function() {
+ itemSvc.changeItemOwningLib([{
+ id : $scope.args.copyId,
+ 'call_number.id' : $scope.args.cnId,
+ 'call_number.owning_lib' : $scope.args.cnOwningLib,
+ 'call_number.record.id' : $scope.args.recordId,
+ 'call_number.label' : $scope.args.cnLabel,
+ 'call_number.label_class' : $scope.args.cnLabelClass,
+ 'call_number.prefix.id' : $scope.args.cnPrefixId,
+ 'call_number.suffix.id' : $scope.args.cnSuffixId,
+ barcode : $scope.args.copyBarcode
+ }]);
+ }
+
+ $scope.transferItems = function (){
+ itemSvc.transferItems([{
+ id : $scope.args.copyId,
+ barcode : $scope.args.copyBarcode
+ }]);
+ }
+
+}])
+
+/**
+ * List view - grid stuff
+ */
+.controller('ListCtrl',
+ ['$scope','$q','$routeParams','$location','$timeout','$window','egCore','egGridDataProvider','itemSvc','egUser','$uibModal','egCirc','egConfirmDialog',
+function($scope , $q , $routeParams , $location , $timeout , $window , egCore , egGridDataProvider , itemSvc , egUser , $uibModal , egCirc , egConfirmDialog) {
+ var copyId = [];
+ var cp_list = $routeParams.idList;
+ if (cp_list) {
+ copyId = cp_list.split(',');
+ }
+
+ $scope.context.page = 'list';
+
+ /*
+ var provider = egGridDataProvider.instance();
+ provider.get = function(offset, count) {
+ }
+ */
+
+ $scope.gridDataProvider = egGridDataProvider.instance({
+ get : function(offset, count) {
+ //return provider.arrayNotifier(itemSvc.copies, offset, count);
+ return this.arrayNotifier(itemSvc.copies, offset, count);
+ }
+ });
+
+ // If a copy was just displayed in the detail view, ensure it's
+ // focused in the list view.
+ var selected = false;
+ var copyGrid = $scope.gridControls = {
+ itemRetrieved : function(item) {
+ if (selected || !itemSvc.copy) return;
+ if (itemSvc.copy.id() == item.id) {
+ copyGrid.selectItems([item.index]);
+ selected = true;
+ }
+ }
+ };
+
+ $scope.$watch('barcodesFromFile', function(newVal, oldVal) {
+ if (newVal && newVal != oldVal) {
+ $scope.args.barcode = '';
+ var barcodes = [];
+
+ angular.forEach(newVal.split(/\n/), function(line) {
+ if (!line) return;
+ // scrub any trailing spaces or commas from the barcode
+ line = line.replace(/(.*?)($|\s.*|,.*)/,'$1');
+ barcodes.push(line);
+ });
+
+ itemSvc.fetch(barcodes).then(
+ function() {
+ copyGrid.refresh();
+ copyGrid.selectItems([itemSvc.copies[0].index]);
+ }
+ );
+ }
+ });
+
+ $scope.context.search = function(args) {
+ if (!args.barcode) return;
+ $scope.context.itemNotFound = false;
+ itemSvc.fetch(args.barcode).then(function(res) {
+ if (res) {
+ copyGrid.refresh();
+ copyGrid.selectItems([res.index]);
+ $scope.args.barcode = '';
+ } else {
+ $scope.context.itemNotFound = true;
+ egCore.audio.play('warning.item_status.itemNotFound');
+ }
+ $scope.context.selectBarcode = true;
+ })
+ }
+
+ var add_barcode_to_list = function (b) {
+ //console.log('listCtrl: add_barcode_to_list',b);
+ $scope.context.search({barcode:b});
+ }
+ itemSvc.add_barcode_to_list = add_barcode_to_list;
+
+ $scope.context.toggleDisplay = function() {
+ var item = copyGrid.selectedItems()[0];
+ if (item)
+ $location.path('/cat/item/' + item.id);
+ }
+
+ $scope.context.show_triggered_events = function() {
+ var item = copyGrid.selectedItems()[0];
+ if (item)
+ $location.path('/cat/item/' + item.id + '/triggered_events');
+ }
+
+ function gatherSelectedRecordIds () {
+ var rid_list = [];
+ angular.forEach(
+ copyGrid.selectedItems(),
+ function (item) {
+ if (rid_list.indexOf(item['call_number.record.id']) == -1)
+ rid_list.push(item['call_number.record.id'])
+ }
+ );
+ return rid_list;
+ }
+
+ function gatherSelectedVolumeIds (rid) {
+ var cn_id_list = [];
+ angular.forEach(
+ copyGrid.selectedItems(),
+ function (item) {
+ if (rid && item['call_number.record.id'] != rid) return;
+ if (cn_id_list.indexOf(item['call_number.id']) == -1)
+ cn_id_list.push(item['call_number.id'])
+ }
+ );
+ return cn_id_list;
+ }
+
+ function gatherSelectedHoldingsIds (rid) {
+ var cp_id_list = [];
+ angular.forEach(
+ copyGrid.selectedItems(),
+ function (item) {
+ if (rid && item['call_number.record.id'] != rid) return;
+ cp_id_list.push(item.id)
+ }
+ );
+ return cp_id_list;
+ }
+
+ $scope.add_copies_to_bucket = function() {
+ var copy_list = gatherSelectedHoldingsIds();
+ itemSvc.add_copies_to_bucket(copy_list);
+ }
+
+ $scope.need_one_selected = function() {
+ var items = $scope.gridControls.selectedItems();
+ if (items.length == 1) return false;
+ return true;
+ };
+
+ $scope.make_copies_bookable = function() {
+ itemSvc.make_copies_bookable(copyGrid.selectedItems());
+ }
+
+ $scope.book_copies_now = function() {
+ itemSvc.book_copies_now(copyGrid.selectedItems());
+ }
+
+ $scope.requestItems = function() {
+ var copy_list = gatherSelectedHoldingsIds();
+ itemSvc.requestItems(copy_list);
+ }
+
+ $scope.replaceBarcodes = function() {
+ itemSvc.replaceBarcodes(copyGrid.selectedItems());
+ }
+
+ $scope.attach_to_peer_bib = function() {
+ itemSvc.attach_to_peer_bib(copyGrid.selectedItems());
+ }
+
+ $scope.selectedHoldingsCopyDelete = function () {
+ itemSvc.selectedHoldingsCopyDelete(copyGrid.selectedItems());
+ }
+
+ $scope.selectedHoldingsItemStatusTgrEvt= function() {
+ var item = copyGrid.selectedItems()[0];
+ if (item)
+ $location.path('/cat/item/' + item.id + '/triggered_events');
+ }
+
+ $scope.selectedHoldingsItemStatusHolds= function() {
+ var item = copyGrid.selectedItems()[0];
+ if (item)
+ $location.path('/cat/item/' + item.id + '/holds');
+ }
+
+ $scope.cancel_transit = function () {
+ itemSvc.cancel_transit(copyGrid.selectedItems());
+ }
+
+ $scope.selectedHoldingsDamaged = function () {
+ itemSvc.selectedHoldingsDamaged(copyGrid.selectedItems());
+ }
+
+ $scope.selectedHoldingsMissing = function () {
+ itemSvc.selectedHoldingsMissing(copyGrid.selectedItems());
+ }
+
+ $scope.checkin = function () {
+ itemSvc.checkin(copyGrid.selectedItems());
+ }
+
+ $scope.renew = function () {
+ itemSvc.renew(copyGrid.selectedItems());
+ }
+
+ $scope.selectedHoldingsVolCopyAdd = function () {
+ itemSvc.spawnHoldingsAdd(copyGrid.selectedItems(),true,false);
+ }
+ $scope.selectedHoldingsCopyAdd = function () {
+ itemSvc.spawnHoldingsAdd(copyGrid.selectedItems(),false,true);
+ }
+
+ $scope.showBibHolds = function () {
+ angular.forEach(gatherSelectedRecordIds(), function (r) {
+ var url = egCore.env.basePath + 'cat/catalog/record/' + r + '/holds';
+ $timeout(function() { $window.open(url, '_blank') });
+ });
+ }
+
+ $scope.selectedHoldingsVolCopyEdit = function () {
+ itemSvc.spawnHoldingsEdit(copyGrid.selectedItems(),false,false);
+ }
+ $scope.selectedHoldingsVolEdit = function () {
+ itemSvc.spawnHoldingsEdit(copyGrid.selectedItems(),false,true);
+ }
+ $scope.selectedHoldingsCopyEdit = function () {
+ itemSvc.spawnHoldingsEdit(copyGrid.selectedItems(),true,false);
+ }
+
+ $scope.changeItemOwningLib = function() {
+ itemSvc.changeItemOwningLib(copyGrid.selectedItems());
+ }
+
+ $scope.transferItems = function (){
+ itemSvc.transferItems(copyGrid.selectedItems());
+ }
+
$scope.print_list = function() {
var print_data = { copies : copyGrid.allItems() };
['$scope','$q','$location','$routeParams','$timeout','$window','egCore','itemSvc','egBilling',
function($scope , $q , $location , $routeParams , $timeout , $window , egCore , itemSvc , egBilling) {
var copyId = $routeParams.id;
+ $scope.args.copyId = copyId;
$scope.tab = $routeParams.tab || 'summary';
$scope.context.page = 'detail';
$scope.summaryRecord = null;
// use the cached record info
- if (itemSvc.copy)
+ if (itemSvc.copy) {
$scope.recordId = itemSvc.copy.call_number().record().id();
+ $scope.args.recordId = $scope.recordId;
+ $scope.args.cnId = itemSvc.copy.call_number().id();
+ $scope.args.cnOwningLib = itemSvc.copy.call_number().owning_lib();
+ $scope.args.cnLabel = itemSvc.copy.call_number().label();
+ $scope.args.cnLabelClass = itemSvc.copy.call_number().label_class();
+ $scope.args.cnPrefixId = itemSvc.copy.call_number().prefix().id();
+ $scope.args.cnSuffixId = itemSvc.copy.call_number().suffix().id();
+ $scope.args.copyBarcode = itemSvc.copy.barcode();
+ }
function loadCopy(barcode) {
$scope.context.itemNotFound = false;
if (!barcode && itemSvc.copy && itemSvc.copy.id() == copyId) {
$scope.copy = itemSvc.copy;
$scope.recordId = itemSvc.copy.call_number().record().id();
+ $scope.args.recordId = $scope.recordId;
+ $scope.args.cnId = itemSvc.copy.call_number().id();
+ $scope.args.cnOwningLib = itemSvc.copy.call_number().owning_lib();
+ $scope.args.cnLabel = itemSvc.copy.call_number().label();
+ $scope.args.cnLabelClass = itemSvc.copy.call_number().label_class();
+ $scope.args.cnPrefixId = itemSvc.copy.call_number().prefix().id();
+ $scope.args.cnSuffixId = itemSvc.copy.call_number().suffix().id();
+ $scope.args.copyBarcode = itemSvc.copy.barcode();
return $q.when();
}
$scope.copy = copy;
$scope.recordId = copy.call_number().record().id();
+ $scope.args.recordId = $scope.recordId;
+ $scope.args.cnId = itemSvc.copy.call_number().id();
+ $scope.args.cnOwningLib = itemSvc.copy.call_number().owning_lib();
+ $scope.args.cnLabel = itemSvc.copy.call_number().label();
+ $scope.args.cnLabelClass = itemSvc.copy.call_number().label_class();
+ $scope.args.cnPrefixId = itemSvc.copy.call_number().prefix().id();
+ $scope.args.cnSuffixId = itemSvc.copy.call_number().suffix().id();
+ $scope.args.copyBarcode = copy.barcode();
$scope.args.barcode = '';
// locally flesh org units