use of de.symeda.sormas.ui.utils.CommitDiscardWrapperComponent in project SORMAS-Project by hzi-braunschweig.
the class SormasToSormasController method handleShareWithOptions.
private void handleShareWithOptions(HandleShareWithOptions handleShareWithOptions, Runnable callback, SormasToSormasOptionsForm optionsForm, SormasToSormasOptionsDto defaultOptions) {
optionsForm.setValue(defaultOptions);
CommitDiscardWrapperComponent<SormasToSormasOptionsForm> optionsCommitDiscard = new CommitDiscardWrapperComponent<>(optionsForm, optionsForm.getFieldGroup());
optionsCommitDiscard.getCommitButton().setCaption(I18nProperties.getCaption(Captions.sormasToSormasShare));
optionsCommitDiscard.setWidth(100, Sizeable.Unit.PERCENTAGE);
Window optionsPopup = VaadinUiUtil.showPopupWindow(optionsCommitDiscard, I18nProperties.getCaption(Captions.sormasToSormasShare));
optionsCommitDiscard.addCommitListener(() -> {
SormasToSormasOptionsDto options = optionsForm.getValue();
handleSormasToSormasRequest(() -> handleShareWithOptions.handle(options), () -> {
callback.run();
optionsPopup.close();
});
});
optionsCommitDiscard.addDiscardListener(optionsPopup::close);
}
use of de.symeda.sormas.ui.utils.CommitDiscardWrapperComponent in project SORMAS-Project by hzi-braunschweig.
the class TherapyController method openTreatmentCreateForm.
public void openTreatmentCreateForm(PrescriptionDto prescription, Runnable callback) {
TreatmentForm form = new TreatmentForm(true, false);
form.setValue(TreatmentDto.build(prescription));
final CommitDiscardWrapperComponent<TreatmentForm> view = new CommitDiscardWrapperComponent<>(form, UserProvider.getCurrent().hasUserRight(UserRight.TREATMENT_CREATE), form.getFieldGroup());
view.addCommitListener(new CommitListener() {
@Override
public void onCommit() {
if (!form.getFieldGroup().isModified()) {
TreatmentDto dto = form.getValue();
FacadeProvider.getTreatmentFacade().saveTreatment(dto);
Notification.show(I18nProperties.getString(Strings.messageTreatmentCreated), Type.TRAY_NOTIFICATION);
callback.run();
}
}
});
VaadinUiUtil.showModalPopupWindow(view, I18nProperties.getString(Strings.headingCreateNewTreatment));
}
use of de.symeda.sormas.ui.utils.CommitDiscardWrapperComponent in project SORMAS-Project by hzi-braunschweig.
the class TherapyController method openTreatmentEditForm.
public void openTreatmentEditForm(TreatmentIndexDto treatmentIndex, Runnable callback) {
TreatmentDto treatment = FacadeProvider.getTreatmentFacade().getTreatmentByUuid(treatmentIndex.getUuid());
TreatmentForm form = new TreatmentForm(false, treatment.isPseudonymized());
form.setValue(treatment);
final CommitDiscardWrapperComponent<TreatmentForm> view = new CommitDiscardWrapperComponent<>(form, UserProvider.getCurrent().hasUserRight(UserRight.TREATMENT_EDIT), form.getFieldGroup());
Window popupWindow = VaadinUiUtil.showModalPopupWindow(view, I18nProperties.getString(Strings.headingEditTreatment));
view.addCommitListener(() -> {
if (!form.getFieldGroup().isModified()) {
TreatmentDto dto = form.getValue();
FacadeProvider.getTreatmentFacade().saveTreatment(dto);
popupWindow.close();
Notification.show(I18nProperties.getString(Strings.messageTreatmentSaved), Type.TRAY_NOTIFICATION);
callback.run();
}
});
view.addDiscardListener(popupWindow::close);
if (UserProvider.getCurrent().hasUserRight(UserRight.TREATMENT_DELETE)) {
view.addDeleteListener(() -> {
FacadeProvider.getTreatmentFacade().deleteTreatment(treatment.getUuid());
popupWindow.close();
callback.run();
}, I18nProperties.getString(Strings.entityTreatment));
}
if (treatment.getPrescription() != null) {
Button openPrescriptionButton = ButtonHelper.createButton(Captions.treatmentOpenPrescription, e -> {
openPrescriptionEditForm(treatment.getPrescription(), null, true);
});
view.getButtonsPanel().addComponent(openPrescriptionButton, view.getButtonsPanel().getComponentIndex(view.getDiscardButton()));
view.getButtonsPanel().setComponentAlignment(openPrescriptionButton, Alignment.MIDDLE_LEFT);
}
}
use of de.symeda.sormas.ui.utils.CommitDiscardWrapperComponent in project SORMAS-Project by hzi-braunschweig.
the class TherapyController method openTreatmentCreateForm.
public void openTreatmentCreateForm(TherapyReferenceDto therapy, Runnable callback) {
TreatmentForm form = new TreatmentForm(true, false);
form.setValue(TreatmentDto.build(therapy));
final CommitDiscardWrapperComponent<TreatmentForm> view = new CommitDiscardWrapperComponent<>(form, UserProvider.getCurrent().hasUserRight(UserRight.TREATMENT_CREATE), form.getFieldGroup());
view.addCommitListener(new CommitListener() {
@Override
public void onCommit() {
if (!form.getFieldGroup().isModified()) {
TreatmentDto dto = form.getValue();
FacadeProvider.getTreatmentFacade().saveTreatment(dto);
Notification.show(I18nProperties.getString(Strings.messageTreatmentCreated), Type.TRAY_NOTIFICATION);
callback.run();
}
}
});
VaadinUiUtil.showModalPopupWindow(view, I18nProperties.getString(Strings.headingCreateNewTreatment));
}
use of de.symeda.sormas.ui.utils.CommitDiscardWrapperComponent in project SORMAS-Project by hzi-braunschweig.
the class TherapyController method openPrescriptionCreateForm.
public void openPrescriptionCreateForm(TherapyReferenceDto therapy, Runnable callback) {
PrescriptionForm form = new PrescriptionForm(true, false, false);
form.setValue(PrescriptionDto.buildPrescription(therapy));
final CommitDiscardWrapperComponent<PrescriptionForm> view = new CommitDiscardWrapperComponent<>(form, UserProvider.getCurrent().hasUserRight(UserRight.PRESCRIPTION_CREATE), form.getFieldGroup());
view.addCommitListener(new CommitListener() {
@Override
public void onCommit() {
if (!form.getFieldGroup().isModified()) {
PrescriptionDto dto = form.getValue();
FacadeProvider.getPrescriptionFacade().savePrescription(dto);
Notification.show(I18nProperties.getString(Strings.messagePrescriptionCreated), Type.TRAY_NOTIFICATION);
callback.run();
}
}
});
VaadinUiUtil.showModalPopupWindow(view, I18nProperties.getString(Strings.headingCreateNewPrescription));
}
Aggregations