Erweiterungen
This commit is contained in:
@@ -5,6 +5,8 @@ import com.vaadin.flow.component.button.ButtonVariant;
|
|||||||
import com.vaadin.flow.component.checkbox.Checkbox;
|
import com.vaadin.flow.component.checkbox.Checkbox;
|
||||||
import com.vaadin.flow.component.combobox.ComboBox;
|
import com.vaadin.flow.component.combobox.ComboBox;
|
||||||
|
|
||||||
|
import com.vaadin.flow.component.datepicker.DatePicker;
|
||||||
|
import com.vaadin.flow.component.timepicker.TimePicker;
|
||||||
import com.vaadin.flow.component.html.Div;
|
import com.vaadin.flow.component.html.Div;
|
||||||
import com.vaadin.flow.component.html.H3;
|
import com.vaadin.flow.component.html.H3;
|
||||||
import com.vaadin.flow.component.html.Main;
|
import com.vaadin.flow.component.html.Main;
|
||||||
@@ -17,6 +19,8 @@ import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
|
|||||||
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
|
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
|
||||||
import com.vaadin.flow.component.textfield.TextField;
|
import com.vaadin.flow.component.textfield.TextField;
|
||||||
import com.vaadin.flow.component.ClientCallable;
|
import com.vaadin.flow.component.ClientCallable;
|
||||||
|
import com.vaadin.flow.component.textfield.IntegerField;
|
||||||
|
import com.vaadin.flow.component.textfield.NumberField;
|
||||||
import com.vaadin.flow.component.UI;
|
import com.vaadin.flow.component.UI;
|
||||||
import com.vaadin.flow.component.dnd.DragSource;
|
import com.vaadin.flow.component.dnd.DragSource;
|
||||||
import com.vaadin.flow.component.dnd.DropTarget;
|
import com.vaadin.flow.component.dnd.DropTarget;
|
||||||
@@ -24,6 +28,7 @@ import com.vaadin.flow.component.dnd.EffectAllowed;
|
|||||||
import com.vaadin.flow.data.binder.Binder;
|
import com.vaadin.flow.data.binder.Binder;
|
||||||
import com.vaadin.flow.data.binder.ValidationException;
|
import com.vaadin.flow.data.binder.ValidationException;
|
||||||
import com.vaadin.flow.router.Menu;
|
import com.vaadin.flow.router.Menu;
|
||||||
|
import com.vaadin.flow.component.Component;
|
||||||
import com.vaadin.flow.router.PageTitle;
|
import com.vaadin.flow.router.PageTitle;
|
||||||
import com.vaadin.flow.router.Route;
|
import com.vaadin.flow.router.Route;
|
||||||
import com.vaadin.flow.theme.lumo.LumoUtility;
|
import com.vaadin.flow.theme.lumo.LumoUtility;
|
||||||
@@ -95,8 +100,6 @@ public class AddJobView extends Main {
|
|||||||
|
|
||||||
private final Binder<Job> binder = new Binder<>(Job.class);
|
private final Binder<Job> binder = new Binder<>(Job.class);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public AddJobView(AddJobService addJobService) {
|
public AddJobView(AddJobService addJobService) {
|
||||||
this.addJobService = addJobService;
|
this.addJobService = addJobService;
|
||||||
initializeComponents();
|
initializeComponents();
|
||||||
@@ -230,11 +233,62 @@ public class AddJobView extends Main {
|
|||||||
|
|
||||||
add(mainLayout);
|
add(mainLayout);
|
||||||
|
|
||||||
// Digital processing section
|
// Section under the stages (centered)
|
||||||
VerticalLayout digitalSection = new VerticalLayout();
|
VerticalLayout belowSection = new VerticalLayout();
|
||||||
digitalSection.setSpacing(false);
|
belowSection.setWidthFull();
|
||||||
digitalSection.add(digitalProcessing, appUser);
|
belowSection.setPadding(false);
|
||||||
add(digitalSection);
|
belowSection.setSpacing(true);
|
||||||
|
belowSection.setDefaultHorizontalComponentAlignment(FlexComponent.Alignment.CENTER);
|
||||||
|
|
||||||
|
// Container with fixed width to center content
|
||||||
|
VerticalLayout content = new VerticalLayout();
|
||||||
|
content.setPadding(false);
|
||||||
|
content.setSpacing(true);
|
||||||
|
content.setWidth("720px");
|
||||||
|
content.setDefaultHorizontalComponentAlignment(FlexComponent.Alignment.STRETCH);
|
||||||
|
|
||||||
|
// Row: Digital processing + App user
|
||||||
|
HorizontalLayout digitalRow = new HorizontalLayout();
|
||||||
|
digitalRow.setWidthFull();
|
||||||
|
digitalRow.setAlignItems(FlexComponent.Alignment.BASELINE);
|
||||||
|
digitalRow.setJustifyContentMode(FlexComponent.JustifyContentMode.START);
|
||||||
|
digitalProcessing.getStyle().set("margin-right", "12px");
|
||||||
|
digitalRow.add(digitalProcessing);
|
||||||
|
|
||||||
|
// App user selector full width
|
||||||
|
appUser.setWidthFull();
|
||||||
|
content.add(digitalRow, appUser);
|
||||||
|
|
||||||
|
// Appointment (Pickup)
|
||||||
|
H3 pickupApptTitle = new H3("Termin (Abholung)");
|
||||||
|
pickupApptTitle.getStyle().set("margin", "0");
|
||||||
|
DatePicker pickupDate = new DatePicker("Datum");
|
||||||
|
pickupDate.setRequiredIndicatorVisible(true);
|
||||||
|
TimePicker pickupTime = new TimePicker("Uhrzeit");
|
||||||
|
HorizontalLayout pickupApptRow = new HorizontalLayout(pickupDate, pickupTime);
|
||||||
|
pickupApptRow.setWidthFull();
|
||||||
|
pickupApptRow.setSpacing(true);
|
||||||
|
pickupDate.setWidth("50%");
|
||||||
|
pickupTime.setWidth("50%");
|
||||||
|
content.add(pickupApptTitle, pickupApptRow);
|
||||||
|
|
||||||
|
// Appointment (Delivery)
|
||||||
|
H3 deliveryApptTitle = new H3("Termin (Lieferung)");
|
||||||
|
deliveryApptTitle.getStyle().set("margin", "0");
|
||||||
|
DatePicker deliveryDate = new DatePicker("Datum");
|
||||||
|
deliveryDate.setRequiredIndicatorVisible(true);
|
||||||
|
TimePicker deliveryTime = new TimePicker("Uhrzeit");
|
||||||
|
HorizontalLayout deliveryApptRow = new HorizontalLayout(deliveryDate, deliveryTime);
|
||||||
|
deliveryApptRow.setWidthFull();
|
||||||
|
deliveryApptRow.setSpacing(true);
|
||||||
|
deliveryDate.setWidth("50%");
|
||||||
|
deliveryTime.setWidth("50%");
|
||||||
|
content.add(deliveryApptTitle, deliveryApptRow);
|
||||||
|
|
||||||
|
belowSection.add(content);
|
||||||
|
add(belowSection);
|
||||||
|
// Ladung – Bereich vor dem Button
|
||||||
|
add(createCargoSection());
|
||||||
|
|
||||||
// Submit button
|
// Submit button
|
||||||
HorizontalLayout submitLayout = new HorizontalLayout();
|
HorizontalLayout submitLayout = new HorizontalLayout();
|
||||||
@@ -291,6 +345,7 @@ public class AddJobView extends Main {
|
|||||||
|
|
||||||
section.add(pickupAddressAddition);
|
section.add(pickupAddressAddition);
|
||||||
|
|
||||||
|
// zip/city row
|
||||||
HorizontalLayout zipCityLayout = new HorizontalLayout();
|
HorizontalLayout zipCityLayout = new HorizontalLayout();
|
||||||
zipCityLayout.setWidthFull();
|
zipCityLayout.setWidthFull();
|
||||||
zipCityLayout.setSpacing(true);
|
zipCityLayout.setSpacing(true);
|
||||||
@@ -644,7 +699,72 @@ public class AddJobView extends Main {
|
|||||||
if (job.getCustomerSelection() != null) {
|
if (job.getCustomerSelection() != null) {
|
||||||
customerSelection.setValue(job.getCustomerSelection());
|
customerSelection.setValue(job.getCustomerSelection());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Component createCargoSection() {
|
||||||
|
VerticalLayout wrapper = new VerticalLayout();
|
||||||
|
wrapper.setWidthFull();
|
||||||
|
wrapper.setSpacing(true);
|
||||||
|
|
||||||
|
VerticalLayout cargoArea = new VerticalLayout();
|
||||||
|
cargoArea.setWidthFull();
|
||||||
|
cargoArea.setSpacing(true);
|
||||||
|
cargoArea.getStyle().set("background", "var(--lumo-base-color)");
|
||||||
|
cargoArea.getStyle().set("border", "1px solid var(--lumo-contrast-20pct)");
|
||||||
|
cargoArea.getStyle().set("border-radius", "var(--lumo-border-radius-m)");
|
||||||
|
cargoArea.getStyle().set("padding", "var(--lumo-space-m)");
|
||||||
|
|
||||||
|
VerticalLayout cargoList = new VerticalLayout();
|
||||||
|
cargoList.setPadding(false);
|
||||||
|
cargoList.setSpacing(true);
|
||||||
|
cargoArea.add(cargoList);
|
||||||
|
|
||||||
|
java.util.function.BiConsumer<String, java.util.function.Consumer<HorizontalLayout>> addCargoRow = (iconName, afterCreate) -> {
|
||||||
|
HorizontalLayout row = new HorizontalLayout();
|
||||||
|
row.setWidthFull();
|
||||||
|
row.setAlignItems(FlexComponent.Alignment.END);
|
||||||
|
|
||||||
|
TextField desc = new TextField("Beschreibung");
|
||||||
|
desc.setPlaceholder("z. B. Gitterboxpalette, Paket …");
|
||||||
|
desc.setWidth("40%");
|
||||||
|
|
||||||
|
IntegerField qty = new IntegerField("Anzahl");
|
||||||
|
qty.setMin(1);
|
||||||
|
qty.setValue(1);
|
||||||
|
qty.setWidth("10%");
|
||||||
|
|
||||||
|
NumberField weight = new NumberField("Gewicht");
|
||||||
|
weight.setSuffixComponent(new Span("kg"));
|
||||||
|
weight.setWidth("15%");
|
||||||
|
|
||||||
|
NumberField len = new NumberField("Länge");
|
||||||
|
len.setSuffixComponent(new Span("mm"));
|
||||||
|
len.setWidth("12%");
|
||||||
|
NumberField wid = new NumberField("Breite");
|
||||||
|
wid.setSuffixComponent(new Span("mm"));
|
||||||
|
wid.setWidth("12%");
|
||||||
|
NumberField hei = new NumberField("Höhe");
|
||||||
|
hei.setSuffixComponent(new Span("mm"));
|
||||||
|
hei.setWidth("12%");
|
||||||
|
|
||||||
|
Button remove = new Button(new Icon(VaadinIcon.CLOSE_SMALL));
|
||||||
|
remove.addThemeVariants(ButtonVariant.LUMO_ERROR, ButtonVariant.LUMO_TERTIARY);
|
||||||
|
remove.addClickListener(e -> cargoList.remove(row));
|
||||||
|
|
||||||
|
row.add(desc, qty, weight, len, wid, hei, remove);
|
||||||
|
cargoList.add(row);
|
||||||
|
if (afterCreate != null) afterCreate.accept(row);
|
||||||
|
};
|
||||||
|
|
||||||
|
addCargoRow.accept("gitterbox", r -> {});
|
||||||
|
addCargoRow.accept("paket", r -> {});
|
||||||
|
addCargoRow.accept("", r -> {});
|
||||||
|
|
||||||
|
wrapper.add(cargoArea);
|
||||||
|
return wrapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void populateFromJob(Job job) {
|
||||||
// Pickup address
|
// Pickup address
|
||||||
if (job.getPickupCompany() != null) pickupCompany.setValue(job.getPickupCompany());
|
if (job.getPickupCompany() != null) pickupCompany.setValue(job.getPickupCompany());
|
||||||
if (job.getPickupSalutation() != null) pickupSalutation.setValue(job.getPickupSalutation());
|
if (job.getPickupSalutation() != null) pickupSalutation.setValue(job.getPickupSalutation());
|
||||||
|
|||||||
Reference in New Issue
Block a user