From baf15002195889c847f099de7d6fd077a0464d60 Mon Sep 17 00:00:00 2001 From: Tony Valle Date: Thu, 2 May 2024 15:09:32 +0200 Subject: [PATCH] fix: prevent adding event to program stage --- components/dataentry/dataentry-controller.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/components/dataentry/dataentry-controller.js b/components/dataentry/dataentry-controller.js index 7188327af..acdc57c80 100644 --- a/components/dataentry/dataentry-controller.js +++ b/components/dataentry/dataentry-controller.js @@ -330,20 +330,21 @@ trackerCapture.controller('DataEntryController', //Adds support for HIDEPROGRAMSTAGE even if no event exists in enrollment var processRegistrationRuleEffect = function(event, callerId){ + $scope.stagesNotShowingInStageTasks = {}; + angular.forEach($rootScope.ruleeffects[event], function(effect){ if (effect.action === "HIDEPROGRAMSTAGE") { if (effect.programStage) { - if($scope.stagesNotShowingInStageTasks[effect.programStage.id] !== effect.ineffect ) - { - $scope.stagesNotShowingInStageTasks[effect.programStage.id] = effect.ineffect; + if(effect.ineffect) { + $scope.stagesNotShowingInStageTasks[effect.programStage.id] = true; } - updateTabularEntryStages(); } else { $log.warn("ProgramRuleAction " + effect.id + " is of type HIDEPROGRAMSTAGE, bot does not have a stage defined"); } } }); + updateTabularEntryStages(); } var processRuleEffect = function(event, callerId){ @@ -378,7 +379,8 @@ trackerCapture.controller('DataEntryController', $scope.errorMessages[event] = []; $scope.hiddenFields[event] = []; $scope.mandatoryFields[event] = []; - $scope.optionVisibility[event] = { showOnly: null, hidden: {}};; + $scope.optionVisibility[event] = { showOnly: null, hidden: {}}; + $scope.stagesNotShowingInStageTasks = {}; var dataElementOptionsChanged = []; @@ -495,9 +497,8 @@ trackerCapture.controller('DataEntryController', } else if (effect.action === "HIDEPROGRAMSTAGE") { if (effect.programStage) { - if($scope.stagesNotShowingInStageTasks[effect.programStage.id] !== effect.ineffect ) - { - $scope.stagesNotShowingInStageTasks[effect.programStage.id] = effect.ineffect; + if(effect.ineffect) { + $scope.stagesNotShowingInStageTasks[effect.programStage.id] = true; } } else {