Skip to content

Commit 4b0fca0

Browse files
authored
Merge pull request #13448 from SORMAS-Foundation/13441-therapy-form-filter-issue
Therapy form filter issue fix
2 parents 243370d + e7dd3ef commit 4b0fca0

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

sormas-ui/src/main/java/de/symeda/sormas/ui/therapy/TherapyForm.java

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,9 @@ public class TherapyForm extends AbstractEditForm<TherapyDto> {
112112
private TextField prescriptionTextFilter;
113113
private ComboBox treatmentTypeFilter;
114114
private TextField treatmentTextFilter;
115-
protected boolean applyingCriteria;
115+
// To avoid form going infinite loop, need two different flags to track whether the criteria are being applied or not
116+
protected boolean prescriptionApplyingCriteria;
117+
protected boolean treatmentApplyingCriteria;
116118

117119
public TherapyForm(CaseDataDto caze, Disease disease, boolean isPseudonymized, boolean inJurisdiction, boolean isEditAllowed) {
118120

@@ -285,9 +287,9 @@ public void run() {
285287
prescriptionTypeFilter.addItems((Object[]) TreatmentType.values());
286288
prescriptionTypeFilter.addValueChangeListener(e -> {
287289
prescriptionCriteria.prescriptionType(((TreatmentType) e.getProperty().getValue()));
288-
ControllerProvider.getTherapyController().navigateTo(applyingCriteria, true, prescriptionCriteria);
290+
ControllerProvider.getTherapyController().navigateTo(prescriptionApplyingCriteria, true, prescriptionCriteria);
289291

290-
applyingCriteria = false;
292+
prescriptionApplyingCriteria = false;
291293
});
292294
filterRow.addComponent(prescriptionTypeFilter);
293295

@@ -363,8 +365,9 @@ public void run() {
363365
treatmentTypeFilter.addItems((Object[]) TreatmentType.values());
364366
treatmentTypeFilter.addValueChangeListener(e -> {
365367
treatmentCriteria.treatmentType(((TreatmentType) e.getProperty().getValue()));
366-
ControllerProvider.getTherapyController().navigateTo(applyingCriteria, true, treatmentCriteria);
367-
applyingCriteria = false;
368+
ControllerProvider.getTherapyController().navigateTo(treatmentApplyingCriteria, true, treatmentCriteria);
369+
370+
treatmentApplyingCriteria = false;
368371
});
369372
filterRow.addComponent(treatmentTypeFilter);
370373

@@ -394,14 +397,16 @@ private void update(CaseDataDto caze) {
394397
prescriptionCriteria.therapy(caze.getTherapy().toReference());
395398
treatmentCriteria.therapy(caze.getTherapy().toReference());
396399

397-
applyingCriteria = true;
400+
prescriptionApplyingCriteria = true;
398401

399402
prescriptionTypeFilter.setValue(prescriptionCriteria.getPrescriptionType());
400403
prescriptionTextFilter.setValue(prescriptionCriteria.getTextFilter());
404+
treatmentApplyingCriteria = true;
401405
treatmentTypeFilter.setValue(treatmentCriteria.getTreatmentType());
402406
treatmentTextFilter.setValue(treatmentCriteria.getTextFilter());
403407

404-
applyingCriteria = false;
408+
prescriptionApplyingCriteria = false;
409+
treatmentApplyingCriteria = false;
405410
}
406411

407412
public void reloadPrescriptionGrid() {

0 commit comments

Comments
 (0)