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();
}
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());
}
Aggregations