$scope.holdings_cb_changed(item.checkbox,item.checked);
}
+ function gatherSelectedOwners () {
+ var owner_list = [];
+ angular.forEach(
+ $scope.holdingsGridControls.selectedItems(),
+ function (item) { owner_list.push(item.owner_id) }
+ );
+ return owner_list;
+ }
+
function gatherSelectedHoldingsIds () {
var cp_id_list = [];
angular.forEach(
$scope.selectedHoldingsVolCopyAdd = function () { spawnHoldingsAdd(true,false) }
$scope.selectedHoldingsCopyAdd = function () { spawnHoldingsAdd(false,true) }
- spawnHoldingsEdit = function (hide_vols,hide_copies){
+ spawnHoldingsEdit = function (hide_vols,hide_copies,add_vol){
+
+ var raw;
+ if (add_vol) {
+ raw = [{callnumber:null}];
+ } else {
+ raw = gatherSelectedEmptyVolumeIds().map(
+ function(v){ return { callnumber : v } }
+ );
+ }
+
egCore.net.request(
'open-ils.actor',
'open-ils.actor.anon_cache.set_value',
null, 'edit-these-copies', {
record_id: $scope.record_id,
copies: gatherSelectedHoldingsIds(),
- raw: gatherSelectedEmptyVolumeIds().map(
- function(v){ return { callnumber : v } }
- ),
+ raw: raw,
hide_vols : hide_vols,
- hide_copies : hide_copies
+ hide_copies : hide_copies,
+ only_add_vol : ((add_vol) ? true : false),
+ owners : gatherSelectedOwners()
}
).then(function(key) {
if (key) {
$scope.selectedHoldingsVolEdit = function () { spawnHoldingsEdit(false,true) }
$scope.selectedHoldingsCopyEdit = function () { spawnHoldingsEdit(true,false) }
+ $scope.selectedHoldingsVolAdd = function () { spawnHoldingsEdit(false,true,true) }
+
$scope.selectedHoldingsItemStatus = function (){
var url = egCore.env.basePath + 'cat/item/search/' + gatherSelectedHoldingsIds().join(',')
$timeout(function() { $window.open(url, '_blank') });
}
});
+ function gatherSelectedOwners () {
+ var owner_list = [];
+ angular.forEach(
+ $scope.holdingsGridControls.selectedItems(),
+ function (item) { owner_list.push(item.owner_id) }
+ );
+ return owner_list;
+ }
+
function gatherHoldingsIds () {
var cp_id_list = [];
angular.forEach(
return cp_id_list;
}
- var spawn_volume_editor = function (copies_too) {
+ var spawn_volume_editor = function (copies_too,add_vol) {
egCore.net.request(
'open-ils.actor',
'open-ils.actor.anon_cache.set_value',
record_id: $scope.recordId,
copies: gatherHoldingsIds(),
hide_vols : false,
- hide_copies : ((copies_too) ? false : true)
+ hide_copies : ((copies_too) ? false : true),
+ only_add_vol : ((add_vol) ? true : false),
+ owners : gatherSelectedOwners()
}
).then(function(key) {
if (key) {
}
});
}
+ $scope.add_emtpy_volumes = function() {
+ spawn_volume_editor(false,true);
+ }
$scope.edit_volumes = function() {
- spawn_volume_editor(false);
+ spawn_volume_editor(false,false);
}
$scope.edit_copies = function() {
- spawn_volume_editor(true);
+ spawn_volume_editor(true,false);
}
function load_holdings() {
).then(function (data) {
if (data) {
+ var owners = [ egCore.auth.user().ws_ou() ];
+
if (data.hide_vols && !$scope.defaults.always_volumes) $scope.show_vols = false;
if (data.hide_copies) {
$scope.show_copies = false;
$scope.only_vols = true;
}
+ if (data.only_add_vol) {
+ $scope.only_add_vol = true;
+ $scope.only_vols = true;
+ $scope.show_copies = false;
+ owners = data.owners;
+ }
$scope.record_id = data.record_id;
itemSvc.addCopy(cp)
});
} else {
- 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( proto.owner || egCore.auth.user().ws_ou() );
- 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;
+ 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();
$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;
}
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) {