julianpoy / RecipeSage

A Collaborative Recipe Keeper, Meal Planner, and Shopping List Organizer in PWA form.
https://recipesage.com
616 stars 61 forks source link

Separate Ingredient Name from Ingredient Prep, and discard Prep when creating grocery list. #688

Open Gazook89 opened 3 years ago

Gazook89 commented 3 years ago

Is your new feature related to a problem? Please describe. The ingredient list does not work translate well to a shopping list when it contains a description of how the ingredient is prepared, such as this:

When pulled into the grocery list, it counts those as individual items separate from another recipe that might have:

So the grocery list ends up like:

Ideally, the grocery list condenses those 4 items into two.

Describe the solution you'd like I think this could be solved by adding another field for each ingredient that offers a place to describe the "prep". This level of prep shouldn't need to be included in the actual instructions as it would unnecessarily clutter that area. The ingredient "prep" would then be discarded when creating the grocery list.

The Grocery list for the above items would look like this:

Describe alternatives you've considered Alternatively, this prep could be separated from the actual ingredient automatically using , or | as a logical break point, though on entry it should turn that text grey or another color so it's clear it is separate from the ingredient. In fact, going further, it'd be nice if that happened for the Quantity/Measurement as well as the name of the ingredient as you typed. Overall it'd provide validation that the measurement you are using is recognized.

Further, this type of ingredient condensing could maybe be toggleable-- "condensed" vs "verbose" or whatever. When implementing, the default could be verbose so that this feature doesn't break existing recipes. Then could be toggled to condensed if someone wants to opt in.

Gazook89 commented 3 years ago

@julianpoy, I took some time tonight to dig through the source and found this:

const fillerWordsRegexp = /(cubed|peeled|minced|grated|heaped|chopped|about|(slice(s)?)) /;

const notesRegexp = /\(.*?\)/;

function stripNotes(ingredient) {
  return ingredient.replace(new RegExp(notesRegexp, 'g'), '').trim();
}

Is this essentially what I'm requesting above? If I'm reading this right, an ingredient can be done as 2 cups parmesan cheese, grated and the , grated would be left out from the ingredient 'item' when it gets included in a shopping list?

And secondly, anything inside parentheses is disregarded in the same manner?

If so, that would be great! Would you be open to more keywords for fillerWordsRegexp? I could run through a few cookbooks and see what might be added.

julianpoy commented 3 years ago

I believe the functionality that you're looking for already exists. Turn on the "group similar items" option on the shopping list page and it does exactly what you've described here using the example you provided.

image

Grouped items expanded:

image

Grouped items collapsed:

image

Gazook89 commented 3 years ago

The use of parentheses to exclude portions of text from the ingredient is what I was looking for, and found in the code. It may be helpful to add that to the tutorial on editing recipes, that the ingredient can be written as 1 lb chicken (trimmed and flattened) and everything inside the parantheses will be disregarded when creating a shopping list.

Additionally, though, to my last question: could you extend the list of keywords to discard to include the following?

const fillerWordsRegexp = /(halved|cored|cubed|peeled|minced|grated|shredded|crushed|roasted|toasted|melted|chilled|whipped|diced|trimmed|rinsed|chopped fine|chopped course|chilled|patted dry|heaped|chopped|about|(slice(s)?)) /;

Likely the regex would also need to check to see if any of these words come after a comma, otherwise will run into issues with ingredients like "diced tomatoes" or "whipped cream". Maybe something like /,.*(whipped)/.

julianpoy commented 3 years ago

Gotcha. If you want to make that change I'd be happy to take a look at the PR!

If not, I'll definitely put this on the list of things to tackle after multi-language support is finished