Search in sources :

Example 1 with EventDocumentsComponent

use of de.symeda.sormas.ui.docgeneration.EventDocumentsComponent in project SORMAS-Project by hzi-braunschweig.

the class EventDataView method initView.

@Override
protected void initView(String params) {
    EventDto event = FacadeProvider.getEventFacade().getEventByUuid(getEventRef().getUuid(), false);
    setHeightUndefined();
    DetailSubComponentWrapper container = new DetailSubComponentWrapper(() -> editComponent);
    container.setWidth(100, Unit.PERCENTAGE);
    container.setMargin(true);
    setSubComponent(container);
    editComponent = ControllerProvider.getEventController().getEventDataEditComponent(getEventRef().getUuid(), this::setExternalSurvToolLayoutVisibility);
    LayoutWithSidePanel layout = new LayoutWithSidePanel(editComponent, TASKS_LOC, ACTIONS_LOC, DOCUMENTS_LOC, EventDocumentsComponent.DOCGENERATION_LOC, SUPERORDINATE_EVENT_LOC, SUBORDINATE_EVENTS_LOC, EVENT_GROUPS_LOC, SORMAS_TO_SORMAS_LOC, ExternalSurveillanceServiceGateway.EXTERANEL_SURVEILLANCE_TOOL_GATEWAY_LOC, SHORTCUT_LINKS_LOC);
    container.addComponent(layout);
    externalSurvToolLayout = ExternalSurveillanceServiceGateway.addComponentToLayout(layout.getSidePanelComponent(), editComponent, event);
    setExternalSurvToolLayoutVisibility(event.getEventStatus());
    if (FacadeProvider.getFeatureConfigurationFacade().isFeatureEnabled(FeatureType.TASK_MANAGEMENT)) {
        TaskListComponent taskList = new TaskListComponent(TaskContext.EVENT, getEventRef(), event.getDisease());
        taskList.addStyleName(CssStyles.SIDE_COMPONENT);
        layout.addSidePanelComponent(taskList, TASKS_LOC);
    }
    ActionStatsComponent actionList = new ActionStatsComponent(ActionContext.EVENT, getEventRef());
    actionList.addStyleName(CssStyles.SIDE_COMPONENT);
    layout.addSidePanelComponent(actionList, ACTIONS_LOC);
    DocumentListComponent documentList = null;
    if (FacadeProvider.getFeatureConfigurationFacade().isFeatureEnabled(FeatureType.DOCUMENTS)) {
        // TODO: user rights?
        documentList = new DocumentListComponent(DocumentRelatedEntityType.EVENT, getEventRef(), UserRight.EVENT_EDIT, event.isPseudonymized());
        layout.addSidePanelComponent(new SideComponentLayout(documentList), DOCUMENTS_LOC);
    }
    EventDocumentsComponent eventDocuments = new EventDocumentsComponent(getEventRef(), documentList);
    eventDocuments.addStyleName(CssStyles.SIDE_COMPONENT);
    layout.addSidePanelComponent(eventDocuments, EventDocumentsComponent.DOCGENERATION_LOC);
    boolean eventHierarchiesFeatureEnabled = FacadeProvider.getFeatureConfigurationFacade().isFeatureEnabled(FeatureType.EVENT_HIERARCHIES);
    if (eventHierarchiesFeatureEnabled) {
        SuperordinateEventComponent superordinateEventComponent = new SuperordinateEventComponent(event, this::showUnsavedChangesPopup);
        superordinateEventComponent.addStyleName(CssStyles.SIDE_COMPONENT);
        layout.addSidePanelComponent(superordinateEventComponent, SUPERORDINATE_EVENT_LOC);
        EventListComponent subordinateEventList = new EventListComponent(event.toReference(), this::showUnsavedChangesPopup);
        subordinateEventList.addStyleName(CssStyles.SIDE_COMPONENT);
        layout.addSidePanelComponent(subordinateEventList, SUBORDINATE_EVENTS_LOC);
    }
    boolean eventGroupsFeatureEnabled = FacadeProvider.getFeatureConfigurationFacade().isFeatureEnabled(FeatureType.EVENT_GROUPS);
    if (eventGroupsFeatureEnabled) {
        layout.addSidePanelComponent(new SideComponentLayout(new EventGroupListComponent(event.toReference(), this::showUnsavedChangesPopup)), EVENT_GROUPS_LOC);
    }
    boolean sormasToSormasEnabled = FacadeProvider.getSormasToSormasFacade().isSharingEventsEnabledForUser();
    if (sormasToSormasEnabled || event.getSormasToSormasOriginInfo() != null) {
        VerticalLayout sormasToSormasLocLayout = new VerticalLayout();
        sormasToSormasLocLayout.setMargin(false);
        sormasToSormasLocLayout.setSpacing(false);
        SormasToSormasListComponent sormasToSormasListComponent = new SormasToSormasListComponent(event, sormasToSormasEnabled);
        sormasToSormasListComponent.addStyleNames(CssStyles.SIDE_COMPONENT);
        sormasToSormasLocLayout.addComponent(sormasToSormasListComponent);
        layout.addSidePanelComponent(sormasToSormasLocLayout, SORMAS_TO_SORMAS_LOC);
    }
    VerticalLayout shortcutLinksLayout = new VerticalLayout();
    shortcutLinksLayout.setMargin(false);
    shortcutLinksLayout.setSpacing(true);
    if (UserProvider.getCurrent().hasUserRight(UserRight.CASE_VIEW)) {
        Button seeEventCasesBtn = ButtonHelper.createButton("eventLinkToCases", I18nProperties.getCaption(Captions.eventLinkToCases), thisEvent -> ControllerProvider.getCaseController().navigateTo(new CaseCriteria().eventLike(getEventRef().getUuid())), ValoTheme.BUTTON_PRIMARY);
        shortcutLinksLayout.addComponent(seeEventCasesBtn);
    }
    if (UserProvider.getCurrent().hasUserRight(UserRight.CONTACT_VIEW)) {
        Button seeEventContactsBtn = ButtonHelper.createButton("eventLinkToContacts", I18nProperties.getCaption(Captions.eventLinkToContacts), thisEvent -> ControllerProvider.getContactController().navigateTo(new ContactCriteria().eventUuid(getEventRef().getUuid())), ValoTheme.BUTTON_PRIMARY);
        shortcutLinksLayout.addComponent(seeEventContactsBtn);
    }
    LocationDto eventLocationDto = ((EventDataForm) editComponent.getWrappedComponent()).getValue().getEventLocation();
    if (eventLocationDto.getFacility() != null) {
        Button seeEventsWithinTheSameFacility = ButtonHelper.createButton("eventLinkToEventsWithinTheSameFacility", I18nProperties.getCaption(Captions.eventLinkToEventsWithinTheSameFacility), thisEvent -> ControllerProvider.getEventController().navigateTo(new EventCriteria().region(eventLocationDto.getRegion()).district(eventLocationDto.getDistrict()).eventCommunity(eventLocationDto.getCommunity()).typeOfPlace(TypeOfPlace.FACILITY).facilityType(eventLocationDto.getFacilityType()).facility(eventLocationDto.getFacility())), ValoTheme.BUTTON_PRIMARY);
        shortcutLinksLayout.addComponent(seeEventsWithinTheSameFacility);
    }
    layout.addSidePanelComponent(shortcutLinksLayout, SHORTCUT_LINKS_LOC);
    if (!UserProvider.getCurrent().hasUserRight(UserRight.EVENT_EDIT)) {
        layout.setEnabled(false);
    }
    EditPermissionType eventEditAllowed = FacadeProvider.getEventFacade().isEventEditAllowed(event.getUuid());
    if (eventEditAllowed == EditPermissionType.ARCHIVING_STATUS_ONLY) {
        layout.disable(ArchivingController.ARCHIVE_DEARCHIVE_BUTTON_ID);
    } else if (eventEditAllowed == EditPermissionType.REFUSED) {
        layout.disable();
    }
}
Also used : DetailSubComponentWrapper(de.symeda.sormas.ui.utils.DetailSubComponentWrapper) SuperordinateEventComponent(de.symeda.sormas.ui.events.eventLink.SuperordinateEventComponent) SormasToSormasListComponent(de.symeda.sormas.ui.sormastosormas.SormasToSormasListComponent) EventDto(de.symeda.sormas.api.event.EventDto) EditPermissionType(de.symeda.sormas.api.EditPermissionType) ActionStatsComponent(de.symeda.sormas.ui.action.ActionStatsComponent) EventCriteria(de.symeda.sormas.api.event.EventCriteria) DocumentListComponent(de.symeda.sormas.ui.document.DocumentListComponent) SideComponentLayout(de.symeda.sormas.ui.utils.components.sidecomponent.SideComponentLayout) EventGroupListComponent(de.symeda.sormas.ui.events.groups.EventGroupListComponent) LayoutWithSidePanel(de.symeda.sormas.ui.utils.LayoutWithSidePanel) Button(com.vaadin.ui.Button) TaskListComponent(de.symeda.sormas.ui.task.TaskListComponent) CaseCriteria(de.symeda.sormas.api.caze.CaseCriteria) ContactCriteria(de.symeda.sormas.api.contact.ContactCriteria) EventDocumentsComponent(de.symeda.sormas.ui.docgeneration.EventDocumentsComponent) VerticalLayout(com.vaadin.ui.VerticalLayout) EventListComponent(de.symeda.sormas.ui.events.eventLink.EventListComponent) LocationDto(de.symeda.sormas.api.location.LocationDto)

Aggregations

Button (com.vaadin.ui.Button)1 VerticalLayout (com.vaadin.ui.VerticalLayout)1 EditPermissionType (de.symeda.sormas.api.EditPermissionType)1 CaseCriteria (de.symeda.sormas.api.caze.CaseCriteria)1 ContactCriteria (de.symeda.sormas.api.contact.ContactCriteria)1 EventCriteria (de.symeda.sormas.api.event.EventCriteria)1 EventDto (de.symeda.sormas.api.event.EventDto)1 LocationDto (de.symeda.sormas.api.location.LocationDto)1 ActionStatsComponent (de.symeda.sormas.ui.action.ActionStatsComponent)1 EventDocumentsComponent (de.symeda.sormas.ui.docgeneration.EventDocumentsComponent)1 DocumentListComponent (de.symeda.sormas.ui.document.DocumentListComponent)1 EventListComponent (de.symeda.sormas.ui.events.eventLink.EventListComponent)1 SuperordinateEventComponent (de.symeda.sormas.ui.events.eventLink.SuperordinateEventComponent)1 EventGroupListComponent (de.symeda.sormas.ui.events.groups.EventGroupListComponent)1 SormasToSormasListComponent (de.symeda.sormas.ui.sormastosormas.SormasToSormasListComponent)1 TaskListComponent (de.symeda.sormas.ui.task.TaskListComponent)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