dirtyFlag : '=',
recordId : '=',
marcXml : '=',
+ bibSource : '=?',
onSave : '=',
// in-place mode means that the editor is being
// used just to munge some MARCXML client-side, rather
if (newVal != oldVal) egCore.hatch.setItem('cat.marcedit.flateditor', newVal);
});
+ // necessary to prevent ng-model scope hiding ugliness in egMarcEditBibSource:
+ $scope.bib_source = {
+ id : $scope.bibSource ? $scope.bibSource : null
+ };
$scope.brandNewRecord = false;
- $scope.bib_source = null;
$scope.record_type = $scope.recordType || 'bre';
$scope.max_undo = $scope.maxUndo || 100;
$scope.record_undo_stack = [];
$scope.dirtyFlag = false;
$scope.flat_text_marc = $scope.record.toBreaker();
- if ($scope.record_type == 'bre') {
- $scope.bib_source = $scope.Record().source();
+ if ($scope.record_type == 'bre' && !$scope.brandNewRecord) {
+ $scope.bib_source.id = $scope.bibSource = rec.source(); //$scope.Record().source();
}
}).then(function(){
};
$scope.saveRecord = function () {
+
if ($scope.inPlaceMode) {
$scope.marcXml = $scope.record.toXmlString();
+
+ if ($scope.record_type == 'bre'){
+ $scope.bibSource = $scope.bib_source.id;
+ }
+
return $timeout(processOnSaveCallbacks);
}
+
$scope.mangle_005();
$scope.Record().editor(egCore.auth.user().id());
$scope.Record().edit_date('now');
restrict: 'E',
replace: true,
template: '<span class="nullable">'+
- '<select class="form-control" ng-model="bib_source" ng-options="s.id() as s.source() for s in bib_sources | orderBy: \'source()\'">'+
+ '<select class="form-control" ng-model="bib_source.id" ng-options="s.id() as s.source() for s in bib_sources | orderBy: \'source()\'">'+
'<option value="">Select a Source</option>'+
'</select>'+
'</span>',
function ($scope , egCore) {
egCore.pcrud.retrieveAll('cbs', {}, {atomic : true})
- .then(function(list) { $scope.bib_sources = list; });
+ .then(function(list) {
+ $scope.bib_sources = list;
+ });
- $scope.$watch('bib_source',
+ $scope.$watch('bib_source.id',
function(newVal, oldVal) {
if (newVal !== oldVal) {
$scope.bre.source(newVal);
$scope.total_hits = 0;
+ var bib_sources = null;
+ egCore.pcrud.retrieveAll('cbs', {}, {atomic : true})
+ .then(function(l) { bib_sources = l; });
+
var provider = egGridDataProvider.instance({});
provider.get = function(offset, count) {
$scope.raw_search_impossible = function() {
return egZ3950TargetSvc.rawSearchImpossible();
}
+
+ $scope.get_bibsrc_name_from_id = function(bs_id){
+ // var sel_bib_src = bib_src.id ? bib_src.list.filter(s => s.id() == bib_src.id) : null;
+ // TODO can we use arrow syntax yet???
+ if (!bs_id) return null;
+ var cbs = bib_sources.filter(function(s){ return s.id() == bs_id });
+
+ return (cbs && cbs[0] ? cbs[0].source() : null);
+ };
+
$scope.showRawSearchForm = function() {
$uibModal.open({
templateUrl: './cat/z3950/t_raw_search',
return $scope._import(items[0]['marcxml']);
};
- $scope._import = function(marc_xml) {
+ $scope._import = function(marc_xml,bib_source) {
+
+ var bibsrc_name = $scope.get_bibsrc_name_from_id(bib_source);
+
var deferred = $q.defer();
egCore.net.request(
'open-ils.cat',
'open-ils.cat.biblio.record.xml.import',
egCore.auth.token(),
marc_xml,
- null, // FIXME bib source
+ bibsrc_name,
null,
null,
$scope.selectFieldStripGroups()
$scope.focusMe = true;
$scope.record_id = recId;
$scope.dirty_flag = false;
- $scope.marc_xml = items[0]['marcxml'];
+ $scope.args = {};
+ $scope.args.marc_xml = items[0]['marcxml'];
+ $scope.args.bib_source = null;
$scope.ok = function(args) { $uibModalInstance.close(args) }
$scope.cancel = function () { $uibModalInstance.dismiss() }
$scope.save_label = egCore.strings.IMPORT_BUTTON_LABEL;
// This timeout is required to allow angular to finish variable assignments
// in the marcediter app. Allowing marc_xml to propigate here.
$timeout( function() {
- _import($scope.marc_xml).then( function(record_obj) {
+ _import($scope.args.marc_xml, $scope.args.bib_source).then( function(record_obj) {
if( record_obj.id ) {
$scope.record_id = record_obj.id();
$scope.save_label = egCore.strings.SAVE_BUTTON_LABEL;
var overlay_target = $scope.local_overlay_target;
var live_overlay_target = egCore.hatch.getLocalItem('eg.cat.marked_overlay_record') || 0;
var args = {
- 'marc_xml' : items[0]['marcxml']
+ 'marc_xml' : items[0]['marcxml'],
+ 'bib_source' : null
};
+
$uibModal.open({
templateUrl: './cat/z3950/t_overlay',
backdrop: 'static',
}]
}).result.then(function (args) {
+ var bibsrc_name = $scope.get_bibsrc_name_from_id(args.bib_source);
egCore.net.request(
'open-ils.cat',
'open-ils.cat.biblio.record.marc.replace',
egCore.auth.token(),
overlay_target,
(args.overlay_target.merged ? args.overlay_target.marc_xml : args.marc_xml),
- null, // FIXME bib source
+ bibsrc_name,
null,
$scope.selectFieldStripGroups()
).then(