From 59e93686496dc8790bd224b71131590250d2a42a Mon Sep 17 00:00:00 2001 From: filippo-ferrari Date: Fri, 24 May 2024 00:18:37 +0200 Subject: [PATCH] feat: Category added description field --- src/main/java/com/application/munera/data/Category.java | 3 +++ .../application/munera/views/expenses/CategoriesView.java | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/application/munera/data/Category.java b/src/main/java/com/application/munera/data/Category.java index 5408b4b..cb9b46b 100644 --- a/src/main/java/com/application/munera/data/Category.java +++ b/src/main/java/com/application/munera/data/Category.java @@ -18,4 +18,7 @@ public class Category { @Size(max = 100) @Column(name = "Name", nullable = false) private String name; + + @Column(name = "Description") + private String description; } diff --git a/src/main/java/com/application/munera/views/expenses/CategoriesView.java b/src/main/java/com/application/munera/views/expenses/CategoriesView.java index 76638f2..3f02f53 100644 --- a/src/main/java/com/application/munera/views/expenses/CategoriesView.java +++ b/src/main/java/com/application/munera/views/expenses/CategoriesView.java @@ -16,6 +16,7 @@ import com.vaadin.flow.component.notification.Notification; 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.TextArea; import com.vaadin.flow.component.textfield.TextField; import com.vaadin.flow.data.binder.BeanValidationBinder; import com.vaadin.flow.data.binder.ValidationException; @@ -46,6 +47,8 @@ public class CategoriesView extends Div implements BeforeEnterObserver { private final CategoryService categoryService; private TextField name; + private TextArea description; + public CategoriesView(CategoryService categoryService) { this.categoryService = categoryService; addClassNames("categories-view"); @@ -60,6 +63,7 @@ public class CategoriesView extends Div implements BeforeEnterObserver { // Configure Grid grid.addColumn(Category::getName).setHeader("Name").setSortable(true); + grid.addColumn(Category::getDescription).setHeader("Description").setSortable(true); grid.getColumns().forEach(col -> col.setAutoWidth(true)); grid.setItems(query -> categoryService.list( @@ -139,7 +143,8 @@ public class CategoriesView extends Div implements BeforeEnterObserver { FormLayout formLayout = new FormLayout(); name = new TextField("Name"); - formLayout.add(name); + description = new TextArea("Description"); + formLayout.add(name, description); editorDiv.add(formLayout); createButtonLayout(editorLayoutDiv);