refactor
This commit is contained in:
parent
7450fe3857
commit
0fc5b07f5e
1 changed files with 14 additions and 10 deletions
|
@ -83,16 +83,7 @@ public class PeopleView extends Div implements BeforeEnterObserver {
|
||||||
|
|
||||||
List<Person> people = (List<Person>) personService.findAll();
|
List<Person> people = (List<Person>) personService.findAll();
|
||||||
|
|
||||||
for (Person person : people) {
|
this.setGridData(people);
|
||||||
// Add the person as a root item
|
|
||||||
grid.getTreeData().addItem(null, person);
|
|
||||||
|
|
||||||
// Fetch expenses for the current person
|
|
||||||
List<Expense> expenses = expenseService.findExpenseByUser(person);
|
|
||||||
|
|
||||||
// Add each expense as a child item under the person
|
|
||||||
for (Expense expense : expenses) grid.getTreeData().addItem(person, expense);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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 -> {
|
||||||
|
@ -261,4 +252,17 @@ public class PeopleView extends Div implements BeforeEnterObserver {
|
||||||
}
|
}
|
||||||
return badge;
|
return badge;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setGridData(List<Person> people) {
|
||||||
|
for (Person person : people) {
|
||||||
|
// Add the person as a root item
|
||||||
|
grid.getTreeData().addItem(null, person);
|
||||||
|
|
||||||
|
// Fetch expenses for the current person
|
||||||
|
List<Expense> expenses = expenseService.findExpenseByUser(person);
|
||||||
|
|
||||||
|
// Add each expense as a child item under the person
|
||||||
|
for (Expense expense : expenses) grid.getTreeData().addItem(person, expense);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue