Search in sources :

Example 1 with SideComponentLayout

use of de.symeda.sormas.ui.utils.components.sidecomponent.SideComponentLayout in project SORMAS-Project by hzi-braunschweig.

the class PersonDataView method initView.

@Override
protected void initView(String params) {
    setHeightUndefined();
    String htmlLayout = LayoutUtil.fluidRow(LayoutUtil.fluidColumnLoc(8, 0, 12, 0, PERSON_LOC), LayoutUtil.fluidColumnLoc(4, 0, 6, 0, CASES_LOC), LayoutUtil.fluidColumnLoc(4, 0, 6, 0, CONTACTS_LOC), LayoutUtil.fluidColumnLoc(4, 0, 6, 0, EVENT_PARTICIPANTS_LOC), LayoutUtil.fluidColumnLoc(4, 0, 6, 0, TRAVEL_ENTRIES_LOC), LayoutUtil.fluidColumnLoc(4, 0, 6, 0, IMMUNIZATION_LOC), LayoutUtil.fluidColumnLoc(4, 0, 6, 0, VACCINATIONS_LOC));
    DetailSubComponentWrapper container = new DetailSubComponentWrapper(() -> editComponent);
    container.setWidth(100, Unit.PERCENTAGE);
    container.setMargin(true);
    setSubComponent(container);
    CustomLayout layout = new CustomLayout();
    layout.addStyleName(CssStyles.ROOT_COMPONENT);
    layout.setTemplateContents(htmlLayout);
    layout.setWidth(100, Unit.PERCENTAGE);
    layout.setHeightUndefined();
    container.addComponent(layout);
    editComponent = ControllerProvider.getPersonController().getPersonEditComponent(getReference().getUuid(), UserRight.PERSON_EDIT);
    editComponent.setMargin(false);
    editComponent.setWidth(100, Unit.PERCENTAGE);
    editComponent.getWrappedComponent().setWidth(100, Unit.PERCENTAGE);
    editComponent.addStyleName(CssStyles.MAIN_COMPONENT);
    layout.addComponent(editComponent, PERSON_LOC);
    if (FacadeProvider.getPersonFacade().isSharedWithoutOwnership(getReference().getUuid())) {
        editComponent.setEnabled(false);
    }
    if (FacadeProvider.getFeatureConfigurationFacade().isFeatureEnabled(FeatureType.CASE_SURVEILANCE)) {
        layout.addComponent(new SideComponentLayout(new CaseListComponent(getReference())), CASES_LOC);
    }
    if (FacadeProvider.getFeatureConfigurationFacade().isFeatureEnabled(FeatureType.CONTACT_TRACING) && UserProvider.getCurrent().hasUserRight(UserRight.CONTACT_VIEW)) {
        layout.addComponent(new SideComponentLayout(new ContactListComponent(getReference())), CONTACTS_LOC);
    }
    if (FacadeProvider.getFeatureConfigurationFacade().isFeatureEnabled(FeatureType.EVENT_SURVEILLANCE)) {
        layout.addComponent(new SideComponentLayout(new EventParticipantListComponent(getReference())), EVENT_PARTICIPANTS_LOC);
    }
    UserProvider currentUser = UserProvider.getCurrent();
    if (FacadeProvider.getConfigFacade().isConfiguredCountry(CountryHelper.COUNTRY_CODE_GERMANY) && FacadeProvider.getFeatureConfigurationFacade().isFeatureEnabled(FeatureType.TRAVEL_ENTRIES) && currentUser != null && currentUser.hasUserRight(UserRight.TRAVEL_ENTRY_VIEW)) {
        TravelEntryListCriteria travelEntryListCriteria = new TravelEntryListCriteria.Builder().withPerson(getReference()).build();
        layout.addComponent(new SideComponentLayout(new TravelEntryListComponent(travelEntryListCriteria, this::showUnsavedChangesPopup)), TRAVEL_ENTRIES_LOC);
    }
    if (FacadeProvider.getFeatureConfigurationFacade().isFeatureEnabled(FeatureType.IMMUNIZATION_MANAGEMENT) && currentUser != null && currentUser.hasUserRight(UserRight.IMMUNIZATION_VIEW)) {
        if (!FacadeProvider.getFeatureConfigurationFacade().isPropertyValueTrue(FeatureType.IMMUNIZATION_MANAGEMENT, FeatureTypeProperty.REDUCED)) {
            final ImmunizationListCriteria immunizationListCriteria = new ImmunizationListCriteria.Builder(getReference()).build();
            layout.addComponent(new SideComponentLayout(new ImmunizationListComponent(immunizationListCriteria, this::showUnsavedChangesPopup)), IMMUNIZATION_LOC);
        } else {
            VaccinationListCriteria criteria = new VaccinationListCriteria.Builder(getReference()).build();
            layout.addComponent(new SideComponentLayout(new VaccinationListComponent(criteria)), VACCINATIONS_LOC);
        }
    }
}
Also used : DetailSubComponentWrapper(de.symeda.sormas.ui.utils.DetailSubComponentWrapper) EventParticipantListComponent(de.symeda.sormas.ui.events.eventParticipantLink.EventParticipantListComponent) VaccinationListComponent(de.symeda.sormas.ui.vaccination.list.VaccinationListComponent) TravelEntryListCriteria(de.symeda.sormas.api.travelentry.TravelEntryListCriteria) SideComponentLayout(de.symeda.sormas.ui.utils.components.sidecomponent.SideComponentLayout) VaccinationListCriteria(de.symeda.sormas.api.vaccination.VaccinationListCriteria) UserProvider(de.symeda.sormas.ui.UserProvider) CustomLayout(com.vaadin.ui.CustomLayout) ContactListComponent(de.symeda.sormas.ui.contact.contactlink.ContactListComponent) ImmunizationListCriteria(de.symeda.sormas.api.immunization.ImmunizationListCriteria) CaseListComponent(de.symeda.sormas.ui.caze.caselink.CaseListComponent) TravelEntryListComponent(de.symeda.sormas.ui.travelentry.travelentrylink.TravelEntryListComponent) ImmunizationListComponent(de.symeda.sormas.ui.immunization.immunizationlink.ImmunizationListComponent)

Example 2 with SideComponentLayout

use of de.symeda.sormas.ui.utils.components.sidecomponent.SideComponentLayout in project SORMAS-Project by hzi-braunschweig.

the class SampleDataView method initView.

@Override
protected void initView(String params) {
    setHeightUndefined();
    String htmlLayout = LayoutUtil.fluidRow(LayoutUtil.fluidColumnLoc(8, 0, 12, 0, EDIT_LOC), LayoutUtil.fluidColumnLoc(4, 0, 6, 0, CASE_LOC), LayoutUtil.fluidColumnLoc(4, 0, 6, 0, CONTACT_LOC), LayoutUtil.fluidColumnLoc(4, 0, 6, 0, EVENT_PARTICIPANT_LOC), LayoutUtil.fluidColumnLoc(4, 0, 6, 0, PATHOGEN_TESTS_LOC), LayoutUtil.fluidColumnLoc(4, 0, 6, 0, ADDITIONAL_TESTS_LOC), LayoutUtil.fluidColumnLoc(4, 0, 6, 0, SORMAS_TO_SORMAS_LOC));
    DetailSubComponentWrapper container = new DetailSubComponentWrapper(() -> editComponent);
    container.setWidth(100, Unit.PERCENTAGE);
    container.setMargin(true);
    setSubComponent(container);
    CustomLayout layout = new CustomLayout();
    layout.addStyleName(CssStyles.ROOT_COMPONENT);
    layout.setTemplateContents(htmlLayout);
    layout.setWidth(100, Unit.PERCENTAGE);
    layout.setHeightUndefined();
    container.addComponent(layout);
    SampleDto sampleDto = FacadeProvider.getSampleFacade().getSampleByUuid(getSampleRef().getUuid());
    Disease disease = null;
    final CaseReferenceDto associatedCase = sampleDto.getAssociatedCase();
    if (associatedCase != null && UserProvider.getCurrent().hasAllUserRights(UserRight.CASE_VIEW)) {
        final CaseDataDto caseDto = FacadeProvider.getCaseFacade().getCaseDataByUuid(associatedCase.getUuid());
        disease = caseDto.getDisease();
        final CaseInfoLayout caseInfoLayout = new CaseInfoLayout(caseDto);
        caseInfoLayout.addStyleName(CssStyles.SIDE_COMPONENT);
        layout.addComponent(caseInfoLayout, CASE_LOC);
    }
    final ContactReferenceDto associatedContact = sampleDto.getAssociatedContact();
    if (associatedContact != null && UserProvider.getCurrent().hasAllUserRights(UserRight.CONTACT_VIEW)) {
        final ContactDto contactDto = FacadeProvider.getContactFacade().getByUuid(associatedContact.getUuid());
        disease = contactDto.getDisease();
        final ContactInfoLayout contactInfoLayout = new ContactInfoLayout(contactDto, UiFieldAccessCheckers.getDefault(contactDto.isPseudonymized()));
        contactInfoLayout.addStyleName(CssStyles.SIDE_COMPONENT);
        layout.addComponent(contactInfoLayout, CONTACT_LOC);
    }
    final EventParticipantReferenceDto associatedEventParticipant = sampleDto.getAssociatedEventParticipant();
    if (associatedEventParticipant != null && UserProvider.getCurrent().hasAllUserRights(UserRight.EVENTPARTICIPANT_VIEW)) {
        final EventParticipantDto eventParticipantDto = FacadeProvider.getEventParticipantFacade().getEventParticipantByUuid(associatedEventParticipant.getUuid());
        final EventDto eventDto = FacadeProvider.getEventFacade().getEventByUuid(eventParticipantDto.getEvent().getUuid(), false);
        disease = eventDto.getDisease();
        final EventParticipantInfoLayout eventParticipantInfoLayout = new EventParticipantInfoLayout(eventParticipantDto, eventDto, UiFieldAccessCheckers.getDefault(eventParticipantDto.isPseudonymized()));
        eventParticipantInfoLayout.addStyleName(CssStyles.SIDE_COMPONENT);
        layout.addComponent(eventParticipantInfoLayout, EVENT_PARTICIPANT_LOC);
    }
    SampleController sampleController = ControllerProvider.getSampleController();
    editComponent = sampleController.getSampleEditComponent(getSampleRef().getUuid(), sampleDto.isPseudonymized(), disease, true);
    Consumer<Disease> createReferral = (relatedDisease) -> {
        // save changes before referral creation
        editComponent.commit();
        SampleDto committedSample = editComponent.getWrappedComponent().getValue();
        sampleController.createReferral(committedSample, relatedDisease);
    };
    Consumer<SampleDto> openReferredSample = referredSample -> sampleController.navigateToData(referredSample.getUuid());
    sampleController.addReferOrLinkToOtherLabButton(editComponent, disease, createReferral, openReferredSample);
    Consumer<SampleDto> navigate = targetSampleDto -> sampleController.navigateToData(targetSampleDto.getUuid());
    sampleController.addReferredFromButton(editComponent, navigate);
    editComponent.setMargin(new MarginInfo(false, false, true, false));
    editComponent.setWidth(100, Unit.PERCENTAGE);
    editComponent.getWrappedComponent().setWidth(100, Unit.PERCENTAGE);
    editComponent.addStyleName(CssStyles.MAIN_COMPONENT);
    layout.addComponent(editComponent, EDIT_LOC);
    SampleReferenceDto sampleReferenceDto = getSampleRef();
    PathogenTestListComponent pathogenTestListComponent = new PathogenTestListComponent(sampleReferenceDto, this::showUnsavedChangesPopup);
    layout.addComponent(new SideComponentLayout(pathogenTestListComponent), PATHOGEN_TESTS_LOC);
    if (UserProvider.getCurrent() != null && UserProvider.getCurrent().hasUserRight(UserRight.ADDITIONAL_TEST_VIEW) && FacadeProvider.getFeatureConfigurationFacade().isFeatureEnabled(FeatureType.ADDITIONAL_TESTS)) {
        AdditionalTestListComponent additionalTestList = new AdditionalTestListComponent(sampleReferenceDto.getUuid());
        additionalTestList.addStyleName(CssStyles.SIDE_COMPONENT);
        layout.addComponent(additionalTestList, ADDITIONAL_TESTS_LOC);
    }
    boolean sormasToSormasEnabled = FacadeProvider.getSormasToSormasFacade().isSharingCasesContactsAndSamplesEnabledForUser();
    if (sormasToSormasEnabled || sampleDto.getSormasToSormasOriginInfo() != null) {
        VerticalLayout sormasToSormasLocLayout = new VerticalLayout();
        sormasToSormasLocLayout.setMargin(false);
        sormasToSormasLocLayout.setSpacing(false);
        SormasToSormasListComponent sormasToSormasListComponent = new SormasToSormasListComponent(sampleDto);
        sormasToSormasListComponent.addStyleNames(CssStyles.SIDE_COMPONENT);
        sormasToSormasLocLayout.addComponent(sormasToSormasListComponent);
        layout.addComponent(sormasToSormasLocLayout, SORMAS_TO_SORMAS_LOC);
    }
    setSampleEditPermission(container);
}
Also used : FeatureType(de.symeda.sormas.api.feature.FeatureType) SideComponentLayout(de.symeda.sormas.ui.utils.components.sidecomponent.SideComponentLayout) FacadeProvider(de.symeda.sormas.api.FacadeProvider) PathogenTestListComponent(de.symeda.sormas.ui.samples.pathogentestlink.PathogenTestListComponent) VerticalLayout(com.vaadin.ui.VerticalLayout) EventParticipantDto(de.symeda.sormas.api.event.EventParticipantDto) CustomLayout(com.vaadin.ui.CustomLayout) DetailSubComponentWrapper(de.symeda.sormas.ui.utils.DetailSubComponentWrapper) ControllerProvider(de.symeda.sormas.ui.ControllerProvider) CaseReferenceDto(de.symeda.sormas.api.caze.CaseReferenceDto) SampleReferenceDto(de.symeda.sormas.api.sample.SampleReferenceDto) CssStyles(de.symeda.sormas.ui.utils.CssStyles) CaseInfoLayout(de.symeda.sormas.ui.caze.CaseInfoLayout) CommitDiscardWrapperComponent(de.symeda.sormas.ui.utils.CommitDiscardWrapperComponent) EventParticipantReferenceDto(de.symeda.sormas.api.event.EventParticipantReferenceDto) UserProvider(de.symeda.sormas.ui.UserProvider) EventParticipantInfoLayout(de.symeda.sormas.ui.events.EventParticipantInfoLayout) CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) EventDto(de.symeda.sormas.api.event.EventDto) MarginInfo(com.vaadin.shared.ui.MarginInfo) SormasToSormasListComponent(de.symeda.sormas.ui.sormastosormas.SormasToSormasListComponent) ContactInfoLayout(de.symeda.sormas.ui.contact.ContactInfoLayout) Consumer(java.util.function.Consumer) UserRight(de.symeda.sormas.api.user.UserRight) LayoutUtil(de.symeda.sormas.ui.utils.LayoutUtil) Disease(de.symeda.sormas.api.Disease) SampleDto(de.symeda.sormas.api.sample.SampleDto) ContactDto(de.symeda.sormas.api.contact.ContactDto) ContactReferenceDto(de.symeda.sormas.api.contact.ContactReferenceDto) UiFieldAccessCheckers(de.symeda.sormas.api.utils.fieldaccess.UiFieldAccessCheckers) ContactInfoLayout(de.symeda.sormas.ui.contact.ContactInfoLayout) Disease(de.symeda.sormas.api.Disease) SideComponentLayout(de.symeda.sormas.ui.utils.components.sidecomponent.SideComponentLayout) PathogenTestListComponent(de.symeda.sormas.ui.samples.pathogentestlink.PathogenTestListComponent) MarginInfo(com.vaadin.shared.ui.MarginInfo) ContactDto(de.symeda.sormas.api.contact.ContactDto) VerticalLayout(com.vaadin.ui.VerticalLayout) EventParticipantInfoLayout(de.symeda.sormas.ui.events.EventParticipantInfoLayout) DetailSubComponentWrapper(de.symeda.sormas.ui.utils.DetailSubComponentWrapper) SampleReferenceDto(de.symeda.sormas.api.sample.SampleReferenceDto) CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) SormasToSormasListComponent(de.symeda.sormas.ui.sormastosormas.SormasToSormasListComponent) EventDto(de.symeda.sormas.api.event.EventDto) EventParticipantDto(de.symeda.sormas.api.event.EventParticipantDto) CaseInfoLayout(de.symeda.sormas.ui.caze.CaseInfoLayout) CustomLayout(com.vaadin.ui.CustomLayout) ContactReferenceDto(de.symeda.sormas.api.contact.ContactReferenceDto) EventParticipantReferenceDto(de.symeda.sormas.api.event.EventParticipantReferenceDto) SampleDto(de.symeda.sormas.api.sample.SampleDto) CaseReferenceDto(de.symeda.sormas.api.caze.CaseReferenceDto)

Example 3 with SideComponentLayout

use of de.symeda.sormas.ui.utils.components.sidecomponent.SideComponentLayout in project SORMAS-Project by hzi-braunschweig.

the class CaseEpiDataView method initView.

@Override
protected void initView(String params) {
    setHeightUndefined();
    String htmlLayout = LayoutUtil.fluidRow(LayoutUtil.fluidColumnLoc(8, 0, 12, 0, LOC_EPI_DATA), LayoutUtil.fluidColumnLoc(4, 0, 6, 0, LOC_SOURCE_CONTACTS), LayoutUtil.fluidColumnLoc(4, 0, 6, 0, TRAVEL_ENTRIES_LOC));
    DetailSubComponentWrapper container = new DetailSubComponentWrapper(() -> epiDataComponent);
    container.setWidth(100, Unit.PERCENTAGE);
    container.setMargin(true);
    setSubComponent(container);
    CustomLayout layout = new CustomLayout();
    layout.addStyleName(CssStyles.ROOT_COMPONENT);
    layout.setTemplateContents(htmlLayout);
    layout.setWidth(100, Unit.PERCENTAGE);
    layout.setHeightUndefined();
    container.addComponent(layout);
    UserProvider currentUser = UserProvider.getCurrent();
    boolean sourceContactsVisible = currentUser != null && currentUser.hasUserRight(UserRight.CONTACT_VIEW);
    VerticalLayout sourceContactsLayout = new VerticalLayout();
    Consumer<Boolean> sourceContactsToggleCallback = (visible) -> sourceContactsLayout.setVisible(visible != null && sourceContactsVisible ? visible : false);
    epiDataComponent = ControllerProvider.getCaseController().getEpiDataComponent(getCaseRef().getUuid(), sourceContactsToggleCallback);
    epiDataComponent.setMargin(false);
    epiDataComponent.setWidth(100, Unit.PERCENTAGE);
    epiDataComponent.getWrappedComponent().setWidth(100, Unit.PERCENTAGE);
    epiDataComponent.addStyleName(CssStyles.MAIN_COMPONENT);
    layout.addComponent(epiDataComponent, LOC_EPI_DATA);
    if (sourceContactsVisible) {
        sourceContactsLayout.setMargin(false);
        sourceContactsLayout.setSpacing(false);
        final SourceContactListComponent sourceContactList = new SourceContactListComponent(getCaseRef(), this);
        sourceContactList.addStyleName(CssStyles.SIDE_COMPONENT);
        sourceContactsLayout.addComponent(sourceContactList);
        if (currentUser.hasUserRight(UserRight.CONTACT_CREATE)) {
            sourceContactList.addStyleName(CssStyles.VSPACE_NONE);
            Label contactCreationDisclaimer = new Label(VaadinIcons.INFO_CIRCLE.getHtml() + " " + I18nProperties.getString(Strings.infoCreateNewContactDiscardsChanges), ContentMode.HTML);
            contactCreationDisclaimer.addStyleName(CssStyles.VSPACE_TOP_4);
            sourceContactsLayout.addComponent(contactCreationDisclaimer);
        }
        if (!sourceContactList.isEmpty()) {
            epiDataComponent.getWrappedComponent().disableContactWithSourceCaseKnownField();
        }
        epiDataComponent.getWrappedComponent().setGetSourceContactsCallback(sourceContactList::getEntries);
    }
    layout.addComponent(sourceContactsLayout, LOC_SOURCE_CONTACTS);
    if (FacadeProvider.getConfigFacade().isConfiguredCountry(CountryHelper.COUNTRY_CODE_GERMANY) && FacadeProvider.getFeatureConfigurationFacade().isFeatureEnabled(FeatureType.TRAVEL_ENTRIES) && currentUser != null && currentUser.hasUserRight(UserRight.TRAVEL_ENTRY_VIEW)) {
        TravelEntryListCriteria travelEntryListCriteria = new TravelEntryListCriteria.Builder().withCase(getCaseRef()).build();
        layout.addComponent(new SideComponentLayout(new TravelEntryListComponent(travelEntryListCriteria, this::showUnsavedChangesPopup)), TRAVEL_ENTRIES_LOC);
    }
    setCaseEditPermission(container);
}
Also used : FeatureType(de.symeda.sormas.api.feature.FeatureType) SideComponentLayout(de.symeda.sormas.ui.utils.components.sidecomponent.SideComponentLayout) ContentMode(com.vaadin.shared.ui.ContentMode) FacadeProvider(de.symeda.sormas.api.FacadeProvider) I18nProperties(de.symeda.sormas.api.i18n.I18nProperties) VerticalLayout(com.vaadin.ui.VerticalLayout) SourceContactListComponent(de.symeda.sormas.ui.contact.SourceContactListComponent) CustomLayout(com.vaadin.ui.CustomLayout) DetailSubComponentWrapper(de.symeda.sormas.ui.utils.DetailSubComponentWrapper) ControllerProvider(de.symeda.sormas.ui.ControllerProvider) Consumer(java.util.function.Consumer) UserRight(de.symeda.sormas.api.user.UserRight) TravelEntryListComponent(de.symeda.sormas.ui.travelentry.travelentrylink.TravelEntryListComponent) LayoutUtil(de.symeda.sormas.ui.utils.LayoutUtil) AbstractCaseView(de.symeda.sormas.ui.caze.AbstractCaseView) CssStyles(de.symeda.sormas.ui.utils.CssStyles) CommitDiscardWrapperComponent(de.symeda.sormas.ui.utils.CommitDiscardWrapperComponent) Label(com.vaadin.ui.Label) TravelEntryListCriteria(de.symeda.sormas.api.travelentry.TravelEntryListCriteria) VaadinIcons(com.vaadin.icons.VaadinIcons) CountryHelper(de.symeda.sormas.api.CountryHelper) Strings(de.symeda.sormas.api.i18n.Strings) UserProvider(de.symeda.sormas.ui.UserProvider) DetailSubComponentWrapper(de.symeda.sormas.ui.utils.DetailSubComponentWrapper) Label(com.vaadin.ui.Label) TravelEntryListCriteria(de.symeda.sormas.api.travelentry.TravelEntryListCriteria) SideComponentLayout(de.symeda.sormas.ui.utils.components.sidecomponent.SideComponentLayout) UserProvider(de.symeda.sormas.ui.UserProvider) CustomLayout(com.vaadin.ui.CustomLayout) SourceContactListComponent(de.symeda.sormas.ui.contact.SourceContactListComponent) VerticalLayout(com.vaadin.ui.VerticalLayout) TravelEntryListComponent(de.symeda.sormas.ui.travelentry.travelentrylink.TravelEntryListComponent)

Example 4 with SideComponentLayout

use of de.symeda.sormas.ui.utils.components.sidecomponent.SideComponentLayout in project SORMAS-Project by hzi-braunschweig.

the class TravelEntryDataView method initView.

@Override
protected void initView(String params) {
    setHeightUndefined();
    TravelEntryDto travelEntryDto = FacadeProvider.getTravelEntryFacade().getByUuid(getReference().getUuid());
    editComponent = ControllerProvider.getTravelEntryController().getTravelEntryDataEditComponent(getTravelEntryRef().getUuid());
    DetailSubComponentWrapper container = new DetailSubComponentWrapper(() -> editComponent);
    container.setWidth(100, Unit.PERCENTAGE);
    container.setMargin(true);
    setSubComponent(container);
    LayoutWithSidePanel layout = new LayoutWithSidePanel(editComponent, CASE_LOC, DOCUMENTS_LOC, QuarantineOrderDocumentsComponent.QUARANTINE_LOC, TASKS_LOC);
    container.addComponent(layout);
    CaseReferenceDto resultingCase = travelEntryDto.getResultingCase();
    if (resultingCase == null) {
        Button createCaseButton = ButtonHelper.createButton(Captions.travelEntryCreateCase, e -> showUnsavedChangesPopup(() -> ControllerProvider.getCaseController().createFromTravelEntry(travelEntryDto)), ValoTheme.BUTTON_PRIMARY, CssStyles.VSPACE_2);
        layout.addSidePanelComponent(createCaseButton, CASE_LOC);
    } else {
        layout.addSidePanelComponent(createCaseInfoLayout(resultingCase.getUuid()), CASE_LOC);
    }
    DocumentListComponent documentList = null;
    if (FacadeProvider.getFeatureConfigurationFacade().isFeatureEnabled(FeatureType.DOCUMENTS)) {
        documentList = new DocumentListComponent(DocumentRelatedEntityType.TRAVEL_ENTRY, getReference(), UserRight.TRAVEL_ENTRY_EDIT, travelEntryDto.isPseudonymized());
        layout.addSidePanelComponent(new SideComponentLayout(documentList), DOCUMENTS_LOC);
    }
    QuarantineOrderDocumentsComponent.addComponentToLayout(layout.getSidePanelComponent(), getTravelEntryRef(), documentList);
    if (FacadeProvider.getFeatureConfigurationFacade().isFeatureEnabled(FeatureType.TASK_MANAGEMENT)) {
        TaskListComponent taskList = new TaskListComponent(TaskContext.TRAVEL_ENTRY, getTravelEntryRef(), travelEntryDto.getDisease());
        taskList.addStyleName(CssStyles.SIDE_COMPONENT);
        layout.addSidePanelComponent(taskList, TASKS_LOC);
    }
    EditPermissionType travelEntryEditAllowed = FacadeProvider.getTravelEntryFacade().isTravelEntryEditAllowed(travelEntryDto.getUuid());
    if (travelEntryEditAllowed.equals(EditPermissionType.ARCHIVING_STATUS_ONLY)) {
        layout.disable(ArchivingController.ARCHIVE_DEARCHIVE_BUTTON_ID);
    } else if (travelEntryEditAllowed.equals(EditPermissionType.REFUSED)) {
        layout.disable();
    }
}
Also used : DetailSubComponentWrapper(de.symeda.sormas.ui.utils.DetailSubComponentWrapper) LayoutWithSidePanel(de.symeda.sormas.ui.utils.LayoutWithSidePanel) Button(com.vaadin.ui.Button) TravelEntryDto(de.symeda.sormas.api.travelentry.TravelEntryDto) TaskListComponent(de.symeda.sormas.ui.task.TaskListComponent) EditPermissionType(de.symeda.sormas.api.EditPermissionType) CaseReferenceDto(de.symeda.sormas.api.caze.CaseReferenceDto) DocumentListComponent(de.symeda.sormas.ui.document.DocumentListComponent) SideComponentLayout(de.symeda.sormas.ui.utils.components.sidecomponent.SideComponentLayout)

Example 5 with SideComponentLayout

use of de.symeda.sormas.ui.utils.components.sidecomponent.SideComponentLayout in project SORMAS-Project by hzi-braunschweig.

the class ContactDataView method initView.

@Override
protected void initView(String params) {
    setHeightUndefined();
    ContactDto contactDto = FacadeProvider.getContactFacade().getByUuid(getContactRef().getUuid());
    editComponent = ControllerProvider.getContactController().getContactDataEditComponent(getContactRef().getUuid(), ViewMode.NORMAL, contactDto.isPseudonymized());
    addCreateFromCaseButtonLogic();
    DetailSubComponentWrapper container = new DetailSubComponentWrapper(() -> editComponent);
    container.setWidth(100, Unit.PERCENTAGE);
    container.setMargin(true);
    setSubComponent(container);
    LayoutWithSidePanel layout = new LayoutWithSidePanel(editComponent, CASE_LOC, CASE_BUTTONS_LOC, EVENTS_LOC, TASKS_LOC, SAMPLES_LOC, IMMUNIZATION_LOC, VACCINATIONS_LOC, SORMAS_TO_SORMAS_LOC, DOCUMENTS_LOC, QuarantineOrderDocumentsComponent.QUARANTINE_LOC);
    container.addComponent(layout);
    CaseDataDto caseDto = null;
    if (contactDto.getCaze() != null) {
        caseDto = FacadeProvider.getCaseFacade().getCaseDataByUuid(contactDto.getCaze().getUuid());
        layout.addSidePanelComponent(createCaseInfoLayout(caseDto), CASE_LOC);
    }
    if (UserProvider.getCurrent().hasUserRight(UserRight.CONTACT_REASSIGN_CASE)) {
        HorizontalLayout buttonsLayout = new HorizontalLayout();
        buttonsLayout.setSpacing(true);
        Button chooseCaseButton = ButtonHelper.createButton(contactDto.getCaze() == null ? Captions.contactChooseSourceCase : Captions.contactChangeCase, null, ValoTheme.BUTTON_PRIMARY, CssStyles.VSPACE_2);
        buttonsLayout.addComponent(chooseCaseButton);
        Button removeCaseButton = ButtonHelper.createButton(Captions.contactRemoveCase, null, ValoTheme.BUTTON_LINK);
        if (contactDto.getCaze() != null) {
            buttonsLayout.addComponent(removeCaseButton);
        }
        chooseCaseButton.addClickListener(e -> {
            VaadinUiUtil.showConfirmationPopup(I18nProperties.getString(Strings.headingDiscardUnsavedChanges), new Label(I18nProperties.getString(Strings.confirmationContactSourceCaseDiscardUnsavedChanges)), I18nProperties.getString(Strings.yes), I18nProperties.getString(Strings.no), 480, confirmed -> {
                if (confirmed) {
                    editComponent.discard();
                    Disease selectedDisease = editComponent.getWrappedComponent().getSelectedDisease();
                    ControllerProvider.getContactController().openSelectCaseForContactWindow(selectedDisease, selectedCase -> {
                        if (selectedCase != null) {
                            editComponent.getWrappedComponent().setSourceCase(selectedCase.toReference());
                            ContactDto contactToChange = FacadeProvider.getContactFacade().getByUuid(getContactRef().getUuid());
                            contactToChange.setCaze(selectedCase.toReference());
                            FacadeProvider.getContactFacade().save(contactToChange);
                            layout.addComponent(createCaseInfoLayout(selectedCase.getUuid()), CASE_LOC);
                            removeCaseButton.setVisible(true);
                            chooseCaseButton.setCaption(I18nProperties.getCaption(Captions.contactChangeCase));
                            ControllerProvider.getContactController().navigateToData(contactDto.getUuid());
                            new Notification(null, I18nProperties.getString(Strings.messageContactCaseChanged), Type.TRAY_NOTIFICATION, false).show(Page.getCurrent());
                        }
                    });
                }
            });
        });
        removeCaseButton.addClickListener(e -> {
            if (contactDto.getRegion() == null || contactDto.getDistrict() == null) {
                // Ask user to fill in a region and district before removing the source case
                VaadinUiUtil.showSimplePopupWindow(I18nProperties.getString(Strings.headingContactDataNotComplete), I18nProperties.getString(Strings.messageSetContactRegionAndDistrict));
            } else {
                VaadinUiUtil.showConfirmationPopup(I18nProperties.getString(Strings.headingRemoveCaseFromContact), new Label(I18nProperties.getString(Strings.confirmationContactSourceCaseDiscardUnsavedChanges)), I18nProperties.getString(Strings.yes), I18nProperties.getString(Strings.no), 480, confirmed -> {
                    if (confirmed) {
                        editComponent.discard();
                        layout.removeComponent(CASE_LOC);
                        editComponent.getWrappedComponent().setSourceCase(null);
                        ContactDto contactToChange = FacadeProvider.getContactFacade().getByUuid(getContactRef().getUuid());
                        contactToChange.setCaze(null);
                        FacadeProvider.getContactFacade().save(contactToChange);
                        removeCaseButton.setVisible(false);
                        chooseCaseButton.setCaption(I18nProperties.getCaption(Captions.contactChooseSourceCase));
                        ControllerProvider.getContactController().navigateToData(contactDto.getUuid());
                        new Notification(null, I18nProperties.getString(Strings.messageContactCaseRemoved), Type.TRAY_NOTIFICATION, false).show(Page.getCurrent());
                    }
                });
            }
        });
        layout.addSidePanelComponent(buttonsLayout, CASE_BUTTONS_LOC);
    }
    if (FacadeProvider.getFeatureConfigurationFacade().isFeatureEnabled(FeatureType.TASK_MANAGEMENT)) {
        TaskListComponent taskList = new TaskListComponent(TaskContext.CONTACT, getContactRef(), contactDto.getDisease());
        taskList.addStyleName(CssStyles.SIDE_COMPONENT);
        layout.addSidePanelComponent(taskList, TASKS_LOC);
    }
    if (UserProvider.getCurrent().hasUserRight(UserRight.SAMPLE_VIEW)) {
        SampleListComponent sampleList = new SampleListComponent(new SampleCriteria().contact(getContactRef()).disease(contactDto.getDisease()).sampleAssociationType(SampleAssociationType.CONTACT), this::showUnsavedChangesPopup);
        SampleListComponentLayout sampleListComponentLayout = new SampleListComponentLayout(sampleList, I18nProperties.getString(Strings.infoCreateNewSampleDiscardsChangesContact));
        layout.addSidePanelComponent(sampleListComponentLayout, SAMPLES_LOC);
    }
    if (FacadeProvider.getFeatureConfigurationFacade().isFeatureEnabled(FeatureType.EVENT_SURVEILLANCE) && UserProvider.getCurrent().hasUserRight(UserRight.EVENT_VIEW)) {
        VerticalLayout eventsLayout = new VerticalLayout();
        eventsLayout.setMargin(false);
        eventsLayout.setSpacing(false);
        EventListComponent eventList = new EventListComponent(getContactRef(), this::showUnsavedChangesPopup);
        eventList.addStyleName(CssStyles.SIDE_COMPONENT);
        eventsLayout.addComponent(eventList);
        layout.addSidePanelComponent(eventsLayout, EVENTS_LOC);
    }
    if (FacadeProvider.getFeatureConfigurationFacade().isFeatureEnabled(FeatureType.IMMUNIZATION_MANAGEMENT) && UserProvider.getCurrent().hasUserRight(UserRight.IMMUNIZATION_VIEW)) {
        if (!FacadeProvider.getFeatureConfigurationFacade().isPropertyValueTrue(FeatureType.IMMUNIZATION_MANAGEMENT, FeatureTypeProperty.REDUCED)) {
            final ImmunizationListCriteria immunizationListCriteria = new ImmunizationListCriteria.Builder(contactDto.getPerson()).wihDisease(contactDto.getDisease()).build();
            layout.addSidePanelComponent(new SideComponentLayout(new ImmunizationListComponent(immunizationListCriteria, this::showUnsavedChangesPopup)), IMMUNIZATION_LOC);
        } else {
            VaccinationListCriteria criteria = new VaccinationListCriteria.Builder(contactDto.getPerson()).withDisease(contactDto.getDisease()).build().vaccinationAssociationType(VaccinationAssociationType.CONTACT).contactReference(getContactRef()).region(contactDto.getRegion() != null ? contactDto.getRegion() : caseDto.getResponsibleRegion()).district(contactDto.getDistrict() != null ? contactDto.getDistrict() : caseDto.getResponsibleDistrict());
            layout.addSidePanelComponent(new SideComponentLayout(new VaccinationListComponent(criteria, this::showUnsavedChangesPopup)), VACCINATIONS_LOC);
        }
    }
    boolean sormasToSormasfeatureEnabled = FacadeProvider.getSormasToSormasFacade().isSharingCasesContactsAndSamplesEnabledForUser();
    if (sormasToSormasfeatureEnabled || contactDto.getSormasToSormasOriginInfo() != null) {
        VerticalLayout sormasToSormasLocLayout = new VerticalLayout();
        sormasToSormasLocLayout.setMargin(false);
        sormasToSormasLocLayout.setSpacing(false);
        SormasToSormasListComponent sormasToSormasListComponent = new SormasToSormasListComponent(contactDto, sormasToSormasfeatureEnabled);
        sormasToSormasListComponent.addStyleNames(CssStyles.SIDE_COMPONENT);
        sormasToSormasLocLayout.addComponent(sormasToSormasListComponent);
        layout.addSidePanelComponent(sormasToSormasLocLayout, SORMAS_TO_SORMAS_LOC);
    }
    DocumentListComponent documentList = null;
    if (FacadeProvider.getFeatureConfigurationFacade().isFeatureEnabled(FeatureType.DOCUMENTS)) {
        documentList = new DocumentListComponent(DocumentRelatedEntityType.CONTACT, getContactRef(), UserRight.CONTACT_EDIT, contactDto.isPseudonymized());
        layout.addSidePanelComponent(new SideComponentLayout(documentList), DOCUMENTS_LOC);
    }
    QuarantineOrderDocumentsComponent.addComponentToLayout(layout.getSidePanelComponent(), contactDto, documentList);
    EditPermissionType contactEditAllowed = FacadeProvider.getContactFacade().isContactEditAllowed(contactDto.getUuid());
    if (contactEditAllowed.equals(EditPermissionType.ARCHIVING_STATUS_ONLY)) {
        layout.disable(ArchivingController.ARCHIVE_DEARCHIVE_BUTTON_ID);
    } else if (contactEditAllowed.equals(EditPermissionType.REFUSED)) {
        layout.disable();
    }
}
Also used : Disease(de.symeda.sormas.api.Disease) Label(com.vaadin.ui.Label) EditPermissionType(de.symeda.sormas.api.EditPermissionType) VaccinationListComponent(de.symeda.sormas.ui.vaccination.list.VaccinationListComponent) Notification(com.vaadin.ui.Notification) HorizontalLayout(com.vaadin.ui.HorizontalLayout) SideComponentLayout(de.symeda.sormas.ui.utils.components.sidecomponent.SideComponentLayout) DocumentListComponent(de.symeda.sormas.ui.document.DocumentListComponent) SampleListComponent(de.symeda.sormas.ui.samples.sampleLink.SampleListComponent) Button(com.vaadin.ui.Button) TaskListComponent(de.symeda.sormas.ui.task.TaskListComponent) ContactDto(de.symeda.sormas.api.contact.ContactDto) VerticalLayout(com.vaadin.ui.VerticalLayout) ImmunizationListCriteria(de.symeda.sormas.api.immunization.ImmunizationListCriteria) EventListComponent(de.symeda.sormas.ui.events.eventLink.EventListComponent) DetailSubComponentWrapper(de.symeda.sormas.ui.utils.DetailSubComponentWrapper) CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) SampleCriteria(de.symeda.sormas.api.sample.SampleCriteria) SampleListComponentLayout(de.symeda.sormas.ui.samples.sampleLink.SampleListComponentLayout) SormasToSormasListComponent(de.symeda.sormas.ui.sormastosormas.SormasToSormasListComponent) VaccinationListCriteria(de.symeda.sormas.api.vaccination.VaccinationListCriteria) LayoutWithSidePanel(de.symeda.sormas.ui.utils.LayoutWithSidePanel) ImmunizationListComponent(de.symeda.sormas.ui.immunization.immunizationlink.ImmunizationListComponent)

Aggregations

DetailSubComponentWrapper (de.symeda.sormas.ui.utils.DetailSubComponentWrapper)8 SideComponentLayout (de.symeda.sormas.ui.utils.components.sidecomponent.SideComponentLayout)8 VerticalLayout (com.vaadin.ui.VerticalLayout)6 EditPermissionType (de.symeda.sormas.api.EditPermissionType)5 ImmunizationListCriteria (de.symeda.sormas.api.immunization.ImmunizationListCriteria)4 VaccinationListCriteria (de.symeda.sormas.api.vaccination.VaccinationListCriteria)4 SormasToSormasListComponent (de.symeda.sormas.ui.sormastosormas.SormasToSormasListComponent)4 LayoutWithSidePanel (de.symeda.sormas.ui.utils.LayoutWithSidePanel)4 Button (com.vaadin.ui.Button)3 CustomLayout (com.vaadin.ui.CustomLayout)3 CaseDataDto (de.symeda.sormas.api.caze.CaseDataDto)3 EventDto (de.symeda.sormas.api.event.EventDto)3 SampleCriteria (de.symeda.sormas.api.sample.SampleCriteria)3 UserProvider (de.symeda.sormas.ui.UserProvider)3 DocumentListComponent (de.symeda.sormas.ui.document.DocumentListComponent)3 EventListComponent (de.symeda.sormas.ui.events.eventLink.EventListComponent)3 ImmunizationListComponent (de.symeda.sormas.ui.immunization.immunizationlink.ImmunizationListComponent)3 SampleListComponent (de.symeda.sormas.ui.samples.sampleLink.SampleListComponent)3 SampleListComponentLayout (de.symeda.sormas.ui.samples.sampleLink.SampleListComponentLayout)3 TaskListComponent (de.symeda.sormas.ui.task.TaskListComponent)3