Skip to content

Commit

Permalink
#183 added the new request features
Browse files Browse the repository at this point in the history
  • Loading branch information
Anthony4m committed Jan 21, 2025
1 parent 42b8734 commit b70b500
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import de.symeda.sormas.api.i18n.I18nProperties;

public enum ResponseStatus {
NOT_STARTED,
// NOT_STARTED,
ON_GOING,
COMPLETED;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,13 @@ public class EbsAlertDataForm extends AbstractEditForm<EbsAlertDto> {

private final EbsDto ebs;
private final Class<? extends EntityDto> parentClass;

NullableOptionGroup actionInitiated;
OptionGroup responseStatus;
TextArea detailsResponse;
NullableOptionGroup alertIssued;
DateField alertDate;
DateField responseDate;
TextArea details_alert_issued;
private static final String HTML_LAYOUT = fluidRowLocs(EbsAlertDto.ALERT_ISSUED, EbsAlertDto.ALERT_DATE)
+ fluidRowLocs(EbsAlertDto.DETAILS_ALERT_USED)
+ fluidRowLocs(EbsAlertDto.ACTION_INITIATED)
Expand Down Expand Up @@ -68,39 +74,75 @@ protected void addFields() {
return;
}

addField(EbsAlertDto.ACTION_INITIATED, NullableOptionGroup.class);
addField(EbsAlertDto.RESPONSE_STATUS, OptionGroup.class);
addField(EbsAlertDto.DETAILS_RESPONSE_ACTIVITIES, TextArea.class);
addField(EbsAlertDto.ALERT_ISSUED, NullableOptionGroup.class);
addField(EbsAlertDto.ALERT_DATE, DateField.class);
addField(EbsAlertDto.RESPONSE_DATE, DateField.class);
addField(EbsAlertDto.DETAILS_ALERT_USED, TextArea.class);
actionInitiated = addField(EbsAlertDto.ACTION_INITIATED, NullableOptionGroup.class);
responseStatus = addField(EbsAlertDto.RESPONSE_STATUS, OptionGroup.class);
detailsResponse = addField(EbsAlertDto.DETAILS_RESPONSE_ACTIVITIES, TextArea.class);
alertIssued = addField(EbsAlertDto.ALERT_ISSUED, NullableOptionGroup.class);
alertDate = addField(EbsAlertDto.ALERT_DATE, DateField.class);
responseDate = addField(EbsAlertDto.RESPONSE_DATE, DateField.class);
details_alert_issued = addField(EbsAlertDto.DETAILS_ALERT_USED, TextArea.class);

FieldHelper.setVisibleWhen(
getFieldGroup(),
Arrays.asList(EbsAlertDto.DETAILS_ALERT_USED, EbsAlertDto.ALERT_DATE),
Arrays.asList(EbsAlertDto.ALERT_DATE,EbsAlertDto.ACTION_INITIATED),
EbsAlertDto.ALERT_ISSUED,
Arrays.asList(YesNo.YES),
true);

FieldHelper.setVisibleWhen(
getFieldGroup(),
Arrays.asList(EbsAlertDto.DETAILS_ALERT_USED),
EbsAlertDto.ALERT_ISSUED,
Arrays.asList(YesNo.NO,YesNo.YES),
true);
FieldHelper.setVisibleWhen(
getFieldGroup(),
Arrays.asList(EbsAlertDto.RESPONSE_STATUS,EbsAlertDto.DETAILS_RESPONSE_ACTIVITIES),
EbsAlertDto.ACTION_INITIATED,
Arrays.asList(YesNo.YES),
true);
FieldHelper.setVisibleWhen(
getFieldGroup(),
Arrays.asList(EbsAlertDto.RESPONSE_DATE),
EbsAlertDto.RESPONSE_STATUS,
Arrays.asList(ResponseStatus.COMPLETED),
true);

FieldHelper.setRequiredWhen(
getFieldGroup(),
Arrays.asList(EbsAlertDto.DETAILS_ALERT_USED, EbsAlertDto.ALERT_DATE),
Collections.singletonList(EbsAlertDto.ALERT_ISSUED),
Arrays.asList(YesNo.YES));
alertIssued.addValueChangeListener(event -> {
if (alertIssued.getValue() != null && alertIssued.getValue().equals(YesNo.YES)) {
details_alert_issued.setRequired(true);
alertDate.setRequired(true);
actionInitiated.setRequired(true);
}else {
details_alert_issued.setRequired(false);
alertDate.setRequired(false);
actionInitiated.setRequired(false);
}
});
alertIssued.addValueChangeListener(event -> {
if (alertIssued.getValue() != null && alertIssued.getValue().equals(YesNo.NO)) {
details_alert_issued.setRequired(true);
}
});

actionInitiated.addValueChangeListener(event -> {
if (actionInitiated.getValue() != null && actionInitiated.getValue().equals(YesNo.YES)) {
detailsResponse.setRequired(true);
responseStatus.setRequired(true);
}else{
detailsResponse.setRequired(false);
responseStatus.setRequired(false);
}
});
responseStatus.addValueChangeListener(event -> {
if (responseStatus.getValue() != null && responseStatus.getValue().equals(ResponseStatus.COMPLETED)) {
responseDate.setRequired(true);
}else {
responseDate.setRequired(false);
}
});

setRequired(
true,
EbsAlertDto.ACTION_INITIATED,
EbsAlertDto.RESPONSE_STATUS,
EbsAlertDto.ALERT_ISSUED,
EbsAlertDto.DETAILS_RESPONSE_ACTIVITIES);
true,
EbsAlertDto.ALERT_ISSUED);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ public CommitDiscardWrapperComponent<EbsDataForm> getEbsCreateComponent() {

final CommitDiscardWrapperComponent<EbsDataForm> component =
new CommitDiscardWrapperComponent<>(form, UserProvider.getCurrent().hasAllUserRights(), form.getFieldGroup());
component.getDiscardButton().setCaption(Captions.actionCancel);
component.getDiscardButton().setCaption(I18nProperties.getCaption(Captions.actionCancel));
component.addCommitListener(() -> {
if (!form.getFieldGroup().isModified()) {
EbsDto newEvent = form.getValue();
Expand All @@ -191,7 +191,7 @@ public CommitDiscardWrapperComponent<TriagingDataForm> getEbsCreateTriagingCompo

final CommitDiscardWrapperComponent<TriagingDataForm> editView =
new CommitDiscardWrapperComponent<TriagingDataForm>(triagingDataForm, triagingDataForm.getFieldGroup());
editView.getDiscardButton().setCaption(Captions.actionCancel);
editView.getDiscardButton().setCaption(I18nProperties.getCaption(Captions.actionCancel));
editView.addCommitListener(() -> {
ebs.setTriaging(triagingDataForm.getValue());
FacadeProvider.getEbsFacade().save(ebs);
Expand All @@ -210,7 +210,7 @@ public CommitDiscardWrapperComponent<SignalVerificationDataForm> getEbsCreateSig
signalVerificationDataForm.setValue(ebs.getSignalVerification());
final CommitDiscardWrapperComponent<SignalVerificationDataForm> editView =
new CommitDiscardWrapperComponent<SignalVerificationDataForm>(signalVerificationDataForm, signalVerificationDataForm.getFieldGroup());
editView.getDiscardButton().setCaption(Captions.actionCancel);
editView.getDiscardButton().setCaption(I18nProperties.getCaption(Captions.actionCancel));
editView.addCommitListener(() -> {
ebs.setSignalVerification(signalVerificationDataForm.getValue());
callDeathCount(signalVerificationDataForm);
Expand Down Expand Up @@ -242,7 +242,7 @@ public CommitDiscardWrapperComponent<RiskAssessmentDataForm> getEbsCreateRiskAss
riskAssessmentDataForm.setValue(riskAssessmentDto);
final CommitDiscardWrapperComponent<RiskAssessmentDataForm> editView =
new CommitDiscardWrapperComponent<RiskAssessmentDataForm>(riskAssessmentDataForm, riskAssessmentDataForm.getFieldGroup());
editView.getDiscardButton().setCaption(Captions.actionCancel);
editView.getDiscardButton().setCaption(I18nProperties.getCaption(Captions.actionCancel));
editView.addCommitListener(() -> {
ebs.setRiskAssessment(riskAssessmentDataForm.getValue());
riskAssessmentDto.setRiskAssessment(riskAssessmentDataForm.getValue().getRiskAssessment());
Expand Down Expand Up @@ -375,7 +375,7 @@ public CommitDiscardWrapperComponent<EbsAlertDataForm> getEbsCreateAlertComponen
alertDataForm.setValue(ebsAlertDto);
final CommitDiscardWrapperComponent<EbsAlertDataForm> editView =
new CommitDiscardWrapperComponent<EbsAlertDataForm>(alertDataForm, alertDataForm.getFieldGroup());
editView.getDiscardButton().setCaption(Captions.actionCancel);
editView.getDiscardButton().setCaption(I18nProperties.getCaption(Captions.actionCancel));
editView.addCommitListener(() -> {
ebs.setAlert(alertDataForm.getValue());
ebsAlertDto.setAlertIssued(alertDataForm.getValue().getAlertIssued());
Expand Down Expand Up @@ -493,7 +493,7 @@ public CommitDiscardWrapperComponent<EbsDataForm> getEbsDataEditComponent(final
ControllerProvider.getArchiveController()
.addArchivingButton(event, ArchiveHandlers.forEbs(), editView, () -> navigateToData(uuid));
}
editView.getDiscardButton().setCaption(Captions.actionCancel);
editView.getDiscardButton().setCaption(I18nProperties.getCaption(Captions.actionCancel));

return editView;
}
Expand All @@ -508,7 +508,7 @@ public CommitDiscardWrapperComponent<RiskAssessmentDataForm> getRiskAssessmented
riskAssessmentDataForm.setValue(riskAssessmentDto);
final CommitDiscardWrapperComponent<RiskAssessmentDataForm> editView =
new CommitDiscardWrapperComponent<RiskAssessmentDataForm>(riskAssessmentDataForm, riskAssessmentDataForm.getFieldGroup());
editView.getDiscardButton().setCaption(Captions.actionCancel);
editView.getDiscardButton().setCaption(I18nProperties.getCaption(Captions.actionCancel));
editView.addCommitListener(() -> {
ebs.setRiskAssessment(riskAssessmentDataForm.getValue());
riskAssessmentDto.setRiskAssessment(riskAssessmentDataForm.getValue().getRiskAssessment());
Expand All @@ -534,7 +534,7 @@ public CommitDiscardWrapperComponent<EbsAlertDataForm> getEbsCreateAlertEditComp
alertDataForm.setValue(ebsAlertDto);
final CommitDiscardWrapperComponent<EbsAlertDataForm> editView =
new CommitDiscardWrapperComponent<EbsAlertDataForm>(alertDataForm, alertDataForm.getFieldGroup());
editView.getDiscardButton().setCaption(Captions.actionCancel);
editView.getDiscardButton().setCaption(I18nProperties.getCaption(Captions.actionCancel));
editView.addCommitListener(() -> {
ebs.setAlert(alertDataForm.getValue());
ebsAlertDto.setAlertIssued(alertDataForm.getValue().getAlertIssued());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,9 @@ protected void addFields() {
EbsDto.DESCRIPTION_OCCURRENCE,
EbsDto.PERSON_DESIGNATION,
EbsDto.PERSON_REGISTERING,
EbsDto.PERSON_PHONE);
EbsDto.PERSON_PHONE,
EbsDto.OTHER_INFORMANT,
EbsDto.OTHER);

FieldHelper.setVisibleWhen(
getFieldGroup(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import de.symeda.sormas.ui.utils.NullableOptionGroup;
import de.symeda.sormas.ui.utils.NumberNumericValueValidator;

;
;import javax.enterprise.inject.New;

public class SignalVerificationDataForm extends AbstractEditForm<SignalVerificationDto> {

Expand Down Expand Up @@ -372,7 +372,11 @@ public void validateSignalVerificationDateOfOccurrence(EbsDto selectedEbs) {
}

private Date clearTime(Date date) {
assert date != null;
Calendar calendar = Calendar.getInstance();
if (date == null) {
date = new Date();
}
calendar.setTime(date);
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
Expand Down

0 comments on commit b70b500

Please sign in to comment.