Search in sources :

Example 1 with ContactListComponent

use of de.symeda.sormas.ui.contact.ContactListComponent in project SORMAS-Project by hzi-braunschweig.

the class EventParticipantDataView method initView.

@Override
protected void initView(String params) {
    EventParticipantDto eventParticipant = FacadeProvider.getEventParticipantFacade().getEventParticipantByUuid(getReference().getUuid());
    setHeightUndefined();
    final EventParticipantReferenceDto eventParticipantRef = getReference();
    editComponent = ControllerProvider.getEventParticipantController().getEventParticipantDataEditComponent(eventParticipantRef.getUuid());
    DetailSubComponentWrapper container = new DetailSubComponentWrapper(() -> editComponent);
    container.setWidth(100, Unit.PERCENTAGE);
    container.setMargin(true);
    setSubComponent(container);
    LayoutWithSidePanel layout = new LayoutWithSidePanel(editComponent, SAMPLES_LOC, CONTACTS_LOC, IMMUNIZATION_LOC, VACCINATIONS_LOC, QUARANTINE_LOC, SORMAS_TO_SORMAS_LOC);
    container.addComponent(layout);
    EventDto event = FacadeProvider.getEventFacade().getEventByUuid(eventParticipant.getEvent().getUuid(), false);
    SampleCriteria sampleCriteria = new SampleCriteria().eventParticipant(eventParticipantRef);
    if (UserProvider.getCurrent().hasUserRight(UserRight.SAMPLE_VIEW)) {
        SampleListComponent sampleList = new SampleListComponent(sampleCriteria.eventParticipant(eventParticipantRef).disease(event.getDisease()).sampleAssociationType(SampleAssociationType.EVENT_PARTICIPANT), this::showUnsavedChangesPopup);
        SampleListComponentLayout sampleListComponentLayout = new SampleListComponentLayout(sampleList, I18nProperties.getString(Strings.infoCreateNewSampleDiscardsChangesEventParticipant));
        layout.addSidePanelComponent(sampleListComponentLayout, SAMPLES_LOC);
    }
    if (UserProvider.getCurrent().hasUserRight(UserRight.CONTACT_VIEW)) {
        VerticalLayout contactsLayout = new VerticalLayout();
        contactsLayout.setMargin(false);
        contactsLayout.setSpacing(false);
        ContactListComponent contactList = new ContactListComponent(eventParticipantRef, this::showUnsavedChangesPopup);
        contactList.addStyleName(CssStyles.SIDE_COMPONENT);
        contactsLayout.addComponent(contactList);
        layout.addSidePanelComponent(contactsLayout, CONTACTS_LOC);
    }
    boolean sormasToSormasEnabled = FacadeProvider.getSormasToSormasFacade().isSharingEventsEnabledForUser();
    if (sormasToSormasEnabled || eventParticipant.getSormasToSormasOriginInfo() != null) {
        VerticalLayout sormasToSormasLocLayout = new VerticalLayout();
        sormasToSormasLocLayout.setMargin(false);
        sormasToSormasLocLayout.setSpacing(false);
        SormasToSormasListComponent sormasToSormasListComponent = new SormasToSormasListComponent(eventParticipant, sormasToSormasEnabled);
        sormasToSormasListComponent.addStyleNames(CssStyles.SIDE_COMPONENT);
        sormasToSormasLocLayout.addComponent(sormasToSormasListComponent);
        layout.addSidePanelComponent(sormasToSormasLocLayout, SORMAS_TO_SORMAS_LOC);
    }
    VaccinationListCriteria vaccinationCriteria = new VaccinationListCriteria.Builder(eventParticipant.getPerson().toReference()).withDisease(event.getDisease()).build();
    QuarantineOrderDocumentsComponent.addComponentToLayout(layout.getSidePanelComponent(), eventParticipantRef, DocumentWorkflow.QUARANTINE_ORDER_EVENT_PARTICIPANT, sampleCriteria, vaccinationCriteria);
    if (FacadeProvider.getFeatureConfigurationFacade().isFeatureEnabled(FeatureType.IMMUNIZATION_MANAGEMENT) && UserProvider.getCurrent().hasUserRight(UserRight.IMMUNIZATION_VIEW) && event.getDisease() != null) {
        if (!FacadeProvider.getFeatureConfigurationFacade().isPropertyValueTrue(FeatureType.IMMUNIZATION_MANAGEMENT, FeatureTypeProperty.REDUCED)) {
            final ImmunizationListCriteria immunizationListCriteria = new ImmunizationListCriteria.Builder(eventParticipant.getPerson().toReference()).wihDisease(event.getDisease()).build();
            layout.addSidePanelComponent(new SideComponentLayout(new ImmunizationListComponent(immunizationListCriteria, this::showUnsavedChangesPopup)), IMMUNIZATION_LOC);
        } else {
            VaccinationListCriteria criteria = vaccinationCriteria.vaccinationAssociationType(VaccinationAssociationType.EVENT_PARTICIPANT).eventParticipantReference(getReference()).region(eventParticipant.getRegion() != null ? eventParticipant.getRegion() : event.getEventLocation().getRegion()).district(eventParticipant.getDistrict() != null ? eventParticipant.getDistrict() : event.getEventLocation().getDistrict());
            layout.addSidePanelComponent(new SideComponentLayout(new VaccinationListComponent(criteria, this::showUnsavedChangesPopup)), VACCINATIONS_LOC);
        }
    }
    EditPermissionType eventParticipantEditAllowed = FacadeProvider.getEventParticipantFacade().isEventParticipantEditAllowed(eventParticipantRef.getUuid());
    if (eventParticipantEditAllowed.equals(EditPermissionType.ARCHIVING_STATUS_ONLY)) {
        layout.disable(ArchivingController.ARCHIVE_DEARCHIVE_BUTTON_ID);
    } else if (eventParticipantEditAllowed.equals(EditPermissionType.REFUSED)) {
        layout.disable();
    }
}
Also used : DetailSubComponentWrapper(de.symeda.sormas.ui.utils.DetailSubComponentWrapper) SampleCriteria(de.symeda.sormas.api.sample.SampleCriteria) SampleListComponentLayout(de.symeda.sormas.ui.samples.sampleLink.SampleListComponentLayout) SormasToSormasListComponent(de.symeda.sormas.ui.sormastosormas.SormasToSormasListComponent) EventDto(de.symeda.sormas.api.event.EventDto) EditPermissionType(de.symeda.sormas.api.EditPermissionType) EventParticipantDto(de.symeda.sormas.api.event.EventParticipantDto) VaccinationListComponent(de.symeda.sormas.ui.vaccination.list.VaccinationListComponent) VaccinationListCriteria(de.symeda.sormas.api.vaccination.VaccinationListCriteria) SideComponentLayout(de.symeda.sormas.ui.utils.components.sidecomponent.SideComponentLayout) LayoutWithSidePanel(de.symeda.sormas.ui.utils.LayoutWithSidePanel) SampleListComponent(de.symeda.sormas.ui.samples.sampleLink.SampleListComponent) ContactListComponent(de.symeda.sormas.ui.contact.ContactListComponent) EventParticipantReferenceDto(de.symeda.sormas.api.event.EventParticipantReferenceDto) VerticalLayout(com.vaadin.ui.VerticalLayout) ImmunizationListCriteria(de.symeda.sormas.api.immunization.ImmunizationListCriteria) ImmunizationListComponent(de.symeda.sormas.ui.immunization.immunizationlink.ImmunizationListComponent)

Aggregations

VerticalLayout (com.vaadin.ui.VerticalLayout)1 EditPermissionType (de.symeda.sormas.api.EditPermissionType)1 EventDto (de.symeda.sormas.api.event.EventDto)1 EventParticipantDto (de.symeda.sormas.api.event.EventParticipantDto)1 EventParticipantReferenceDto (de.symeda.sormas.api.event.EventParticipantReferenceDto)1 ImmunizationListCriteria (de.symeda.sormas.api.immunization.ImmunizationListCriteria)1 SampleCriteria (de.symeda.sormas.api.sample.SampleCriteria)1 VaccinationListCriteria (de.symeda.sormas.api.vaccination.VaccinationListCriteria)1 ContactListComponent (de.symeda.sormas.ui.contact.ContactListComponent)1 ImmunizationListComponent (de.symeda.sormas.ui.immunization.immunizationlink.ImmunizationListComponent)1 SampleListComponent (de.symeda.sormas.ui.samples.sampleLink.SampleListComponent)1 SampleListComponentLayout (de.symeda.sormas.ui.samples.sampleLink.SampleListComponentLayout)1 SormasToSormasListComponent (de.symeda.sormas.ui.sormastosormas.SormasToSormasListComponent)1 DetailSubComponentWrapper (de.symeda.sormas.ui.utils.DetailSubComponentWrapper)1 LayoutWithSidePanel (de.symeda.sormas.ui.utils.LayoutWithSidePanel)1 SideComponentLayout (de.symeda.sormas.ui.utils.components.sidecomponent.SideComponentLayout)1 VaccinationListComponent (de.symeda.sormas.ui.vaccination.list.VaccinationListComponent)1