use of de.symeda.sormas.ui.customexport.ExportConfigurationsLayout in project SORMAS-Project by hzi-braunschweig.
the class CasesView method addCommonCasesOverviewToolbar.
private void addCommonCasesOverviewToolbar() {
final PopupMenu moreButton = new PopupMenu(I18nProperties.getCaption(Captions.moreActions));
Button openGuideButton = ButtonHelper.createIconButton(Captions.caseOpenCasesGuide, VaadinIcons.QUESTION, e -> buildAndOpenCasesInstructions(), ValoTheme.BUTTON_PRIMARY);
openGuideButton.setWidth(100, Unit.PERCENTAGE);
moreButton.addMenuEntry(openGuideButton);
if (UserProvider.getCurrent().hasUserRight(UserRight.CASE_IMPORT)) {
VerticalLayout importLayout = new VerticalLayout();
{
importLayout.setSpacing(true);
importLayout.setMargin(true);
importLayout.addStyleName(CssStyles.LAYOUT_MINIMAL);
importLayout.setWidth(250, Unit.PIXELS);
PopupButton importButton = ButtonHelper.createIconPopupButton(Captions.actionImport, VaadinIcons.UPLOAD, importLayout);
addHeaderComponent(importButton);
}
addImportButton(importLayout, Captions.importLineListing, Strings.headingLineListingImport, LineListingImportLayout::new);
addImportButton(importLayout, Captions.importDetailed, Strings.headingImportCases, CaseImportLayout::new);
}
if (UserProvider.getCurrent().hasUserRight(UserRight.CASE_EXPORT)) {
VerticalLayout exportLayout = new VerticalLayout();
{
exportLayout.setSpacing(true);
exportLayout.setMargin(true);
exportLayout.addStyleName(CssStyles.LAYOUT_MINIMAL);
exportLayout.setWidth(250, Unit.PIXELS);
}
PopupButton exportPopupButton = ButtonHelper.createIconPopupButton(Captions.export, VaadinIcons.DOWNLOAD, exportLayout);
addHeaderComponent(exportPopupButton);
{
StreamResource streamResource = GridExportStreamResource.createStreamResourceWithSelectedItems(grid, () -> this.viewConfiguration.isInEagerMode() ? this.grid.asMultiSelect().getSelectedItems() : Collections.emptySet(), ExportEntityName.CASES);
addExportButton(streamResource, exportPopupButton, exportLayout, VaadinIcons.TABLE, Captions.exportBasic, Strings.infoBasicExport);
}
{
StreamResource exportStreamResource = CaseDownloadUtil.createCaseExportResource(grid.getCriteria(), this::getSelectedRows, CaseExportType.CASE_SURVEILLANCE, detailedExportConfiguration);
addExportButton(exportStreamResource, exportPopupButton, exportLayout, VaadinIcons.FILE_TEXT, Captions.exportDetailed, Strings.infoDetailedExport);
}
if (hasClinicalCourseRight || hasTherapyRight) {
StreamResource caseManagementExportStreamResource = DownloadUtil.createCaseManagementExportResource(grid.getCriteria(), this::getSelectedRows, ExportEntityName.CONTACTS);
addExportButton(caseManagementExportStreamResource, exportPopupButton, exportLayout, VaadinIcons.FILE_TEXT, Captions.exportCaseManagement, Strings.infoCaseManagementExport);
}
{
StreamResource sampleExportStreamResource = DownloadUtil.createCsvExportStreamResource(SampleExportDto.class, null, (Integer start, Integer max) -> FacadeProvider.getSampleFacade().getExportList(grid.getCriteria(), this.getSelectedRows(), start, max), (propertyId, type) -> {
String caption = I18nProperties.findPrefixCaption(propertyId, SampleExportDto.I18N_PREFIX, SampleDto.I18N_PREFIX, CaseDataDto.I18N_PREFIX, PersonDto.I18N_PREFIX, AdditionalTestDto.I18N_PREFIX);
if (Date.class.isAssignableFrom(type)) {
caption += " (" + DateFormatHelper.getDateFormatPattern() + ")";
}
return caption;
}, ExportEntityName.SAMPLES, null);
addExportButton(sampleExportStreamResource, exportPopupButton, exportLayout, VaadinIcons.FILE_TEXT, Captions.exportSamples, Strings.infoSampleExport);
}
if (FacadeProvider.getConfigFacade().isConfiguredCountry(CountryHelper.COUNTRY_CODE_SWITZERLAND) && UserProvider.getCurrent().hasUserRight(UserRight.BAG_EXPORT)) {
StreamResource bagExportResource = DownloadUtil.createCsvExportStreamResource(BAGExportCaseDto.class, null, (Integer start, Integer max) -> FacadeProvider.getBAGExportFacade().getCaseExportList(this.getSelectedRows(), start, max), (propertyId, type) -> propertyId, ExportEntityName.BAG_CASES, null);
addExportButton(bagExportResource, exportPopupButton, exportLayout, VaadinIcons.FILE_TEXT, Captions.BAGExport, Strings.infoBAGExport);
}
{
Button btnCustomCaseExport = ButtonHelper.createIconButton(Captions.exportCaseCustom, VaadinIcons.FILE_TEXT, e -> {
Window customExportWindow = VaadinUiUtil.createPopupWindow();
ExportConfigurationsLayout customExportsLayout = new ExportConfigurationsLayout(ExportType.CASE, ImportExportUtils.getCaseExportProperties(CaseDownloadUtil::getPropertyCaption, caseFollowUpEnabled, hasClinicalCourseRight, hasTherapyRight, FacadeProvider.getConfigFacade().getCountryLocale()), customExportWindow::close);
customExportsLayout.setExportCallback((exportConfig) -> Page.getCurrent().open(CaseDownloadUtil.createCaseExportResource(grid.getCriteria(), this::getSelectedRows, null, exportConfig), null, true));
customExportWindow.setWidth(1024, Unit.PIXELS);
customExportWindow.setCaption(I18nProperties.getCaption(Captions.exportCaseCustom));
customExportWindow.setContent(customExportsLayout);
UI.getCurrent().addWindow(customExportWindow);
exportPopupButton.setPopupVisible(false);
}, ValoTheme.BUTTON_PRIMARY);
btnCustomCaseExport.setDescription(I18nProperties.getString(Strings.infoCustomExport));
btnCustomCaseExport.setWidth(100, Unit.PERCENTAGE);
exportLayout.addComponent(btnCustomCaseExport);
}
{
// Warning if no filters have been selected
Label warningLabel = new Label(I18nProperties.getString(Strings.infoExportNoFilters), ContentMode.HTML);
warningLabel.setWidth(100, Unit.PERCENTAGE);
exportLayout.addComponent(warningLabel);
warningLabel.setVisible(false);
exportPopupButton.addClickListener(e -> warningLabel.setVisible(!criteria.hasAnyFilterActive()));
}
}
if (isBulkEditAllowed()) {
btnEnterBulkEditMode = ButtonHelper.createIconButton(Captions.actionEnterBulkEditMode, VaadinIcons.CHECK_SQUARE_O, e -> {
if (grid.getItemCount() > BULK_EDIT_MODE_WARNING_THRESHOLD) {
VaadinUiUtil.showConfirmationPopup(I18nProperties.getCaption(Captions.actionEnterBulkEditMode), new Label(String.format(I18nProperties.getString(Strings.confirmationEnterBulkEditMode), BULK_EDIT_MODE_WARNING_THRESHOLD)), I18nProperties.getString(Strings.yes), I18nProperties.getString(Strings.no), 640, (result) -> {
if (result == true) {
enterBulkEditMode();
}
});
} else {
enterBulkEditMode();
}
}, ValoTheme.BUTTON_PRIMARY);
btnEnterBulkEditMode.setVisible(!viewConfiguration.isInEagerMode());
btnEnterBulkEditMode.setWidth(100, Unit.PERCENTAGE);
moreButton.addMenuEntry(btnEnterBulkEditMode);
btnLeaveBulkEditMode = ButtonHelper.createIconButton(Captions.actionLeaveBulkEditMode, VaadinIcons.CLOSE, e -> {
bulkOperationsDropdown.setVisible(false);
ViewModelProviders.of(CasesView.class).get(CasesViewConfiguration.class).setInEagerMode(false);
btnLeaveBulkEditMode.setVisible(false);
btnEnterBulkEditMode.setVisible(true);
this.filterForm.enableSearchAndReportingUser();
navigateTo(criteria);
}, ValoTheme.BUTTON_PRIMARY);
btnLeaveBulkEditMode.setVisible(viewConfiguration.isInEagerMode());
addHeaderComponent(btnLeaveBulkEditMode);
}
if (UserProvider.getCurrent().hasUserRight(UserRight.CASE_MERGE)) {
Button mergeDuplicatesButton = ButtonHelper.createIconButton(Captions.caseMergeDuplicates, VaadinIcons.COMPRESS_SQUARE, e -> ControllerProvider.getCaseController().navigateToMergeCasesView(), ValoTheme.BUTTON_PRIMARY);
mergeDuplicatesButton.setWidth(100, Unit.PERCENTAGE);
moreButton.addMenuEntry(mergeDuplicatesButton);
}
Button searchSpecificCaseButton = ButtonHelper.createIconButton(Captions.caseSearchSpecificCase, VaadinIcons.SEARCH, e -> buildAndOpenSearchSpecificCaseWindow(), ValoTheme.BUTTON_PRIMARY);
searchSpecificCaseButton.setWidth(100, Unit.PERCENTAGE);
moreButton.addMenuEntry(searchSpecificCaseButton);
if (UserProvider.getCurrent().hasUserRight(UserRight.CASE_CREATE)) {
final ExpandableButton lineListingButton = new ExpandableButton(Captions.lineListing).expand(e -> ControllerProvider.getCaseController().openLineListingWindow());
addHeaderComponent(lineListingButton);
final ExpandableButton createButton = new ExpandableButton(Captions.caseNewCase).expand(e -> ControllerProvider.getCaseController().create());
addHeaderComponent(createButton);
}
if (moreButton.hasMenuEntries()) {
addHeaderComponent(moreButton);
}
}
use of de.symeda.sormas.ui.customexport.ExportConfigurationsLayout in project SORMAS-Project by hzi-braunschweig.
the class EventParticipantsView method createTopBar.
public HorizontalLayout createTopBar() {
HorizontalLayout topLayout = new HorizontalLayout();
topLayout.setSpacing(true);
topLayout.setWidth("100%");
VerticalLayout exportLayout = new VerticalLayout();
{
exportLayout.setSpacing(true);
exportLayout.setMargin(true);
exportLayout.addStyleName(CssStyles.LAYOUT_MINIMAL);
exportLayout.setWidth(250, Unit.PIXELS);
}
// import
if (UserProvider.getCurrent().hasUserRight(UserRight.EVENTPARTICIPANT_IMPORT)) {
Button importButton = ButtonHelper.createIconButton(Captions.actionImport, VaadinIcons.UPLOAD, e -> {
Window popupWindow = VaadinUiUtil.showPopupWindow(new EventParticipantImportLayout(getEventRef()));
popupWindow.setCaption(I18nProperties.getString(Strings.headingImportEventParticipant));
popupWindow.addCloseListener(c -> this.grid.reload());
}, ValoTheme.BUTTON_PRIMARY);
addHeaderComponent(importButton);
}
// export
PopupButton exportPopupButton = ButtonHelper.createIconPopupButton(Captions.export, VaadinIcons.DOWNLOAD, exportLayout);
addHeaderComponent(exportPopupButton);
{
StreamResource streamResource = GridExportStreamResource.createStreamResourceWithSelectedItems(grid, () -> this.grid.getSelectionModel() instanceof MultiSelectionModelImpl ? this.grid.asMultiSelect().getSelectedItems() : null, ExportEntityName.EVENT_PARTICIPANTS);
addExportButton(streamResource, exportPopupButton, exportLayout, VaadinIcons.TABLE, Captions.exportBasic, Strings.infoBasicExport);
}
{
StreamResource extendedExportStreamResource = EventParticipantDownloadUtil.createExtendedEventParticipantExportResource(grid.getCriteria(), this::getSelectedRows, null);
addExportButton(extendedExportStreamResource, exportPopupButton, exportLayout, VaadinIcons.FILE_TEXT, Captions.exportDetailed, Descriptions.descDetailedExportButton);
}
{
Button btnCustomExport = ButtonHelper.createIconButton(Captions.exportCustom, VaadinIcons.FILE_TEXT, e -> {
Window customExportWindow = VaadinUiUtil.createPopupWindow();
ExportConfigurationsLayout customExportsLayout = new ExportConfigurationsLayout(ExportType.EVENT_PARTICIPANTS, ImportExportUtils.getEventParticipantExportProperties(EventParticipantDownloadUtil::getPropertyCaption, FacadeProvider.getConfigFacade().getCountryLocale()), customExportWindow::close);
customExportsLayout.setExportCallback((exportConfig) -> Page.getCurrent().open(EventParticipantDownloadUtil.createExtendedEventParticipantExportResource(grid.getCriteria(), this::getSelectedRows, exportConfig), null, true));
customExportWindow.setWidth(1024, Unit.PIXELS);
customExportWindow.setCaption(I18nProperties.getCaption(Captions.exportCustom));
customExportWindow.setContent(customExportsLayout);
UI.getCurrent().addWindow(customExportWindow);
exportPopupButton.setPopupVisible(false);
}, ValoTheme.BUTTON_PRIMARY);
btnCustomExport.setDescription(I18nProperties.getString(Strings.infoCustomExport));
btnCustomExport.setWidth(100, Unit.PERCENTAGE);
exportLayout.addComponent(btnCustomExport);
}
filterForm = new EventParticipantsFilterForm();
filterForm.addValueChangeListener(e -> {
if (!filterForm.hasFilter()) {
navigateTo(null);
}
});
filterForm.addResetHandler(e -> {
ViewModelProviders.of(EventParticipantsView.class).remove(EventParticipantCriteria.class);
navigateTo(null);
});
filterForm.addApplyHandler(e -> navigateTo(criteria));
topLayout.addComponent(filterForm);
// Bulk operation dropdown
if (UserProvider.getCurrent().hasUserRight(UserRight.PERFORM_BULK_OPERATIONS_EVENTPARTICIPANT)) {
topLayout.setWidth(100, Unit.PERCENTAGE);
List<MenuBarHelper.MenuBarItem> bulkActions = new ArrayList<>();
bulkActions.add(new MenuBarHelper.MenuBarItem(I18nProperties.getCaption(Captions.bulkEventParticipantsToContacts), VaadinIcons.HAND, mi -> {
grid.bulkActionHandler(items -> {
EventDto eventDto = FacadeProvider.getEventFacade().getEventByUuid(getEventRef().getUuid(), false);
ControllerProvider.getContactController().openLineListingWindow(eventDto, items);
}, true);
}));
if (UserProvider.getCurrent().hasUserRight(UserRight.EVENTPARTICIPANT_DELETE)) {
bulkActions.add(new MenuBarHelper.MenuBarItem(I18nProperties.getCaption(Captions.bulkDelete), VaadinIcons.TRASH, mi -> {
grid.bulkActionHandler(items -> {
ControllerProvider.getEventParticipantController().deleteAllSelectedItems(items, () -> navigateTo(criteria));
}, true);
}));
}
if (isDocGenerationAllowed()) {
bulkActions.add(new MenuBarHelper.MenuBarItem(I18nProperties.getCaption(Captions.bulkActionCreatDocuments), VaadinIcons.FILE_TEXT, mi -> {
grid.bulkActionHandler(items -> {
List<EventParticipantReferenceDto> references = grid.asMultiSelect().getSelectedItems().stream().map(EventParticipantIndexDto::toReference).collect(Collectors.toList());
if (references.size() == 0) {
new Notification(I18nProperties.getString(Strings.headingNoEventParticipantsSelected), I18nProperties.getString(Strings.messageNoEventParticipantsSelected), Notification.Type.WARNING_MESSAGE, false).show(Page.getCurrent());
return;
}
EventDto eventDto = FacadeProvider.getEventFacade().getEventByUuid(getEventRef().getUuid(), false);
ControllerProvider.getDocGenerationController().showBulkEventParticipantQuarantineOrderDocumentDialog(references, eventDto.getDisease());
});
}));
}
MenuBar bulkOperationsDropdown = MenuBarHelper.createDropDown(Captions.bulkActions, bulkActions);
topLayout.addComponent(bulkOperationsDropdown);
topLayout.setComponentAlignment(bulkOperationsDropdown, Alignment.TOP_RIGHT);
}
topLayout.addStyleName(CssStyles.VSPACE_3);
return topLayout;
}
Aggregations