feat: added default sorting to grid
This commit is contained in:
parent
3a2c1ff782
commit
435ddd65a2
3 changed files with 7 additions and 2 deletions
|
@ -28,4 +28,5 @@ public interface ExpenseRepository extends JpaRepository<Expense, Long>, JpaSpec
|
||||||
Set<Expense> findUnpaidDebtorsExpensesByPersonId(@Param("personId") Long personId);
|
Set<Expense> findUnpaidDebtorsExpensesByPersonId(@Param("personId") Long personId);
|
||||||
|
|
||||||
boolean existsByIdAndIsResolvedTrue(Long id);
|
boolean existsByIdAndIsResolvedTrue(Long id);
|
||||||
}
|
|
||||||
|
List<Expense> findAllByOrderByDateDesc();}
|
|
@ -70,4 +70,8 @@ public class ExpenseService {
|
||||||
return this.repository.existsByIdAndIsResolvedTrue(expense.getId());
|
return this.repository.existsByIdAndIsResolvedTrue(expense.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<Expense> findAllOrderByDateDescending() {
|
||||||
|
return this.repository.findAllByOrderByDateDesc();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,7 +99,7 @@ public class ExpensesView extends Div implements BeforeEnterObserver {
|
||||||
grid.addColumn(new ComponentRenderer<>(expense1 -> createBadge(expenseService.isExpenseResolved(expense1)))).setHeader("Status").setSortable(true);
|
grid.addColumn(new ComponentRenderer<>(expense1 -> createBadge(expenseService.isExpenseResolved(expense1)))).setHeader("Status").setSortable(true);
|
||||||
grid.getColumns().forEach(col -> col.setAutoWidth(true));
|
grid.getColumns().forEach(col -> col.setAutoWidth(true));
|
||||||
|
|
||||||
grid.setItems(this.expenseService.findAll());
|
grid.setItems(this.expenseService.findAllOrderByDateDescending());
|
||||||
grid.setPaginatorSize(5);
|
grid.setPaginatorSize(5);
|
||||||
grid.setPageSize(25); // setting page size
|
grid.setPageSize(25); // setting page size
|
||||||
grid.addThemeVariants(GridVariant.LUMO_NO_BORDER);
|
grid.addThemeVariants(GridVariant.LUMO_NO_BORDER);
|
||||||
|
|
Loading…
Reference in a new issue