From 2e31e0d8114acb6ef92f69dbe8ac4d407ebea847 Mon Sep 17 00:00:00 2001 From: Tony Valle <79843014+superskip@users.noreply.github.com> Date: Fri, 10 May 2024 11:54:25 +0200 Subject: [PATCH] fix: [DHIS2-17301] prevent adding event to program stage bug (#1927) --- 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 {