Search in sources :

Example 1 with EntityRelevanceStatus

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

the class CasesView 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<>();
    Button statusAll = ButtonHelper.createButton(Captions.all, e -> {
        criteria.investigationStatus(null);
        navigateTo(criteria);
    }, ValoTheme.BUTTON_BORDERLESS, CssStyles.BUTTON_FILTER);
    statusAll.setCaptionAsHtml(true);
    statusFilterLayout.addComponent(statusAll);
    statusButtons.put(statusAll, I18nProperties.getCaption(Captions.all));
    activeStatusButton = statusAll;
    for (InvestigationStatus status : InvestigationStatus.values()) {
        Button statusButton = ButtonHelper.createButton(status.toString(), e -> {
            criteria.investigationStatus(status);
            navigateTo(criteria);
        }, ValoTheme.BUTTON_BORDERLESS, CssStyles.BUTTON_FILTER, CssStyles.BUTTON_FILTER_LIGHT);
        statusButton.setData(status);
        statusButton.setCaptionAsHtml(true);
        statusFilterLayout.addComponent(statusButton);
        statusButtons.put(statusButton, status.toString());
    }
    HorizontalLayout actionButtonsLayout = new HorizontalLayout();
    actionButtonsLayout.setSpacing(true);
    {
        // Show active/archived/all dropdown
        if (Objects.nonNull(UserProvider.getCurrent()) && UserProvider.getCurrent().hasUserRight(UserRight.CASE_VIEW)) {
            int daysAfterCaseGetsArchived = FacadeProvider.getConfigFacade().getDaysAfterCaseGetsArchived();
            if (daysAfterCaseGetsArchived > 0) {
                relevanceStatusInfoLabel = new Label(VaadinIcons.INFO_CIRCLE.getHtml() + " " + String.format(I18nProperties.getString(Strings.infoArchivedCases), daysAfterCaseGetsArchived), ContentMode.HTML);
                relevanceStatusInfoLabel.setVisible(false);
                relevanceStatusInfoLabel.addStyleName(CssStyles.LABEL_VERTICAL_ALIGN_SUPER);
                actionButtonsLayout.addComponent(relevanceStatusInfoLabel);
                actionButtonsLayout.setComponentAlignment(relevanceStatusInfoLabel, Alignment.MIDDLE_RIGHT);
            }
            relevanceStatusFilter = ComboBoxHelper.createComboBoxV7();
            relevanceStatusFilter.setId("relevanceStatus");
            relevanceStatusFilter.setWidth(140, Unit.PIXELS);
            relevanceStatusFilter.setNullSelectionAllowed(false);
            relevanceStatusFilter.addItems((Object[]) EntityRelevanceStatus.values());
            relevanceStatusFilter.setItemCaption(EntityRelevanceStatus.ACTIVE, I18nProperties.getCaption(Captions.caseActiveCases));
            relevanceStatusFilter.setItemCaption(EntityRelevanceStatus.ARCHIVED, I18nProperties.getCaption(Captions.caseArchivedCases));
            relevanceStatusFilter.setItemCaption(EntityRelevanceStatus.ALL, I18nProperties.getCaption(Captions.caseAllCases));
            relevanceStatusFilter.addValueChangeListener(e -> {
                relevanceStatusInfoLabel.setVisible(EntityRelevanceStatus.ARCHIVED.equals(e.getProperty().getValue()));
                criteria.relevanceStatus((EntityRelevanceStatus) e.getProperty().getValue());
                navigateTo(criteria);
            });
            actionButtonsLayout.addComponent(relevanceStatusFilter);
        }
        if (viewConfiguration.getViewType().isCaseOverview()) {
            AbstractCaseGrid<?> caseGrid = (AbstractCaseGrid<?>) this.grid;
            // Bulk operation dropdown
            if (isBulkEditAllowed()) {
                boolean hasBulkOperationsRight = UserProvider.getCurrent().hasUserRight(UserRight.PERFORM_BULK_OPERATIONS_CASE_SAMPLES);
                final List<MenuBarHelper.MenuBarItem> menuBarItems = new ArrayList<>();
                menuBarItems.add(new MenuBarHelper.MenuBarItem(I18nProperties.getCaption(Captions.bulkEdit), VaadinIcons.ELLIPSIS_H, mi -> {
                    grid.bulkActionHandler(items -> ControllerProvider.getCaseController().showBulkCaseDataEditComponent(items));
                }, hasBulkOperationsRight));
                menuBarItems.add(new MenuBarHelper.MenuBarItem(I18nProperties.getCaption(Captions.bulkDelete), VaadinIcons.TRASH, mi -> {
                    grid.bulkActionHandler(items -> ControllerProvider.getCaseController().deleteAllSelectedItems(items, () -> navigateTo(criteria)), true);
                }, hasBulkOperationsRight));
                final boolean externalMessagesEnabled = FacadeProvider.getFeatureConfigurationFacade().isFeatureEnabled(FeatureType.MANUAL_EXTERNAL_MESSAGES);
                final boolean isSmsServiceSetUp = FacadeProvider.getConfigFacade().isSmsServiceSetUp();
                if (isSmsServiceSetUp && externalMessagesEnabled && UserProvider.getCurrent().hasUserRight(UserRight.SEND_MANUAL_EXTERNAL_MESSAGES)) {
                    menuBarItems.add(new MenuBarHelper.MenuBarItem(I18nProperties.getCaption(Captions.messagesSendSMS), VaadinIcons.MOBILE_RETRO, mi -> {
                        grid.bulkActionHandler(items -> ControllerProvider.getCaseController().sendSmsToAllSelectedItems(items, () -> navigateTo(criteria)));
                    }, hasBulkOperationsRight));
                }
                menuBarItems.add(new MenuBarHelper.MenuBarItem(I18nProperties.getCaption(Captions.actionArchive), VaadinIcons.ARCHIVE, mi -> {
                    grid.bulkActionHandler(items -> ControllerProvider.getCaseController().archiveAllSelectedItems(items, () -> navigateTo(criteria, true)), true);
                }, hasBulkOperationsRight && EntityRelevanceStatus.ACTIVE.equals(criteria.getRelevanceStatus())));
                menuBarItems.add(new MenuBarHelper.MenuBarItem(I18nProperties.getCaption(Captions.actionDearchive), VaadinIcons.ARCHIVE, mi -> {
                    grid.bulkActionHandler(items -> ControllerProvider.getCaseController().dearchiveAllSelectedItems(items, () -> navigateTo(criteria, true)), true);
                }, hasBulkOperationsRight && EntityRelevanceStatus.ARCHIVED.equals(criteria.getRelevanceStatus())));
                menuBarItems.add(new MenuBarHelper.MenuBarItem(I18nProperties.getCaption(Captions.sormasToSormasShare), VaadinIcons.SHARE, mi -> {
                    grid.bulkActionHandler(items -> ControllerProvider.getSormasToSormasController().shareSelectedCases(items, () -> navigateTo(criteria)));
                }, FacadeProvider.getSormasToSormasFacade().isSharingCasesContactsAndSamplesEnabledForUser()));
                menuBarItems.add(new MenuBarHelper.MenuBarItem(I18nProperties.getCaption(Captions.ExternalSurveillanceToolGateway_send), VaadinIcons.SHARE, mi -> {
                    grid.bulkActionHandler(items -> ControllerProvider.getCaseController().sendCasesToExternalSurveillanceTool(items, () -> navigateTo(criteria)));
                }, FacadeProvider.getExternalSurveillanceToolFacade().isFeatureEnabled()));
                if (isDocGenerationAllowed()) {
                    menuBarItems.add(new MenuBarHelper.MenuBarItem(I18nProperties.getCaption(Captions.bulkActionCreatDocuments), VaadinIcons.FILE_TEXT, mi -> {
                        grid.bulkActionHandler(items -> {
                            List<ReferenceDto> references = caseGrid.asMultiSelect().getSelectedItems().stream().map(CaseIndexDto::toReference).collect(Collectors.toList());
                            if (references.size() == 0) {
                                new Notification(I18nProperties.getString(Strings.headingNoCasesSelected), I18nProperties.getString(Strings.messageNoCasesSelected), Notification.Type.WARNING_MESSAGE, false).show(Page.getCurrent());
                                return;
                            }
                            ControllerProvider.getDocGenerationController().showBulkQuarantineOrderDocumentDialog(references, DocumentWorkflow.QUARANTINE_ORDER_CASE);
                        });
                    }));
                }
                if (FacadeProvider.getFeatureConfigurationFacade().isFeatureEnabled(FeatureType.EVENT_SURVEILLANCE)) {
                    menuBarItems.add(new MenuBarHelper.MenuBarItem(I18nProperties.getCaption(Captions.bulkLinkToEvent), VaadinIcons.PHONE, mi -> grid.bulkActionHandler(items -> {
                        List<CaseIndexDto> selectedCases = caseGrid.asMultiSelect().getSelectedItems().stream().collect(Collectors.toList());
                        if (selectedCases.isEmpty()) {
                            new Notification(I18nProperties.getString(Strings.headingNoCasesSelected), I18nProperties.getString(Strings.messageNoCasesSelected), Notification.Type.WARNING_MESSAGE, false).show(Page.getCurrent());
                            return;
                        }
                        if (!selectedCases.stream().allMatch(caze -> caze.getDisease().equals(selectedCases.stream().findAny().get().getDisease()))) {
                            new Notification(I18nProperties.getString(Strings.messageBulkCasesWithDifferentDiseasesSelected), Notification.Type.WARNING_MESSAGE).show(Page.getCurrent());
                            return;
                        }
                        ControllerProvider.getEventController().selectOrCreateEventForCaseList(selectedCases.stream().map(CaseIndexDto::toReference).collect(Collectors.toList()));
                    })));
                }
                bulkOperationsDropdown = MenuBarHelper.createDropDown(Captions.bulkActions, menuBarItems);
                bulkOperationsDropdown.setVisible(viewConfiguration.isInEagerMode());
                actionButtonsLayout.addComponent(bulkOperationsDropdown);
            }
        }
    }
    statusFilterLayout.addComponent(actionButtonsLayout);
    statusFilterLayout.setComponentAlignment(actionButtonsLayout, Alignment.TOP_RIGHT);
    statusFilterLayout.setExpandRatio(actionButtonsLayout, 1);
    return statusFilterLayout;
}
Also used : FeatureType(de.symeda.sormas.api.feature.FeatureType) CaseImportLayout(de.symeda.sormas.ui.caze.importer.CaseImportLayout) TextField(com.vaadin.ui.TextField) Date(java.util.Date) DocumentWorkflow(de.symeda.sormas.api.docgeneneration.DocumentWorkflow) I18nProperties(de.symeda.sormas.api.i18n.I18nProperties) Alignment(com.vaadin.ui.Alignment) UI(com.vaadin.ui.UI) ReferenceDto(de.symeda.sormas.api.ReferenceDto) Window(com.vaadin.ui.Window) PersonDto(de.symeda.sormas.api.person.PersonDto) 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) ExpandableButton(de.symeda.sormas.ui.utils.components.expandablebutton.ExpandableButton) 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) DateField(com.vaadin.ui.DateField) MenuBar(com.vaadin.ui.MenuBar) CaseCriteria(de.symeda.sormas.api.caze.CaseCriteria) ComboBox(com.vaadin.v7.ui.ComboBox) ExportType(de.symeda.sormas.api.importexport.ExportType) Set(java.util.Set) CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) InvestigationStatus(de.symeda.sormas.api.caze.InvestigationStatus) Collectors(java.util.stream.Collectors) Objects(java.util.Objects) CaseIndexDto(de.symeda.sormas.api.caze.CaseIndexDto) ExportConfigurationDto(de.symeda.sormas.api.importexport.ExportConfigurationDto) List(java.util.List) LocalDate(java.time.LocalDate) DateHelper8(de.symeda.sormas.ui.utils.DateHelper8) ExportConfigurationsLayout(de.symeda.sormas.ui.customexport.ExportConfigurationsLayout) FollowUpUtils.createFollowUpLegend(de.symeda.sormas.ui.utils.FollowUpUtils.createFollowUpLegend) 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) DateHelper(de.symeda.sormas.api.utils.DateHelper) GridExportStreamResource(de.symeda.sormas.ui.utils.GridExportStreamResource) HashMap(java.util.HashMap) PopupButton(org.vaadin.hene.popupbutton.PopupButton) EntityRelevanceStatus(de.symeda.sormas.api.EntityRelevanceStatus) AdditionalTestDto(de.symeda.sormas.api.sample.AdditionalTestDto) PopupMenu(de.symeda.sormas.ui.utils.components.popupmenu.PopupMenu) Supplier(java.util.function.Supplier) ArrayList(java.util.ArrayList) CaseExportType(de.symeda.sormas.api.caze.CaseExportType) OptionGroup(com.vaadin.v7.ui.OptionGroup) Notification(com.vaadin.ui.Notification) SormasUI(de.symeda.sormas.ui.SormasUI) Label(com.vaadin.ui.Label) CountryHelper(de.symeda.sormas.api.CountryHelper) AbstractView(de.symeda.sormas.ui.utils.AbstractView) CaseDownloadUtil(de.symeda.sormas.ui.utils.CaseDownloadUtil) ButtonHelper(de.symeda.sormas.ui.utils.ButtonHelper) ContentMode(com.vaadin.shared.ui.ContentMode) Validations(de.symeda.sormas.api.i18n.Validations) LineListingImportLayout(de.symeda.sormas.ui.caze.importer.LineListingImportLayout) BAGExportCaseDto(de.symeda.sormas.api.bagexport.BAGExportCaseDto) Captions(de.symeda.sormas.api.i18n.Captions) UserRight(de.symeda.sormas.api.user.UserRight) Button(com.vaadin.ui.Button) LayoutUtil(de.symeda.sormas.ui.utils.LayoutUtil) SampleExportDto(de.symeda.sormas.api.sample.SampleExportDto) ImportExportUtils(de.symeda.sormas.api.importexport.ImportExportUtils) SampleDto(de.symeda.sormas.api.sample.SampleDto) HorizontalLayout(com.vaadin.ui.HorizontalLayout) 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) Component(com.vaadin.ui.Component) ReferenceDto(de.symeda.sormas.api.ReferenceDto) Label(com.vaadin.ui.Label) EntityRelevanceStatus(de.symeda.sormas.api.EntityRelevanceStatus) Notification(com.vaadin.ui.Notification) HorizontalLayout(com.vaadin.ui.HorizontalLayout) MenuBarHelper(de.symeda.sormas.ui.utils.MenuBarHelper) ExpandableButton(de.symeda.sormas.ui.utils.components.expandablebutton.ExpandableButton) PopupButton(org.vaadin.hene.popupbutton.PopupButton) Button(com.vaadin.ui.Button) List(java.util.List) ArrayList(java.util.ArrayList) InvestigationStatus(de.symeda.sormas.api.caze.InvestigationStatus)

Example 2 with EntityRelevanceStatus

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

the class SampleGridComponent method createShipmentFilterBar.

public HorizontalLayout createShipmentFilterBar() {
    HorizontalLayout shipmentFilterLayout = new HorizontalLayout();
    shipmentFilterLayout.setMargin(false);
    shipmentFilterLayout.setSpacing(true);
    shipmentFilterLayout.setWidth(100, Unit.PERCENTAGE);
    shipmentFilterLayout.addStyleName(CssStyles.VSPACE_3);
    statusButtons = new HashMap<>();
    HorizontalLayout buttonFilterLayout = new HorizontalLayout();
    buttonFilterLayout.setSpacing(true);
    {
        Button statusAll = ButtonHelper.createButton(Captions.all, e -> processStatusChange(null), ValoTheme.BUTTON_BORDERLESS, CssStyles.BUTTON_FILTER);
        statusAll.setCaptionAsHtml(true);
        buttonFilterLayout.addComponent(statusAll);
        statusButtons.put(statusAll, I18nProperties.getCaption(Captions.all));
        activeStatusButton = statusAll;
        createAndAddStatusButton(Captions.sampleNotShipped, NOT_SHIPPED, buttonFilterLayout);
        createAndAddStatusButton(Captions.sampleShipped, SHIPPED, buttonFilterLayout);
        createAndAddStatusButton(Captions.sampleReceived, RECEIVED, buttonFilterLayout);
        createAndAddStatusButton(Captions.sampleReferred, REFERRED, buttonFilterLayout);
    }
    shipmentFilterLayout.addComponent(buttonFilterLayout);
    HorizontalLayout actionButtonsLayout = new HorizontalLayout();
    actionButtonsLayout.setSpacing(true);
    {
        // Show active/archived/all dropdown
        if (UserProvider.getCurrent().hasUserRight(UserRight.SAMPLE_VIEW)) {
            relevanceStatusFilter = ComboBoxHelper.createComboBoxV7();
            relevanceStatusFilter.setId("relevanceStatusFilter");
            relevanceStatusFilter.setWidth(140, Unit.PERCENTAGE);
            relevanceStatusFilter.setNullSelectionAllowed(false);
            relevanceStatusFilter.addItems((Object[]) EntityRelevanceStatus.values());
            relevanceStatusFilter.setItemCaption(EntityRelevanceStatus.ACTIVE, I18nProperties.getCaption(Captions.sampleActiveSamples));
            relevanceStatusFilter.setItemCaption(EntityRelevanceStatus.ARCHIVED, I18nProperties.getCaption(Captions.sampleArchivedSamples));
            relevanceStatusFilter.setItemCaption(EntityRelevanceStatus.ALL, I18nProperties.getCaption(Captions.sampleAllSamples));
            relevanceStatusFilter.addValueChangeListener(e -> {
                criteria.relevanceStatus((EntityRelevanceStatus) e.getProperty().getValue());
                samplesView.navigateTo(criteria);
            });
            actionButtonsLayout.addComponent(relevanceStatusFilter);
        }
        // Bulk operation dropdown
        if (UserProvider.getCurrent().hasUserRight(UserRight.PERFORM_BULK_OPERATIONS_CASE_SAMPLES)) {
            shipmentFilterLayout.setWidth(100, Unit.PERCENTAGE);
            bulkOperationsDropdown = MenuBarHelper.createDropDown(Captions.bulkActions, new MenuBarHelper.MenuBarItem(I18nProperties.getCaption(Captions.bulkDelete), VaadinIcons.TRASH, selectedItem -> {
                ControllerProvider.getSampleController().deleteAllSelectedItems(grid.asMultiSelect().getSelectedItems(), new Runnable() {

                    public void run() {
                        samplesView.navigateTo(criteria);
                    }
                });
            }));
            bulkOperationsDropdown.setVisible(samplesView.getViewConfiguration().isInEagerMode());
            actionButtonsLayout.addComponent(bulkOperationsDropdown);
        }
        sampleTypeFilter = ComboBoxHelper.createComboBoxV7();
        sampleTypeFilter.setWidth(140, Unit.PERCENTAGE);
        sampleTypeFilter.setId("sampleTypeFilter");
        sampleTypeFilter.setNullSelectionAllowed(false);
        sampleTypeFilter.addItems((Object[]) SampleAssociationType.values());
        sampleTypeFilter.setItemCaption(SampleAssociationType.ALL, I18nProperties.getEnumCaption(SampleAssociationType.ALL));
        sampleTypeFilter.setItemCaption(SampleAssociationType.CASE, I18nProperties.getEnumCaption(SampleAssociationType.CASE));
        sampleTypeFilter.setItemCaption(SampleAssociationType.CONTACT, I18nProperties.getEnumCaption(SampleAssociationType.CONTACT));
        sampleTypeFilter.setItemCaption(SampleAssociationType.EVENT_PARTICIPANT, I18nProperties.getEnumCaption(SampleAssociationType.EVENT_PARTICIPANT));
        sampleTypeFilter.addValueChangeListener(e -> {
            criteria.sampleAssociationType(((SampleAssociationType) e.getProperty().getValue()));
            samplesView.navigateTo(criteria);
        });
        actionButtonsLayout.addComponent(sampleTypeFilter);
    }
    shipmentFilterLayout.addComponent(actionButtonsLayout);
    shipmentFilterLayout.setComponentAlignment(actionButtonsLayout, Alignment.TOP_RIGHT);
    shipmentFilterLayout.setExpandRatio(actionButtonsLayout, 1);
    return shipmentFilterLayout;
}
Also used : SampleCriteria(de.symeda.sormas.api.sample.SampleCriteria) I18nProperties(de.symeda.sormas.api.i18n.I18nProperties) VerticalLayout(com.vaadin.ui.VerticalLayout) Alignment(com.vaadin.ui.Alignment) HashMap(java.util.HashMap) EntityRelevanceStatus(de.symeda.sormas.api.EntityRelevanceStatus) ControllerProvider(de.symeda.sormas.ui.ControllerProvider) ViewModelProviders(de.symeda.sormas.ui.ViewModelProviders) CssStyles(de.symeda.sormas.ui.utils.CssStyles) MenuBarHelper(de.symeda.sormas.ui.utils.MenuBarHelper) Label(com.vaadin.ui.Label) ViewChangeEvent(com.vaadin.navigator.ViewChangeListener.ViewChangeEvent) VaadinIcons(com.vaadin.icons.VaadinIcons) ComboBoxHelper(de.symeda.sormas.ui.utils.ComboBoxHelper) UserProvider(de.symeda.sormas.ui.UserProvider) ButtonHelper(de.symeda.sormas.ui.utils.ButtonHelper) ValoTheme(com.vaadin.ui.themes.ValoTheme) MenuBar(com.vaadin.ui.MenuBar) ComboBox(com.vaadin.v7.ui.ComboBox) Captions(de.symeda.sormas.api.i18n.Captions) UserRight(de.symeda.sormas.api.user.UserRight) Button(com.vaadin.ui.Button) LayoutUtil(de.symeda.sormas.ui.utils.LayoutUtil) HorizontalLayout(com.vaadin.ui.HorizontalLayout) TextField(com.vaadin.v7.ui.TextField) SampleAssociationType(de.symeda.sormas.api.sample.SampleAssociationType) MenuBarHelper(de.symeda.sormas.ui.utils.MenuBarHelper) Button(com.vaadin.ui.Button) EntityRelevanceStatus(de.symeda.sormas.api.EntityRelevanceStatus) HorizontalLayout(com.vaadin.ui.HorizontalLayout)

Example 3 with EntityRelevanceStatus

use of de.symeda.sormas.api.EntityRelevanceStatus 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)

Example 4 with EntityRelevanceStatus

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

the class ContactsView method createStatusFilterBar.

public HorizontalLayout createStatusFilterBar() {
    HorizontalLayout statusFilterLayout = new HorizontalLayout();
    statusFilterLayout.setMargin(false);
    statusFilterLayout.setSpacing(true);
    statusFilterLayout.setWidth(100, Unit.PERCENTAGE);
    statusFilterLayout.addStyleName(CssStyles.VSPACE_3);
    statusButtons = new HashMap<>();
    Button statusAll = ButtonHelper.createButton(I18nProperties.getCaption(Captions.all), e -> {
        criteria.contactStatus(null);
        navigateTo(criteria);
    }, ValoTheme.BUTTON_BORDERLESS, CssStyles.BUTTON_FILTER);
    statusAll.setCaptionAsHtml(true);
    if (ContactsViewType.FOLLOW_UP_VISITS_OVERVIEW.equals(viewConfiguration.getViewType())) {
        CssStyles.style(statusAll, CssStyles.FORCE_CAPTION);
    }
    statusFilterLayout.addComponent(statusAll);
    statusButtons.put(statusAll, I18nProperties.getCaption(Captions.all));
    activeStatusButton = statusAll;
    for (ContactStatus status : ContactStatus.values()) {
        Button statusButton = ButtonHelper.createButton("status-" + status.toString(), status.toString(), e -> {
            criteria.contactStatus(status);
            navigateTo(criteria);
        }, ValoTheme.BUTTON_BORDERLESS, CssStyles.BUTTON_FILTER, CssStyles.BUTTON_FILTER_LIGHT);
        statusButton.setCaptionAsHtml(true);
        statusButton.setData(status);
        if (ContactsViewType.FOLLOW_UP_VISITS_OVERVIEW.equals(viewConfiguration.getViewType())) {
            CssStyles.style(statusButton, CssStyles.FORCE_CAPTION);
        }
        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.CONTACT_VIEW)) {
            relevanceStatusFilter = ComboBoxHelper.createComboBoxV7();
            relevanceStatusFilter.setId("relevanceStatus");
            relevanceStatusFilter.setWidth(140, Unit.PERCENTAGE);
            relevanceStatusFilter.setNullSelectionAllowed(false);
            relevanceStatusFilter.addItems((Object[]) EntityRelevanceStatus.values());
            relevanceStatusFilter.setItemCaption(EntityRelevanceStatus.ACTIVE, I18nProperties.getCaption(Captions.contactActiveContacts));
            relevanceStatusFilter.setItemCaption(EntityRelevanceStatus.ARCHIVED, I18nProperties.getCaption(Captions.contactArchivedContacts));
            relevanceStatusFilter.setItemCaption(EntityRelevanceStatus.ALL, I18nProperties.getCaption(Captions.contactAllContacts));
            relevanceStatusFilter.addValueChangeListener(e -> {
                criteria.relevanceStatus((EntityRelevanceStatus) e.getProperty().getValue());
                navigateTo(criteria);
            });
            actionButtonsLayout.addComponent(relevanceStatusFilter);
        }
        // Bulk operation dropdown
        if (isBulkEditAllowed()) {
            statusFilterLayout.setWidth(100, Unit.PERCENTAGE);
            boolean hasBulkOperationsRight = UserProvider.getCurrent().hasUserRight(UserRight.PERFORM_BULK_OPERATIONS);
            List<MenuBarHelper.MenuBarItem> bulkActions = new ArrayList<>(Arrays.asList(new MenuBarHelper.MenuBarItem(I18nProperties.getCaption(Captions.bulkEdit), VaadinIcons.ELLIPSIS_H, mi -> grid.bulkActionHandler(items -> ControllerProvider.getContactController().showBulkContactDataEditComponent(items, null)), hasBulkOperationsRight), new MenuBarHelper.MenuBarItem(I18nProperties.getCaption(Captions.bulkCancelFollowUp), VaadinIcons.CLOSE, mi -> grid.bulkActionHandler(items -> ControllerProvider.getContactController().cancelFollowUpOfAllSelectedItems(items, () -> navigateTo(criteria))), hasBulkOperationsRight), new MenuBarHelper.MenuBarItem(I18nProperties.getCaption(Captions.bulkLostToFollowUp), VaadinIcons.UNLINK, mi -> grid.bulkActionHandler(items -> ControllerProvider.getContactController().setAllSelectedItemsToLostToFollowUp(items, () -> navigateTo(criteria))), hasBulkOperationsRight), new MenuBarHelper.MenuBarItem(I18nProperties.getCaption(Captions.bulkDelete), VaadinIcons.TRASH, mi -> grid.bulkActionHandler(items -> ControllerProvider.getContactController().deleteAllSelectedItems(items, () -> navigateTo(criteria)), true), hasBulkOperationsRight), new MenuBarHelper.MenuBarItem(I18nProperties.getCaption(Captions.sormasToSormasShare), VaadinIcons.SHARE, mi -> grid.bulkActionHandler(items -> ControllerProvider.getSormasToSormasController().shareSelectedContacts(items, () -> navigateTo(criteria))), FacadeProvider.getSormasToSormasFacade().isSharingCasesContactsAndSamplesEnabledForUser())));
            if (isDocGenerationAllowed() && grid instanceof AbstractContactGrid) {
                bulkActions.add(new MenuBarHelper.MenuBarItem(I18nProperties.getCaption(Captions.bulkActionCreatDocuments), VaadinIcons.FILE_TEXT, mi -> grid.bulkActionHandler(items -> {
                    List<ReferenceDto> references = ((AbstractContactGrid<?>) grid).asMultiSelect().getSelectedItems().stream().map(ContactIndexDto::toReference).collect(Collectors.toList());
                    if (references.size() == 0) {
                        new Notification(I18nProperties.getString(Strings.headingNoContactsSelected), I18nProperties.getString(Strings.messageNoContactsSelected), Notification.Type.WARNING_MESSAGE, false).show(Page.getCurrent());
                        return;
                    }
                    ControllerProvider.getDocGenerationController().showBulkQuarantineOrderDocumentDialog(references, DocumentWorkflow.QUARANTINE_ORDER_CONTACT);
                })));
            }
            if (FacadeProvider.getFeatureConfigurationFacade().isFeatureEnabled(FeatureType.EVENT_SURVEILLANCE)) {
                bulkActions.add(new MenuBarHelper.MenuBarItem(I18nProperties.getCaption(Captions.bulkLinkToEvent), VaadinIcons.PHONE, mi -> grid.bulkActionHandler(items -> {
                    List<ContactIndexDto> selectedContacts = grid.asMultiSelect().getSelectedItems().stream().map(item -> (ContactIndexDto) item).collect(Collectors.toList());
                    if (selectedContacts.isEmpty()) {
                        new Notification(I18nProperties.getString(Strings.headingNoContactsSelected), I18nProperties.getString(Strings.messageNoContactsSelected), Notification.Type.WARNING_MESSAGE, false).show(Page.getCurrent());
                        return;
                    }
                    if (!selectedContacts.stream().allMatch(contact -> contact.getDisease().equals(selectedContacts.stream().findAny().get().getDisease()))) {
                        new Notification(I18nProperties.getString(Strings.messageBulkContactsWithDifferentDiseasesSelected), Notification.Type.WARNING_MESSAGE).show(Page.getCurrent());
                        return;
                    }
                    ControllerProvider.getEventController().selectOrCreateEventForContactList(selectedContacts.stream().map(ContactIndexDto::toReference).collect(Collectors.toList()));
                })));
            }
            bulkOperationsDropdown = MenuBarHelper.createDropDown(Captions.bulkActions, bulkActions);
            bulkOperationsDropdown.setVisible(viewConfiguration.isInEagerMode());
            actionButtonsLayout.addComponent(bulkOperationsDropdown);
        }
    }
    statusFilterLayout.addComponent(actionButtonsLayout);
    statusFilterLayout.setComponentAlignment(actionButtonsLayout, Alignment.TOP_RIGHT);
    statusFilterLayout.setExpandRatio(actionButtonsLayout, 1);
    return statusFilterLayout;
}
Also used : FeatureType(de.symeda.sormas.api.feature.FeatureType) ContactCriteria(de.symeda.sormas.api.contact.ContactCriteria) Arrays(java.util.Arrays) CaseController(de.symeda.sormas.ui.caze.CaseController) Date(java.util.Date) DocumentWorkflow(de.symeda.sormas.api.docgeneneration.DocumentWorkflow) I18nProperties(de.symeda.sormas.api.i18n.I18nProperties) Alignment(com.vaadin.ui.Alignment) ReferenceDto(de.symeda.sormas.api.ReferenceDto) Window(com.vaadin.ui.Window) ControllerProvider(de.symeda.sormas.ui.ControllerProvider) ExportEntityName(de.symeda.sormas.ui.utils.ExportEntityName) ContactDownloadUtil(de.symeda.sormas.ui.utils.ContactDownloadUtil) ViewModelProviders(de.symeda.sormas.ui.ViewModelProviders) CssStyles(de.symeda.sormas.ui.utils.CssStyles) ExpandableButton(de.symeda.sormas.ui.utils.components.expandablebutton.ExpandableButton) ContactIndexDto(de.symeda.sormas.api.contact.ContactIndexDto) 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) DateField(com.vaadin.ui.DateField) MenuBar(com.vaadin.ui.MenuBar) ComboBox(com.vaadin.v7.ui.ComboBox) Set(java.util.Set) Collectors(java.util.stream.Collectors) List(java.util.List) LocalDate(java.time.LocalDate) DateHelper8(de.symeda.sormas.ui.utils.DateHelper8) ContactsImportLayout(de.symeda.sormas.ui.contact.importer.ContactsImportLayout) Descriptions(de.symeda.sormas.api.i18n.Descriptions) FollowUpUtils.createFollowUpLegend(de.symeda.sormas.ui.utils.FollowUpUtils.createFollowUpLegend) StreamResource(com.vaadin.server.StreamResource) VaadinUiUtil(de.symeda.sormas.ui.utils.VaadinUiUtil) FacadeProvider(de.symeda.sormas.api.FacadeProvider) VerticalLayout(com.vaadin.ui.VerticalLayout) DateHelper(de.symeda.sormas.api.utils.DateHelper) GridExportStreamResource(de.symeda.sormas.ui.utils.GridExportStreamResource) HashMap(java.util.HashMap) PopupButton(org.vaadin.hene.popupbutton.PopupButton) EntityRelevanceStatus(de.symeda.sormas.api.EntityRelevanceStatus) PopupMenu(de.symeda.sormas.ui.utils.components.popupmenu.PopupMenu) ArrayList(java.util.ArrayList) BAGExportContactDto(de.symeda.sormas.api.bagexport.BAGExportContactDto) OptionGroup(com.vaadin.v7.ui.OptionGroup) Notification(com.vaadin.ui.Notification) SormasUI(de.symeda.sormas.ui.SormasUI) Label(com.vaadin.ui.Label) CountryHelper(de.symeda.sormas.api.CountryHelper) AbstractView(de.symeda.sormas.ui.utils.AbstractView) ButtonHelper(de.symeda.sormas.ui.utils.ButtonHelper) Validations(de.symeda.sormas.api.i18n.Validations) ContactStatus(de.symeda.sormas.api.contact.ContactStatus) Captions(de.symeda.sormas.api.i18n.Captions) UserRight(de.symeda.sormas.api.user.UserRight) Button(com.vaadin.ui.Button) LayoutUtil(de.symeda.sormas.ui.utils.LayoutUtil) HorizontalLayout(com.vaadin.ui.HorizontalLayout) Strings(de.symeda.sormas.api.i18n.Strings) DocGenerationHelper.isDocGenerationAllowed(de.symeda.sormas.ui.docgeneration.DocGenerationHelper.isDocGenerationAllowed) Collections(java.util.Collections) EntityRelevanceStatus(de.symeda.sormas.api.EntityRelevanceStatus) Notification(com.vaadin.ui.Notification) HorizontalLayout(com.vaadin.ui.HorizontalLayout) ContactIndexDto(de.symeda.sormas.api.contact.ContactIndexDto) MenuBarHelper(de.symeda.sormas.ui.utils.MenuBarHelper) ExpandableButton(de.symeda.sormas.ui.utils.components.expandablebutton.ExpandableButton) PopupButton(org.vaadin.hene.popupbutton.PopupButton) Button(com.vaadin.ui.Button) ContactStatus(de.symeda.sormas.api.contact.ContactStatus) List(java.util.List) ArrayList(java.util.ArrayList)

Example 5 with EntityRelevanceStatus

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

the class TravelEntriesView 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);
    HorizontalLayout actionButtonsLayout = new HorizontalLayout();
    actionButtonsLayout.setSpacing(true);
    // Show active/archived/all dropdown
    if (Objects.nonNull(UserProvider.getCurrent()) && UserProvider.getCurrent().hasUserRight(UserRight.TRAVEL_ENTRY_VIEW)) {
        int daysAfterTravelEntryGetsArchived = FacadeProvider.getConfigFacade().getDaysAfterTravelEntryGetsArchived();
        if (daysAfterTravelEntryGetsArchived > 0) {
            relevanceStatusInfoLabel = new Label(VaadinIcons.INFO_CIRCLE.getHtml() + " " + String.format(I18nProperties.getString(Strings.infoArchivedTravelEntries), daysAfterTravelEntryGetsArchived), ContentMode.HTML);
            relevanceStatusInfoLabel.setVisible(false);
            relevanceStatusInfoLabel.addStyleName(CssStyles.LABEL_VERTICAL_ALIGN_SUPER);
            actionButtonsLayout.addComponent(relevanceStatusInfoLabel);
            actionButtonsLayout.setComponentAlignment(relevanceStatusInfoLabel, Alignment.MIDDLE_RIGHT);
        }
        relevanceStatusFilter = ComboBoxHelper.createComboBoxV7();
        relevanceStatusFilter.setId("relevanceStatus");
        relevanceStatusFilter.setWidth(140, Unit.PIXELS);
        relevanceStatusFilter.setNullSelectionAllowed(false);
        relevanceStatusFilter.setTextInputAllowed(false);
        relevanceStatusFilter.addItems((Object[]) EntityRelevanceStatus.values());
        relevanceStatusFilter.setItemCaption(EntityRelevanceStatus.ACTIVE, I18nProperties.getCaption(Captions.travelEntryActiveTravelEntries));
        relevanceStatusFilter.setItemCaption(EntityRelevanceStatus.ARCHIVED, I18nProperties.getCaption(Captions.travelEntryArchivedTravelEntries));
        relevanceStatusFilter.setItemCaption(EntityRelevanceStatus.ALL, I18nProperties.getCaption(Captions.travelEntryAllTravelEntries));
        relevanceStatusFilter.setCaption("");
        relevanceStatusFilter.addValueChangeListener(e -> {
            relevanceStatusInfoLabel.setVisible(EntityRelevanceStatus.ARCHIVED.equals(e.getProperty().getValue()));
            criteria.relevanceStatus((EntityRelevanceStatus) e.getProperty().getValue());
            navigateTo(criteria);
        });
        actionButtonsLayout.addComponent(relevanceStatusFilter);
    }
    statusFilterLayout.addComponent(actionButtonsLayout);
    statusFilterLayout.setComponentAlignment(actionButtonsLayout, Alignment.TOP_RIGHT);
    statusFilterLayout.setExpandRatio(actionButtonsLayout, 1);
    // Bulk operation dropdown
    if (UserProvider.getCurrent().hasUserRight(UserRight.TRAVEL_ENTRY_DELETE) && UserProvider.getCurrent().hasUserRight(UserRight.PERFORM_BULK_OPERATIONS)) {
        List<MenuBarHelper.MenuBarItem> bulkActions = new ArrayList<>();
        bulkActions.add(new MenuBarHelper.MenuBarItem(I18nProperties.getCaption(Captions.bulkDelete), VaadinIcons.TRASH, mi -> grid.bulkActionHandler(items -> ControllerProvider.getTravelEntryController().deleteAllSelectedItems(items, () -> navigateTo(criteria)), true)));
        bulkOperationsDropdown = MenuBarHelper.createDropDown(Captions.bulkActions, bulkActions);
        bulkOperationsDropdown.setVisible(viewConfiguration.isInEagerMode());
        bulkOperationsDropdown.setCaption("");
        actionButtonsLayout.addComponent(bulkOperationsDropdown);
    }
    return statusFilterLayout;
}
Also used : TravelEntryCriteria(de.symeda.sormas.api.travelentry.TravelEntryCriteria) VaadinUiUtil(de.symeda.sormas.ui.utils.VaadinUiUtil) FacadeProvider(de.symeda.sormas.api.FacadeProvider) I18nProperties(de.symeda.sormas.api.i18n.I18nProperties) VerticalLayout(com.vaadin.ui.VerticalLayout) Alignment(com.vaadin.ui.Alignment) Window(com.vaadin.ui.Window) EntityRelevanceStatus(de.symeda.sormas.api.EntityRelevanceStatus) ControllerProvider(de.symeda.sormas.ui.ControllerProvider) ArrayList(java.util.ArrayList) ViewConfiguration(de.symeda.sormas.ui.utils.ViewConfiguration) ViewModelProviders(de.symeda.sormas.ui.ViewModelProviders) CssStyles(de.symeda.sormas.ui.utils.CssStyles) ExpandableButton(de.symeda.sormas.ui.utils.components.expandablebutton.ExpandableButton) MenuBarHelper(de.symeda.sormas.ui.utils.MenuBarHelper) Label(com.vaadin.ui.Label) VaadinIcons(com.vaadin.icons.VaadinIcons) ComboBoxHelper(de.symeda.sormas.ui.utils.ComboBoxHelper) ViewChangeListener(com.vaadin.navigator.ViewChangeListener) UserProvider(de.symeda.sormas.ui.UserProvider) AbstractView(de.symeda.sormas.ui.utils.AbstractView) ButtonHelper(de.symeda.sormas.ui.utils.ButtonHelper) ValoTheme(com.vaadin.ui.themes.ValoTheme) ContentMode(com.vaadin.shared.ui.ContentMode) FilteredGrid(de.symeda.sormas.ui.utils.FilteredGrid) MenuBar(com.vaadin.ui.MenuBar) ComboBox(com.vaadin.v7.ui.ComboBox) Captions(de.symeda.sormas.api.i18n.Captions) Objects(java.util.Objects) UserRight(de.symeda.sormas.api.user.UserRight) List(java.util.List) Button(com.vaadin.ui.Button) HorizontalLayout(com.vaadin.ui.HorizontalLayout) TravelEntryImportLayout(de.symeda.sormas.ui.travelentry.importer.TravelEntryImportLayout) Strings(de.symeda.sormas.api.i18n.Strings) MenuBarHelper(de.symeda.sormas.ui.utils.MenuBarHelper) Label(com.vaadin.ui.Label) ArrayList(java.util.ArrayList) HorizontalLayout(com.vaadin.ui.HorizontalLayout)

Aggregations

EntityRelevanceStatus (de.symeda.sormas.api.EntityRelevanceStatus)18 I18nProperties (de.symeda.sormas.api.i18n.I18nProperties)18 UserRight (de.symeda.sormas.api.user.UserRight)18 ControllerProvider (de.symeda.sormas.ui.ControllerProvider)18 UserProvider (de.symeda.sormas.ui.UserProvider)18 ViewModelProviders (de.symeda.sormas.ui.ViewModelProviders)18 FacadeProvider (de.symeda.sormas.api.FacadeProvider)17 VaadinIcons (com.vaadin.icons.VaadinIcons)15 Alignment (com.vaadin.ui.Alignment)15 Button (com.vaadin.ui.Button)15 MenuBar (com.vaadin.ui.MenuBar)15 ValoTheme (com.vaadin.ui.themes.ValoTheme)15 ComboBox (com.vaadin.v7.ui.ComboBox)15 Captions (de.symeda.sormas.api.i18n.Captions)15 ButtonHelper (de.symeda.sormas.ui.utils.ButtonHelper)15 ComboBoxHelper (de.symeda.sormas.ui.utils.ComboBoxHelper)15 CssStyles (de.symeda.sormas.ui.utils.CssStyles)15 MenuBarHelper (de.symeda.sormas.ui.utils.MenuBarHelper)15 HorizontalLayout (com.vaadin.ui.HorizontalLayout)14 VerticalLayout (com.vaadin.ui.VerticalLayout)14