Search in sources :

Example 1 with SearchField

use of de.symeda.sormas.ui.configuration.infrastructure.components.SearchField in project SORMAS-Project by hzi-braunschweig.

the class ContinentsView method createFilterBar.

private HorizontalLayout createFilterBar() {
    filterLayout = new HorizontalLayout();
    filterLayout.setMargin(false);
    filterLayout.setSpacing(true);
    filterLayout.setWidth(100, Unit.PERCENTAGE);
    searchField = new SearchField();
    searchField.addTextChangeListener(e -> {
        criteria.nameLike(e.getText());
        grid.reload();
    });
    filterLayout.addComponent(searchField);
    resetButton = ButtonHelper.createButton(Captions.actionResetFilters, event -> {
        ViewModelProviders.of(ContinentsView.class).remove(ContinentCriteria.class);
        navigateTo(null);
    }, CssStyles.FORCE_CAPTION);
    resetButton.setVisible(false);
    filterLayout.addComponent(resetButton);
    HorizontalLayout actionButtonsLayout = new HorizontalLayout();
    actionButtonsLayout.setSpacing(true);
    {
        // Show active/archived/all dropdown
        if (UserProvider.getCurrent().hasUserRight(UserRight.INFRASTRUCTURE_VIEW)) {
            relevanceStatusFilter = ComboBoxHelper.createComboBoxV7();
            relevanceStatusFilter.setId("relevanceStatus");
            relevanceStatusFilter.setWidth(220, Unit.PERCENTAGE);
            relevanceStatusFilter.setNullSelectionAllowed(false);
            relevanceStatusFilter.addItems((Object[]) EntityRelevanceStatus.values());
            relevanceStatusFilter.setItemCaption(EntityRelevanceStatus.ACTIVE, I18nProperties.getCaption(Captions.continentActiveContinents));
            relevanceStatusFilter.setItemCaption(EntityRelevanceStatus.ARCHIVED, I18nProperties.getCaption(Captions.continentArchivedContinents));
            relevanceStatusFilter.setItemCaption(EntityRelevanceStatus.ALL, I18nProperties.getCaption(Captions.continentAllContinents));
            relevanceStatusFilter.addValueChangeListener(e -> {
                criteria.relevanceStatus((EntityRelevanceStatus) e.getProperty().getValue());
                navigateTo(criteria);
            });
            actionButtonsLayout.addComponent(relevanceStatusFilter);
            // Bulk operation dropdown
            if (UserProvider.getCurrent().hasUserRight(UserRight.PERFORM_BULK_OPERATIONS)) {
                bulkOperationsDropdown = MenuBarHelper.createDropDown(Captions.bulkActions, new MenuBarHelper.MenuBarItem(I18nProperties.getCaption(Captions.actionArchiveInfrastructure), VaadinIcons.ARCHIVE, selectedItem -> {
                    ControllerProvider.getInfrastructureController().archiveOrDearchiveAllSelectedItems(true, grid.asMultiSelect().getSelectedItems(), InfrastructureType.CONTINENT, () -> navigateTo(criteria));
                }, EntityRelevanceStatus.ACTIVE.equals(criteria.getRelevanceStatus())), new MenuBarHelper.MenuBarItem(I18nProperties.getCaption(Captions.actionDearchiveInfrastructure), VaadinIcons.ARCHIVE, selectedItem -> {
                    ControllerProvider.getInfrastructureController().archiveOrDearchiveAllSelectedItems(false, grid.asMultiSelect().getSelectedItems(), InfrastructureType.CONTINENT, () -> navigateTo(criteria));
                }, EntityRelevanceStatus.ARCHIVED.equals(criteria.getRelevanceStatus())));
                bulkOperationsDropdown.setVisible(isBulkOperationsDropdownVisible());
                actionButtonsLayout.addComponent(bulkOperationsDropdown);
            }
        }
    }
    filterLayout.addComponent(actionButtonsLayout);
    filterLayout.setComponentAlignment(actionButtonsLayout, Alignment.BOTTOM_RIGHT);
    filterLayout.setExpandRatio(actionButtonsLayout, 1);
    return filterLayout;
}
Also used : FeatureType(de.symeda.sormas.api.feature.FeatureType) RowCount(de.symeda.sormas.ui.utils.RowCount) StreamResource(com.vaadin.server.StreamResource) SearchField(de.symeda.sormas.ui.configuration.infrastructure.components.SearchField) 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) GridExportStreamResource(de.symeda.sormas.ui.utils.GridExportStreamResource) Window(com.vaadin.ui.Window) EntityRelevanceStatus(de.symeda.sormas.api.EntityRelevanceStatus) ContinentCriteria(de.symeda.sormas.api.infrastructure.continent.ContinentCriteria) ControllerProvider(de.symeda.sormas.ui.ControllerProvider) ExportEntityName(de.symeda.sormas.ui.utils.ExportEntityName) ViewConfiguration(de.symeda.sormas.ui.utils.ViewConfiguration) 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) VaadinIcons(com.vaadin.icons.VaadinIcons) ComboBoxHelper(de.symeda.sormas.ui.utils.ComboBoxHelper) ViewChangeListener(com.vaadin.navigator.ViewChangeListener) AbstractConfigurationView(de.symeda.sormas.ui.configuration.AbstractConfigurationView) 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) InfrastructureType(de.symeda.sormas.api.infrastructure.InfrastructureType) ContinentIndexDto(de.symeda.sormas.api.infrastructure.continent.ContinentIndexDto) Captions(de.symeda.sormas.api.i18n.Captions) UserRight(de.symeda.sormas.api.user.UserRight) Button(com.vaadin.ui.Button) HorizontalLayout(com.vaadin.ui.HorizontalLayout) FileDownloader(com.vaadin.server.FileDownloader) Descriptions(de.symeda.sormas.api.i18n.Descriptions) Strings(de.symeda.sormas.api.i18n.Strings) Collections(java.util.Collections) SearchField(de.symeda.sormas.ui.configuration.infrastructure.components.SearchField) MenuBarHelper(de.symeda.sormas.ui.utils.MenuBarHelper) EntityRelevanceStatus(de.symeda.sormas.api.EntityRelevanceStatus) ContinentCriteria(de.symeda.sormas.api.infrastructure.continent.ContinentCriteria) HorizontalLayout(com.vaadin.ui.HorizontalLayout)

Example 2 with SearchField

use of de.symeda.sormas.ui.configuration.infrastructure.components.SearchField in project SORMAS-Project by hzi-braunschweig.

the class CountriesView method createFilterBar.

private HorizontalLayout createFilterBar() {
    filterLayout = new HorizontalLayout();
    filterLayout.setMargin(false);
    filterLayout.setSpacing(true);
    filterLayout.setWidth(100, Unit.PERCENTAGE);
    searchField = new SearchField();
    searchField.addTextChangeListener(e -> {
        criteria.nameCodeLike(e.getText());
        grid.reload();
    });
    filterLayout.addComponent(searchField);
    subcontinentFilter = ComboBoxHelper.createComboBoxV7();
    subcontinentFilter.setId(CountryDto.SUBCONTINENT);
    subcontinentFilter.setWidth(140, Unit.PIXELS);
    subcontinentFilter.setCaption(I18nProperties.getPrefixCaption(CountryDto.I18N_PREFIX, CountryDto.SUBCONTINENT));
    subcontinentFilter.addItems(FacadeProvider.getSubcontinentFacade().getAllActiveAsReference());
    subcontinentFilter.addValueChangeListener(e -> {
        criteria.subcontinent((SubcontinentReferenceDto) e.getProperty().getValue());
        navigateTo(criteria);
    });
    filterLayout.addComponent(subcontinentFilter);
    resetButton = ButtonHelper.createButton(Captions.actionResetFilters, event -> {
        ViewModelProviders.of(CountriesView.class).remove(CountryCriteria.class);
        navigateTo(null);
    }, CssStyles.FORCE_CAPTION);
    resetButton.setVisible(false);
    filterLayout.addComponent(resetButton);
    HorizontalLayout actionButtonsLayout = new HorizontalLayout();
    actionButtonsLayout.setSpacing(true);
    {
        // Show active/archived/all dropdown
        if (UserProvider.getCurrent().hasUserRight(UserRight.INFRASTRUCTURE_VIEW)) {
            relevanceStatusFilter = ComboBoxHelper.createComboBoxV7();
            relevanceStatusFilter.setId("relevanceStatus");
            relevanceStatusFilter.setWidth(220, Unit.PERCENTAGE);
            relevanceStatusFilter.setNullSelectionAllowed(false);
            relevanceStatusFilter.addItems((Object[]) EntityRelevanceStatus.values());
            relevanceStatusFilter.setItemCaption(EntityRelevanceStatus.ACTIVE, I18nProperties.getCaption(Captions.countryActiveCountries));
            relevanceStatusFilter.setItemCaption(EntityRelevanceStatus.ARCHIVED, I18nProperties.getCaption(Captions.countryArchivedCountries));
            relevanceStatusFilter.setItemCaption(EntityRelevanceStatus.ALL, I18nProperties.getCaption(Captions.countryAllCountries));
            relevanceStatusFilter.addValueChangeListener(e -> {
                criteria.relevanceStatus((EntityRelevanceStatus) e.getProperty().getValue());
                navigateTo(criteria);
            });
            actionButtonsLayout.addComponent(relevanceStatusFilter);
            // Bulk operation dropdown
            if (UserProvider.getCurrent().hasUserRight(UserRight.PERFORM_BULK_OPERATIONS)) {
                bulkOperationsDropdown = MenuBarHelper.createDropDown(Captions.bulkActions, new MenuBarHelper.MenuBarItem(I18nProperties.getCaption(Captions.actionArchiveInfrastructure), VaadinIcons.ARCHIVE, selectedItem -> {
                    ControllerProvider.getInfrastructureController().archiveOrDearchiveAllSelectedItems(true, grid.asMultiSelect().getSelectedItems(), InfrastructureType.COUNTRY, () -> navigateTo(criteria));
                }, EntityRelevanceStatus.ACTIVE.equals(criteria.getRelevanceStatus())), new MenuBarHelper.MenuBarItem(I18nProperties.getCaption(Captions.actionDearchiveInfrastructure), VaadinIcons.ARCHIVE, selectedItem -> {
                    ControllerProvider.getInfrastructureController().archiveOrDearchiveAllSelectedItems(false, grid.asMultiSelect().getSelectedItems(), InfrastructureType.COUNTRY, () -> navigateTo(criteria));
                }, EntityRelevanceStatus.ARCHIVED.equals(criteria.getRelevanceStatus())));
                bulkOperationsDropdown.setVisible(isBulkOperationsDropdownVisible());
                actionButtonsLayout.addComponent(bulkOperationsDropdown);
            }
        }
    }
    filterLayout.addComponent(actionButtonsLayout);
    filterLayout.setComponentAlignment(actionButtonsLayout, Alignment.BOTTOM_RIGHT);
    filterLayout.setExpandRatio(actionButtonsLayout, 1);
    return filterLayout;
}
Also used : FeatureType(de.symeda.sormas.api.feature.FeatureType) RowCount(de.symeda.sormas.ui.utils.RowCount) CountryDto(de.symeda.sormas.api.infrastructure.country.CountryDto) StreamResource(com.vaadin.server.StreamResource) SearchField(de.symeda.sormas.ui.configuration.infrastructure.components.SearchField) 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) GridExportStreamResource(de.symeda.sormas.ui.utils.GridExportStreamResource) Window(com.vaadin.ui.Window) EntityRelevanceStatus(de.symeda.sormas.api.EntityRelevanceStatus) ControllerProvider(de.symeda.sormas.ui.ControllerProvider) ExportEntityName(de.symeda.sormas.ui.utils.ExportEntityName) ViewConfiguration(de.symeda.sormas.ui.utils.ViewConfiguration) 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) VaadinIcons(com.vaadin.icons.VaadinIcons) ComboBoxHelper(de.symeda.sormas.ui.utils.ComboBoxHelper) ViewChangeListener(com.vaadin.navigator.ViewChangeListener) AbstractConfigurationView(de.symeda.sormas.ui.configuration.AbstractConfigurationView) UserProvider(de.symeda.sormas.ui.UserProvider) ButtonHelper(de.symeda.sormas.ui.utils.ButtonHelper) ValoTheme(com.vaadin.ui.themes.ValoTheme) CountryCriteria(de.symeda.sormas.api.infrastructure.country.CountryCriteria) MenuBar(com.vaadin.ui.MenuBar) ComboBox(com.vaadin.v7.ui.ComboBox) InfrastructureType(de.symeda.sormas.api.infrastructure.InfrastructureType) CountryIndexDto(de.symeda.sormas.api.infrastructure.country.CountryIndexDto) Captions(de.symeda.sormas.api.i18n.Captions) UserRight(de.symeda.sormas.api.user.UserRight) Button(com.vaadin.ui.Button) HorizontalLayout(com.vaadin.ui.HorizontalLayout) FileDownloader(com.vaadin.server.FileDownloader) Descriptions(de.symeda.sormas.api.i18n.Descriptions) SubcontinentReferenceDto(de.symeda.sormas.api.infrastructure.subcontinent.SubcontinentReferenceDto) Strings(de.symeda.sormas.api.i18n.Strings) Collections(java.util.Collections) SearchField(de.symeda.sormas.ui.configuration.infrastructure.components.SearchField) MenuBarHelper(de.symeda.sormas.ui.utils.MenuBarHelper) CountryCriteria(de.symeda.sormas.api.infrastructure.country.CountryCriteria) EntityRelevanceStatus(de.symeda.sormas.api.EntityRelevanceStatus) HorizontalLayout(com.vaadin.ui.HorizontalLayout)

Example 3 with SearchField

use of de.symeda.sormas.ui.configuration.infrastructure.components.SearchField in project SORMAS-Project by hzi-braunschweig.

the class FacilitiesView method createFilterBar.

// TODO additional filter bar (active, archived and other)
// private HorizontalLayout createHeaderBar() {
// headerLayout = new HorizontalLayout();
// headerLayout.setSpacing(true);
// headerLayout.setWidth(100, Unit.PERCENTAGE);
// 
// return headerLayout;
// }
private HorizontalLayout createFilterBar() {
    filterLayout = new HorizontalLayout();
    filterLayout.setMargin(false);
    filterLayout.setSpacing(true);
    filterLayout.setWidth(100, Unit.PERCENTAGE);
    searchField = new SearchField();
    searchField.addTextChangeListener(e -> {
        criteria.nameCityLike(e.getText());
        grid.reload();
        rowCount.update(grid.getItemCount());
    });
    filterLayout.addComponent(searchField);
    typeGroupFilter = ComboBoxHelper.createComboBoxV7();
    typeGroupFilter.setId("typeGroup");
    typeGroupFilter.setWidth(220, Unit.PIXELS);
    typeGroupFilter.setCaption(I18nProperties.getCaption(Captions.Facility_typeGroup));
    typeGroupFilter.addItems(FacilityTypeGroup.values());
    typeGroupFilter.addValueChangeListener(e -> {
        criteria.typeGroup((FacilityTypeGroup) e.getProperty().getValue());
        FieldHelper.updateItems(typeFilter, FacilityType.getTypes((FacilityTypeGroup) typeGroupFilter.getValue()));
    });
    filterLayout.addComponent(typeGroupFilter);
    typeFilter = ComboBoxHelper.createComboBoxV7();
    typeFilter.setId(FacilityDto.TYPE);
    typeFilter.setWidth(220, Unit.PIXELS);
    typeFilter.setCaption(I18nProperties.getPrefixCaption(FacilityDto.I18N_PREFIX, FacilityDto.TYPE));
    typeFilter.addValueChangeListener(e -> {
        criteria.type((FacilityType) e.getProperty().getValue());
        navigateTo(criteria);
    });
    filterLayout.addComponent(typeFilter);
    countryFilter = addCountryFilter(filterLayout, country -> {
        criteria.country(country);
        grid.reload();
        rowCount.update(grid.getItemCount());
    }, regionFilter);
    countryFilter.addValueChangeListener(country -> {
        CountryReferenceDto countryReferenceDto = (CountryReferenceDto) country.getProperty().getValue();
        criteria.country(countryReferenceDto);
        navigateTo(criteria);
        FieldHelper.updateItems(regionFilter, countryReferenceDto != null ? FacadeProvider.getRegionFacade().getAllActiveByCountry(countryReferenceDto.getUuid()) : null);
    });
    regionFilter = ComboBoxHelper.createComboBoxV7();
    regionFilter.setId(FacilityDto.REGION);
    regionFilter.setWidth(140, Unit.PIXELS);
    regionFilter.setCaption(I18nProperties.getPrefixCaption(FacilityDto.I18N_PREFIX, FacilityDto.REGION));
    regionFilter.addItems(FacadeProvider.getRegionFacade().getAllActiveAsReference());
    regionFilter.addValueChangeListener(e -> {
        RegionReferenceDto region = (RegionReferenceDto) e.getProperty().getValue();
        criteria.region(region);
        navigateTo(criteria);
        FieldHelper.updateItems(districtFilter, region != null ? FacadeProvider.getDistrictFacade().getAllActiveByRegion(region.getUuid()) : null);
    });
    filterLayout.addComponent(regionFilter);
    districtFilter = ComboBoxHelper.createComboBoxV7();
    districtFilter.setId(FacilityDto.DISTRICT);
    districtFilter.setWidth(140, Unit.PIXELS);
    districtFilter.setCaption(I18nProperties.getPrefixCaption(FacilityDto.I18N_PREFIX, FacilityDto.DISTRICT));
    districtFilter.addValueChangeListener(e -> {
        DistrictReferenceDto district = (DistrictReferenceDto) e.getProperty().getValue();
        criteria.district(district);
        navigateTo(criteria);
        FieldHelper.updateItems(communityFilter, district != null ? FacadeProvider.getCommunityFacade().getAllActiveByDistrict(district.getUuid()) : null);
    });
    filterLayout.addComponent(districtFilter);
    communityFilter = ComboBoxHelper.createComboBoxV7();
    communityFilter.setId(FacilityDto.COMMUNITY);
    communityFilter.setWidth(140, Unit.PIXELS);
    communityFilter.setCaption(I18nProperties.getPrefixCaption(FacilityDto.I18N_PREFIX, FacilityDto.COMMUNITY));
    communityFilter.addValueChangeListener(e -> {
        criteria.community((CommunityReferenceDto) e.getProperty().getValue());
        navigateTo(criteria);
    });
    filterLayout.addComponent(communityFilter);
    resetButton = ButtonHelper.createButton(Captions.actionResetFilters, event -> {
        ViewModelProviders.of(FacilitiesView.class).remove(FacilityCriteria.class);
        navigateTo(null);
    }, CssStyles.FORCE_CAPTION);
    resetButton.setVisible(false);
    filterLayout.addComponent(resetButton);
    HorizontalLayout actionButtonsLayout = new HorizontalLayout();
    actionButtonsLayout.setSpacing(true);
    {
        // Show active/archived/all dropdown
        if (UserProvider.getCurrent().hasUserRight(UserRight.INFRASTRUCTURE_VIEW)) {
            relevanceStatusFilter = ComboBoxHelper.createComboBoxV7();
            relevanceStatusFilter.setId("relevanceStatus");
            relevanceStatusFilter.setWidth(220, Unit.PERCENTAGE);
            relevanceStatusFilter.setNullSelectionAllowed(false);
            relevanceStatusFilter.addItems((Object[]) EntityRelevanceStatus.values());
            relevanceStatusFilter.setItemCaption(EntityRelevanceStatus.ACTIVE, I18nProperties.getCaption(Captions.facilityActiveFacilities));
            relevanceStatusFilter.setItemCaption(EntityRelevanceStatus.ARCHIVED, I18nProperties.getCaption(Captions.facilityArchivedFacilities));
            relevanceStatusFilter.setItemCaption(EntityRelevanceStatus.ALL, I18nProperties.getCaption(Captions.facilityAllFacilities));
            relevanceStatusFilter.addValueChangeListener(e -> {
                criteria.relevanceStatus((EntityRelevanceStatus) e.getProperty().getValue());
                navigateTo(criteria);
            });
            actionButtonsLayout.addComponent(relevanceStatusFilter);
            // Bulk operation dropdown
            if (UserProvider.getCurrent().hasUserRight(UserRight.PERFORM_BULK_OPERATIONS)) {
                bulkOperationsDropdown = MenuBarHelper.createDropDown(Captions.bulkActions, new MenuBarHelper.MenuBarItem(I18nProperties.getCaption(Captions.actionArchiveInfrastructure), VaadinIcons.ARCHIVE, selectedItem -> {
                    ControllerProvider.getInfrastructureController().archiveOrDearchiveAllSelectedItems(true, grid.asMultiSelect().getSelectedItems(), InfrastructureType.FACILITY, new Runnable() {

                        public void run() {
                            navigateTo(criteria);
                        }
                    });
                }, EntityRelevanceStatus.ACTIVE.equals(criteria.getRelevanceStatus())), new MenuBarHelper.MenuBarItem(I18nProperties.getCaption(Captions.actionDearchiveInfrastructure), VaadinIcons.ARCHIVE, selectedItem -> {
                    ControllerProvider.getInfrastructureController().archiveOrDearchiveAllSelectedItems(false, grid.asMultiSelect().getSelectedItems(), InfrastructureType.FACILITY, new Runnable() {

                        public void run() {
                            navigateTo(criteria);
                        }
                    });
                }, EntityRelevanceStatus.ARCHIVED.equals(criteria.getRelevanceStatus())));
                bulkOperationsDropdown.setVisible(viewConfiguration.isInEagerMode() && !EntityRelevanceStatus.ALL.equals(criteria.getRelevanceStatus()));
                actionButtonsLayout.addComponent(bulkOperationsDropdown);
            }
        }
    }
    filterLayout.addComponent(actionButtonsLayout);
    filterLayout.setComponentAlignment(actionButtonsLayout, Alignment.BOTTOM_RIGHT);
    filterLayout.setExpandRatio(actionButtonsLayout, 1);
    return filterLayout;
}
Also used : RowCount(de.symeda.sormas.ui.utils.RowCount) FacilityDto(de.symeda.sormas.api.infrastructure.facility.FacilityDto) StreamResource(com.vaadin.server.StreamResource) SearchField(de.symeda.sormas.ui.configuration.infrastructure.components.SearchField) VaadinUiUtil(de.symeda.sormas.ui.utils.VaadinUiUtil) Date(java.util.Date) FacadeProvider(de.symeda.sormas.api.FacadeProvider) I18nProperties(de.symeda.sormas.api.i18n.I18nProperties) DateFormatHelper(de.symeda.sormas.ui.utils.DateFormatHelper) VerticalLayout(com.vaadin.ui.VerticalLayout) Alignment(com.vaadin.ui.Alignment) GridExportStreamResource(de.symeda.sormas.ui.utils.GridExportStreamResource) PopupButton(org.vaadin.hene.popupbutton.PopupButton) Window(com.vaadin.ui.Window) EntityRelevanceStatus(de.symeda.sormas.api.EntityRelevanceStatus) ControllerProvider(de.symeda.sormas.ui.ControllerProvider) ExportEntityName(de.symeda.sormas.ui.utils.ExportEntityName) ViewConfiguration(de.symeda.sormas.ui.utils.ViewConfiguration) CountryReferenceDto(de.symeda.sormas.api.infrastructure.country.CountryReferenceDto) ViewModelProviders(de.symeda.sormas.ui.ViewModelProviders) CssStyles(de.symeda.sormas.ui.utils.CssStyles) FacilityCriteria(de.symeda.sormas.api.infrastructure.facility.FacilityCriteria) MenuBarHelper(de.symeda.sormas.ui.utils.MenuBarHelper) ViewChangeEvent(com.vaadin.navigator.ViewChangeListener.ViewChangeEvent) VaadinIcons(com.vaadin.icons.VaadinIcons) ComboBoxHelper(de.symeda.sormas.ui.utils.ComboBoxHelper) AbstractConfigurationView(de.symeda.sormas.ui.configuration.AbstractConfigurationView) UserProvider(de.symeda.sormas.ui.UserProvider) ButtonHelper(de.symeda.sormas.ui.utils.ButtonHelper) ValoTheme(com.vaadin.ui.themes.ValoTheme) DownloadUtil(de.symeda.sormas.ui.utils.DownloadUtil) MenuBar(com.vaadin.ui.MenuBar) ComboBox(com.vaadin.v7.ui.ComboBox) DistrictReferenceDto(de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto) FacilityType(de.symeda.sormas.api.infrastructure.facility.FacilityType) InfrastructureType(de.symeda.sormas.api.infrastructure.InfrastructureType) FieldHelper(de.symeda.sormas.ui.utils.FieldHelper) Captions(de.symeda.sormas.api.i18n.Captions) CommunityReferenceDto(de.symeda.sormas.api.infrastructure.community.CommunityReferenceDto) UserRight(de.symeda.sormas.api.user.UserRight) Button(com.vaadin.ui.Button) HorizontalLayout(com.vaadin.ui.HorizontalLayout) FacilityExportDto(de.symeda.sormas.api.infrastructure.facility.FacilityExportDto) FacilityTypeGroup(de.symeda.sormas.api.infrastructure.facility.FacilityTypeGroup) Strings(de.symeda.sormas.api.i18n.Strings) RegionReferenceDto(de.symeda.sormas.api.infrastructure.region.RegionReferenceDto) SearchField(de.symeda.sormas.ui.configuration.infrastructure.components.SearchField) MenuBarHelper(de.symeda.sormas.ui.utils.MenuBarHelper) RegionReferenceDto(de.symeda.sormas.api.infrastructure.region.RegionReferenceDto) CountryReferenceDto(de.symeda.sormas.api.infrastructure.country.CountryReferenceDto) EntityRelevanceStatus(de.symeda.sormas.api.EntityRelevanceStatus) FacilityCriteria(de.symeda.sormas.api.infrastructure.facility.FacilityCriteria) FacilityTypeGroup(de.symeda.sormas.api.infrastructure.facility.FacilityTypeGroup) DistrictReferenceDto(de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto) HorizontalLayout(com.vaadin.ui.HorizontalLayout)

Example 4 with SearchField

use of de.symeda.sormas.ui.configuration.infrastructure.components.SearchField in project SORMAS-Project by hzi-braunschweig.

the class AreasView method createFilterBar.

private HorizontalLayout createFilterBar() {
    HorizontalLayout filterLayout = new HorizontalLayout();
    filterLayout.setMargin(false);
    filterLayout.setSpacing(true);
    filterLayout.setWidth(100, Unit.PERCENTAGE);
    searchField = new SearchField();
    searchField.addTextChangeListener(e -> {
        criteria.textFilter(e.getText());
        grid.reload();
    });
    filterLayout.addComponent(searchField);
    btnResetFilters = ButtonHelper.createButton(Captions.actionResetFilters, event -> {
        ViewModelProviders.of(AreasView.class).remove(AreaCriteria.class);
        navigateTo(null);
    }, CssStyles.FORCE_CAPTION);
    btnResetFilters.setVisible(false);
    filterLayout.addComponent(btnResetFilters);
    HorizontalLayout actionButtonsLayout = new HorizontalLayout();
    actionButtonsLayout.setSpacing(true);
    {
        // Show active/archived/all dropdown
        if (UserProvider.getCurrent().hasUserRight(UserRight.INFRASTRUCTURE_VIEW)) {
            filterRelevanceStatus = new ComboBox<>();
            filterRelevanceStatus.setId("relevanceStatus");
            filterRelevanceStatus.setWidth(220, Unit.PERCENTAGE);
            filterRelevanceStatus.setEmptySelectionAllowed(false);
            filterRelevanceStatus.setItems(EntityRelevanceStatus.values());
            filterRelevanceStatus.setItemCaptionGenerator(status -> {
                switch(status) {
                    case ACTIVE:
                        return I18nProperties.getCaption(Captions.areaActiveAreas);
                    case ARCHIVED:
                        return I18nProperties.getCaption(Captions.areaArchivedAreas);
                    default:
                        return I18nProperties.getCaption(Captions.areaAllAreas);
                }
            });
            filterRelevanceStatus.addValueChangeListener(e -> {
                criteria.relevanceStatus(e.getValue());
                navigateTo(criteria);
            });
            actionButtonsLayout.addComponent(filterRelevanceStatus);
            // Bulk operation dropdown
            if (UserProvider.getCurrent().hasUserRight(UserRight.PERFORM_BULK_OPERATIONS)) {
                dropdownBulkOperations = MenuBarHelper.createDropDown(Captions.bulkActions, new MenuBarHelper.MenuBarItem(I18nProperties.getCaption(Captions.actionArchiveInfrastructure), VaadinIcons.ARCHIVE, selectedItem -> {
                    ControllerProvider.getInfrastructureController().archiveOrDearchiveAllSelectedItems(true, grid.asMultiSelect().getSelectedItems(), InfrastructureType.AREA, () -> navigateTo(criteria));
                }, EntityRelevanceStatus.ACTIVE.equals(criteria.getRelevanceStatus())), new MenuBarHelper.MenuBarItem(I18nProperties.getCaption(Captions.actionDearchiveInfrastructure), VaadinIcons.ARCHIVE, selectedItem -> {
                    ControllerProvider.getInfrastructureController().archiveOrDearchiveAllSelectedItems(false, grid.asMultiSelect().getSelectedItems(), InfrastructureType.AREA, () -> navigateTo(criteria));
                }, EntityRelevanceStatus.ARCHIVED.equals(criteria.getRelevanceStatus())));
                dropdownBulkOperations.setVisible(viewConfiguration.isInEagerMode() && !EntityRelevanceStatus.ALL.equals(criteria.getRelevanceStatus()));
                actionButtonsLayout.addComponent(dropdownBulkOperations);
            }
        }
    }
    filterLayout.addComponent(actionButtonsLayout);
    filterLayout.setComponentAlignment(actionButtonsLayout, Alignment.BOTTOM_RIGHT);
    filterLayout.setExpandRatio(actionButtonsLayout, 1);
    return filterLayout;
}
Also used : RowCount(de.symeda.sormas.ui.utils.RowCount) StreamResource(com.vaadin.server.StreamResource) SearchField(de.symeda.sormas.ui.configuration.infrastructure.components.SearchField) VaadinUiUtil(de.symeda.sormas.ui.utils.VaadinUiUtil) I18nProperties(de.symeda.sormas.api.i18n.I18nProperties) VerticalLayout(com.vaadin.ui.VerticalLayout) Alignment(com.vaadin.ui.Alignment) ComboBox(com.vaadin.ui.ComboBox) GridExportStreamResource(de.symeda.sormas.ui.utils.GridExportStreamResource) Window(com.vaadin.ui.Window) EntityRelevanceStatus(de.symeda.sormas.api.EntityRelevanceStatus) ControllerProvider(de.symeda.sormas.ui.ControllerProvider) ExportEntityName(de.symeda.sormas.ui.utils.ExportEntityName) ViewConfiguration(de.symeda.sormas.ui.utils.ViewConfiguration) ViewModelProviders(de.symeda.sormas.ui.ViewModelProviders) CssStyles(de.symeda.sormas.ui.utils.CssStyles) MenuBarHelper(de.symeda.sormas.ui.utils.MenuBarHelper) ViewChangeEvent(com.vaadin.navigator.ViewChangeListener.ViewChangeEvent) VaadinIcons(com.vaadin.icons.VaadinIcons) AbstractConfigurationView(de.symeda.sormas.ui.configuration.AbstractConfigurationView) UserProvider(de.symeda.sormas.ui.UserProvider) ButtonHelper(de.symeda.sormas.ui.utils.ButtonHelper) ValoTheme(com.vaadin.ui.themes.ValoTheme) AreaCriteria(de.symeda.sormas.api.infrastructure.area.AreaCriteria) MenuBar(com.vaadin.ui.MenuBar) InfrastructureType(de.symeda.sormas.api.infrastructure.InfrastructureType) Captions(de.symeda.sormas.api.i18n.Captions) UserRight(de.symeda.sormas.api.user.UserRight) Button(com.vaadin.ui.Button) HorizontalLayout(com.vaadin.ui.HorizontalLayout) FileDownloader(com.vaadin.server.FileDownloader) Descriptions(de.symeda.sormas.api.i18n.Descriptions) Strings(de.symeda.sormas.api.i18n.Strings) SearchField(de.symeda.sormas.ui.configuration.infrastructure.components.SearchField) AreaCriteria(de.symeda.sormas.api.infrastructure.area.AreaCriteria) MenuBarHelper(de.symeda.sormas.ui.utils.MenuBarHelper) ComboBox(com.vaadin.ui.ComboBox) HorizontalLayout(com.vaadin.ui.HorizontalLayout)

Example 5 with SearchField

use of de.symeda.sormas.ui.configuration.infrastructure.components.SearchField in project SORMAS-Project by hzi-braunschweig.

the class RegionsView method createFilterBar.

private HorizontalLayout createFilterBar() {
    filterLayout = new HorizontalLayout();
    filterLayout.setMargin(false);
    filterLayout.setSpacing(true);
    filterLayout.setWidth(100, Unit.PERCENTAGE);
    searchField = new SearchField();
    searchField.addTextChangeListener(e -> {
        criteria.nameEpidLike(e.getText());
        grid.reload();
    });
    filterLayout.addComponent(searchField);
    countryFilter = addCountryFilter(filterLayout, country -> {
        criteria.country(country);
        grid.reload();
    }, null);
    resetButton = ButtonHelper.createButton(Captions.actionResetFilters, event -> {
        ViewModelProviders.of(RegionsView.class).remove(RegionCriteria.class);
        navigateTo(null);
    }, CssStyles.FORCE_CAPTION);
    resetButton.setVisible(false);
    filterLayout.addComponent(resetButton);
    HorizontalLayout actionButtonsLayout = new HorizontalLayout();
    actionButtonsLayout.setSpacing(true);
    {
        // Show active/archived/all dropdown
        if (UserProvider.getCurrent().hasUserRight(UserRight.INFRASTRUCTURE_VIEW)) {
            relevanceStatusFilter = ComboBoxHelper.createComboBoxV7();
            relevanceStatusFilter.setId("relevanceStatus");
            relevanceStatusFilter.setWidth(220, Unit.PERCENTAGE);
            relevanceStatusFilter.setNullSelectionAllowed(false);
            relevanceStatusFilter.addItems((Object[]) EntityRelevanceStatus.values());
            relevanceStatusFilter.setItemCaption(EntityRelevanceStatus.ACTIVE, I18nProperties.getCaption(Captions.regionActiveRegions));
            relevanceStatusFilter.setItemCaption(EntityRelevanceStatus.ARCHIVED, I18nProperties.getCaption(Captions.regionArchivedRegions));
            relevanceStatusFilter.setItemCaption(EntityRelevanceStatus.ALL, I18nProperties.getCaption(Captions.regionAllRegions));
            relevanceStatusFilter.addValueChangeListener(e -> {
                criteria.relevanceStatus((EntityRelevanceStatus) e.getProperty().getValue());
                navigateTo(criteria);
            });
            actionButtonsLayout.addComponent(relevanceStatusFilter);
            // Bulk operation dropdown
            if (UserProvider.getCurrent().hasUserRight(UserRight.PERFORM_BULK_OPERATIONS)) {
                bulkOperationsDropdown = MenuBarHelper.createDropDown(Captions.bulkActions, new MenuBarHelper.MenuBarItem(I18nProperties.getCaption(Captions.actionArchiveInfrastructure), VaadinIcons.ARCHIVE, selectedItem -> {
                    ControllerProvider.getInfrastructureController().archiveOrDearchiveAllSelectedItems(true, grid.asMultiSelect().getSelectedItems(), InfrastructureType.REGION, () -> navigateTo(criteria));
                }, EntityRelevanceStatus.ACTIVE.equals(criteria.getRelevanceStatus())), new MenuBarHelper.MenuBarItem(I18nProperties.getCaption(Captions.actionDearchiveInfrastructure), VaadinIcons.ARCHIVE, selectedItem -> {
                    ControllerProvider.getInfrastructureController().archiveOrDearchiveAllSelectedItems(false, grid.asMultiSelect().getSelectedItems(), InfrastructureType.REGION, () -> navigateTo(criteria));
                }, EntityRelevanceStatus.ARCHIVED.equals(criteria.getRelevanceStatus())));
                bulkOperationsDropdown.setVisible(isBulkOperationsDropdownVisible());
                actionButtonsLayout.addComponent(bulkOperationsDropdown);
            }
        }
    }
    filterLayout.addComponent(actionButtonsLayout);
    filterLayout.setComponentAlignment(actionButtonsLayout, Alignment.BOTTOM_RIGHT);
    filterLayout.setExpandRatio(actionButtonsLayout, 1);
    return filterLayout;
}
Also used : FeatureType(de.symeda.sormas.api.feature.FeatureType) RowCount(de.symeda.sormas.ui.utils.RowCount) StreamResource(com.vaadin.server.StreamResource) SearchField(de.symeda.sormas.ui.configuration.infrastructure.components.SearchField) 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) GridExportStreamResource(de.symeda.sormas.ui.utils.GridExportStreamResource) Window(com.vaadin.ui.Window) EntityRelevanceStatus(de.symeda.sormas.api.EntityRelevanceStatus) RegionCriteria(de.symeda.sormas.api.infrastructure.region.RegionCriteria) ControllerProvider(de.symeda.sormas.ui.ControllerProvider) ExportEntityName(de.symeda.sormas.ui.utils.ExportEntityName) ViewConfiguration(de.symeda.sormas.ui.utils.ViewConfiguration) 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) AbstractConfigurationView(de.symeda.sormas.ui.configuration.AbstractConfigurationView) 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) InfrastructureType(de.symeda.sormas.api.infrastructure.InfrastructureType) Captions(de.symeda.sormas.api.i18n.Captions) UserRight(de.symeda.sormas.api.user.UserRight) Button(com.vaadin.ui.Button) HorizontalLayout(com.vaadin.ui.HorizontalLayout) FileDownloader(com.vaadin.server.FileDownloader) Descriptions(de.symeda.sormas.api.i18n.Descriptions) Strings(de.symeda.sormas.api.i18n.Strings) SearchField(de.symeda.sormas.ui.configuration.infrastructure.components.SearchField) MenuBarHelper(de.symeda.sormas.ui.utils.MenuBarHelper) RegionCriteria(de.symeda.sormas.api.infrastructure.region.RegionCriteria) EntityRelevanceStatus(de.symeda.sormas.api.EntityRelevanceStatus) HorizontalLayout(com.vaadin.ui.HorizontalLayout)

Aggregations

VaadinIcons (com.vaadin.icons.VaadinIcons)9 StreamResource (com.vaadin.server.StreamResource)9 Alignment (com.vaadin.ui.Alignment)9 Button (com.vaadin.ui.Button)9 MenuBar (com.vaadin.ui.MenuBar)9 Window (com.vaadin.ui.Window)9 ValoTheme (com.vaadin.ui.themes.ValoTheme)9 EntityRelevanceStatus (de.symeda.sormas.api.EntityRelevanceStatus)9 Captions (de.symeda.sormas.api.i18n.Captions)9 I18nProperties (de.symeda.sormas.api.i18n.I18nProperties)9 Strings (de.symeda.sormas.api.i18n.Strings)9 InfrastructureType (de.symeda.sormas.api.infrastructure.InfrastructureType)9 UserRight (de.symeda.sormas.api.user.UserRight)9 ControllerProvider (de.symeda.sormas.ui.ControllerProvider)9 UserProvider (de.symeda.sormas.ui.UserProvider)9 ViewModelProviders (de.symeda.sormas.ui.ViewModelProviders)9 AbstractConfigurationView (de.symeda.sormas.ui.configuration.AbstractConfigurationView)9 SearchField (de.symeda.sormas.ui.configuration.infrastructure.components.SearchField)9 ButtonHelper (de.symeda.sormas.ui.utils.ButtonHelper)9 CssStyles (de.symeda.sormas.ui.utils.CssStyles)9