nextcloud / cookbook

🍲 A library for all your recipes
https://apps.nextcloud.com/apps/cookbook
GNU Affero General Public License v3.0
532 stars 91 forks source link

Ability to paste multiple ingredients/instructions at once #325

Closed stativ closed 3 years ago

stativ commented 4 years ago

Use Case I have a recipe with ingredients with each ingredient on a separate line. I dare to say this is a common format that is used across many websites. Assume I have the recipe in a text file or I have found the recipe on a website that doesn't use schema.org. Now I want to enter it into the Cookbook. A similar case applies to the instructions, where steps can be separated by an empty line.

Current Situation Right now I have to copy-paste each ingredient separately.

Suggested Solution When multiple lines are pasted into the ingredient input field, they are automatically split by newline and entered as several ingredients. An example of such behaviour can be found in the Gourmet Recipe Manager where pasting multiline input into the ingredient field automatically adds multiple ingredients. A similar behaviour can be also found in OpenEats which uses a single form to enter ingredients one ingredient per line.

For instructions, it would be nice to split them into separate steps at empty lines.

christianlupus commented 4 years ago

@sam-19 I assume, this is no big issue to realize this from the GUI perspective, right? It should be sufficient to make the input field multiline.

I see two ways:

  1. The multiline text is kept during the editing view. After sending to the backend the lines are split accordingly. The recipe is then viewed and the ingredients/instructions are separated accordingly.
  2. Once a newline character is entered using pasting, in Vue the splitting is done. Thus, during editing the individual entries are already separated and the backend can work just as it is doing now.

What do you think of that? In the backend I can help. Please tell me your thoughts.

sam-19 commented 4 years ago

I would prefer option 2, as this is more WYSIWYG and the recipe doesn't come back looking different after it has been saved. I'll take a look at this soon.

seyfeb commented 3 years ago

I created PR #379 for this feature. Please check it out. Currently it’s only creating new fields for tools and ingredients since i wasn’t sure if it would also be expected behavior for the recipe steps.

Edit: On second thought, and reading this thread again, it probably makes sense to have the same behavior for the instructions, so I added it there as well.