Erweiterungen
This commit is contained in:
@@ -139,6 +139,7 @@ public class AddJobView extends Main {
|
||||
customerSelection = new ComboBox<>("Auftraggeber/Rechnungsempfänger");
|
||||
customerSelection.setPlaceholder("Wählen Sie einen Auftraggeber aus...");
|
||||
customerSelection.setWidthFull();
|
||||
customerSelection.setRequiredIndicatorVisible(true);
|
||||
// Mit Kunden des angemeldeten Benutzers befüllen und Mapping aufbauen
|
||||
List<Customer> ownerCustomers = customerService.findAllForCurrentOwner();
|
||||
customerLabelToEntity.clear();
|
||||
@@ -653,8 +654,12 @@ public class AddJobView extends Main {
|
||||
.asRequired("")
|
||||
.bind(Job::getDeliveryDate, Job::setDeliveryDate);
|
||||
|
||||
// Bind customerSelection field with validation
|
||||
binder.forField(customerSelection)
|
||||
.asRequired("Auftraggeber/Rechnungsempfänger ist erforderlich")
|
||||
.bind(Job::getCustomerSelection, Job::setCustomerSelection);
|
||||
|
||||
// Bind optional fields without validation
|
||||
binder.bind(customerSelection, Job::getCustomerSelection, Job::setCustomerSelection);
|
||||
binder.bind(pickupCompany, Job::getPickupCompany, Job::setPickupCompany);
|
||||
binder.bind(pickupSalutation, Job::getPickupSalutation, Job::setPickupSalutation);
|
||||
binder.bind(pickupPhone, Job::getPickupPhone, Job::setPickupPhone);
|
||||
@@ -691,6 +696,12 @@ public class AddJobView extends Main {
|
||||
pickupDate, deliveryDate
|
||||
};
|
||||
|
||||
// Add validation listener for customerSelection ComboBox
|
||||
customerSelection.addValueChangeListener(event -> {
|
||||
triggerValidation();
|
||||
updateTabLabels();
|
||||
});
|
||||
|
||||
// Add value change listeners to trigger validation on every change for text fields
|
||||
for (TextField field : requiredTextFields) {
|
||||
field.addValueChangeListener(event -> {
|
||||
@@ -775,6 +786,9 @@ public class AddJobView extends Main {
|
||||
}
|
||||
|
||||
private boolean hasAddressValidationErrors() {
|
||||
// Check customer selection
|
||||
boolean customerSelectionEmpty = customerSelection.getValue() == null || customerSelection.getValue().trim().isEmpty();
|
||||
|
||||
// Check pickup address fields
|
||||
boolean pickupErrors = isFieldEmpty(pickupFirstName) || isFieldEmpty(pickupLastName) ||
|
||||
isFieldEmpty(pickupStreet) || isFieldEmpty(pickupHouseNumber) ||
|
||||
@@ -785,7 +799,7 @@ public class AddJobView extends Main {
|
||||
isFieldEmpty(deliveryStreet) || isFieldEmpty(deliveryHouseNumber) ||
|
||||
isFieldEmpty(deliveryZip) || isFieldEmpty(deliveryCity);
|
||||
|
||||
return pickupErrors || deliveryErrors;
|
||||
return customerSelectionEmpty || pickupErrors || deliveryErrors;
|
||||
}
|
||||
|
||||
private boolean hasAppointmentValidationErrors() {
|
||||
|
||||
Reference in New Issue
Block a user