Search in sources :

Example 1 with EnhancedButton

use of org.komunumo.ui.component.EnhancedButton in project komunumo-server by komunumo.

the class MembersView method configureGrid.

private void configureGrid() {
    final var sponsorDomains = databaseService.getActiveSponsorDomains();
    grid.setSelectionMode(Grid.SelectionMode.NONE);
    grid.addThemeVariants(GridVariant.LUMO_NO_BORDER, GridVariant.LUMO_ROW_STRIPES);
    grid.addColumn(LitRenderer.<Member>of("<span style=\"font-weight: bold;\">${item.fullName}</span><br/><span>${item.company}</span>").withProperty("fullName", Member::getFullName).withProperty("company", Member::getCompany)).setHeader("Name").setAutoWidth(true).setFlexGrow(1);
    grid.addColumn(LitRenderer.<Member>of("<a href=\"mailto:${item.email}\" target=\"_blank\">${item.email}</a>").withProperty("email", Member::getEmail)).setHeader("Email").setAutoWidth(true).setKey("email").setFlexGrow(0);
    grid.addColumn(new ComponentRenderer<>(member -> new Text(getMembershipText(member, sponsorDomains)))).setHeader("Membership").setAutoWidth(true).setFlexGrow(0);
    grid.addColumn(new ComponentRenderer<>(member -> new Icon(member.getAdmin() ? VaadinIcon.CHECK : VaadinIcon.MINUS))).setHeader("Admin").setAutoWidth(true).setTextAlign(ColumnTextAlign.CENTER).setFlexGrow(0);
    grid.addColumn(new ComponentRenderer<>(member -> {
        final var icon = new Icon(member.getAccountBlocked() ? VaadinIcon.BAN : VaadinIcon.MINUS);
        icon.getElement().setAttribute("title", member.getAccountBlockedReason());
        return icon;
    })).setHeader("Blocked").setAutoWidth(true).setTextAlign(ColumnTextAlign.CENTER).setFlexGrow(0);
    grid.addColumn(new ComponentRenderer<>(member -> {
        final var editButton = new EnhancedButton(new Icon(VaadinIcon.EDIT), clickEvent -> showMemberDialog(member));
        editButton.setTitle("Edit this member");
        final var deleteButton = new EnhancedButton(new Icon(VaadinIcon.TRASH), clickEvent -> deleteMember(member));
        deleteButton.setTitle("Delete this member");
        return new HorizontalLayout(editButton, deleteButton);
    })).setHeader("Actions").setAutoWidth(true).setFlexGrow(0);
    grid.setHeightFull();
}
Also used : Member(org.komunumo.data.entity.Member) ComponentRenderer(com.vaadin.flow.data.renderer.ComponentRenderer) HasUrlParameter(com.vaadin.flow.router.HasUrlParameter) AdminLayout(org.komunumo.ui.view.admin.AdminLayout) RolesAllowed(javax.annotation.security.RolesAllowed) CssImport(com.vaadin.flow.component.dependency.CssImport) HorizontalLayout(com.vaadin.flow.component.orderedlayout.HorizontalLayout) EnhancedButton(org.komunumo.ui.component.EnhancedButton) PageTitle(com.vaadin.flow.router.PageTitle) BeforeEvent(com.vaadin.flow.router.BeforeEvent) FormatterUtil.formatDate(org.komunumo.util.FormatterUtil.formatDate) Route(com.vaadin.flow.router.Route) ByteArrayInputStream(java.io.ByteArrayInputStream) UI(com.vaadin.flow.component.UI) ResizableView(org.komunumo.ui.component.ResizableView) Icon(com.vaadin.flow.component.icon.Icon) TextField(com.vaadin.flow.component.textfield.TextField) StreamRegistration(com.vaadin.flow.server.StreamRegistration) Role(org.komunumo.data.entity.Role) Text(com.vaadin.flow.component.Text) VaadinSession(com.vaadin.flow.server.VaadinSession) Serial(java.io.Serial) Grid(com.vaadin.flow.component.grid.Grid) GridVariant(com.vaadin.flow.component.grid.GridVariant) LitRenderer(com.vaadin.flow.data.renderer.LitRenderer) UTF_8(java.nio.charset.StandardCharsets.UTF_8) StringWriter(java.io.StringWriter) VaadinIcon(com.vaadin.flow.component.icon.VaadinIcon) Set(java.util.Set) CSVWriter(com.opencsv.CSVWriter) OptionalParameter(com.vaadin.flow.router.OptionalParameter) Nullable(org.jetbrains.annotations.Nullable) DatabaseService(org.komunumo.data.service.DatabaseService) List(java.util.List) LocalDate(java.time.LocalDate) 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) FilterField(org.komunumo.ui.component.FilterField) FormatterUtil.formatDateTime(org.komunumo.util.FormatterUtil.formatDateTime) EnhancedButton(org.komunumo.ui.component.EnhancedButton) ComponentRenderer(com.vaadin.flow.data.renderer.ComponentRenderer) Text(com.vaadin.flow.component.Text) Icon(com.vaadin.flow.component.icon.Icon) VaadinIcon(com.vaadin.flow.component.icon.VaadinIcon) Member(org.komunumo.data.entity.Member) HorizontalLayout(com.vaadin.flow.component.orderedlayout.HorizontalLayout)

Example 2 with EnhancedButton

use of org.komunumo.ui.component.EnhancedButton in project komunumo-server by komunumo.

the class NewsView method configureGrid.

private void configureGrid() {
    grid.setSelectionMode(Grid.SelectionMode.NONE);
    grid.addThemeVariants(GridVariant.LUMO_NO_BORDER, GridVariant.LUMO_ROW_STRIPES);
    grid.addColumn(TemplateRenderer.<NewsEntity>of("<span style=\"font-weight: bold;\">[[item.title]]</span><br/><span>[[item.subtitle]]</span>").withProperty("title", NewsEntity::title).withProperty("subtitle", NewsEntity::subtitle)).setHeader("Title").setAutoWidth(true).setFlexGrow(1);
    grid.addColumn(newsEntity -> formatDateTime(newsEntity.showFrom())).setHeader("Show from").setAutoWidth(true).setFlexGrow(0).setKey("showFrom");
    grid.addColumn(newsEntity -> formatDateTime(newsEntity.showTo())).setHeader("Show to").setAutoWidth(true).setFlexGrow(0).setKey("showTo");
    grid.addColumn(new ComponentRenderer<>(newsEntity -> {
        final var editButton = new EnhancedButton(new Icon(VaadinIcon.EDIT), clickEvent -> showNewsDialog(newsEntity));
        editButton.setTitle("Edit news");
        final var deleteButton = new EnhancedButton(new Icon(VaadinIcon.TRASH), clickEvent -> deleteNews(newsEntity));
        deleteButton.setTitle("Delete news");
        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) NewsEntity(org.komunumo.data.entity.NewsEntity) HorizontalLayout(com.vaadin.flow.component.orderedlayout.HorizontalLayout)

Example 3 with EnhancedButton

use of org.komunumo.ui.component.EnhancedButton in project komunumo-server by komunumo.

the class LocationColorSetting method configureGrid.

private void configureGrid() {
    grid.setSelectionMode(Grid.SelectionMode.NONE);
    grid.addThemeVariants(GridVariant.LUMO_NO_BORDER, GridVariant.LUMO_ROW_STRIPES);
    grid.addColumn(LocationColorRecord::getLocation).setHeader("Location").setAutoWidth(true).setFlexGrow(0);
    grid.addColumn(new ComponentRenderer<>(locationColorRecord -> {
        final var icon = new Icon(VaadinIcon.CIRCLE);
        icon.setSize("16px");
        icon.setColor(locationColorRecord.getColor());
        icon.getElement().setAttribute("title", locationColorRecord.getColor());
        return icon;
    })).setHeader("Color").setAutoWidth(true).setTextAlign(ColumnTextAlign.CENTER).setFlexGrow(0);
    grid.addColumn(new ComponentRenderer<>(locationColorRecord -> {
        final var editButton = new EnhancedButton(new Icon(VaadinIcon.EDIT), clickEvent -> showLocationColorDialog(locationColorRecord));
        editButton.setTitle("Edit this location color setting");
        final var deleteButton = new EnhancedButton(new Icon(VaadinIcon.TRASH), clickEvent -> deleteLocationColor(locationColorRecord));
        deleteButton.setTitle("Delete this location color setting");
        return new HorizontalLayout(editButton, deleteButton);
    })).setHeader("Actions").setAutoWidth(true).setFlexGrow(0);
    grid.setHeightFull();
}
Also used : ComponentRenderer(com.vaadin.flow.data.renderer.ComponentRenderer) CssImport(com.vaadin.flow.component.dependency.CssImport) HorizontalLayout(com.vaadin.flow.component.orderedlayout.HorizontalLayout) EnhancedButton(org.komunumo.ui.component.EnhancedButton) ByteArrayInputStream(java.io.ByteArrayInputStream) UI(com.vaadin.flow.component.UI) ResizableView(org.komunumo.ui.component.ResizableView) Icon(com.vaadin.flow.component.icon.Icon) TextField(com.vaadin.flow.component.textfield.TextField) StreamRegistration(com.vaadin.flow.server.StreamRegistration) VaadinSession(com.vaadin.flow.server.VaadinSession) Grid(com.vaadin.flow.component.grid.Grid) 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) Nullable(org.jetbrains.annotations.Nullable) DatabaseService(org.komunumo.data.service.DatabaseService) LocationColorRecord(org.komunumo.data.db.tables.records.LocationColorRecord) 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) FilterField(org.komunumo.ui.component.FilterField) 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 4 with EnhancedButton

use of org.komunumo.ui.component.EnhancedButton in project komunumo-server by komunumo.

the class FeedbackView method configureGrid.

private void configureGrid() {
    grid.setSelectionMode(Grid.SelectionMode.NONE);
    grid.addThemeVariants(GridVariant.LUMO_NO_BORDER, GridVariant.LUMO_ROW_STRIPES);
    grid.addColumn(feedbackRecord -> formatDateTime(feedbackRecord.getReceived())).setHeader("Received").setAutoWidth(true).setFlexGrow(0);
    grid.addColumn(feedbackRecord -> "%s %s".formatted(feedbackRecord.getFirstName(), feedbackRecord.getLastName())).setHeader("Name").setAutoWidth(true).setFlexGrow(1);
    grid.addColumn(FeedbackRecord::getEmail).setHeader("Email").setAutoWidth(true).setFlexGrow(1);
    grid.addColumn(new ComponentRenderer<>(feedbackRecord -> {
        final var showButton = new EnhancedButton(new Icon(VaadinIcon.EYE), clickEvent -> showEditDialog(feedbackRecord));
        showButton.setTitle("Show this entry");
        final var deleteButton = new EnhancedButton(new Icon(VaadinIcon.TRASH), clickEvent -> deleteEntry(feedbackRecord));
        deleteButton.setTitle("Delete this entry");
        return new HorizontalLayout(showButton, deleteButton);
    })).setHeader("Actions").setAutoWidth(true).setFlexGrow(0);
    grid.setHeightFull();
}
Also used : ComponentRenderer(com.vaadin.flow.data.renderer.ComponentRenderer) AdminLayout(org.komunumo.ui.view.admin.AdminLayout) RolesAllowed(javax.annotation.security.RolesAllowed) CssImport(com.vaadin.flow.component.dependency.CssImport) HorizontalLayout(com.vaadin.flow.component.orderedlayout.HorizontalLayout) EnhancedButton(org.komunumo.ui.component.EnhancedButton) PageTitle(com.vaadin.flow.router.PageTitle) Route(com.vaadin.flow.router.Route) ByteArrayInputStream(java.io.ByteArrayInputStream) UI(com.vaadin.flow.component.UI) ResizableView(org.komunumo.ui.component.ResizableView) Icon(com.vaadin.flow.component.icon.Icon) TextField(com.vaadin.flow.component.textfield.TextField) StreamRegistration(com.vaadin.flow.server.StreamRegistration) Role(org.komunumo.data.entity.Role) VaadinSession(com.vaadin.flow.server.VaadinSession) Grid(com.vaadin.flow.component.grid.Grid) GridVariant(com.vaadin.flow.component.grid.GridVariant) UTF_8(java.nio.charset.StandardCharsets.UTF_8) FeedbackRecord(org.komunumo.data.db.tables.records.FeedbackRecord) StringWriter(java.io.StringWriter) VaadinIcon(com.vaadin.flow.component.icon.VaadinIcon) CSVWriter(com.opencsv.CSVWriter) DatabaseService(org.komunumo.data.service.DatabaseService) StreamResource(com.vaadin.flow.server.StreamResource) ConfirmDialog(com.vaadin.flow.component.confirmdialog.ConfirmDialog) NotNull(org.jetbrains.annotations.NotNull) FilterField(org.komunumo.ui.component.FilterField) FormatterUtil.formatDateTime(org.komunumo.util.FormatterUtil.formatDateTime) 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 5 with EnhancedButton

use of org.komunumo.ui.component.EnhancedButton 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)

Aggregations

Icon (com.vaadin.flow.component.icon.Icon)12 VaadinIcon (com.vaadin.flow.component.icon.VaadinIcon)12 HorizontalLayout (com.vaadin.flow.component.orderedlayout.HorizontalLayout)12 ComponentRenderer (com.vaadin.flow.data.renderer.ComponentRenderer)12 EnhancedButton (org.komunumo.ui.component.EnhancedButton)12 CSVWriter (com.opencsv.CSVWriter)4 UI (com.vaadin.flow.component.UI)4 ConfirmDialog (com.vaadin.flow.component.confirmdialog.ConfirmDialog)4 CssImport (com.vaadin.flow.component.dependency.CssImport)4 Grid (com.vaadin.flow.component.grid.Grid)4 GridVariant (com.vaadin.flow.component.grid.GridVariant)4 TextField (com.vaadin.flow.component.textfield.TextField)4 StreamRegistration (com.vaadin.flow.server.StreamRegistration)4 StreamResource (com.vaadin.flow.server.StreamResource)4 VaadinSession (com.vaadin.flow.server.VaadinSession)4 ByteArrayInputStream (java.io.ByteArrayInputStream)4 StringWriter (java.io.StringWriter)4 UTF_8 (java.nio.charset.StandardCharsets.UTF_8)4 NotNull (org.jetbrains.annotations.NotNull)4 DatabaseService (org.komunumo.data.service.DatabaseService)4