Search in sources :

Example 26 with ComponentRenderer

use of com.vaadin.flow.data.renderer.ComponentRenderer in project komunumo-server by komunumo.

the class MailTemplateSetting method configureGrid.

private void configureGrid() {
    grid.setSelectionMode(Grid.SelectionMode.NONE);
    grid.addThemeVariants(GridVariant.LUMO_NO_BORDER, GridVariant.LUMO_ROW_STRIPES);
    grid.addColumn(MailTemplateRecord::getId).setHeader("ID").setAutoWidth(true).setFlexGrow(0);
    grid.addColumn(MailTemplateRecord::getSubject).setHeader("Subject").setAutoWidth(true).setFlexGrow(0);
    grid.addColumn(new ComponentRenderer<>(mailTemplateRecord -> {
        final var editButton = new EnhancedButton(new Icon(VaadinIcon.EDIT), clickEvent -> showEditDialog(mailTemplateRecord));
        editButton.setTitle("Edit this mail template");
        final var deleteButton = new EnhancedButton(new Icon(VaadinIcon.TRASH), clickEvent -> deleteMailTemplate(mailTemplateRecord));
        deleteButton.setTitle("Delete this mail template");
        return new HorizontalLayout(editButton, deleteButton);
    })).setHeader("Actions").setAutoWidth(true).setFlexGrow(0);
    grid.setHeightFull();
}
Also used : EnhancedButton(org.komunumo.ui.component.EnhancedButton) ComponentRenderer(com.vaadin.flow.data.renderer.ComponentRenderer) Icon(com.vaadin.flow.component.icon.Icon) VaadinIcon(com.vaadin.flow.component.icon.VaadinIcon) HorizontalLayout(com.vaadin.flow.component.orderedlayout.HorizontalLayout)

Example 27 with ComponentRenderer

use of com.vaadin.flow.data.renderer.ComponentRenderer in project komunumo-server by komunumo.

the class RedirectSetting method configureGrid.

private void configureGrid() {
    grid.setSelectionMode(Grid.SelectionMode.NONE);
    grid.addThemeVariants(GridVariant.LUMO_NO_BORDER, GridVariant.LUMO_ROW_STRIPES);
    grid.addColumn(RedirectRecord::getOldUrl).setHeader("Old URL").setAutoWidth(true).setFlexGrow(0);
    grid.addColumn(RedirectRecord::getNewUrl).setHeader("New URL").setAutoWidth(true).setFlexGrow(0);
    grid.addColumn(new ComponentRenderer<>(redirectRecord -> {
        final var editButton = new EnhancedButton(new Icon(VaadinIcon.EDIT), clickEvent -> showEditDialog(redirectRecord));
        editButton.setTitle("Edit this location color setting");
        final var deleteButton = new EnhancedButton(new Icon(VaadinIcon.TRASH), clickEvent -> deleteRedirect(redirectRecord));
        deleteButton.setTitle("Delete this location color setting");
        return new HorizontalLayout(editButton, deleteButton);
    })).setHeader("Actions").setAutoWidth(true).setFlexGrow(0);
    grid.setHeightFull();
}
Also used : EnhancedButton(org.komunumo.ui.component.EnhancedButton) ComponentRenderer(com.vaadin.flow.data.renderer.ComponentRenderer) Icon(com.vaadin.flow.component.icon.Icon) VaadinIcon(com.vaadin.flow.component.icon.VaadinIcon) HorizontalLayout(com.vaadin.flow.component.orderedlayout.HorizontalLayout)

Example 28 with ComponentRenderer

use of com.vaadin.flow.data.renderer.ComponentRenderer 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 29 with ComponentRenderer

use of com.vaadin.flow.data.renderer.ComponentRenderer in project komunumo-server by komunumo.

the class FaqView method configureGrid.

private void configureGrid() {
    grid.setSelectionMode(Grid.SelectionMode.NONE);
    grid.addThemeVariants(GridVariant.LUMO_NO_BORDER, GridVariant.LUMO_ROW_STRIPES);
    grid.addColumn(FaqRecord::getQuestion).setHeader("Question").setAutoWidth(true).setFlexGrow(0);
    grid.addColumn(new ComponentRenderer<>(faqRecord -> {
        final var editButton = new EnhancedButton(new Icon(VaadinIcon.EDIT), clickEvent -> showEditDialog(faqRecord));
        editButton.setTitle("Edit this entry");
        final var deleteButton = new EnhancedButton(new Icon(VaadinIcon.TRASH), clickEvent -> deleteEntry(faqRecord));
        deleteButton.setTitle("Delete this entry");
        return new HorizontalLayout(editButton, deleteButton);
    })).setHeader("Actions").setAutoWidth(true).setFlexGrow(0);
    grid.setHeightFull();
}
Also used : EnhancedButton(org.komunumo.ui.component.EnhancedButton) ComponentRenderer(com.vaadin.flow.data.renderer.ComponentRenderer) Icon(com.vaadin.flow.component.icon.Icon) VaadinIcon(com.vaadin.flow.component.icon.VaadinIcon) HorizontalLayout(com.vaadin.flow.component.orderedlayout.HorizontalLayout)

Example 30 with ComponentRenderer

use of com.vaadin.flow.data.renderer.ComponentRenderer in project komunumo-server by komunumo.

the class SpeakersView method configureGrid.

private void configureGrid() {
    grid.setSelectionMode(Grid.SelectionMode.NONE);
    grid.addThemeVariants(GridVariant.LUMO_NO_BORDER, GridVariant.LUMO_ROW_STRIPES);
    grid.addColumn(LitRenderer.<SpeakerListEntity>of("<span style=\"font-weight: bold;\">${item.fullName}</span><br/>" + "<a href=\"${item.website}\" target=\"_blank\" title=\"${item.title}\">${item.company}</a>").withProperty("fullName", SpeakerListEntity::fullName).withProperty("company", speakerListEntity -> FormatterUtil.formatString(speakerListEntity.company(), 50)).withProperty("title", SpeakerListEntity::company).withProperty("website", SpeakerListEntity::website)).setHeader("Name & Company").setAutoWidth(true).setFlexGrow(1);
    grid.addColumn(LitRenderer.<SpeakerListEntity>of("<a href=\"mailto:${item.email}\" target=\"_blank\">${item.email}</a>").withProperty("email", SpeakerListEntity::email)).setHeader("Email").setAutoWidth(true).setFlexGrow(0).setKey("email");
    grid.addColumn(LitRenderer.<SpeakerListEntity>of("<a href=\"https://twitter.com/${item.twitter}\" target=\"_blank\" title=\"${item.twitter}\">${item.twitter}</a>").withProperty("twitter", SpeakerListEntity::twitter)).setHeader("Twitter").setAutoWidth(true).setFlexGrow(0).setKey("twitter");
    final var eventCountRenderer = LitRenderer.<SpeakerListEntity>of("<a href=\"/admin/events?filter=${item.filterValue}\">${item.eventCount}</a>").withProperty("eventCount", SpeakerListEntity::eventCount).withProperty("filterValue", speakerListEntity -> URLEncoder.encode(speakerListEntity.fullName(), UTF_8));
    grid.addColumn(eventCountRenderer).setHeader("Events").setAutoWidth(true).setTextAlign(ColumnTextAlign.CENTER).setFlexGrow(0);
    grid.addColumn(new ComponentRenderer<>(speakerListEntity -> {
        final var editButton = new EnhancedButton(new Icon(VaadinIcon.EDIT), clickEvent -> showSpeakerDialog(speakerListEntity));
        editButton.setTitle("Edit this speaker");
        final var deleteButton = new EnhancedButton(new Icon(VaadinIcon.TRASH), clickEvent -> deleteSpeaker(speakerListEntity));
        deleteButton.setTitle("Delete this speaker");
        deleteButton.setEnabled(speakerListEntity.eventCount() == 0);
        return new HorizontalLayout(editButton, deleteButton);
    })).setHeader("Actions").setAutoWidth(true).setFlexGrow(0);
    grid.setHeightFull();
}
Also used : EnhancedButton(org.komunumo.ui.component.EnhancedButton) ComponentRenderer(com.vaadin.flow.data.renderer.ComponentRenderer) SpeakerListEntity(org.komunumo.data.entity.SpeakerListEntity) Icon(com.vaadin.flow.component.icon.Icon) VaadinIcon(com.vaadin.flow.component.icon.VaadinIcon) HorizontalLayout(com.vaadin.flow.component.orderedlayout.HorizontalLayout)

Aggregations

ComponentRenderer (com.vaadin.flow.data.renderer.ComponentRenderer)49 Div (com.vaadin.flow.component.html.Div)33 Route (com.vaadin.flow.router.Route)30 Grid (com.vaadin.flow.component.grid.Grid)23 HorizontalLayout (com.vaadin.flow.component.orderedlayout.HorizontalLayout)20 List (java.util.List)19 Icon (com.vaadin.flow.component.icon.Icon)18 NativeButton (com.vaadin.flow.component.html.NativeButton)14 VaadinIcon (com.vaadin.flow.component.icon.VaadinIcon)14 TemplateRenderer (com.vaadin.flow.data.renderer.TemplateRenderer)14 Collectors (java.util.stream.Collectors)14 Label (com.vaadin.flow.component.html.Label)13 Span (com.vaadin.flow.component.html.Span)12 EnhancedButton (org.komunumo.ui.component.EnhancedButton)12 Component (com.vaadin.flow.component.Component)10 H2 (com.vaadin.flow.component.html.H2)10 ArrayList (java.util.ArrayList)10 Element (com.vaadin.flow.dom.Element)9 Collections (java.util.Collections)9 UI (com.vaadin.flow.component.UI)8