From: Mike Rylander Date: Tue, 15 Sep 2015 21:32:41 +0000 (-0400) Subject: webstaff: Provide hooks for on-save callback for marc edit to, for instance, refresh... X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=d4729caf23587a156de35b422a6bac609e3f4025;p=evergreen%2Fmasslnc.git webstaff: Provide hooks for on-save callback for marc edit to, for instance, refresh the record summary UI Signed-off-by: Mike Rylander --- diff --git a/Open-ILS/src/templates/staff/cat/catalog/t_catalog.tt2 b/Open-ILS/src/templates/staff/cat/catalog/t_catalog.tt2 index 62db3ca76c..8437ee832d 100644 --- a/Open-ILS/src/templates/staff/cat/catalog/t_catalog.tt2 +++ b/Open-ILS/src/templates/staff/cat/catalog/t_catalog.tt2 @@ -76,7 +76,7 @@
- +
diff --git a/Open-ILS/web/js/ui/default/staff/cat/catalog/app.js b/Open-ILS/web/js/ui/default/staff/cat/catalog/app.js index f60abf3130..80423a1cd4 100644 --- a/Open-ILS/web/js/ui/default/staff/cat/catalog/app.js +++ b/Open-ILS/web/js/ui/default/staff/cat/catalog/app.js @@ -233,6 +233,7 @@ function($scope , $routeParams , $location , $window , $q , egCore , egHolds , e // set record ID on page load if available... $scope.record_id = $routeParams.record_id; + $scope.summary_pane_record; if ($routeParams.record_id) $scope.from_route = true; else $scope.from_route = false; @@ -325,6 +326,20 @@ function($scope , $routeParams , $location , $window , $q , egCore , egHolds , e if ($scope.record_id) egCore.hatch.setLocalItem("eg.cat.last_record_retrieved", $scope.record_id); + $scope.refresh_record_callback = function (record_id) { + egCore.pcrud.retrieve('bre', record_id, { + flesh : 1, + flesh_fields : { + bre : ['simple_record','creator','editor'] + } + }).then(function(rec) { + rec.owner(egCore.org.get(rec.owner())); + $scope.summary_pane_record = rec; + }); + + return record_id; + } + // also set it when the iframe changes to a new record $scope.handle_page = function(url) { 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 26a1e6c7d5..d4686ebd77 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 @@ -521,6 +521,7 @@ angular.module('egMarcMod', ['egCoreMod', 'ui.bootstrap']) dirtyFlag : '=', recordId : '=', marcXml : '=', + onSave : '=', // in-place mode means that the editor is being // used just to munge some MARCXML client-side, rather // than to (immediately) update the database @@ -545,6 +546,11 @@ angular.module('egMarcMod', ['egCoreMod', 'ui.bootstrap']) controller : ['$timeout','$scope','$q','$window','egCore', 'egTagTable', function ( $timeout , $scope , $q, $window , egCore , egTagTable ) { + + $scope.onSaveCallback = $scope.onSave; + if (typeof $scope.onSaveCallback !== 'undefined' && !angular.isArray($scope.onSaveCallback)) + $scope.onSaveCallback = [ $scope.onSaveCallback ]; + MARC21.Record.delimiter = '$'; $scope.enable_fast_add = false; @@ -1074,10 +1080,23 @@ angular.module('egMarcMod', ['egCoreMod', 'ui.bootstrap']) }); } + processOnSaveCallbacks = function() { + var deferred = $q.defer(); + if (typeof $scope.onSaveCallback !== 'undefined') { + var promise = deferred.promise; + + angular.forEach($scope.onSaveCallback, function (f) { + if (angular.isFunction(f)) promise = promise.then(f); + }); + + } + return deferred.resolve($scope.recordId) + }; + $scope.saveRecord = function () { if ($scope.inPlaceMode) { $scope.marcXml = $scope.record.toXmlString(); - return; + return processOnSaveCallbacks(); } $scope.mangle_005(); $scope.Record().editor(egCore.auth.user().id()); @@ -1110,7 +1129,7 @@ angular.module('egMarcMod', ['egCoreMod', 'ui.bootstrap']) } }); } - }).then(loadRecord); + }).then(loadRecord).then(processOnSaveCallbacks); } else { $scope.Record().creator(egCore.auth.user().id()); $scope.Record().create_date('now'); @@ -1140,7 +1159,7 @@ angular.module('egMarcMod', ['egCoreMod', 'ui.bootstrap']) } }); } - }).then(loadRecord); + }).then(loadRecord).then(processOnSaveCallbacks); }