use of org.komunumo.data.entity.SpeakerListEntity 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();
}
use of org.komunumo.data.entity.SpeakerListEntity in project komunumo-server by komunumo.
the class SpeakersView method downloadSpeakers.
private void downloadSpeakers() {
final var resource = new StreamResource("speakers.csv", () -> {
final var stringWriter = new StringWriter();
final var csvWriter = new CSVWriter(stringWriter);
csvWriter.writeNext(new String[] { "ID", "First name", "Last name", "Company", "Email", "Twitter", "Website", "Event count" });
grid.getGenericDataView().getItems().map(speakerListEntity -> new String[] { speakerListEntity.id().toString(), speakerListEntity.firstName(), speakerListEntity.lastName(), speakerListEntity.company(), speakerListEntity.email(), speakerListEntity.twitter(), speakerListEntity.website(), speakerListEntity.eventCount().toString() }).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());
}
Aggregations