<eg-embed-frame save-space="300" frame="opac_iframe" url="catalog_url" handlers="handlers" onchange="handle_page"></eg-embed-frame>
</div>
<div ng-show="record_tab == 'marc_edit'">
- <eg-marc-edit-record dirty-flag="stop_unload" record-id="record_id"/>
+ <eg-marc-edit-record on-save="refresh_record_callback" dirty-flag="stop_unload" record-id="record_id"/>
</div>
<!-- ng-if the remaining tabs so they can be instantiated on demand -->
<div ng-if="record_tab == 'marc_html'">
// 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;
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) {
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
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;
});
}
+ 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());
}
});
}
- }).then(loadRecord);
+ }).then(loadRecord).then(processOnSaveCallbacks);
} else {
$scope.Record().creator(egCore.auth.user().id());
$scope.Record().create_date('now');
}
});
}
- }).then(loadRecord);
+ }).then(loadRecord).then(processOnSaveCallbacks);
}