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
|
||||
private void addRecipe() {
|
||||
// a default factory provides the value
|
||||
Recipe newRecipe = DefaultRecipeFactory.getDefaultRecipe();
|
||||
Recipe newRecipe = DefaultRecipeFactory.getDefaultRecipe(); // Create default recipe
|
||||
try {
|
||||
server.addRecipe(newRecipe);
|
||||
refresh();
|
||||
// the list focuses on the new recipe
|
||||
// otherwise strange issues occur when the autofocus on edit box is called
|
||||
recipeList.getFocusModel().focus(recipeList.getItems().indexOf(newRecipe));
|
||||
newRecipe = server.addRecipe(newRecipe); // get the new recipe id
|
||||
refresh(); // refresh view with server recipes
|
||||
|
||||
// Select newly created recipe
|
||||
recipeList.getSelectionModel().select(recipeList.getItems().indexOf(newRecipe));
|
||||
} catch (IOException | InterruptedException e) {
|
||||
printError("Error occurred when adding recipe!");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue