refactoring: ExpensesView

This commit is contained in:
effe 2024-09-15 16:27:03 -04:00
parent 86671693d2
commit c70ea1c76c
2 changed files with 1 additions and 5 deletions

View file

@ -65,7 +65,6 @@ public class ViewsService {
case CREDIT -> isPaid ? BadgeMessage.PAID_TO_ME : BadgeMessage.OWED_TO_ME;
case DEBIT -> isPaid ? BadgeMessage.PAID_BY_ME : BadgeMessage.OWED_BY_ME;
case NONE -> isPaid ? BadgeMessage.PAID : BadgeMessage.NOT_PAID;
default -> BadgeMessage.UNKNOWN;
};
}
}

View file

@ -134,14 +134,12 @@ public class ExpensesView extends Div implements BeforeEnterObserver {
}
});
// Configure Form
binder = new BeanValidationBinder<>(Expense.class);
// Bind fields. This is where you'd define e.g. validation rules
binder = new BeanValidationBinder<>(Expense.class);
binder.bindInstanceFields(this);
binder.forField(name)
.asRequired("Name is required")
.bind(Expense::getName, Expense::setName);
binder.forField(cost)
.asRequired("Cost is required")
.withConverter(new StringToBigDecimalConverter("Invalid cost"))
@ -150,7 +148,6 @@ public class ExpensesView extends Div implements BeforeEnterObserver {
binder.forField(category)
.asRequired("Category is required")
.bind(Expense::getCategory, Expense::setCategory);
binder.forField(date)
.asRequired("Date is required")
.bind(Expense::getDate, Expense::setDate);