fix: ExpenseView fields
This commit is contained in:
parent
3b62e956d3
commit
80fb068af4
1 changed files with 27 additions and 33 deletions
|
@ -6,8 +6,6 @@ import com.application.munera.views.MainLayout;
|
||||||
import com.vaadin.flow.component.UI;
|
import com.vaadin.flow.component.UI;
|
||||||
import com.vaadin.flow.component.button.Button;
|
import com.vaadin.flow.component.button.Button;
|
||||||
import com.vaadin.flow.component.button.ButtonVariant;
|
import com.vaadin.flow.component.button.ButtonVariant;
|
||||||
import com.vaadin.flow.component.checkbox.Checkbox;
|
|
||||||
import com.vaadin.flow.component.datepicker.DatePicker;
|
|
||||||
import com.vaadin.flow.component.dependency.Uses;
|
import com.vaadin.flow.component.dependency.Uses;
|
||||||
import com.vaadin.flow.component.formlayout.FormLayout;
|
import com.vaadin.flow.component.formlayout.FormLayout;
|
||||||
import com.vaadin.flow.component.grid.Grid;
|
import com.vaadin.flow.component.grid.Grid;
|
||||||
|
@ -40,21 +38,19 @@ public class ExpensesView extends Div implements BeforeEnterObserver {
|
||||||
|
|
||||||
private final Grid<Expense> grid = new Grid<>(Expense.class, false);
|
private final Grid<Expense> grid = new Grid<>(Expense.class, false);
|
||||||
|
|
||||||
private TextField firstName;
|
private TextField name;
|
||||||
private TextField lastName;
|
private TextField category;
|
||||||
private TextField email;
|
private TextField cost;
|
||||||
private TextField phone;
|
private TextField isPeriodic;
|
||||||
private DatePicker dateOfBirth;
|
private TextField periodUnit;
|
||||||
private TextField occupation;
|
private TextField periodInterval;
|
||||||
private TextField role;
|
|
||||||
private Checkbox important;
|
|
||||||
|
|
||||||
private final Button cancel = new Button("Cancel");
|
private final Button cancel = new Button("Cancel");
|
||||||
private final Button save = new Button("Save");
|
private final Button save = new Button("Save");
|
||||||
|
|
||||||
private final BeanValidationBinder<Expense> binder;
|
private final BeanValidationBinder<Expense> binder;
|
||||||
|
|
||||||
private Expense samplePerson;
|
private Expense expense;
|
||||||
|
|
||||||
private final SamplePersonService samplePersonService;
|
private final SamplePersonService samplePersonService;
|
||||||
|
|
||||||
|
@ -71,13 +67,12 @@ public class ExpensesView extends Div implements BeforeEnterObserver {
|
||||||
add(splitLayout);
|
add(splitLayout);
|
||||||
|
|
||||||
// Configure Grid
|
// Configure Grid
|
||||||
grid.addColumn("firstName").setAutoWidth(true);
|
grid.addColumn("name").setAutoWidth(true);
|
||||||
grid.addColumn("lastName").setAutoWidth(true);
|
grid.addColumn("category").setAutoWidth(true);
|
||||||
grid.addColumn("email").setAutoWidth(true);
|
grid.addColumn("cost").setAutoWidth(true);
|
||||||
grid.addColumn("phone").setAutoWidth(true);
|
grid.addColumn("isPeriodic").setAutoWidth(true);
|
||||||
grid.addColumn("dateOfBirth").setAutoWidth(true);
|
grid.addColumn("periodUnit").setAutoWidth(true);
|
||||||
grid.addColumn("occupation").setAutoWidth(true);
|
grid.addColumn("periodInterval").setAutoWidth(true);
|
||||||
grid.addColumn("role").setAutoWidth(true);
|
|
||||||
// LitRenderer<Expense> importantRenderer = LitRenderer.<Expense>of(
|
// LitRenderer<Expense> importantRenderer = LitRenderer.<Expense>of(
|
||||||
// "<vaadin-icon icon='vaadin:${item.icon}' style='width: var(--lumo-icon-size-s); height: var(--lumo-icon-size-s); color: ${item.color};'></vaadin-icon>")
|
// "<vaadin-icon icon='vaadin:${item.icon}' style='width: var(--lumo-icon-size-s); height: var(--lumo-icon-size-s); color: ${item.color};'></vaadin-icon>")
|
||||||
// .withProperty("icon", important -> important.isImportant() ? "check" : "minus").withProperty("color",
|
// .withProperty("icon", important -> important.isImportant() ? "check" : "minus").withProperty("color",
|
||||||
|
@ -116,11 +111,11 @@ public class ExpensesView extends Div implements BeforeEnterObserver {
|
||||||
|
|
||||||
save.addClickListener(e -> {
|
save.addClickListener(e -> {
|
||||||
try {
|
try {
|
||||||
if (this.samplePerson == null) {
|
if (this.expense == null) {
|
||||||
this.samplePerson = new Expense();
|
this.expense = new Expense();
|
||||||
}
|
}
|
||||||
binder.writeBean(this.samplePerson);
|
binder.writeBean(this.expense);
|
||||||
samplePersonService.update(this.samplePerson);
|
samplePersonService.update(this.expense);
|
||||||
clearForm();
|
clearForm();
|
||||||
refreshGrid();
|
refreshGrid();
|
||||||
Notification.show("Data updated");
|
Notification.show("Data updated");
|
||||||
|
@ -164,15 +159,14 @@ public class ExpensesView extends Div implements BeforeEnterObserver {
|
||||||
editorLayoutDiv.add(editorDiv);
|
editorLayoutDiv.add(editorDiv);
|
||||||
|
|
||||||
FormLayout formLayout = new FormLayout();
|
FormLayout formLayout = new FormLayout();
|
||||||
firstName = new TextField("First Name");
|
name = new TextField("First Name");
|
||||||
lastName = new TextField("Last Name");
|
category = new TextField("Last Name");
|
||||||
email = new TextField("Email");
|
cost = new TextField("Email");
|
||||||
phone = new TextField("Phone");
|
isPeriodic = new TextField("Phone");
|
||||||
dateOfBirth = new DatePicker("Date Of Birth");
|
periodUnit = new TextField("Date Of Birth");
|
||||||
occupation = new TextField("Occupation");
|
periodInterval = new TextField("Occupation");
|
||||||
role = new TextField("Role");
|
// important = new Checkbox("Important");
|
||||||
important = new Checkbox("Important");
|
formLayout.add(name, category, cost, isPeriodic, periodUnit, periodInterval);
|
||||||
formLayout.add(firstName, lastName, email, phone, dateOfBirth, occupation, role, important);
|
|
||||||
|
|
||||||
editorDiv.add(formLayout);
|
editorDiv.add(formLayout);
|
||||||
createButtonLayout(editorLayoutDiv);
|
createButtonLayout(editorLayoutDiv);
|
||||||
|
@ -206,8 +200,8 @@ public class ExpensesView extends Div implements BeforeEnterObserver {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void populateForm(Expense value) {
|
private void populateForm(Expense value) {
|
||||||
this.samplePerson = value;
|
this.expense = value;
|
||||||
binder.readBean(this.samplePerson);
|
binder.readBean(this.expense);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue