From 07050a58090557e5c650295b03a8a8185c3443c9 Mon Sep 17 00:00:00 2001 From: Johannes Kantz <67144859+JohannesKantz@users.noreply.github.com> Date: Sat, 4 Feb 2023 18:31:08 +0100 Subject: [PATCH] fix: show only vegan food in vegan food dropdown --- .../CreateFoodplanController.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/bib/essensbestellungsverwaltung/CreateFoodplanController.java b/src/main/java/com/bib/essensbestellungsverwaltung/CreateFoodplanController.java index e7290c7..2dc41f2 100644 --- a/src/main/java/com/bib/essensbestellungsverwaltung/CreateFoodplanController.java +++ b/src/main/java/com/bib/essensbestellungsverwaltung/CreateFoodplanController.java @@ -31,20 +31,28 @@ public class CreateFoodplanController { ChoiceBox secondDessert; private List foods; + private List veganFoods; private List desserts; + private List veganDesserts; private FoodPlan currentPlan; @FXML public void initialize() { + veganFoods = FoodMgr.getVeganFood(false); foods = FoodMgr.getFood(false); + veganDesserts = FoodMgr.getVeganFood(true); desserts = FoodMgr.getFood(true); + ObservableList foodOptions = FXCollections.observableArrayList(foods.stream().map(food -> food.getId() + ": " + food.getName()).toList().toArray(new String[0])); - firstMeal.setItems(foodOptions); + ObservableList veganFoodOptions = FXCollections.observableArrayList(veganFoods.stream().map(food -> food.getId() + ": " + food.getName()).toList().toArray(new String[0])); + ObservableList veganDessertOptions = FXCollections.observableArrayList(veganDesserts.stream().map(dessert -> dessert.getId() + ": " + dessert.getName()).toList().toArray(new String[0])); + ObservableList dessertOptions = FXCollections.observableArrayList(desserts.stream().map(dessert -> dessert.getId() + ": " + dessert.getName()).toList().toArray(new String[0])); + firstMeal.setItems(veganFoodOptions); secondMeal.setItems(foodOptions); - ObservableList dessertOptions = FXCollections.observableArrayList(desserts.stream().map(dessert -> dessert.getId() + ": " + dessert.getName()).toList().toArray(new String[0])); - firstDessert.setItems(dessertOptions); + + firstDessert.setItems(veganDessertOptions); secondDessert.setItems(dessertOptions); date.setValue(LocalDate.now());