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 Button submitButton;
|
||||||
private HorizontalLayout submitButtonLayout;
|
private HorizontalLayout submitButtonLayout;
|
||||||
|
|
||||||
|
// Stationen übernehmen Button und Bereich darunter
|
||||||
|
private Button applyStationsButton;
|
||||||
|
private VerticalLayout priceAndDetailsSection;
|
||||||
|
|
||||||
// Backing list for cargo items to mirror UI rows
|
// Backing list for cargo items to mirror UI rows
|
||||||
private final List<CargoItem> cargoItemsState = new ArrayList<>();
|
private final List<CargoItem> cargoItemsState = new ArrayList<>();
|
||||||
// Backing list for tasks per delivery station (stationIndex -> tasks)
|
// Backing list for tasks per delivery station (stationIndex -> tasks)
|
||||||
@@ -339,16 +343,17 @@ public class AddJobView extends Main implements HasDynamicTitle {
|
|||||||
tabContent.add(stationsGridContainer);
|
tabContent.add(stationsGridContainer);
|
||||||
|
|
||||||
// Wrapper für alle Elemente nach Stationen (initial versteckt)
|
// Wrapper für alle Elemente nach Stationen (initial versteckt)
|
||||||
VerticalLayout priceAndDetailsSection = new VerticalLayout();
|
priceAndDetailsSection = new VerticalLayout();
|
||||||
priceAndDetailsSection.setWidthFull();
|
priceAndDetailsSection.setWidthFull();
|
||||||
priceAndDetailsSection.setPadding(false);
|
priceAndDetailsSection.setPadding(false);
|
||||||
priceAndDetailsSection.setSpacing(true);
|
priceAndDetailsSection.setSpacing(true);
|
||||||
priceAndDetailsSection.setVisible(false);
|
priceAndDetailsSection.setVisible(false);
|
||||||
|
|
||||||
// "Stationen übernehmen" Button
|
// "Stationen übernehmen" Button
|
||||||
Button applyStationsButton = new Button(getTranslation("addjob.stations.apply"));
|
applyStationsButton = new Button(getTranslation("addjob.stations.apply"));
|
||||||
applyStationsButton.addThemeVariants(ButtonVariant.LUMO_PRIMARY);
|
applyStationsButton.addThemeVariants(ButtonVariant.LUMO_PRIMARY);
|
||||||
applyStationsButton.setWidthFull();
|
applyStationsButton.setWidthFull();
|
||||||
|
applyStationsButton.setEnabled(false);
|
||||||
applyStationsButton.addClickListener(e -> {
|
applyStationsButton.addClickListener(e -> {
|
||||||
applyStationsButton.setVisible(false);
|
applyStationsButton.setVisible(false);
|
||||||
priceAndDetailsSection.setVisible(true);
|
priceAndDetailsSection.setVisible(true);
|
||||||
@@ -642,6 +647,7 @@ public class AddJobView extends Main implements HasDynamicTitle {
|
|||||||
stationsGridContainer.add(addStationButton);
|
stationsGridContainer.add(addStationButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resetStationsAppliedState();
|
||||||
triggerValidation();
|
triggerValidation();
|
||||||
updateTabLabels();
|
updateTabLabels();
|
||||||
}
|
}
|
||||||
@@ -697,6 +703,7 @@ public class AddJobView extends Main implements HasDynamicTitle {
|
|||||||
}
|
}
|
||||||
|
|
||||||
resetRouteInformation();
|
resetRouteInformation();
|
||||||
|
resetStationsAppliedState();
|
||||||
triggerValidation();
|
triggerValidation();
|
||||||
updateTabLabels();
|
updateTabLabels();
|
||||||
});
|
});
|
||||||
@@ -755,6 +762,7 @@ public class AddJobView extends Main implements HasDynamicTitle {
|
|||||||
pickupTile.setAddressValidated(data.isAddressValidatedByGoogle());
|
pickupTile.setAddressValidated(data.isAddressValidatedByGoogle());
|
||||||
|
|
||||||
resetRouteInformation();
|
resetRouteInformation();
|
||||||
|
resetStationsAppliedState();
|
||||||
triggerValidation();
|
triggerValidation();
|
||||||
updateTabLabels();
|
updateTabLabels();
|
||||||
}, availableAppUsers, addressValidationService);
|
}, availableAppUsers, addressValidationService);
|
||||||
@@ -825,6 +833,7 @@ public class AddJobView extends Main implements HasDynamicTitle {
|
|||||||
tile.setAddressValidated(data.isAddressValidatedByGoogle());
|
tile.setAddressValidated(data.isAddressValidatedByGoogle());
|
||||||
|
|
||||||
resetRouteInformation();
|
resetRouteInformation();
|
||||||
|
resetStationsAppliedState();
|
||||||
triggerValidation();
|
triggerValidation();
|
||||||
updateTabLabels();
|
updateTabLabels();
|
||||||
}, templates, (templateName, tasks) -> {
|
}, templates, (templateName, tasks) -> {
|
||||||
@@ -1210,6 +1219,9 @@ public class AddJobView extends Main implements HasDynamicTitle {
|
|||||||
|| hasCargoValidationErrors() || hasPriceValidationErrors() || hasTasksValidationErrors();
|
|| hasCargoValidationErrors() || hasPriceValidationErrors() || hasTasksValidationErrors();
|
||||||
submitButton.setEnabled(!hasErrors);
|
submitButton.setEnabled(!hasErrors);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update "Stationen übernehmen" button state
|
||||||
|
updateApplyStationsButtonState();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateFieldStyling(TextField field) {
|
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
|
* Setzt alle Streckeninformationen zurück, wenn sich Adressdaten ändern. Dies
|
||||||
* bewirkt, dass der Validierungsdialog beim Tab-Wechsel erneut angezeigt wird.
|
* 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() {
|
private void resetRouteInformation() {
|
||||||
// Routenberechnung zurücksetzen
|
// Routenberechnung zurücksetzen
|
||||||
routeCalculationResult = null;
|
routeCalculationResult = null;
|
||||||
|
|||||||
Reference in New Issue
Block a user