From d17aa5b825261cbaf1614fd7fcfbb86026fcd410 Mon Sep 17 00:00:00 2001 From: Cesar Velez Date: Thu, 29 Jun 2017 13:27:40 -0400 Subject: [PATCH] LP#1668314 - Webstaff make marcEditor's flateditor checkbox sticky Just followed the same pattern of using $watch and localstorage to store a boolean for FlatEditor checkbox. Made $scope.flatEditor be an object wrapping an isEnabled :bool to avoid *future* ng-if parent scope issues that could (potentially) occur. Signed-off by: Cesar Velez Signed-off-by: Josh Stompro Signed-off-by: Galen Charlton --- .../src/templates/staff/cat/share/t_marcedit.tt2 | 6 +++--- .../js/ui/default/staff/cat/services/marcedit.js | 14 ++++++++++++-- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/Open-ILS/src/templates/staff/cat/share/t_marcedit.tt2 b/Open-ILS/src/templates/staff/cat/share/t_marcedit.tt2 index d7ed391bc5..c9dfdbcbca 100644 --- a/Open-ILS/src/templates/staff/cat/share/t_marcedit.tt2 +++ b/Open-ILS/src/templates/staff/cat/share/t_marcedit.tt2 @@ -14,7 +14,7 @@
@@ -52,10 +52,10 @@
-
+
-
+
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 1e9460bb50..fb3a05a568 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 @@ -666,7 +666,17 @@ angular.module('egMarcMod', ['egCoreMod', 'ui.bootstrap']) $scope.enable_fast_add = false; $scope.fast_item_callnumber = ''; $scope.fast_item_barcode = ''; - $scope.flatEditor = $scope.flatOnly ? true : false; + + $scope.flatEditor = { isEnabled : $scope.flatOnly ? true : false }; + + egCore.hatch.getItem('cat.marcedit.flateditor').then(function(val) { + $scope.flatEditor.isEnabled = val; + }); + + $scope.$watch('flatEditor.isEnabled', function (newVal, oldVal) { + if (newVal != oldVal) egCore.hatch.setItem('cat.marcedit.flateditor', newVal); + }); + $scope.brandNewRecord = false; $scope.bib_source = null; $scope.record_type = $scope.recordType || 'bre'; @@ -696,7 +706,7 @@ angular.module('egMarcMod', ['egCoreMod', 'ui.bootstrap']) }; $scope.refreshVisual = function () { - if (!$scope.flatEditor) { + if (!$scope.flatEditor.isEnabled) { $scope.controlfields = $scope.record.fields.filter(function(f){ return f.isControlfield() }); $scope.datafields = $scope.record.fields.filter(function(f){ return !f.isControlfield() }); } -- 2.43.2