</div>
</div>
<div class="col-xs-2" ng-show="only_vols">
- <button class="btn btn-default center-block" ng-click="workingToComplete() && saveAndExit()" type="button">
+ <button class="btn btn-default center-block" ng-disabled="disableSave()" ng-click="workingToComplete() && saveAndExit()" type="button">
<span ng-if="embedded">[% l('Save changes') %]</span>
<span ng-if="!embedded">[% l('Save & Exit') %]</span>
</button>
<eg-grid-menu-item handler="workingToComplete"
label="[% l('Store Selected') %]"></eg-grid-menu-item>
- <eg-grid-menu-item handler="workingSaveAndExit"
+ <eg-grid-menu-item disabled="disableSave" handler="workingSaveAndExit"
label="[% l('Save & Exit') %]"></eg-grid-menu-item>
<eg-grid-menu-item standalone="true" handler="completeToWorking"
label="[% l('Edit Selected') %]"></eg-grid-menu-item>
- <eg-grid-menu-item handler="saveAndContinue"
+ <eg-grid-menu-item disabled="disableSave" handler="saveAndContinue"
label="[% l('Save Completed') %]"></eg-grid-menu-item>
- <eg-grid-menu-item handler="saveAndExit"
+ <eg-grid-menu-item disabled="disableSave" handler="saveAndExit"
label="[% l('Save & Exit') %]"></eg-grid-menu-item>
<eg-grid-field label="[% l('Barcode') %]" path='barcode' visible></eg-grid-field>
service.copies.push(cp);
}
- service.checkDuplicateBarcode = function(bc) {
+ service.checkDuplicateBarcode = function(bc, id) {
var final = false;
- return egCore.pcrud.search('acp', { deleted : 'f', 'barcode' : bc })
+ return egCore.pcrud.search('acp', { deleted : 'f', 'barcode' : bc, id : { '!=' : id } })
.then(
function () { return final },
function () { return final },
cp.opac_visible('t');
cp.ref('f');
cp.mint_condition('t');
+ cp.empty_barcode = true;
var status_setting = isFastAdd ?
'cat.default_copy_status_fast' :
$scope.duplicate_barcode_string = window.duplicate_barcode_string;
$scope.empty_barcode_string = window.empty_barcode_string;
+ if (!$scope.copy.barcode()) $scope.copy.empty_barcode = true;
+
$scope.nextBarcode = function (i) {
$scope.focusNext(i, $scope.barcode);
}
$scope.updateBarcode = function () {
if ($scope.barcode != '') {
- $scope.empty_barcode = false;
+ $scope.copy.empty_barcode = $scope.empty_barcode = false;
$scope.barcode_has_error = !Boolean(itemSvc.checkBarcode($scope.barcode));
- if ($scope.copy.isnew()) {
- itemSvc.checkDuplicateBarcode($scope.barcode)
- .then(function (state) { $scope.duplicate_barcode = state });
- }
+ itemSvc.checkDuplicateBarcode($scope.barcode, $scope.copy.id())
+ .then(function (state) { $scope.copy.duplicate_barcode = $scope.duplicate_barcode = state });
} else {
- $scope.empty_barcode = true;
+ $scope.copy.empty_barcode = $scope.empty_barcode = true;
}
$scope.copy.barcode($scope.barcode);
controller : ['$scope','itemSvc','egCore',
function ( $scope , itemSvc , egCore ) {
$scope.callNumber = $scope.copies[0].call_number();
+ if (!$scope.callNumber.label()) $scope.callNumber.emtpy_label = true;
$scope.empty_label = false;
$scope.empty_label_string = window.empty_label_string;
$scope.updateLabel = function () {
if ($scope.label == '') {
- $scope.empty_label = true;
+ $scope.callNumber.empty_label = $scope.empty_label = true;
} else {
- $scope.empty_label = false;
+ $scope.callNumber.empty_label = $scope.empty_label = false;
}
angular.forEach($scope.copies, function(cp) {
cp.call_number().label($scope.label);
$scope.workingGridDataProvider.refresh();
});
+ $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)
+ can_save = false;
+ }
+ );
+
+ $scope.can_save = can_save;
+ }
+
+ $scope.disableSave = function () {
+ check_saveable();
+ return !$scope.can_save;
+ }
+
$scope.focusNextFirst = function(prev_lib,prev_bc) {
var n;
var yep = false;