use of io.imunity.furms.ui.components.FurmsProgressBar in project furms by unity-idm.
the class ResourceCreditsView method createResourceCreditGrid.
private Grid<ResourceCreditViewModel> createResourceCreditGrid() {
Grid<ResourceCreditViewModel> grid = new DenseGrid<>(ResourceCreditViewModel.class);
grid.addComponentColumn(c -> new RouterLink(c.getName(), ResourceCreditFormView.class, c.getId())).setHeader(getTranslation("view.site-admin.resource-credits.grid.column.name")).setSortable(true).setFlexGrow(20).setComparator(x -> x.getName().toLowerCase());
grid.addColumn(ResourceCreditViewModel::getId).setHeader(getTranslation("view.site-admin.resource-credits.grid.column.id")).setSortable(true).setFlexGrow(20).setComparator(x -> x.getName().toLowerCase());
grid.addColumn(ResourceCreditViewModel::getResourceTypeName).setHeader(getTranslation("view.site-admin.resource-credits.grid.column.resourceType")).setSortable(true);
grid.addColumn(ResourceCreditViewModel::getAmount).setHeader(getTranslation("view.site-admin.resource-credits.grid.column.credit")).setSortable(true).setComparator(comparing(model -> model.getAmount().amount));
grid.addColumn(ResourceCreditViewModel::getDistributed).setHeader(getTranslation("view.site-admin.resource-credits.grid.column.distributed")).setSortable(true).setComparator(comparing(model -> model.getDistributed().amount));
grid.addColumn(ResourceCreditViewModel::getRemaining).setHeader(getTranslation("view.site-admin.resource-credits.grid.column.remaining")).setSortable(true).setComparator(comparing(model -> model.getRemaining().amount));
grid.addColumn(c -> c.getCreateTime().toLocalDate()).setHeader(getTranslation("view.site-admin.resource-credits.grid.column.created")).setSortable(true);
grid.addColumn(c -> c.getStartTime().toLocalDate()).setHeader(getTranslation("view.site-admin.resource-credits.grid.column.validFrom")).setSortable(true);
grid.addColumn(c -> c.getEndTime().toLocalDate()).setHeader(getTranslation("view.site-admin.resource-credits.grid.column.validTo")).setSortable(true);
grid.addComponentColumn(model -> {
double value = model.getConsumed().divide(model.getAmount().amount, 4, HALF_UP).doubleValue();
return new FurmsProgressBar(value);
}).setHeader(getTranslation("view.site-admin.resource-credits.grid.column.consumption")).setComparator(comparing(ResourceCreditViewModel::getConsumed));
grid.addComponentColumn(this::createLastColumnContent).setHeader(getTranslation("view.site-admin.resource-credits.grid.column.actions")).setWidth("4em").setTextAlign(ColumnTextAlign.END);
return grid;
}
Aggregations