A section is a "partial recipe" which doesn't stand on its own. For example, you might have frosting as a section of a german chocolate cake recipe in your library. On the other hand, you might consider buttercream icing to be a recipe itself, only loosely associated with various other recipes.
This distinction is entirely in the mind of the cook, and varies contextually. Continuing the example, buttercream "becomes" a section of the cupcake recipe you're planning Clara's birthday party this weekend. When you're making the cupcakes, the icing is a section of the cupcakes recipe, even though they're separate in your library.
Sections are stored as recipes, with "section-ness" represented implicitly. Owned sections (frosting) are "part of" their owning recipe (german chocolate cake). Recipes (buttercream icing) may be by reference sections of other recipes (cupcakes). An owned section may also be the referent of by reference sections (reuse german chocolate cake's frosting for cupcakes, without 'promoting' frosting to a top-level recipe).
- Add a new
Recipe sectionOf;field to theRecipeclass, backed by aON DELETE RESTRICTFK column in the database.- The value indicates the recipe the section is owned by.
- Null means the recipe is not an owned section.
- Add a new
boolean section;field to theIngredientRefclass, for whether the ref is a section. Whether owned or by reference is not differentiated. - By reference sections are normal entity associations (aka today's subrecipes).
- Owned sections are as if composed into their owning recipe.
- When an owned section is removed from a recipe, it is either:
- deleted if not otherwise referenced, or
- becomes owned by an arbitrary referrer.
- When a recipe is deleted, its owned sections are removed first.
- When an owned section is removed from a recipe, it is either:
- An owned section can be promoted to a top-level recipe, which converts the section to be by reference.
- A by reference section can be demoted to an owned section, as long as the referent is not already owned.
This model yields two different definitions of "section": a recipe owned by another (w/ sectionOf set), and a
reference from one recipe to another (an IngredientRef referring to a Recipe). This mirrors the two different
contextual viewpoints in the cook's mind. It's also the reason for all the italics.
-
Sections (owned or by reference) are recipes; they can always be retrieved via
LibraryQuery.getRecipeByIdandbulkIngredients. -
Owned sections will not be returned from
LibraryQuery.recipesor.suggestRecipesToCook. -
Create a
LibrarySearchinput type withLibraryQuery.recipes's params and accept that instead. -
Add a new
Sectiontype, sharingid,name,direction,ingredients, andlabelswithRecipe, plus asectionOf: ID. -
Add a new
sections: [Section!]!toRecipe. -
Add a new
LibraryQuery.sectionsfield which also acceptsLibrarySearchand only returns owned sections (as a newSectionConnectionand friends). -
Add a new
SectionInfoinput type, sharingid,name,direction,ingredients, andlabelswithIngredientInfo. Owned sections will always have the data fields populated, as well asidonce persistent. By reference sections will only ever haveid. -
Add a new
sections: [SectionInfo!]toIngredientInfo.
- Exclude owned sections from search results.
- Exclude owned sections from recommendations.
- Owned sections participate in scaling, while by reference sections do not.
- Sections with non-blank description float to the top w/ collapse as subrecipes do today.
- Sections with no description fall to the bottom of the ingredient list, title as subheading.
- New "Add Section" button, to either:
- create a blank owned section, or
- search for owned sections to include by reference.
- This needs a toggle to search for recipes, instead of owned sections. Or between owned sections and everything?
- Owned sections contain title, ingredients, directions, and labels.
- Title is required and gets defaulted to "MOAR Goober Whosit" or something.
- Ingredients are optional, with a blank ElEdit row visible to start.
- Cannot have owned subsections, but can have by reference subsections.
- Directions and labels are optional, and should start collapsed if empty (with an icon to toggle visibility).
- By reference sections:
- are read only,
- show a link to their top-level recipe, which is the section itself if not owned, and
- can be one-click-replaced by a new owned section of the current recipe, duplicating the underlying recipe, as long as it doesn't have owned sections.
- Adding a recipe as an ingredient creates a by reference section (as today).
- Recog suggestions (for ElEdit) exclude sections (like search results).
- Non-section ingredients can be dragged between owned sections and/or the top-level recipe.
- Sections can be reordered, separate from reordering their ingredients. On the form, they don't float/fall.
- Sections can be removed from the recipe.
- Owned sections have a "Used By" button, if any other recipe includes them by reference, which opens a dialog to enumerate referrers. Should all sections?
- FUTURE: New "New Section" action button, which will create a new (name-defaulted) section and add the selected text as its ingredients.
- FUTURE: make the existing buttons into combo buttons which allow targeting a section, instead of the top-level recipe, if any sections exist.
FUTURE
Owned sections shouldn't have a "Cook" button.
- Remove ingredient scaling UI; it's too late.
- Sections with non-blank description float to the top w/ collapse as subrecipes do today.
- Sections with no description fall to the bottom of the ingredient list, title as subheading.
- Hide "I Cooked It!" and "Open Library Recipe" for
- owned sections if the top-level recipe is also visible, and
- all sections without a description.
No special handling.
FUTURE: Adjust the attribution breadcrumbs, so section names come after the top-level recipe? Using sugar for the baking example:
- sugar (10 c)
- 1 c sugar
German Chocolate Cake / Our Week - 2 c sugar
Buttercream Icing / Cupcakes / Clara's Birthday / Our Week - 3 c sugar
Cupcakes / Clara's Birthday / Our Week - 4 c sugar
Frosting / German Chocolate Cake / Our Week
- 1 c sugar
I believe the frosting attribution would be better as "German Chocolate Cake - Frosting / Our Week". This gets awkward with Clara's cupcakes, as the same rule would yield "Cupcakes - Buttercream Icing / Clara's Birthday / Our Week" for the icing (reasonable) and "Clara's Birthday - Cupcakes / Our Week" for the cupcakes themselves (less reasonable). This might need to pass section ownership information from library to planner, so only frosting gets flipped around. Or maybe everything should always be top-down, period?
Note that the "Our Week" breadcrumb is only visible if you're shopping multiple plans, and "Clara's Birthday" might be a bucket, not a plan item.
- ASSUMPTION: Sections usually stay with their recipe, so if you want to move them, having to open the full planner
is reasonable for the reduced clutter of the sidebar. Hide planned recipes which:
- are a section,
- are a descendant of their aggregate, and
- are in the same bucket as their aggregate, or not bucketed.
- The "Uses" popup needs to include the top-level recipe's name for owned sections.
- Include "and 7 other referrers"?
- For by reference sections too?
- A quantity of an owned section makes no sense; it's part of this recipe.
- A quantity of a by reference section makes a lot of sense.
- If you want to add buttercream icing to a recipe, you'd want to multiply across the buttercream recipe's yield. E.g., if buttercream yields 4 c icing, but I only need 2 c for my recipe, I want "1/2 buttercream icing"
- A quantity of a by reference section targeting an owned section is ... uh
- If you want to reuse german chocolate cake's coconut frosting for cupcakes, there's no yield for the frosting alone. If the cake recipe makes two 9-inch layers, but your cupcake recipe makes 12, you need a lot less frosting... but there's no yield on a section to multiple across.