diff --git a/src/main/java/com/application/munera/data/Person.java b/src/main/java/com/application/munera/data/Person.java index 0471f93..42cf0bc 100644 --- a/src/main/java/com/application/munera/data/Person.java +++ b/src/main/java/com/application/munera/data/Person.java @@ -1,6 +1,7 @@ package com.application.munera.data; import jakarta.persistence.*; +import jakarta.validation.constraints.Email; import jakarta.validation.constraints.Size; import lombok.Getter; import lombok.Setter; @@ -26,6 +27,11 @@ public class Person { @Column(name = "LastName", nullable = false) private String lastName; + @Email + @Size(max = 100) + @Column(name = "email") + private String email; + // @JsonIgnore @ManyToMany(mappedBy = "creditors") private Set creditorExpenses; 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 17634f4..9b37412 100644 --- a/src/main/java/com/application/munera/views/expenses/ExpensesView.java +++ b/src/main/java/com/application/munera/views/expenses/ExpensesView.java @@ -182,7 +182,7 @@ public class ExpensesView extends Div implements BeforeEnterObserver { : "var(--lumo-disabled-text-color)"); formLayout.add(name, cost, category, description, isPeriodic, periodUnit, periodInterval, date); - grid.addColumn(importantRenderer).setHeader("Important").setAutoWidth(true); + grid.addColumn(importantRenderer).setHeader("Periodic").setAutoWidth(true); editorDiv.add(formLayout); createButtonLayout(editorLayoutDiv); diff --git a/src/main/java/com/application/munera/views/expenses/PeopleView.java b/src/main/java/com/application/munera/views/expenses/PeopleView.java index 7c78749..d773a40 100644 --- a/src/main/java/com/application/munera/views/expenses/PeopleView.java +++ b/src/main/java/com/application/munera/views/expenses/PeopleView.java @@ -1,8 +1,6 @@ package com.application.munera.views.expenses; import com.application.munera.data.Person; -import com.application.munera.services.CategoryService; -import com.application.munera.services.ExpenseService; import com.application.munera.services.PersonService; import com.application.munera.views.MainLayout; import com.vaadin.flow.component.UI; @@ -19,10 +17,14 @@ import com.vaadin.flow.component.notification.Notification.Position; import com.vaadin.flow.component.notification.NotificationVariant; import com.vaadin.flow.component.orderedlayout.HorizontalLayout; import com.vaadin.flow.component.splitlayout.SplitLayout; +import com.vaadin.flow.component.textfield.EmailField; import com.vaadin.flow.component.textfield.TextField; import com.vaadin.flow.data.binder.BeanValidationBinder; import com.vaadin.flow.data.binder.ValidationException; -import com.vaadin.flow.router.*; +import com.vaadin.flow.router.BeforeEnterEvent; +import com.vaadin.flow.router.BeforeEnterObserver; +import com.vaadin.flow.router.PageTitle; +import com.vaadin.flow.router.Route; import com.vaadin.flow.spring.data.VaadinSpringDataHelpers; import org.springframework.data.domain.PageRequest; import org.springframework.orm.ObjectOptimisticLockingFailureException; @@ -45,16 +47,12 @@ public class PeopleView extends Div implements BeforeEnterObserver { private final BeanValidationBinder binder; private Person person; - - private final ExpenseService expenseService; - private final CategoryService categoryService; private final PersonService personService; private TextField firstName; private TextField lastName; + private EmailField email; - public PeopleView(ExpenseService expenseService, CategoryService categoryService, PersonService personService) { - this.expenseService = expenseService; - this.categoryService = categoryService; + public PeopleView(PersonService personService) { this.personService = personService; addClassNames("people-view"); @@ -69,6 +67,7 @@ public class PeopleView extends Div implements BeforeEnterObserver { // Configure Grid grid.addColumn(Person::getFirstName).setHeader("First Name").setSortable(true); grid.addColumn(Person::getLastName).setHeader("Last Name").setSortable(true); + grid.addColumn(Person::getEmail).setHeader("Email").setSortable(true); grid.getColumns().forEach(col -> col.setAutoWidth(true)); grid.setItems(query -> personService.list( @@ -150,7 +149,8 @@ public class PeopleView extends Div implements BeforeEnterObserver { FormLayout formLayout = new FormLayout(); firstName = new TextField("Name"); lastName = new TextField("Cost"); - formLayout.add(firstName, lastName); + email = new EmailField("Email"); + formLayout.add(firstName, lastName, email); editorDiv.add(formLayout); createButtonLayout(editorLayoutDiv);