From 4d36b7dca2746312d386d2e8642eacdb860da5dd Mon Sep 17 00:00:00 2001 From: Filippo Ferrari Date: Sat, 27 Jul 2024 18:13:51 +0200 Subject: [PATCH] refactor --- .../munera/views/expenses/ExpensesView.java | 11 ++++------- .../application/munera/views/people/PeopleView.java | 4 +--- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/application/munera/views/expenses/ExpensesView.java b/src/main/java/com/application/munera/views/expenses/ExpensesView.java index b02b8d1..98ffbb3 100644 --- a/src/main/java/com/application/munera/views/expenses/ExpensesView.java +++ b/src/main/java/com/application/munera/views/expenses/ExpensesView.java @@ -108,9 +108,8 @@ public class ExpensesView extends Div implements BeforeEnterObserver { // when a row is selected or deselected, populate form grid.asSingleSelect().addValueChangeListener(event -> { - if (event.getValue() != null) { - UI.getCurrent().navigate(String.format(EXPENSE_EDIT_ROUTE_TEMPLATE, event.getValue().getId())); - } else { + if (event.getValue() != null) UI.getCurrent().navigate(String.format(EXPENSE_EDIT_ROUTE_TEMPLATE, event.getValue().getId())); + else { clearForm(); UI.getCurrent().navigate(ExpensesView.class); } @@ -164,9 +163,7 @@ public class ExpensesView extends Div implements BeforeEnterObserver { save.addClickListener(e -> { try { - if (this.expense == null) { - this.expense = new Expense(); - } + if (this.expense == null) this.expense = new Expense(); binder.writeBean(this.expense); expenseService.update(this.expense); clearForm(); @@ -306,4 +303,4 @@ public class ExpensesView extends Div implements BeforeEnterObserver { } return badge; } -} +} \ No newline at end of file diff --git a/src/main/java/com/application/munera/views/people/PeopleView.java b/src/main/java/com/application/munera/views/people/PeopleView.java index 3032b9e..99f6b0e 100644 --- a/src/main/java/com/application/munera/views/people/PeopleView.java +++ b/src/main/java/com/application/munera/views/people/PeopleView.java @@ -105,9 +105,7 @@ public class PeopleView extends Div implements BeforeEnterObserver { save.addClickListener(e -> { try { - if (this.person == null) { - this.person = new Person(); - } + if (this.person == null) this.person = new Person(); binder.writeBean(this.person); personService.update(this.person); clearForm();