Search in sources :

Example 1 with RegistrationListEntity

use of org.komunumo.data.entity.RegistrationListEntity in project komunumo-server by komunumo.

the class RegistrationsDialog method configureGrid.

private void configureGrid() {
    grid.setSelectionMode(Grid.SelectionMode.NONE);
    grid.addThemeVariants(GridVariant.LUMO_NO_BORDER, GridVariant.LUMO_ROW_STRIPES);
    grid.addClassName("registration-dialog");
    grid.addColumn(new ComponentRenderer<>(registrationListEntity -> new Anchor("mailto:" + registrationListEntity.email(), registrationListEntity.fullName()))).setHeader("Attendee").setAutoWidth(true).setFlexGrow(0);
    grid.addColumn(new LocalDateTimeRenderer<>(RegistrationListEntity::date, FormatterUtil.dateTimeFormatter())).setHeader("Registration date").setAutoWidth(true).setFlexGrow(0);
    grid.addColumn(RegistrationListEntity::source).setHeader("Source").setAutoWidth(true).setFlexGrow(0);
    if (event.getDate().isBefore(LocalDateTime.now())) {
        grid.addColumn(new ComponentRenderer<>(registrationListEntity -> new Icon(registrationListEntity.noShow() ? VaadinIcon.CLOSE_CIRCLE_O : VaadinIcon.CHECK_CIRCLE_O))).setHeader("No show").setTextAlign(ColumnTextAlign.CENTER).setAutoWidth(true).setFlexGrow(0);
    }
    grid.addColumn(new ComponentRenderer<>(registrationListEntity -> {
        final var deregisterButton = new EnhancedButton(new Icon(VaadinIcon.TRASH), clickEvent -> deregister(registrationListEntity));
        deregisterButton.setTitle("Deregister this attendee");
        deregisterButton.setEnabled(event.getDate() != null && event.getDate().isAfter(LocalDateTime.now()));
        return deregisterButton;
    })).setHeader("Actions").setAutoWidth(true).setFlexGrow(0);
    grid.setWidthFull();
    grid.setHeightFull();
}
Also used : ImageBanner(ar.com.fdvs.dj.domain.ImageBanner) ComponentRenderer(com.vaadin.flow.data.renderer.ComponentRenderer) Event(org.komunumo.data.entity.Event) CssImport(com.vaadin.flow.component.dependency.CssImport) HorizontalLayout(com.vaadin.flow.component.orderedlayout.HorizontalLayout) PrintPreviewReport(org.vaadin.reports.PrintPreviewReport) LocalDateTime(java.time.LocalDateTime) EnhancedButton(org.komunumo.ui.component.EnhancedButton) FormatterUtil.formatDate(org.komunumo.util.FormatterUtil.formatDate) RegistrationListEntity(org.komunumo.data.entity.RegistrationListEntity) RegistrationListEntityWrapper(org.komunumo.data.entity.reports.RegistrationListEntityWrapper) ByteArrayInputStream(java.io.ByteArrayInputStream) UI(com.vaadin.flow.component.UI) EnhancedDialog(org.komunumo.ui.component.EnhancedDialog) Icon(com.vaadin.flow.component.icon.Icon) TextField(com.vaadin.flow.component.textfield.TextField) StreamRegistration(com.vaadin.flow.server.StreamRegistration) FormatterUtil(org.komunumo.util.FormatterUtil) VaadinSession(com.vaadin.flow.server.VaadinSession) Grid(com.vaadin.flow.component.grid.Grid) Anchor(com.vaadin.flow.component.html.Anchor) GridVariant(com.vaadin.flow.component.grid.GridVariant) UTF_8(java.nio.charset.StandardCharsets.UTF_8) StringWriter(java.io.StringWriter) VaadinIcon(com.vaadin.flow.component.icon.VaadinIcon) CSVWriter(com.opencsv.CSVWriter) LocalDateTimeRenderer(com.vaadin.flow.data.renderer.LocalDateTimeRenderer) Nullable(org.jetbrains.annotations.Nullable) DatabaseService(org.komunumo.data.service.DatabaseService) ColumnTextAlign(com.vaadin.flow.component.grid.ColumnTextAlign) StreamResource(com.vaadin.flow.server.StreamResource) ConfirmDialog(com.vaadin.flow.component.confirmdialog.ConfirmDialog) NotNull(org.jetbrains.annotations.NotNull) Callback(org.komunumo.Callback) FilterField(org.komunumo.ui.component.FilterField) RegistrationListEntity(org.komunumo.data.entity.RegistrationListEntity) EnhancedButton(org.komunumo.ui.component.EnhancedButton) Anchor(com.vaadin.flow.component.html.Anchor) ComponentRenderer(com.vaadin.flow.data.renderer.ComponentRenderer) Icon(com.vaadin.flow.component.icon.Icon) VaadinIcon(com.vaadin.flow.component.icon.VaadinIcon) LocalDateTimeRenderer(com.vaadin.flow.data.renderer.LocalDateTimeRenderer)

Example 2 with RegistrationListEntity

use of org.komunumo.data.entity.RegistrationListEntity in project komunumo-server by komunumo.

the class RegistrationsDialog method downloadRegistrations.

private void downloadRegistrations() {
    final var resource = new StreamResource("registrations.csv", () -> {
        final var stringWriter = new StringWriter();
        final var csvWriter = new CSVWriter(stringWriter);
        csvWriter.writeNext(new String[] { "First name", "Last name", "Email", "Date", "Source", "No show" });
        grid.getGenericDataView().getItems().map(registrationListEntity -> new String[] { registrationListEntity.firstName(), registrationListEntity.lastName(), registrationListEntity.email(), registrationListEntity.date().toString(), registrationListEntity.source(), Boolean.toString(registrationListEntity.noShow()) }).forEach(csvWriter::writeNext);
        return new ByteArrayInputStream(stringWriter.toString().getBytes(UTF_8));
    });
    final StreamRegistration registration = VaadinSession.getCurrent().getResourceRegistry().registerResource(resource);
    UI.getCurrent().getPage().setLocation(registration.getResourceUri());
}
Also used : ImageBanner(ar.com.fdvs.dj.domain.ImageBanner) ComponentRenderer(com.vaadin.flow.data.renderer.ComponentRenderer) Event(org.komunumo.data.entity.Event) CssImport(com.vaadin.flow.component.dependency.CssImport) HorizontalLayout(com.vaadin.flow.component.orderedlayout.HorizontalLayout) PrintPreviewReport(org.vaadin.reports.PrintPreviewReport) LocalDateTime(java.time.LocalDateTime) EnhancedButton(org.komunumo.ui.component.EnhancedButton) FormatterUtil.formatDate(org.komunumo.util.FormatterUtil.formatDate) RegistrationListEntity(org.komunumo.data.entity.RegistrationListEntity) RegistrationListEntityWrapper(org.komunumo.data.entity.reports.RegistrationListEntityWrapper) ByteArrayInputStream(java.io.ByteArrayInputStream) UI(com.vaadin.flow.component.UI) EnhancedDialog(org.komunumo.ui.component.EnhancedDialog) Icon(com.vaadin.flow.component.icon.Icon) TextField(com.vaadin.flow.component.textfield.TextField) StreamRegistration(com.vaadin.flow.server.StreamRegistration) FormatterUtil(org.komunumo.util.FormatterUtil) VaadinSession(com.vaadin.flow.server.VaadinSession) Grid(com.vaadin.flow.component.grid.Grid) Anchor(com.vaadin.flow.component.html.Anchor) GridVariant(com.vaadin.flow.component.grid.GridVariant) UTF_8(java.nio.charset.StandardCharsets.UTF_8) StringWriter(java.io.StringWriter) VaadinIcon(com.vaadin.flow.component.icon.VaadinIcon) CSVWriter(com.opencsv.CSVWriter) LocalDateTimeRenderer(com.vaadin.flow.data.renderer.LocalDateTimeRenderer) Nullable(org.jetbrains.annotations.Nullable) DatabaseService(org.komunumo.data.service.DatabaseService) ColumnTextAlign(com.vaadin.flow.component.grid.ColumnTextAlign) StreamResource(com.vaadin.flow.server.StreamResource) ConfirmDialog(com.vaadin.flow.component.confirmdialog.ConfirmDialog) NotNull(org.jetbrains.annotations.NotNull) Callback(org.komunumo.Callback) FilterField(org.komunumo.ui.component.FilterField) StreamResource(com.vaadin.flow.server.StreamResource) StringWriter(java.io.StringWriter) StreamRegistration(com.vaadin.flow.server.StreamRegistration) ByteArrayInputStream(java.io.ByteArrayInputStream) CSVWriter(com.opencsv.CSVWriter)

Aggregations

ImageBanner (ar.com.fdvs.dj.domain.ImageBanner)2 CSVWriter (com.opencsv.CSVWriter)2 UI (com.vaadin.flow.component.UI)2 ConfirmDialog (com.vaadin.flow.component.confirmdialog.ConfirmDialog)2 CssImport (com.vaadin.flow.component.dependency.CssImport)2 ColumnTextAlign (com.vaadin.flow.component.grid.ColumnTextAlign)2 Grid (com.vaadin.flow.component.grid.Grid)2 GridVariant (com.vaadin.flow.component.grid.GridVariant)2 Anchor (com.vaadin.flow.component.html.Anchor)2 Icon (com.vaadin.flow.component.icon.Icon)2 VaadinIcon (com.vaadin.flow.component.icon.VaadinIcon)2 HorizontalLayout (com.vaadin.flow.component.orderedlayout.HorizontalLayout)2 TextField (com.vaadin.flow.component.textfield.TextField)2 ComponentRenderer (com.vaadin.flow.data.renderer.ComponentRenderer)2 LocalDateTimeRenderer (com.vaadin.flow.data.renderer.LocalDateTimeRenderer)2 StreamRegistration (com.vaadin.flow.server.StreamRegistration)2 StreamResource (com.vaadin.flow.server.StreamResource)2 VaadinSession (com.vaadin.flow.server.VaadinSession)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 StringWriter (java.io.StringWriter)2