Search in sources :

Example 1 with ActionStatus

use of de.symeda.sormas.api.action.ActionStatus in project SORMAS-Project by hzi-braunschweig.

the class EventsView method createStatusFilterBar.

public HorizontalLayout createStatusFilterBar() {
    HorizontalLayout statusFilterLayout = new HorizontalLayout();
    statusFilterLayout.setSpacing(true);
    statusFilterLayout.setMargin(false);
    statusFilterLayout.setWidth(100, Unit.PERCENTAGE);
    statusFilterLayout.addStyleName(CssStyles.VSPACE_3);
    statusButtons = new HashMap<>();
    if (isDefaultViewType()) {
        Button statusAll = ButtonHelper.createButton(Captions.all, e -> {
            eventCriteria.setEventStatus(null);
            navigateTo(eventCriteria);
        }, ValoTheme.BUTTON_BORDERLESS, CssStyles.BUTTON_FILTER);
        statusAll.setCaptionAsHtml(true);
        statusFilterLayout.addComponent(statusAll);
        statusButtons.put(statusAll, I18nProperties.getCaption(Captions.all));
        activeStatusButton = statusAll;
        for (EventStatus status : EventStatus.values()) {
            Button statusButton = ButtonHelper.createButton("status-" + status, status.toString(), e -> {
                eventCriteria.setEventStatus(status);
                navigateTo(eventCriteria);
            }, ValoTheme.BUTTON_BORDERLESS, CssStyles.BUTTON_FILTER, CssStyles.BUTTON_FILTER_LIGHT);
            statusButton.setCaptionAsHtml(true);
            statusButton.setData(status);
            statusFilterLayout.addComponent(statusButton);
            statusButtons.put(statusButton, status.toString());
        }
    } else if (isActionViewType()) {
        Button statusAll = ButtonHelper.createButton(Captions.all, e -> {
            eventCriteria.setActionStatus(null);
            navigateTo(eventCriteria);
        }, ValoTheme.BUTTON_BORDERLESS, CssStyles.BUTTON_FILTER);
        statusAll.setCaptionAsHtml(true);
        statusFilterLayout.addComponent(statusAll);
        statusButtons.put(statusAll, I18nProperties.getCaption(Captions.all));
        activeStatusButton = statusAll;
        for (ActionStatus status : ActionStatus.values()) {
            Button statusButton = ButtonHelper.createButton("status-" + status, status.toString(), e -> {
                eventCriteria.actionStatus(status);
                navigateTo(eventCriteria);
            }, ValoTheme.BUTTON_BORDERLESS, CssStyles.BUTTON_FILTER, CssStyles.BUTTON_FILTER_LIGHT);
            statusButton.setCaptionAsHtml(true);
            statusButton.setData(status);
            statusFilterLayout.addComponent(statusButton);
            statusButtons.put(statusButton, status.toString());
        }
    }
    HorizontalLayout actionButtonsLayout = new HorizontalLayout();
    actionButtonsLayout.setSpacing(true);
    {
        // Show active/archived/all dropdown
        if (UserProvider.getCurrent().hasUserRight(UserRight.EVENT_VIEW)) {
            if (isGroupViewType()) {
                groupRelevanceStatusFilter = buildRelevanceStatus(Captions.eventActiveGroups, Captions.eventArchivedGroups, Captions.eventAllGroups);
                groupRelevanceStatusFilter.addValueChangeListener(e -> {
                    eventGroupCriteria.relevanceStatus((EntityRelevanceStatus) e.getProperty().getValue());
                    navigateTo(eventGroupCriteria);
                });
                actionButtonsLayout.addComponent(groupRelevanceStatusFilter);
            } else {
                int daysAfterEventGetsArchived = FacadeProvider.getConfigFacade().getDaysAfterEventGetsArchived();
                if (daysAfterEventGetsArchived > 0) {
                    relevanceStatusInfoLabel = new Label(VaadinIcons.INFO_CIRCLE.getHtml() + " " + String.format(I18nProperties.getString(Strings.infoArchivedEvents), daysAfterEventGetsArchived), ContentMode.HTML);
                    relevanceStatusInfoLabel.setVisible(false);
                    relevanceStatusInfoLabel.addStyleName(CssStyles.LABEL_VERTICAL_ALIGN_SUPER);
                    actionButtonsLayout.addComponent(relevanceStatusInfoLabel);
                    actionButtonsLayout.setComponentAlignment(relevanceStatusInfoLabel, Alignment.MIDDLE_RIGHT);
                }
                eventRelevanceStatusFilter = buildRelevanceStatus(Captions.eventActiveEvents, Captions.eventArchivedEvents, Captions.eventAllEvents);
                eventRelevanceStatusFilter.addValueChangeListener(e -> {
                    relevanceStatusInfoLabel.setVisible(EntityRelevanceStatus.ARCHIVED.equals(e.getProperty().getValue()));
                    eventCriteria.relevanceStatus((EntityRelevanceStatus) e.getProperty().getValue());
                    navigateTo(eventCriteria);
                });
                actionButtonsLayout.addComponent(eventRelevanceStatusFilter);
            }
        }
        // Bulk operation dropdown
        if (UserProvider.getCurrent().hasUserRight(UserRight.PERFORM_BULK_OPERATIONS_EVENT) && isDefaultViewType()) {
            EventGrid eventGrid = (EventGrid) grid;
            List<MenuBarHelper.MenuBarItem> bulkActions = new ArrayList<>();
            if (UserProvider.getCurrent().hasUserRight(UserRight.EVENT_EDIT)) {
                bulkActions.add(new MenuBarHelper.MenuBarItem(I18nProperties.getCaption(Captions.bulkEdit), VaadinIcons.ELLIPSIS_H, mi -> grid.bulkActionHandler(items -> ControllerProvider.getEventController().showBulkEventDataEditComponent(items))));
            }
            if (UserProvider.getCurrent().hasUserRight(UserRight.EVENT_DELETE)) {
                bulkActions.add(new MenuBarHelper.MenuBarItem(I18nProperties.getCaption(Captions.bulkDelete), VaadinIcons.TRASH, mi -> grid.bulkActionHandler(items -> ControllerProvider.getEventController().deleteAllSelectedItems(items, () -> navigateTo(eventCriteria)), true)));
            }
            if (UserProvider.getCurrent().hasUserRight(UserRight.EVENT_ARCHIVE)) {
                bulkActions.add(new MenuBarHelper.MenuBarItem(I18nProperties.getCaption(Captions.actionArchive), VaadinIcons.ARCHIVE, mi -> grid.bulkActionHandler(items -> ControllerProvider.getEventController().archiveAllSelectedItems(items, () -> navigateTo(eventCriteria, true)), true), EntityRelevanceStatus.ACTIVE.equals(eventCriteria.getRelevanceStatus())));
                bulkActions.add(new MenuBarHelper.MenuBarItem(I18nProperties.getCaption(Captions.actionDearchive), VaadinIcons.ARCHIVE, mi -> grid.bulkActionHandler(items -> ControllerProvider.getEventController().dearchiveAllSelectedItems(eventGrid.asMultiSelect().getSelectedItems(), () -> navigateTo(eventCriteria, true)), true), EntityRelevanceStatus.ARCHIVED.equals(eventCriteria.getRelevanceStatus())));
            }
            if (UserProvider.getCurrent().hasUserRight(UserRight.EVENTGROUP_CREATE) && UserProvider.getCurrent().hasUserRight(UserRight.EVENTGROUP_LINK)) {
                bulkActions.add(new MenuBarHelper.MenuBarItem(I18nProperties.getCaption(Captions.actionGroupEvent), VaadinIcons.FILE_TREE, mi -> grid.bulkActionHandler(items -> ControllerProvider.getEventGroupController().linkAllToGroup(eventGrid.asMultiSelect().getSelectedItems(), () -> navigateTo(eventCriteria)))));
            }
            bulkActions.add(new MenuBarHelper.MenuBarItem(I18nProperties.getCaption(Captions.ExternalSurveillanceToolGateway_send), VaadinIcons.SHARE, mi -> grid.bulkActionHandler(items -> ControllerProvider.getEventController().sendAllSelectedToExternalSurveillanceTool(eventGrid.asMultiSelect().getSelectedItems(), () -> navigateTo(eventCriteria))), FacadeProvider.getExternalSurveillanceToolFacade().isFeatureEnabled()));
            if (isDocGenerationAllowed()) {
                bulkActions.add(new MenuBarHelper.MenuBarItem(I18nProperties.getCaption(Captions.bulkActionCreatDocuments), VaadinIcons.FILE_TEXT, mi -> {
                    grid.bulkActionHandler(items -> {
                        EventGrid eventGrid1 = (EventGrid) this.grid;
                        List<EventReferenceDto> references = eventGrid1.asMultiSelect().getSelectedItems().stream().map(EventIndexDto::toReference).collect(Collectors.toList());
                        if (references.size() == 0) {
                            new Notification(I18nProperties.getString(Strings.headingNoEventsSelected), I18nProperties.getString(Strings.headingNoEventsSelected), Notification.Type.WARNING_MESSAGE, false).show(Page.getCurrent());
                            return;
                        }
                        ControllerProvider.getDocGenerationController().showEventDocumentDialog(references);
                    });
                }));
            }
            bulkOperationsDropdown = MenuBarHelper.createDropDown(Captions.bulkActions, bulkActions);
            bulkOperationsDropdown.setVisible(viewConfiguration.isInEagerMode());
            bulkOperationsDropdown.setCaption("");
            actionButtonsLayout.addComponent(bulkOperationsDropdown);
        }
        if (isDefaultViewType()) {
            // Contact Count Method Dropdown
            contactCountMethod = ComboBoxHelper.createComboBoxV7();
            contactCountMethod.setCaption(I18nProperties.getCaption(Captions.Event_contactCountMethod));
            contactCountMethod.addItem(EventContactCountMethod.ALL);
            contactCountMethod.addItem(EventContactCountMethod.SOURCE_CASE_IN_EVENT);
            contactCountMethod.addItem(EventContactCountMethod.BOTH_METHODS);
            contactCountMethod.setItemCaption(EventContactCountMethod.ALL, I18nProperties.getEnumCaption(EventContactCountMethod.ALL));
            contactCountMethod.setItemCaption(EventContactCountMethod.SOURCE_CASE_IN_EVENT, I18nProperties.getEnumCaption(EventContactCountMethod.SOURCE_CASE_IN_EVENT));
            contactCountMethod.setItemCaption(EventContactCountMethod.BOTH_METHODS, I18nProperties.getEnumCaption(EventContactCountMethod.BOTH_METHODS));
            contactCountMethod.setValue(EventContactCountMethod.ALL);
            contactCountMethod.setTextInputAllowed(false);
            contactCountMethod.setNullSelectionAllowed(false);
            contactCountMethod.addValueChangeListener(event -> {
                ((EventGrid) grid).setContactCountMethod((EventContactCountMethod) event.getProperty().getValue());
                ((EventGrid) grid).reload();
            });
            actionButtonsLayout.addComponent(contactCountMethod);
        }
    }
    statusFilterLayout.addComponent(actionButtonsLayout);
    statusFilterLayout.setComponentAlignment(actionButtonsLayout, Alignment.TOP_RIGHT);
    statusFilterLayout.setExpandRatio(actionButtonsLayout, 1);
    return statusFilterLayout;
}
Also used : FeatureType(de.symeda.sormas.api.feature.FeatureType) ActionStatus(de.symeda.sormas.api.action.ActionStatus) TextField(com.vaadin.ui.TextField) Date(java.util.Date) I18nProperties(de.symeda.sormas.api.i18n.I18nProperties) Alignment(com.vaadin.ui.Alignment) UI(com.vaadin.ui.UI) Window(com.vaadin.ui.Window) ControllerProvider(de.symeda.sormas.ui.ControllerProvider) ExportEntityName(de.symeda.sormas.ui.utils.ExportEntityName) ViewModelProviders(de.symeda.sormas.ui.ViewModelProviders) CssStyles(de.symeda.sormas.ui.utils.CssStyles) MenuBarHelper(de.symeda.sormas.ui.utils.MenuBarHelper) Page(com.vaadin.server.Page) ViewChangeEvent(com.vaadin.navigator.ViewChangeListener.ViewChangeEvent) VaadinIcons(com.vaadin.icons.VaadinIcons) ComboBoxHelper(de.symeda.sormas.ui.utils.ComboBoxHelper) UserProvider(de.symeda.sormas.ui.UserProvider) ValoTheme(com.vaadin.ui.themes.ValoTheme) DownloadUtil(de.symeda.sormas.ui.utils.DownloadUtil) FilteredGrid(de.symeda.sormas.ui.utils.FilteredGrid) MenuBar(com.vaadin.ui.MenuBar) ComboBox(com.vaadin.v7.ui.ComboBox) Set(java.util.Set) RefreshEvent(org.hibernate.event.spi.RefreshEvent) EventDto(de.symeda.sormas.api.event.EventDto) Collectors(java.util.stream.Collectors) ExportConfigurationDto(de.symeda.sormas.api.importexport.ExportConfigurationDto) List(java.util.List) EventImportLayout(de.symeda.sormas.ui.events.importer.EventImportLayout) EventIndexDto(de.symeda.sormas.api.event.EventIndexDto) StreamResource(com.vaadin.server.StreamResource) VaadinUiUtil(de.symeda.sormas.ui.utils.VaadinUiUtil) SearchSpecificLayout(de.symeda.sormas.ui.SearchSpecificLayout) FacadeProvider(de.symeda.sormas.api.FacadeProvider) DateFormatHelper(de.symeda.sormas.ui.utils.DateFormatHelper) VerticalLayout(com.vaadin.ui.VerticalLayout) GridExportStreamResource(de.symeda.sormas.ui.utils.GridExportStreamResource) HashMap(java.util.HashMap) PopupButton(org.vaadin.hene.popupbutton.PopupButton) EntityRelevanceStatus(de.symeda.sormas.api.EntityRelevanceStatus) EventGroupCriteria(de.symeda.sormas.api.event.EventGroupCriteria) PopupMenu(de.symeda.sormas.ui.utils.components.popupmenu.PopupMenu) EventStatus(de.symeda.sormas.api.event.EventStatus) ArrayList(java.util.ArrayList) CaseReferenceDto(de.symeda.sormas.api.caze.CaseReferenceDto) OptionGroup(com.vaadin.v7.ui.OptionGroup) EventCriteria(de.symeda.sormas.api.event.EventCriteria) Notification(com.vaadin.ui.Notification) SormasUI(de.symeda.sormas.ui.SormasUI) Label(com.vaadin.ui.Label) EventActionExportDto(de.symeda.sormas.api.event.EventActionExportDto) AbstractView(de.symeda.sormas.ui.utils.AbstractView) ButtonHelper(de.symeda.sormas.ui.utils.ButtonHelper) ContentMode(com.vaadin.shared.ui.ContentMode) Captions(de.symeda.sormas.api.i18n.Captions) EventActionIndexDto(de.symeda.sormas.api.event.EventActionIndexDto) UserRight(de.symeda.sormas.api.user.UserRight) Button(com.vaadin.ui.Button) LayoutUtil(de.symeda.sormas.ui.utils.LayoutUtil) ImportExportUtils(de.symeda.sormas.api.importexport.ImportExportUtils) HorizontalLayout(com.vaadin.ui.HorizontalLayout) EventReferenceDto(de.symeda.sormas.api.event.EventReferenceDto) Strings(de.symeda.sormas.api.i18n.Strings) ExportPropertyMetaInfo(de.symeda.sormas.api.importexport.ExportPropertyMetaInfo) DocGenerationHelper.isDocGenerationAllowed(de.symeda.sormas.ui.docgeneration.DocGenerationHelper.isDocGenerationAllowed) Collections(java.util.Collections) EventDownloadUtil(de.symeda.sormas.ui.utils.EventDownloadUtil) ActionDto(de.symeda.sormas.api.action.ActionDto) EventStatus(de.symeda.sormas.api.event.EventStatus) EntityRelevanceStatus(de.symeda.sormas.api.EntityRelevanceStatus) Label(com.vaadin.ui.Label) Notification(com.vaadin.ui.Notification) HorizontalLayout(com.vaadin.ui.HorizontalLayout) ActionStatus(de.symeda.sormas.api.action.ActionStatus) MenuBarHelper(de.symeda.sormas.ui.utils.MenuBarHelper) PopupButton(org.vaadin.hene.popupbutton.PopupButton) Button(com.vaadin.ui.Button) EventReferenceDto(de.symeda.sormas.api.event.EventReferenceDto) List(java.util.List) ArrayList(java.util.ArrayList)

Aggregations

VaadinIcons (com.vaadin.icons.VaadinIcons)1 ViewChangeEvent (com.vaadin.navigator.ViewChangeListener.ViewChangeEvent)1 Page (com.vaadin.server.Page)1 StreamResource (com.vaadin.server.StreamResource)1 ContentMode (com.vaadin.shared.ui.ContentMode)1 Alignment (com.vaadin.ui.Alignment)1 Button (com.vaadin.ui.Button)1 HorizontalLayout (com.vaadin.ui.HorizontalLayout)1 Label (com.vaadin.ui.Label)1 MenuBar (com.vaadin.ui.MenuBar)1 Notification (com.vaadin.ui.Notification)1 TextField (com.vaadin.ui.TextField)1 UI (com.vaadin.ui.UI)1 VerticalLayout (com.vaadin.ui.VerticalLayout)1 Window (com.vaadin.ui.Window)1 ValoTheme (com.vaadin.ui.themes.ValoTheme)1 ComboBox (com.vaadin.v7.ui.ComboBox)1 OptionGroup (com.vaadin.v7.ui.OptionGroup)1 EntityRelevanceStatus (de.symeda.sormas.api.EntityRelevanceStatus)1 FacadeProvider (de.symeda.sormas.api.FacadeProvider)1