restrict adoption pets
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user