use of de.symeda.sormas.ui.utils.CommitDiscardWrapperComponent.CommitListener in project SORMAS-Project by hzi-braunschweig.
the class PreviousHospitalizationsField method editEntry.
@Override
protected void editEntry(PreviousHospitalizationDto entry, boolean create, Consumer<PreviousHospitalizationDto> commitCallback) {
if (create && entry.getUuid() == null) {
entry.setUuid(DataHelper.createUuid());
}
PreviousHospitalizationEditForm editForm = new PreviousHospitalizationEditForm(create, fieldVisibilityCheckers, fieldAccessCheckers);
editForm.setValue(entry);
final CommitDiscardWrapperComponent<PreviousHospitalizationEditForm> editView = new CommitDiscardWrapperComponent<PreviousHospitalizationEditForm>(editForm, UserProvider.getCurrent().hasUserRight(UserRight.CASE_EDIT), editForm.getFieldGroup());
editView.getCommitButton().setCaption(I18nProperties.getString(Strings.done));
Window popupWindow = VaadinUiUtil.showModalPopupWindow(editView, I18nProperties.getCaption(PreviousHospitalizationDto.I18N_PREFIX));
editView.addCommitListener(new CommitListener() {
@Override
public void onCommit() {
if (!editForm.getFieldGroup().isModified()) {
commitCallback.accept(editForm.getValue());
}
}
});
if (!isEmpty(entry)) {
editView.addDeleteListener(new DeleteListener() {
@Override
public void onDelete() {
popupWindow.close();
PreviousHospitalizationsField.this.removeEntry(entry);
}
}, I18nProperties.getCaption(PreviousHospitalizationDto.I18N_PREFIX));
}
}
use of de.symeda.sormas.ui.utils.CommitDiscardWrapperComponent.CommitListener in project SORMAS-Project by hzi-braunschweig.
the class TherapyController method openPrescriptionEditForm.
public void openPrescriptionEditForm(PrescriptionReferenceDto prescriptionReference, Runnable callback, boolean readOnly) {
PrescriptionDto prescription = FacadeProvider.getPrescriptionFacade().getPrescriptionByUuid(prescriptionReference.getUuid());
PrescriptionForm form = new PrescriptionForm(false, readOnly, prescription.isPseudonymized());
form.setValue(prescription);
final CommitDiscardWrapperComponent<PrescriptionForm> view = new CommitDiscardWrapperComponent<>(form, UserProvider.getCurrent().hasUserRight(UserRight.PRESCRIPTION_EDIT), form.getFieldGroup());
Window popupWindow = VaadinUiUtil.showModalPopupWindow(view, I18nProperties.getString(readOnly ? Strings.entityPrescription : Strings.headingEditPrescription));
view.addCommitListener(new CommitListener() {
@Override
public void onCommit() {
if (!form.getFieldGroup().isModified()) {
PrescriptionDto dto = form.getValue();
FacadeProvider.getPrescriptionFacade().savePrescription(dto);
popupWindow.close();
Notification.show(I18nProperties.getString(Strings.messagePrescriptionSaved), Type.TRAY_NOTIFICATION);
if (callback != null) {
callback.run();
}
}
}
});
view.addDiscardListener(() -> popupWindow.close());
if (UserProvider.getCurrent().hasUserRight(UserRight.PRESCRIPTION_DELETE)) {
view.addDeleteListener(new DeleteListener() {
@Override
public void onDelete() {
FacadeProvider.getPrescriptionFacade().deletePrescription(prescription.getUuid());
popupWindow.close();
if (callback != null) {
callback.run();
}
}
}, I18nProperties.getString(Strings.entityPrescription));
}
}
use of de.symeda.sormas.ui.utils.CommitDiscardWrapperComponent.CommitListener in project SORMAS-Project by hzi-braunschweig.
the class InfrastructureController method getDistrictEditComponent.
private CommitDiscardWrapperComponent<DistrictEditForm> getDistrictEditComponent(DistrictDto district) {
boolean isNew = district == null;
DistrictEditForm editForm = new DistrictEditForm(isNew);
if (isNew) {
district = DistrictDto.build();
}
editForm.setValue(district);
final CommitDiscardWrapperComponent<DistrictEditForm> editView = new CommitDiscardWrapperComponent<DistrictEditForm>(editForm, UserProvider.getCurrent().hasUserRight(isNew ? UserRight.INFRASTRUCTURE_CREATE : UserRight.INFRASTRUCTURE_EDIT), editForm.getFieldGroup());
editView.addCommitListener(new CommitListener() {
@Override
public void onCommit() {
FacadeProvider.getDistrictFacade().save(editForm.getValue());
Notification.show(I18nProperties.getString(Strings.messageEntryCreated), Type.ASSISTIVE_NOTIFICATION);
SormasUI.get().getNavigator().navigateTo(DistrictsView.VIEW_NAME);
}
});
if (!isNew) {
extendEditComponentWithArchiveButton(editView, district.isArchived(), district.getUuid(), InfrastructureType.DISTRICT, null);
}
return editView;
}
use of de.symeda.sormas.ui.utils.CommitDiscardWrapperComponent.CommitListener in project SORMAS-Project by hzi-braunschweig.
the class InfrastructureController method getCommunityEditComponent.
private CommitDiscardWrapperComponent<CommunityEditForm> getCommunityEditComponent(CommunityDto community) {
boolean isNew = community == null;
CommunityEditForm editForm = new CommunityEditForm(isNew);
if (isNew) {
community = CommunityDto.build();
}
editForm.setValue(community);
final CommitDiscardWrapperComponent<CommunityEditForm> editView = new CommitDiscardWrapperComponent<CommunityEditForm>(editForm, UserProvider.getCurrent().hasUserRight(isNew ? UserRight.INFRASTRUCTURE_CREATE : UserRight.INFRASTRUCTURE_EDIT), editForm.getFieldGroup());
editView.addCommitListener(new CommitListener() {
@Override
public void onCommit() {
FacadeProvider.getCommunityFacade().save(editForm.getValue());
Notification.show(I18nProperties.getString(Strings.messageEntryCreated), Type.ASSISTIVE_NOTIFICATION);
SormasUI.get().getNavigator().navigateTo(CommunitiesView.VIEW_NAME);
}
});
if (!isNew) {
extendEditComponentWithArchiveButton(editView, community.isArchived(), community.getUuid(), InfrastructureType.COMMUNITY, null);
}
return editView;
}
use of de.symeda.sormas.ui.utils.CommitDiscardWrapperComponent.CommitListener in project SORMAS-Project by hzi-braunschweig.
the class ClinicalCourseController method openClinicalVisitCreateForm.
public void openClinicalVisitCreateForm(ClinicalCourseReferenceDto clinicalCourse, String caseUuid, Runnable callback) {
CaseDataDto caze = FacadeProvider.getCaseFacade().getCaseDataByUuid(caseUuid);
ClinicalVisitDto clinicalVisit = ClinicalVisitDto.build(clinicalCourse, caze.getDisease());
ClinicalVisitForm form = new ClinicalVisitForm(true, clinicalVisit.getDisease(), FacadeProvider.getPersonFacade().getPersonByUuid(caze.getPerson().getUuid()), false);
form.setValue(clinicalVisit);
final CommitDiscardWrapperComponent<ClinicalVisitForm> view = new CommitDiscardWrapperComponent<>(form, UserProvider.getCurrent().hasUserRight(UserRight.CLINICAL_VISIT_CREATE), form.getFieldGroup());
view.setWidth(100, Unit.PERCENTAGE);
view.addCommitListener(new CommitListener() {
@Override
public void onCommit() {
if (!form.getFieldGroup().isModified()) {
ClinicalVisitDto dto = form.getValue();
dto = FacadeProvider.getClinicalVisitFacade().saveClinicalVisit(dto, caseUuid);
Notification.show(I18nProperties.getString(Strings.messageClinicalVisitCreated), Type.TRAY_NOTIFICATION);
if (callback != null) {
callback.run();
}
}
}
});
Window popupWindow = VaadinUiUtil.showModalPopupWindow(view, I18nProperties.getString(Strings.headingCreateNewClinicalVisit));
// Clinical visit form is too big for typical screens
popupWindow.setWidth(form.getWidth() + 90, Unit.PIXELS);
popupWindow.setHeight(80, Unit.PERCENTAGE);
}
Aggregations