feat: horizontal layout for checkboxes
This commit is contained in:
parent
bc1093b736
commit
8e5ba1bb2b
1 changed files with 7 additions and 11 deletions
|
@ -30,7 +30,6 @@ import com.vaadin.flow.component.textfield.TextField;
|
||||||
import com.vaadin.flow.data.binder.BeanValidationBinder;
|
import com.vaadin.flow.data.binder.BeanValidationBinder;
|
||||||
import com.vaadin.flow.data.binder.ValidationException;
|
import com.vaadin.flow.data.binder.ValidationException;
|
||||||
import com.vaadin.flow.data.renderer.ComponentRenderer;
|
import com.vaadin.flow.data.renderer.ComponentRenderer;
|
||||||
import com.vaadin.flow.data.renderer.LitRenderer;
|
|
||||||
import com.vaadin.flow.router.*;
|
import com.vaadin.flow.router.*;
|
||||||
import com.vaadin.flow.spring.data.VaadinSpringDataHelpers;
|
import com.vaadin.flow.spring.data.VaadinSpringDataHelpers;
|
||||||
import org.springframework.data.domain.PageRequest;
|
import org.springframework.data.domain.PageRequest;
|
||||||
|
@ -234,8 +233,6 @@ public class ExpensesView extends Div implements BeforeEnterObserver {
|
||||||
category.setItems(categoryService.findAll());
|
category.setItems(categoryService.findAll());
|
||||||
category.setItemLabelGenerator(Category::getName);
|
category.setItemLabelGenerator(Category::getName);
|
||||||
description = new TextArea("Description");
|
description = new TextArea("Description");
|
||||||
isPeriodic = new Checkbox("Is Periodic");
|
|
||||||
isResolved = new Checkbox("Paid");
|
|
||||||
periodUnit = new ComboBox<>("Period Unit");
|
periodUnit = new ComboBox<>("Period Unit");
|
||||||
periodUnit.setItems(PeriodUnit.values());
|
periodUnit.setItems(PeriodUnit.values());
|
||||||
periodInterval = new TextField("Period Interval");
|
periodInterval = new TextField("Period Interval");
|
||||||
|
@ -249,15 +246,14 @@ public class ExpensesView extends Div implements BeforeEnterObserver {
|
||||||
debtors.setItems(personService.findAll());
|
debtors.setItems(personService.findAll());
|
||||||
debtors.setItemLabelGenerator(Person::getFirstName);
|
debtors.setItemLabelGenerator(Person::getFirstName);
|
||||||
date = new DatePicker("Date");
|
date = new DatePicker("Date");
|
||||||
LitRenderer<Expense> isPeriodicRenderer = 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>")
|
|
||||||
.withProperty("icon", important -> important.getIsPeriodic() ? "check" : "minus").withProperty("color",
|
|
||||||
important -> important.getIsPeriodic()
|
|
||||||
? "var(--lumo-primary-text-color)"
|
|
||||||
: "var(--lumo-disabled-text-color)");
|
|
||||||
|
|
||||||
formLayout.add(name, cost, category, description, isPeriodic, isResolved, periodUnit, periodInterval, date, creditors, debtors, event);
|
// Horizontal layout for checkboxes
|
||||||
grid.addColumn(isPeriodicRenderer).setHeader("Periodic").setAutoWidth(true);
|
HorizontalLayout checkboxLayout = new HorizontalLayout();
|
||||||
|
isPeriodic = new Checkbox("Is Periodic");
|
||||||
|
isResolved = new Checkbox("Paid");
|
||||||
|
checkboxLayout.add(isPeriodic, isResolved);
|
||||||
|
|
||||||
|
formLayout.add(name, cost, category, description, checkboxLayout, periodUnit, periodInterval, date, creditors, debtors, event);
|
||||||
editorDiv.add(formLayout);
|
editorDiv.add(formLayout);
|
||||||
createButtonLayout(editorLayoutDiv);
|
createButtonLayout(editorLayoutDiv);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue