recipe links
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
{% extends 'planner/base.html' %}{% load static %}
|
||||
{% block title %}Build a recipe · Tasknest{% endblock %}
|
||||
{% block content %}<link rel="stylesheet" href="{% static 'recipes/recipes.css' %}?v=13"><div class="recipes-layout recipes-layout--form recipes-compose"><header class="recipes-form-header"><a href="{% url 'recipes:list' %}">← Back to recipes</a><h1>Build a recipe</h1><p>Create a new recipe from explicitly selected components. Linked suggestions are never included.</p></header>{% if error %}<p class="recipes-form-error" role="alert">{{ error }}</p>{% endif %}<form method="post" class="recipes-edit-card" data-recipe-link-picker>{% csrf_token %}<section><h2>New recipe</h2><div class="recipes-form-grid"><div class="recipes-field"><label for="composition-title">Recipe title</label><input id="composition-title" name="title" maxlength="180" value="{{ request.POST.title }}"></div><div class="recipes-field"><label for="composition-servings">New recipe servings</label><input id="composition-servings" type="number" name="default_servings" min="0.01" max="99999.99" step="0.01" value="{{ request.POST.default_servings|default:'2' }}"></div></div></section><section><h2>Choose components</h2><p class="recipes-muted">Select up to ten recipes and set the servings to include from each.</p><div class="recipes-field"><label for="component-search">Search recipes</label><input id="component-search" type="search" data-component-search placeholder="Search by title"><p data-picker-empty role="status" aria-live="polite" hidden>No recipes match. <button type="button" data-clear-search>Clear search</button></p></div><div class="recipes-compose-list">{% for item in available %}<label class="recipes-compose-choice" data-recipe-name="{{ item.title|lower }}"><input type="checkbox" name="component" value="{{ item.api_id }}"{% for api_id, servings in selected_rows %}{% if api_id == item.api_id|stringformat:'s' %} checked{% endif %}{% endfor %}><span><strong>{{ item.title }}</strong><small>{{ item.default_servings|floatformat:-2 }} servings · {{ item.total_minutes }} min</small></span><span class="recipes-field"><span>Servings to include</span><input aria-label="Servings of {{ item.title }}" type="number" name="servings_{{ item.api_id }}" min="0.01" max="99999.99" step="0.01" value="{{ item.default_servings|floatformat:-2 }}"></span></label>{% empty %}<p class="recipes-muted">Create a recipe first to use it as a component.</p>{% endfor %}</div></section><div class="recipes-form-actions"><button type="submit" name="action" value="preview" class="recipes-outline-button">Preview components</button><button type="submit" name="action" value="create" class="button">Create new recipe</button></div></form>{% if preview %}<section class="recipes-panel recipes-compose-preview" aria-live="polite"><h2>Component preview</h2><p>Preview only. Creating this recipe will preserve each source recipe and add explicit component references.</p><h3>Combined nutrition estimate</h3><p>{% for row in nutrition_preview %}{{ row.label }}: {% if row.total is not None %}{{ row.total|floatformat:1 }} {{ row.unit }}{% else %}unknown{% endif %}{% if not row.complete %} · incomplete{% endif %}{% if not forloop.last %} · {% endif %}{% endfor %}</p>{% if duplicates %}<p class="recipes-form-error" role="status">Ingredient overlap: {% for name in duplicates %}{{ name }}{% if not forloop.last %}, {% endif %}{% endfor %}. Check that these components should both be included.</p>{% endif %}{% for component, result in preview %}<article><h3>{{ component.title }} · {{ result.servings }} servings</h3><ul>{% for line in result.lines %}<li>{{ line.quantity|floatformat:-3 }} {{ line.unit }} {{ line.name }}</li>{% empty %}<li>No structured ingredients yet.</li>{% endfor %}</ul><p class="recipes-compose-nutrition">{% for row in result.nutrition_rows %}{{ row.label }}: {% if row.total is not None %}{{ row.total|floatformat:1 }} {{ row.unit }}{% else %}unknown{% endif %}{% if not row.complete %} · incomplete{% endif %}{% if not forloop.last %} · {% endif %}{% endfor %}</p>{% if result.issues %}<p class="recipes-muted">Nutrition or inventory data may be incomplete.</p>{% endif %}</article>{% endfor %}</section>{% endif %}</div><script src="{% static 'recipes/recipe_picker.js' %}?v=1" defer></script>{% endblock %}
|
||||
@@ -51,6 +51,10 @@
|
||||
<section class="recipes-panel" aria-labelledby="recipe-ingredients-heading"><h3 id="recipe-ingredients-heading">Ingredients</h3><ul class="recipes-ingredient-list">{% for line in analysis.lines %}<li><span>{{ line.name }}{% if line.source %}<small>From {{ line.source }}</small>{% endif %}{% if line.ingredient.preparation_note %}<small>{{ line.ingredient.preparation_note }}</small>{% endif %}<small class="recipes-stock-label recipes-stock-label--{{ line.status }}">{{ line.status|capfirst }}{% if line.reason %}: {{ line.reason }}{% endif %}</small></span><strong>{{ line.quantity|floatformat:-3 }} {{ line.unit }}</strong>{% if line.optional %}<em>Optional{% if not analysis.include_optional %} · excluded{% endif %}</em>{% endif %}</li>{% empty %}<li class="recipes-muted">No ingredients added yet.</li>{% endfor %}</ul></section>
|
||||
<div class="recipes-content-stack"><section class="recipes-panel" aria-labelledby="recipe-instructions-heading"><h3 id="recipe-instructions-heading">Instructions</h3>{% if selected.instructions_markdown %}<div class="recipes-markdown-source">{{ selected.instructions_markdown|recipe_markdown }}</div>{% else %}<p class="recipes-muted">No instructions added yet.</p>{% endif %}</section>{% if selected.notes_markdown %}<section class="recipes-panel" aria-labelledby="recipe-notes-heading"><h3 id="recipe-notes-heading">Notes</h3><div class="recipes-markdown-source">{{ selected.notes_markdown|recipe_markdown }}</div></section>{% endif %}</div>
|
||||
</div>
|
||||
<section class="recipes-panel recipes-linked" aria-labelledby="linked-recipes-heading">
|
||||
<div class="recipes-linked__heading"><div><h3 id="linked-recipes-heading">Linked recipes</h3><p class="recipes-muted">Suggestions stay separate from this recipe’s ingredients and nutrition.</p></div><div><a class="recipes-outline-button" href="{% url 'recipes:link' selected.api_id %}">Link a recipe</a> <a class="recipes-outline-button" href="{% url 'recipes:compose' %}">Build a recipe</a></div></div>
|
||||
{% for link, other, direction in linked_recipes %}<article class="recipes-linked-card"><div><a href="{% url 'recipes:detail' other.api_id %}"><strong>{{ other.title }}</strong></a><small>{{ link.get_relationship_display }}{% if direction == 'incoming' %} · shared by {{ link.source.title }}{% endif %}</small>{% if link.note %}<p>{{ link.note }}</p>{% endif %}</div><div class="recipes-linked-actions"><a class="recipes-outline-button" href="{% url 'recipes:link-edit' link.source.api_id link.id %}">Edit</a><form method="post" action="{% url 'recipes:unlink' link.source.api_id link.id %}">{% csrf_token %}<button type="submit" class="recipes-outline-button">Remove</button></form></div></article>{% empty %}<p class="recipes-muted">Link your first recipe to keep a pairing or alternative close by.</p>{% endfor %}
|
||||
</section>
|
||||
{% else %}
|
||||
<div class="recipes-empty-detail"><h2>Make room for something delicious.</h2><p>Save a recipe to see its ingredients and instructions here.</p><a class="button" href="{% url 'recipes:create' %}">Create your first recipe</a></div>
|
||||
{% endif %}
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
{% extends 'planner/base.html' %}{% load static %}
|
||||
{% block title %}Link a recipe · Tasknest{% endblock %}
|
||||
{% block content %}<link rel="stylesheet" href="{% static 'recipes/recipes.css' %}?v=13"><div class="recipes-layout recipes-layout--form recipes-link-form"><header class="recipes-form-header"><a href="{% url 'recipes:detail' recipe.api_id %}">← Back to {{ recipe.title }}</a><h1>{% if existing_link %}Edit linked recipe{% else %}Link a recipe{% endif %}</h1><p>Keep a pairing, alternative, or suggestion beside {{ recipe.title }}. Linked recipes do not change ingredient totals.</p></header><form method="post" class="recipes-edit-card" data-recipe-link-picker>{% csrf_token %}<section><h2>Recipe suggestion</h2><div class="recipes-form-grid">{% if existing_link %}<div class="recipes-field"><span>Recipe</span><strong>{{ existing_link.target.title }}</strong></div>{% else %}<div class="recipes-field"><label for="link-search">Search recipes</label><input id="link-search" type="search" data-recipe-search placeholder="Search by title"><p data-picker-empty role="status" aria-live="polite" hidden>No recipes match. <button type="button" data-clear-search>Clear search</button></p></div><div class="recipes-field"><label for="linked-recipe">Recipe</label><select id="linked-recipe" name="recipe_id" required><option value="">Choose a recipe</option>{% for item in available %}<option value="{{ item.api_id }}"{% if form_data.recipe_id == item.api_id|stringformat:"s" %} selected{% endif %}>{{ item.title }}</option>{% endfor %}</select></div>{% endif %}<div class="recipes-field"><label for="relationship">Relationship</label><select id="relationship" name="relationship">{% for value, label in choices %}<option value="{{ value }}"{% if form_data.relationship == value or not form_data and existing_link.relationship == value %} selected{% endif %}>{{ label }}</option>{% endfor %}</select></div><div class="recipes-field recipes-field--wide"><label for="link-note">Note <span class="recipes-muted">(optional)</span></label><input id="link-note" name="note" maxlength="255" autocomplete="off" value="{% if form_data %}{{ form_data.note }}{% else %}{{ existing_link.note }}{% endif %}"></div><label class="recipes-checkbox"><input type="checkbox" name="reciprocal" value="1"{% if form_data %}{% if form_data.reciprocal == "1" %} checked{% endif %}{% elif not existing_link or existing_link.reciprocal %} checked{% endif %}> Show this suggestion on both recipes</label></div></section><div class="recipes-form-actions"><button type="submit" class="button">{% if existing_link %}Save changes{% else %}Save link{% endif %}</button><a href="{% url 'recipes:detail' recipe.api_id %}">Cancel</a></div></form></div><script src="{% static 'recipes/recipe_picker.js' %}?v=1" defer></script>{% endblock %}
|
||||
Reference in New Issue
Block a user