Stationen übernehmen: Button erst bei vollständigen Stationsdaten aktiv, Reset bei Änderungen
- Button initial deaktiviert, wird erst aktiviert wenn Abholstation und mindestens eine Lieferstation korrekt gefüllt sind - Bei Änderungen an Stationsdaten (Dialog-Speichern, Hinzufügen, Löschen) wird der Bereich unter dem Grid ausgeblendet und der Button wieder angezeigt Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -140,6 +140,10 @@ public class AddJobView extends Main implements HasDynamicTitle {
|
||||
private Button submitButton;
|
||||
private HorizontalLayout submitButtonLayout;
|
||||
|
||||
// Stationen übernehmen Button und Bereich darunter
|
||||
private Button applyStationsButton;
|
||||
private VerticalLayout priceAndDetailsSection;
|
||||
|
||||
// Backing list for cargo items to mirror UI rows
|
||||
private final List<CargoItem> cargoItemsState = new ArrayList<>();
|
||||
// Backing list for tasks per delivery station (stationIndex -> tasks)
|
||||
@@ -339,16 +343,17 @@ public class AddJobView extends Main implements HasDynamicTitle {
|
||||
tabContent.add(stationsGridContainer);
|
||||
|
||||
// Wrapper für alle Elemente nach Stationen (initial versteckt)
|
||||
VerticalLayout priceAndDetailsSection = new VerticalLayout();
|
||||
priceAndDetailsSection = new VerticalLayout();
|
||||
priceAndDetailsSection.setWidthFull();
|
||||
priceAndDetailsSection.setPadding(false);
|
||||
priceAndDetailsSection.setSpacing(true);
|
||||
priceAndDetailsSection.setVisible(false);
|
||||
|
||||
// "Stationen übernehmen" Button
|
||||
Button applyStationsButton = new Button(getTranslation("addjob.stations.apply"));
|
||||
applyStationsButton = new Button(getTranslation("addjob.stations.apply"));
|
||||
applyStationsButton.addThemeVariants(ButtonVariant.LUMO_PRIMARY);
|
||||
applyStationsButton.setWidthFull();
|
||||
applyStationsButton.setEnabled(false);
|
||||
applyStationsButton.addClickListener(e -> {
|
||||
applyStationsButton.setVisible(false);
|
||||
priceAndDetailsSection.setVisible(true);
|
||||
@@ -642,6 +647,7 @@ public class AddJobView extends Main implements HasDynamicTitle {
|
||||
stationsGridContainer.add(addStationButton);
|
||||
}
|
||||
|
||||
resetStationsAppliedState();
|
||||
triggerValidation();
|
||||
updateTabLabels();
|
||||
}
|
||||
@@ -697,6 +703,7 @@ public class AddJobView extends Main implements HasDynamicTitle {
|
||||
}
|
||||
|
||||
resetRouteInformation();
|
||||
resetStationsAppliedState();
|
||||
triggerValidation();
|
||||
updateTabLabels();
|
||||
});
|
||||
@@ -755,6 +762,7 @@ public class AddJobView extends Main implements HasDynamicTitle {
|
||||
pickupTile.setAddressValidated(data.isAddressValidatedByGoogle());
|
||||
|
||||
resetRouteInformation();
|
||||
resetStationsAppliedState();
|
||||
triggerValidation();
|
||||
updateTabLabels();
|
||||
}, availableAppUsers, addressValidationService);
|
||||
@@ -825,6 +833,7 @@ public class AddJobView extends Main implements HasDynamicTitle {
|
||||
tile.setAddressValidated(data.isAddressValidatedByGoogle());
|
||||
|
||||
resetRouteInformation();
|
||||
resetStationsAppliedState();
|
||||
triggerValidation();
|
||||
updateTabLabels();
|
||||
}, templates, (templateName, tasks) -> {
|
||||
@@ -1210,6 +1219,9 @@ public class AddJobView extends Main implements HasDynamicTitle {
|
||||
|| hasCargoValidationErrors() || hasPriceValidationErrors() || hasTasksValidationErrors();
|
||||
submitButton.setEnabled(!hasErrors);
|
||||
}
|
||||
|
||||
// Update "Stationen übernehmen" button state
|
||||
updateApplyStationsButtonState();
|
||||
}
|
||||
|
||||
private void updateFieldStyling(TextField field) {
|
||||
@@ -1724,6 +1736,40 @@ public class AddJobView extends Main implements HasDynamicTitle {
|
||||
* Setzt alle Streckeninformationen zurück, wenn sich Adressdaten ändern. Dies
|
||||
* bewirkt, dass der Validierungsdialog beim Tab-Wechsel erneut angezeigt wird.
|
||||
*/
|
||||
private void resetStationsAppliedState() {
|
||||
if (applyStationsButton != null) {
|
||||
applyStationsButton.setVisible(true);
|
||||
}
|
||||
if (priceAndDetailsSection != null) {
|
||||
priceAndDetailsSection.setVisible(false);
|
||||
}
|
||||
if (submitButtonLayout != null) {
|
||||
submitButtonLayout.setVisible(false);
|
||||
}
|
||||
updateApplyStationsButtonState();
|
||||
}
|
||||
|
||||
/**
|
||||
* Aktiviert den "Stationen übernehmen"-Button nur, wenn die Abholstation und
|
||||
* mindestens eine Lieferstation korrekt mit Daten gefüllt sind.
|
||||
*/
|
||||
private void updateApplyStationsButtonState() {
|
||||
if (applyStationsButton == null) {
|
||||
return;
|
||||
}
|
||||
// Pickup-Adresse prüfen
|
||||
boolean pickupValid = !isFieldEmpty(pickupFirstName) && !isFieldEmpty(pickupLastName)
|
||||
&& !isFieldEmpty(pickupStreet) && !isFieldEmpty(pickupHouseNumber) && !isFieldEmpty(pickupZip)
|
||||
&& !isFieldEmpty(pickupCity) && pickupDate.getValue() != null
|
||||
&& !pickupDate.getValue().isBefore(LocalDate.now());
|
||||
|
||||
// Mindestens eine Lieferstation muss korrekt gefüllt sein
|
||||
boolean atLeastOneDeliveryValid = deliveryStationsState.stream()
|
||||
.anyMatch(station -> !hasDeliveryStationValidationErrors(station));
|
||||
|
||||
applyStationsButton.setEnabled(pickupValid && atLeastOneDeliveryValid);
|
||||
}
|
||||
|
||||
private void resetRouteInformation() {
|
||||
// Routenberechnung zurücksetzen
|
||||
routeCalculationResult = null;
|
||||
|
||||
Reference in New Issue
Block a user