[open-ils-commits] [GIT] Evergreen ILS branch master updated. 98c12d63805d669e328964f019bbd368f51adf1c
Evergreen Git
git at git.evergreen-ils.org
Wed May 22 17:10:45 EDT 2019
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Evergreen ILS".
The branch, master has been updated
via 98c12d63805d669e328964f019bbd368f51adf1c (commit)
via e84ec5ebe830a40acd4a9aa60d3efde2abb784b5 (commit)
from 4dad632c989a1012aae371bd9acb92d63a7832a7 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 98c12d63805d669e328964f019bbd368f51adf1c
Author: Bill Erickson <berickxx at gmail.com>
Date: Fri Mar 15 11:29:07 2019 -0400
LP1693580 Authority create/update API repairs
Fixes issues with the authority record create and update open-ils.cat
API calls, where internal function calls were not passed the correct
values.
Signed-off-by: Bill Erickson <berickxx at gmail.com>
Signed-off-by: Dan Pearl <dpearl at cwmars.org>
diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Cat/Authority.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Cat/Authority.pm
index 717bcb4f44..66c6c4a9eb 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Cat/Authority.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Cat/Authority.pm
@@ -32,7 +32,8 @@ sub import_authority_record {
my $e = new_editor(authtoken=>$auth, xact=>1);
return $e->die_event unless $e->checkauth;
return $e->die_event unless $e->allowed('CREATE_AUTHORITY_RECORD');
- my $rec = OpenILS::Application::Cat::AuthCommon->import_authority_record($marc_xml, $source);
+ my $rec = OpenILS::Application::Cat::AuthCommon->
+ import_authority_record($e, $marc_xml, $source);
$e->commit unless $U->event_code($rec);
return $rec;
}
@@ -129,10 +130,10 @@ sub overlay_authority_record {
my $e = new_editor(authtoken=>$auth, xact=>1);
return $e->die_event unless $e->checkauth;
return $e->die_event unless $e->allowed('UPDATE_AUTHORITY_RECORD');
- my $rec = OpenILS::Application::Cat::AuthCommon->overlay_authority_record($rec_id, $marc_xml, $source);
+ my $rec = OpenILS::Application::Cat::AuthCommon->
+ overlay_authority_record($e, $rec_id, $marc_xml, $source);
$e->commit unless $U->event_code($rec);
return $rec;
-
}
__PACKAGE__->register_method(
commit e84ec5ebe830a40acd4a9aa60d3efde2abb784b5
Author: Bill Erickson <berickxx at gmail.com>
Date: Fri Mar 15 11:29:59 2019 -0400
LP1693580 Marc editor notify and API changes
1. Indicate in the interface when a bib/auth MARC record edit failed or
succeeded.
2. Handle permission failures on MARC edit by displaying the permission
override dialog.
Signed-off-by: Bill Erickson <berickxx at gmail.com>
Signed-off-by: Dan Pearl <dpearl at cwmars.org>
diff --git a/Open-ILS/src/templates/staff/cat/share/marcedit_strings.tt2 b/Open-ILS/src/templates/staff/cat/share/marcedit_strings.tt2
index 8067b96924..295078c534 100644
--- a/Open-ILS/src/templates/staff/cat/share/marcedit_strings.tt2
+++ b/Open-ILS/src/templates/staff/cat/share/marcedit_strings.tt2
@@ -13,5 +13,9 @@ angular.module('egCoreMod').run(['egStrings', function(s) {
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}}') %]";
s.DIRTY_MARC_WARNING = "[% l('There is unsaved data in this record.') %]"
+ s.MARC_ALERT_CREATE_SUCCESS = "[% l('Successfully created new record') %]";
+ s.MARC_ALERT_CREATE_FAILED = "[% l('Failed to create new record: [_1]', '{{error}}') %]";
+ s.MARC_ALERT_UPDATE_SUCCESS = "[% l('Successfully updated record') %]";
+ s.MARC_ALERT_UPDATE_FAILED = "[% l('Failed to update record: [_1]', '{{error}}') %]";
}]);
</script>
diff --git a/Open-ILS/web/js/ui/default/staff/cat/services/marcedit.js b/Open-ILS/web/js/ui/default/staff/cat/services/marcedit.js
index c41b1d5b37..71cf44ba52 100644
--- a/Open-ILS/web/js/ui/default/staff/cat/services/marcedit.js
+++ b/Open-ILS/web/js/ui/default/staff/cat/services/marcedit.js
@@ -696,8 +696,10 @@ angular.module('egMarcMod', ['egCoreMod', 'ui.bootstrap'])
});
},
- controller : ['$timeout','$scope','$q','$window','egCore', 'egTagTable','egConfirmDialog','egAlertDialog',
- function ( $timeout , $scope , $q, $window , egCore , egTagTable , egConfirmDialog , egAlertDialog ) {
+ controller : ['$timeout','$scope','$q','$window','egCore', 'egTagTable',
+ 'egConfirmDialog','egAlertDialog','ngToast','egStrings',
+ function ( $timeout , $scope , $q, $window , egCore , egTagTable ,
+ egConfirmDialog , egAlertDialog , ngToast , egStrings) {
$scope.onSaveCallback = $scope.onSave;
@@ -1384,6 +1386,69 @@ angular.module('egMarcMod', ['egCoreMod', 'ui.bootstrap'])
return deferred.resolve($scope.recordId)
};
+ // Returns a promise
+ function createOrUpdateRecord() {
+
+ var promise;
+ if ($scope.recordId) {
+
+ var method = $scope.record_type === 'bre' ?
+ 'open-ils.cat.biblio.record.marc.replace' :
+ 'open-ils.cat.authority.record.overlay';
+
+ promise = egCore.net.request(
+ 'open-ils.cat', method,
+ egCore.auth.token(), $scope.recordId,
+ $scope.Record().marc(), $scope.Record().source()
+ );
+
+ } else {
+
+ var method = $scope.record_type === 'bre' ?
+ 'open-ils.cat.biblio.record.xml.create' :
+ 'open-ils.cat.authority.record.import';
+
+ promise = egCore.net.request(
+ 'open-ils.cat', method,
+ egCore.auth.token(),
+ $scope.Record().marc(),
+ $scope.Record().source()
+ );
+ }
+
+ return promise.then(handleCreateOrUpdateResult);
+ }
+
+ function handleCreateOrUpdateResult(result) {
+
+ var evt = egCore.evt.parse(result)
+ var mode = $scope.recordId ? 'update' : 'create';
+
+ if (evt) {
+ var msg = mode === 'update' ?
+ egStrings.MARC_ALERT_UPDATE_FAILED :
+ egStrings.MARC_ALERT_CREATE_FAILED;
+ ngToast.warning(msg, {error: '' + evt});
+ return $q.reject();
+ }
+
+ var msg = mode === 'update' ?
+ egStrings.MARC_ALERT_UPDATE_SUCCESS :
+ egStrings.MARC_ALERT_CREATE_SUCCESS;
+ ngToast.create(msg);
+
+ console.debug('MARC create/update returned', result);
+
+ // synchronize values
+ if (!$scope.recordId) {
+ $scope.recordId = $scope.caretRecId = result.id();
+ }
+
+ $scope.dirtyFlag = false;
+
+ return result;
+ }
+
$scope.saveRecord = function () {
if ($scope.inPlaceMode) {
@@ -1397,77 +1462,42 @@ angular.module('egMarcMod', ['egCoreMod', 'ui.bootstrap'])
}
$scope.mangle_005();
- $scope.Record().editor(egCore.auth.user().id());
- $scope.Record().edit_date('now');
$scope.record.pruneEmptyFieldsAndSubfields();
$scope.Record().marc($scope.record.toXmlString());
- if ($scope.recordId) {
- return egCore.pcrud.update(
- $scope.Record()
- ).then(function() { // success
+
+ var updating = Boolean($scope.recordId);
+ return createOrUpdateRecord().then(function(record) {
+
+ if (updating) {
$scope.save_stack_depth = $scope.record_undo_stack.length;
- $scope.dirtyFlag = false;
- if ($scope.enable_fast_add) {
- egCore.net.request(
- 'open-ils.actor',
- 'open-ils.actor.anon_cache.set_value',
- null, 'edit-these-copies', {
- record_id: $scope.recordId,
- raw: [{
- label : $scope.fast_item_callnumber,
- barcode : $scope.fast_item_barcode,
- fast_add : true
- }],
- hide_vols : false,
- hide_copies : false
- }
- ).then(function(key) {
- if (key) {
- var url = egCore.env.basePath + 'cat/volcopy/' + key;
- $timeout(function() { $window.open(url, '_blank') });
- } else {
- alert('Could not create anonymous cache key!');
- }
- });
- }
- }, function() { // failure
- alert('Could not save the record!');
- }).then(loadRecord).then(processOnSaveCallbacks);
- } else {
- $scope.Record().creator(egCore.auth.user().id());
- $scope.Record().create_date('now');
- return egCore.pcrud.create(
- $scope.Record()
- ).then(function(bre) {
- $scope.dirtyFlag = false;
- $scope.recordId = bre.id();
- $scope.caretRecId = $scope.recordId;
- if ($scope.enable_fast_add) {
- egCore.net.request(
- 'open-ils.actor',
- 'open-ils.actor.anon_cache.set_value',
- null, 'edit-these-copies', {
- record_id: $scope.recordId,
- raw: [{
- label : $scope.fast_item_callnumber,
- barcode : $scope.fast_item_barcode,
- }],
- hide_vols : false,
- hide_copies : false
- }
- ).then(function(key) {
- if (key) {
- var url = egCore.env.basePath + 'cat/volcopy/' + key;
- $timeout(function() { $window.open(url, '_blank') });
- } else {
- alert('Could not create anonymous cache key!');
- }
- });
- }
- }).then(loadRecord).then(processOnSaveCallbacks);
- }
+ }
+ if (!$scope.enable_fast_add) {
+ return record;
+ }
+ egCore.net.request(
+ 'open-ils.actor',
+ 'open-ils.actor.anon_cache.set_value',
+ null, 'edit-these-copies', {
+ record_id: $scope.recordId,
+ raw: [{
+ label : $scope.fast_item_callnumber,
+ barcode : $scope.fast_item_barcode,
+ fast_add : true
+ }],
+ hide_vols : false,
+ hide_copies : false
+ }
+ ).then(function(key) {
+ if (key) {
+ var url = egCore.env.basePath + 'cat/volcopy/' + key;
+ $timeout(function() { $window.open(url, '_blank') });
+ } else {
+ alert('Could not create anonymous cache key!');
+ }
+ });
+ }).then(loadRecord).then(processOnSaveCallbacks);
};
$scope.seeBreaker = function () {
-----------------------------------------------------------------------
Summary of changes:
.../lib/OpenILS/Application/Cat/Authority.pm | 7 +-
.../templates/staff/cat/share/marcedit_strings.tt2 | 4 +
.../js/ui/default/staff/cat/services/marcedit.js | 166 ++++++++++++---------
3 files changed, 106 insertions(+), 71 deletions(-)
hooks/post-receive
--
Evergreen ILS
More information about the open-ils-commits
mailing list