feat(client/shoplist): UI control logic for add all to list
This commit is contained in:
parent
40cfc0b98e
commit
c0107d752a
3 changed files with 26 additions and 6 deletions
|
|
@ -9,10 +9,12 @@ import java.util.Optional;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import client.UI;
|
||||||
import client.exception.InvalidModificationException;
|
import client.exception.InvalidModificationException;
|
||||||
import client.scenes.nutrition.NutritionViewCtrl;
|
import client.scenes.nutrition.NutritionViewCtrl;
|
||||||
import client.scenes.recipe.RecipeDetailCtrl;
|
import client.scenes.recipe.RecipeDetailCtrl;
|
||||||
|
|
||||||
|
import client.scenes.shopping.ShoppingListCtrl;
|
||||||
import client.utils.Config;
|
import client.utils.Config;
|
||||||
import client.utils.ConfigService;
|
import client.utils.ConfigService;
|
||||||
import client.utils.DefaultValueFactory;
|
import client.utils.DefaultValueFactory;
|
||||||
|
|
@ -33,8 +35,6 @@ import commons.ws.messages.UpdateRecipeMessage;
|
||||||
import jakarta.inject.Inject;
|
import jakarta.inject.Inject;
|
||||||
import javafx.application.Platform;
|
import javafx.application.Platform;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.fxml.FXMLLoader;
|
|
||||||
import javafx.scene.Parent;
|
|
||||||
import javafx.scene.Scene;
|
import javafx.scene.Scene;
|
||||||
import javafx.scene.control.Alert;
|
import javafx.scene.control.Alert;
|
||||||
import javafx.scene.control.Button;
|
import javafx.scene.control.Button;
|
||||||
|
|
@ -616,11 +616,10 @@ public class FoodpalApplicationCtrl implements LocaleAware {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void openShoppingListWindow() throws IOException {
|
public void openShoppingListWindow() throws IOException {
|
||||||
FXMLLoader loader = new FXMLLoader(getClass().getResource("shopping/ShoppingList.fxml"));
|
var root = UI.getFXML().load(ShoppingListCtrl.class, "client", "scenes", "shopping", "ShoppingList.fxml");
|
||||||
Parent root = (Parent)loader.load();
|
|
||||||
Stage stage = new Stage();
|
Stage stage = new Stage();
|
||||||
stage.setTitle(this.getLocaleString("menu.shopping.title"));
|
stage.setTitle(this.getLocaleString("menu.shopping.title"));
|
||||||
stage.setScene(new Scene(root));
|
stage.setScene(new Scene(root.getValue()));
|
||||||
stage.show();
|
stage.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package client.scenes.recipe;
|
||||||
|
|
||||||
import client.exception.UpdateException;
|
import client.exception.UpdateException;
|
||||||
import client.scenes.FoodpalApplicationCtrl;
|
import client.scenes.FoodpalApplicationCtrl;
|
||||||
|
import client.service.ShoppingListService;
|
||||||
import client.utils.Config;
|
import client.utils.Config;
|
||||||
import client.utils.ConfigService;
|
import client.utils.ConfigService;
|
||||||
import client.utils.LocaleAware;
|
import client.utils.LocaleAware;
|
||||||
|
|
@ -10,6 +11,7 @@ import client.utils.PrintExportService;
|
||||||
import client.utils.server.ServerUtils;
|
import client.utils.server.ServerUtils;
|
||||||
import client.utils.WebSocketDataService;
|
import client.utils.WebSocketDataService;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
|
import commons.FormalIngredient;
|
||||||
import commons.Recipe;
|
import commons.Recipe;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
@ -20,6 +22,7 @@ import java.util.function.BiConsumer;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
import javafx.beans.binding.Bindings;
|
import javafx.beans.binding.Bindings;
|
||||||
|
import javafx.event.ActionEvent;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.scene.control.Button;
|
import javafx.scene.control.Button;
|
||||||
import javafx.scene.control.ComboBox;
|
import javafx.scene.control.ComboBox;
|
||||||
|
|
@ -46,6 +49,7 @@ public class RecipeDetailCtrl implements LocaleAware {
|
||||||
private final FoodpalApplicationCtrl appCtrl;
|
private final FoodpalApplicationCtrl appCtrl;
|
||||||
private final ConfigService configService;
|
private final ConfigService configService;
|
||||||
private final WebSocketDataService<Long, Recipe> webSocketDataService;
|
private final WebSocketDataService<Long, Recipe> webSocketDataService;
|
||||||
|
private final ShoppingListService shoppingListService;
|
||||||
|
|
||||||
public Spinner<Double> scaleSpinner;
|
public Spinner<Double> scaleSpinner;
|
||||||
public Label inferredKcalLabel;
|
public Label inferredKcalLabel;
|
||||||
|
|
@ -67,12 +71,14 @@ public class RecipeDetailCtrl implements LocaleAware {
|
||||||
ServerUtils server,
|
ServerUtils server,
|
||||||
FoodpalApplicationCtrl appCtrl,
|
FoodpalApplicationCtrl appCtrl,
|
||||||
ConfigService configService,
|
ConfigService configService,
|
||||||
|
ShoppingListService listService,
|
||||||
WebSocketDataService<Long, Recipe> webSocketDataService) {
|
WebSocketDataService<Long, Recipe> webSocketDataService) {
|
||||||
this.localeManager = localeManager;
|
this.localeManager = localeManager;
|
||||||
this.server = server;
|
this.server = server;
|
||||||
this.appCtrl = appCtrl;
|
this.appCtrl = appCtrl;
|
||||||
this.configService = configService;
|
this.configService = configService;
|
||||||
this.webSocketDataService = webSocketDataService;
|
this.webSocketDataService = webSocketDataService;
|
||||||
|
this.shoppingListService = listService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
|
|
@ -418,4 +424,13 @@ public class RecipeDetailCtrl implements LocaleAware {
|
||||||
});
|
});
|
||||||
langSelector.getItems().addAll("en", "nl", "pl", "tok");
|
langSelector.getItems().addAll("en", "nl", "pl", "tok");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void handleAddAllToShoppingList(ActionEvent actionEvent) {
|
||||||
|
System.out.println("handleAddAllToShoppingList");
|
||||||
|
// TODO BACKLOG Add overview screen
|
||||||
|
recipe.getIngredients().stream()
|
||||||
|
.filter(x -> x.getClass().equals(FormalIngredient.class))
|
||||||
|
.map(FormalIngredient.class::cast)
|
||||||
|
.forEach(x -> shoppingListService.putIngredient(x, recipe));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import client.utils.LocaleAware;
|
||||||
import client.utils.LocaleManager;
|
import client.utils.LocaleManager;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import commons.FormalIngredient;
|
import commons.FormalIngredient;
|
||||||
|
import javafx.event.ActionEvent;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.scene.control.ListCell;
|
import javafx.scene.control.ListCell;
|
||||||
import javafx.scene.control.ListView;
|
import javafx.scene.control.ListView;
|
||||||
|
|
@ -19,7 +20,6 @@ public class ShoppingListCtrl implements LocaleAware {
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private ListView<Pair<FormalIngredient, Optional<String>>> shoppingListView;
|
private ListView<Pair<FormalIngredient, Optional<String>>> shoppingListView;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public ShoppingListCtrl(
|
public ShoppingListCtrl(
|
||||||
ShoppingListService shopping,
|
ShoppingListService shopping,
|
||||||
|
|
@ -63,4 +63,10 @@ public class ShoppingListCtrl implements LocaleAware {
|
||||||
this.shopping.getItems()
|
this.shopping.getItems()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void handleAddItem(ActionEvent actionEvent) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public void handleRemoveItem(ActionEvent actionEvent) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue