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)
}
);
$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(),
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) {
}
});
}
- $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(
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;
}
$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);
$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();
$scope.show_copies = false;
$scope.only_vols = true;
}
- if (data.only_add_vol) {
- $scope.only_add_vol = true;
- }
$scope.record_id = data.record_id;
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();
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;
}
}
);
- if ($scope.forms.myForm && $scope.forms.myForm.$invalid) {
+ if (!$scope.only_vols && $scope.forms.myForm && $scope.forms.myForm.$invalid) {
can_save = false;
}
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([]);
});