From 01f1b64f3f6baedbe012acc9bbb1195ba7f9b3f2 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Thu, 29 Jun 2017 17:57:28 -0400 Subject: [PATCH] webstaff: fix MARC editor focus-moving when using in-place-mode Signed-off-by: Galen Charlton --- .../js/ui/default/staff/cat/services/marcedit.js | 26 ++++++++++++++-------- 1 file changed, 17 insertions(+), 9 deletions(-) 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 e3749baf92..44d02592f7 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 @@ -688,6 +688,7 @@ angular.module('egMarcMod', ['egCoreMod', 'ui.bootstrap']) $scope.$watch('stackSubfields.enabled', function (newVal, oldVal) { if (newVal != oldVal) egCore.hatch.setItem('cat.marcedit.stack_subfields', newVal); }); + $scope.caretRecId = $scope.recordId; egTagTable.loadTagTable({ marcRecordType : $scope.record_type }); @@ -726,7 +727,7 @@ angular.module('egMarcMod', ['egCoreMod', 'ui.bootstrap']) new_field_index++; } - $scope.current_event_target = 'r' + $scope.recordId + + $scope.current_event_target = 'r' + $scope.caretRecId + 'f' + new_field_index + 'tag'; $scope.current_event_target_cursor_pos = 0; @@ -750,7 +751,7 @@ angular.module('egMarcMod', ['egCoreMod', 'ui.bootstrap']) domnode.scope().$destroy(); domnode.remove(); - $scope.current_event_target = 'r' + $scope.recordId + + $scope.current_event_target = 'r' + $scope.caretRecId + 'f' + del_field + 'tag'; $scope.current_event_target_cursor_pos = 0; @@ -854,7 +855,7 @@ angular.module('egMarcMod', ['egCoreMod', 'ui.bootstrap']) new_sf = index_sf; } - $scope.current_event_target = 'r' + $scope.recordId + + $scope.current_event_target = 'r' + $scope.caretRecId + 'f' + event.data.scope.field.position + 's' + new_sf + 'code'; @@ -905,11 +906,11 @@ angular.module('egMarcMod', ['egCoreMod', 'ui.bootstrap']) ); if (!event.data.scope.field.subfields[sf]) { - $scope.current_event_target = 'r' + $scope.recordId + + $scope.current_event_target = 'r' + $scope.caretRecId + 'f' + event.data.scope.field.position + 'tag'; } else { - $scope.current_event_target = 'r' + $scope.recordId + + $scope.current_event_target = 'r' + $scope.caretRecId + 'f' + event.data.scope.field.position + 's' + sf + 'value'; } @@ -951,7 +952,7 @@ angular.module('egMarcMod', ['egCoreMod', 'ui.bootstrap']) field_obj ); - $scope.current_event_target = 'r' + $scope.recordId + + $scope.current_event_target = 'r' + $scope.caretRecId + 'f' + index_field + 'tag'; $scope.current_event_target_cursor_pos = 0; @@ -965,7 +966,7 @@ angular.module('egMarcMod', ['egCoreMod', 'ui.bootstrap']) $timeout(function(){ $scope.current_event_target_cursor_pos = 0; $scope.current_event_target_cursor_pos_end = 0; - $scope.current_event_target = 'r' + $scope.recordId + + $scope.current_event_target = 'r' + $scope.caretRecId + 'f' + (event.data.scope.field.position - 1) + 'tag'; }).then(setCaret); @@ -1004,7 +1005,7 @@ angular.module('egMarcMod', ['egCoreMod', 'ui.bootstrap']) field_obj ); - $scope.current_event_target = 'r' + $scope.recordId + + $scope.current_event_target = 'r' + $scope.caretRecId + 'f' + new_field + 'tag'; $scope.current_event_target_cursor_pos = 0; @@ -1018,7 +1019,7 @@ angular.module('egMarcMod', ['egCoreMod', 'ui.bootstrap']) $timeout(function(){ $scope.current_event_target_cursor_pos = 0; $scope.current_event_target_cursor_pos_end = 0; - $scope.current_event_target = 'r' + $scope.recordId + + $scope.current_event_target = 'r' + $scope.caretRecId + 'f' + (event.data.scope.field.position + 1) + 'tag'; }).then(setCaret); @@ -1091,6 +1092,12 @@ angular.module('egMarcMod', ['egCoreMod', 'ui.bootstrap']) $scope.in_redo = true; $scope[$scope.record_type] = rec; $scope.record = new MARC21.Record({ marcxml : $scope.Record().marc() }); + if (!$scope.recordId) { + var sf901c = $scope.record.subfield('901', 'c'); + if (sf901c !== null) { + $scope.caretRecId = sf901c[1]; + } + } $scope.calculated_record_type = $scope.record.recordType(); $scope.controlfields = $scope.record.fields.filter(function(f){ return f.isControlfield() }); $scope.datafields = $scope.record.fields.filter(function(f){ return !f.isControlfield() }); @@ -1324,6 +1331,7 @@ angular.module('egMarcMod', ['egCoreMod', 'ui.bootstrap']) $scope.Record() ).then(function(bre) { $scope.recordId = bre.id(); + $scope.caretRecId = $scope.recordId; if ($scope.enable_fast_add) { egCore.net.request( 'open-ils.actor', -- 2.11.0