s.ADD_007 = "[% l('Add 007') %]";
s.ADD_REPLACE_008 = "[% l('Add/Replace 008') %]";
s.DELETE_FIELD = "[% l('Delete field') %]";
+ s.CONFIRM_DELETE_RECORD = "[% l('Delete Record') %]";
+ s.CONFIRM_DELETE_BRE_MSG = "[% l('Are you sure you want to delete title record [_1] from the catalog?', '{{id}}') %]";
+ s.CONFIRM_DELETE_ARE_MSG = "[% l('Are you sure you want to delete authority record [_1] from the catalog?', '{{id}}') %]";
+ s.ALERT_DELETE_FAILED = "[% l('Could not delete record [_1]: [_2]', '{{id}}', '{{desc}}') %]";
}]);
</script>
});
},
- controller : ['$timeout','$scope','$q','$window','egCore', 'egTagTable',
- function ( $timeout , $scope , $q, $window , egCore , egTagTable ) {
+ controller : ['$timeout','$scope','$q','$window','egCore', 'egTagTable','egConfirmDialog','egAlertDialog',
+ function ( $timeout , $scope , $q, $window , egCore , egTagTable , egConfirmDialog , egAlertDialog ) {
$scope.onSaveCallback = $scope.onSave;
};
$scope.deleteRecord = function () {
- $scope.Record().deleted(true);
- return $scope.saveRecord();
+ egConfirmDialog.open(
+ egCore.strings.CONFIRM_DELETE_RECORD,
+ (($scope.record_type == 'bre') ?
+ egCore.strings.CONFIRM_DELETE_BRE_MSG :
+ egCore.strings.CONFIRM_DELETE_ARE_MSG),
+ { id : $scope.recordId }
+ ).result.then(function() {
+ if ($scope.record_type == 'bre') {
+ egCore.net.request(
+ 'open-ils.cat',
+ 'open-ils.cat.biblio.record_entry.delete',
+ egCore.auth.token(), $scope.recordId
+ ).then(function(resp) {
+ var evt = egCore.evt.parse(resp);
+ if (evt) {
+ return egAlertDialog.open(
+ egCore.strings.ALERT_DELETE_FAILED,
+ { id : $scope.recordId, desc : evt.desc }
+ );
+ } else {
+ loadRecord().then(processOnSaveCallbacks);
+ }
+ });
+ } else {
+ $scope.Record().deleted(true);
+ return $scope.saveRecord();
+ }
+ });
};
$scope.undeleteRecord = function () {