restrict adoption pets

This commit is contained in:
2026-04-08 08:11:20 -06:00
parent 55b61d3908
commit 4845aeb479
4 changed files with 29 additions and 5 deletions

View File

@@ -74,6 +74,7 @@ public class AdoptionDialogController {
Platform.runLater(() -> {
if (pets != null) {
ObservableList<DropdownOption> petsObs = FXCollections.observableArrayList(pets);
ensureSelectedPetOption(petsObs);
cbPet.setItems(petsObs);
applySelectedPet();
}
@@ -318,4 +319,17 @@ public class AdoptionDialogController {
}
return null;
}
private void ensureSelectedPetOption(ObservableList<DropdownOption> options) {
if (selectedAdoption == null || selectedAdoption.getPetId() <= 0 || options == null) {
return;
}
DropdownOption existing = findOptionById(options, (long) selectedAdoption.getPetId());
if (existing == null) {
DropdownOption option = new DropdownOption();
option.setId((long) selectedAdoption.getPetId());
option.setLabel(selectedAdoption.getPetName());
options.add(0, option);
}
}
}