From a771197f17e69aee7e6cf75908123903813ac2bd Mon Sep 17 00:00:00 2001 From: Mike Rylander Date: Wed, 1 Apr 2015 12:02:57 -0400 Subject: [PATCH] webstaff: Propagate undo changes into FFs Signed-off-by: Mike Rylander Signed-off-by: Galen Charlton Signed-off-by: Jason Stephenson --- .../ui/default/staff/cat/services/marcedit.js | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) 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 3267af80aa..c114dd8141 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 @@ -140,6 +140,8 @@ angular.module('egMarcMod', ['egCoreMod', 'ui.bootstrap']) $scope.me = null; $scope.content = null; // this is where context menus dump their values $scope.item_container = []; + $scope.in_handler = false; + $scope.ready = false; $scope.$watch('content', function (newVal, oldVal) { var input = $($element).find('input'); @@ -148,25 +150,44 @@ angular.module('egMarcMod', ['egCoreMod', 'ui.bootstrap']) }); $scope.$watch('record.ready', function (newVal, oldVal) { // wait for the record to be loaded - if (newVal) { + if (newVal && !$scope.ready) { $scope.rtype = $scope.record.recordType(); + egTagTable.fetchFFPosTable( $scope.rtype ).then(function (ff_list) { angular.forEach(ff_list, function (ff) { if (!$scope.me) { if (ff.fixed_field == $scope.fixedField && ff.rec_type == $scope.rtype) { $scope.me = ff; + $scope.ready = true; $($element).children().css({ display : 'inline' }); var input = $($element).find('input'); input.attr('maxlength', $scope.me.length); input.val($scope.record.extractFixedField($scope.me.fixed_field)); input.on('keyup', function(e) { + $scope.in_handler = true; $scope.record.setFixedField($scope.me.fixed_field, input.val()); try { $scope.$parent.$digest(); } catch(e) {}; }); } } }); + return $scope.me; + }).then(function (me) { + if (me) { + $scope.$watch( + function() { + return $scope.record.extractFixedField($scope.fixedField); + }, + function (newVal, oldVal) { + if ($scope.in_handler) { + $scope.in_handler = false; + } else if (oldVal != newVal) { + $($element).find('input').val(newVal); + } + } + ); + } }).then(function () { return egTagTable.fetchFFValueTable( $scope.rtype ); }).then(function (vlist) { -- 2.43.2