Search in sources :

Example 96 with CommitDiscardWrapperComponent

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);
}
Also used : Window(com.vaadin.ui.Window) SormasToSormasOptionsDto(de.symeda.sormas.api.sormastosormas.SormasToSormasOptionsDto) CommitDiscardWrapperComponent(de.symeda.sormas.ui.utils.CommitDiscardWrapperComponent)

Example 97 with CommitDiscardWrapperComponent

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));
}
Also used : TreatmentDto(de.symeda.sormas.api.therapy.TreatmentDto) CommitDiscardWrapperComponent(de.symeda.sormas.ui.utils.CommitDiscardWrapperComponent) CommitListener(de.symeda.sormas.ui.utils.CommitDiscardWrapperComponent.CommitListener)

Example 98 with CommitDiscardWrapperComponent

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);
    }
}
Also used : Window(com.vaadin.ui.Window) TreatmentDto(de.symeda.sormas.api.therapy.TreatmentDto) Button(com.vaadin.ui.Button) CommitDiscardWrapperComponent(de.symeda.sormas.ui.utils.CommitDiscardWrapperComponent)

Example 99 with CommitDiscardWrapperComponent

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));
}
Also used : TreatmentDto(de.symeda.sormas.api.therapy.TreatmentDto) CommitDiscardWrapperComponent(de.symeda.sormas.ui.utils.CommitDiscardWrapperComponent) CommitListener(de.symeda.sormas.ui.utils.CommitDiscardWrapperComponent.CommitListener)

Example 100 with CommitDiscardWrapperComponent

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));
}
Also used : PrescriptionDto(de.symeda.sormas.api.therapy.PrescriptionDto) CommitDiscardWrapperComponent(de.symeda.sormas.ui.utils.CommitDiscardWrapperComponent) CommitListener(de.symeda.sormas.ui.utils.CommitDiscardWrapperComponent.CommitListener)

Aggregations

CommitDiscardWrapperComponent (de.symeda.sormas.ui.utils.CommitDiscardWrapperComponent)101 Window (com.vaadin.ui.Window)34 CaseDataDto (de.symeda.sormas.api.caze.CaseDataDto)22 EventDto (de.symeda.sormas.api.event.EventDto)17 Button (com.vaadin.ui.Button)16 CommitListener (de.symeda.sormas.ui.utils.CommitDiscardWrapperComponent.CommitListener)15 SimilarContactDto (de.symeda.sormas.api.contact.SimilarContactDto)13 PersonDto (de.symeda.sormas.api.person.PersonDto)13 ContactDto (de.symeda.sormas.api.contact.ContactDto)12 EventReferenceDto (de.symeda.sormas.api.event.EventReferenceDto)12 Label (com.vaadin.ui.Label)11 DistrictReferenceDto (de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto)11 Notification (com.vaadin.ui.Notification)10 EventIndexDto (de.symeda.sormas.api.event.EventIndexDto)10 AutomaticDeletionLabel (de.symeda.sormas.ui.utils.components.automaticdeletion.AutomaticDeletionLabel)10 EventParticipantDto (de.symeda.sormas.api.event.EventParticipantDto)9 UserDto (de.symeda.sormas.api.user.UserDto)9 EventSelectionField (de.symeda.sormas.ui.events.eventLink.EventSelectionField)9 AutomaticDeletionInfoDto (de.symeda.sormas.api.deletionconfiguration.AutomaticDeletionInfoDto)8 SampleDto (de.symeda.sormas.api.sample.SampleDto)8