Merge branch 'bugfix/new-recipe-selection' into 'main'
Bugfix/new recipe selection Closes #21 and #19 See merge request cse1105/2025-2026/teams/csep-team-76!22
This commit is contained in:
commit
f5eed945a2
2 changed files with 10 additions and 9 deletions
|
|
@ -223,14 +223,13 @@ public class FoodpalApplicationCtrl implements LocaleAware {
|
||||||
*/
|
*/
|
||||||
@FXML
|
@FXML
|
||||||
private void addRecipe() {
|
private void addRecipe() {
|
||||||
// a default factory provides the value
|
Recipe newRecipe = DefaultRecipeFactory.getDefaultRecipe(); // Create default recipe
|
||||||
Recipe newRecipe = DefaultRecipeFactory.getDefaultRecipe();
|
|
||||||
try {
|
try {
|
||||||
server.addRecipe(newRecipe);
|
newRecipe = server.addRecipe(newRecipe); // get the new recipe id
|
||||||
refresh();
|
refresh(); // refresh view with server recipes
|
||||||
// the list focuses on the new recipe
|
|
||||||
// otherwise strange issues occur when the autofocus on edit box is called
|
// Select newly created recipe
|
||||||
recipeList.getFocusModel().focus(recipeList.getItems().indexOf(newRecipe));
|
recipeList.getSelectionModel().select(recipeList.getItems().indexOf(newRecipe));
|
||||||
} catch (IOException | InterruptedException e) {
|
} catch (IOException | InterruptedException e) {
|
||||||
printError("Error occurred when adding recipe!");
|
printError("Error occurred when adding recipe!");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -157,7 +157,8 @@ public class Recipe {
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Recipe{" +
|
return "Recipe{" +
|
||||||
"name='" + name + '\'' +
|
"id=" + id +
|
||||||
|
", name='" + name + '\'' +
|
||||||
", ingredientsCount=" + ingredients.size() +
|
", ingredientsCount=" + ingredients.size() +
|
||||||
", preparationStepsCount=" + preparationSteps.size() +
|
", preparationStepsCount=" + preparationSteps.size() +
|
||||||
"}";
|
"}";
|
||||||
|
|
@ -167,7 +168,8 @@ public class Recipe {
|
||||||
public String toDetailedString() {
|
public String toDetailedString() {
|
||||||
// More detailed toString for debugging.
|
// More detailed toString for debugging.
|
||||||
return "Recipe{" +
|
return "Recipe{" +
|
||||||
"name='" + name + '\'' +
|
"id=" + id +
|
||||||
|
", name='" + name + '\'' +
|
||||||
", ingredients=" + ingredients +
|
", ingredients=" + ingredients +
|
||||||
", preparationSteps=" + preparationSteps +
|
", preparationSteps=" + preparationSteps +
|
||||||
'}';
|
'}';
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue