Cloneing recipes is possible

This commit is contained in:
Mei Chang van der Werff 2025-12-02 18:03:42 +01:00
commit 0525885979
2 changed files with 15 additions and 1 deletions

View file

@ -219,6 +219,20 @@ public class FoodpalApplicationCtrl {
public Recipe getSelectedRecipe() { public Recipe getSelectedRecipe() {
return recipeList.getSelectionModel().getSelectedItem(); return recipeList.getSelectionModel().getSelectedItem();
} }
/**
* Clones a recipe, when clicking on the button "clone"
*/
public void cloneRecipe() throws IOException, InterruptedException {
Recipe selected = recipeList.getSelectionModel().getSelectedItem();
if (selected == null) {
return;
}
server.cloneRecipe(selected.getId());
refresh();
}
} }

View file

@ -94,7 +94,7 @@
<HBox spacing="10"> <HBox spacing="10">
<Button fx:id="AddRecipeButton" onAction="#addRecipe" text="Add Recipe" /> <Button fx:id="AddRecipeButton" onAction="#addRecipe" text="Add Recipe" />
<Button fx:id="RemoveRecipeButton" onAction="#removeSelectedRecipe" text="Remove Recipe" /> <Button fx:id="RemoveRecipeButton" onAction="#removeSelectedRecipe" text="Remove Recipe" />
<Button mnemonicParsing="false" text="Clone" /> <Button fx:id= "CloneREcipeButton" mnemonicParsing="false" onAction="#cloneRecipe" text="Clone" />
</HBox> </HBox>
</VBox> </VBox>
</left> </left>