feat: email field in Person entity
This commit is contained in:
parent
9d127b722f
commit
2cc8862e32
3 changed files with 17 additions and 11 deletions
|
@ -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<Expense> creditorExpenses;
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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<Person> 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);
|
||||
|
||||
|
|
Loading…
Reference in a new issue