refactor: ExpensesView
This commit is contained in:
parent
0e05811a44
commit
68f0d5629f
1 changed files with 2 additions and 5 deletions
|
@ -106,8 +106,6 @@ public class ExpensesView extends Div implements BeforeEnterObserver {
|
||||||
grid.addColumn(Expense::getName).setHeader("Name").setSortable(true).setSortProperty("name");
|
grid.addColumn(Expense::getName).setHeader("Name").setSortable(true).setSortProperty("name");
|
||||||
grid.addColumn(Expense::getCost).setHeader("Amount").setSortable(true).setSortProperty("cost");
|
grid.addColumn(Expense::getCost).setHeader("Amount").setSortable(true).setSortProperty("cost");
|
||||||
grid.addColumn(expenseCategory -> expenseCategory.getCategory().getName()).setHeader("Category").setSortable(true).setSortProperty("category");
|
grid.addColumn(expenseCategory -> expenseCategory.getCategory().getName()).setHeader("Category").setSortable(true).setSortProperty("category");
|
||||||
// grid.addColumn(Expense::getPeriodInterval).setHeader("Period Interval").setSortable(true);
|
|
||||||
// grid.addColumn(Expense::getPeriodUnit).setHeader("Period Unit").setSortable(true);
|
|
||||||
grid.addColumn(Expense::getDate).setHeader("Date").setSortable(true).setSortProperty("date");
|
grid.addColumn(Expense::getDate).setHeader("Date").setSortable(true).setSortProperty("date");
|
||||||
grid.addColumn(new ComponentRenderer<>(this.viewsService::createExpenseBadge)).setHeader("Status").setSortable(true);
|
grid.addColumn(new ComponentRenderer<>(this.viewsService::createExpenseBadge)).setHeader("Status").setSortable(true);
|
||||||
grid.getColumns().forEach(col -> col.setAutoWidth(true));
|
grid.getColumns().forEach(col -> col.setAutoWidth(true));
|
||||||
|
@ -140,9 +138,8 @@ public class ExpensesView extends Div implements BeforeEnterObserver {
|
||||||
|
|
||||||
// when a row is selected or deselected, populate form
|
// when a row is selected or deselected, populate form
|
||||||
grid.asSingleSelect().addValueChangeListener(event -> {
|
grid.asSingleSelect().addValueChangeListener(event -> {
|
||||||
if (event.getValue() != null) {
|
if (event.getValue() != null) UI.getCurrent().navigate(String.format(EXPENSE_EDIT_ROUTE_TEMPLATE, event.getValue().getId()));
|
||||||
UI.getCurrent().navigate(String.format(EXPENSE_EDIT_ROUTE_TEMPLATE, event.getValue().getId()));
|
else {
|
||||||
} else {
|
|
||||||
clearForm();
|
clearForm();
|
||||||
UI.getCurrent().navigate(ExpensesView.class);
|
UI.getCurrent().navigate(ExpensesView.class);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue