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