latest changes
This commit is contained in:
@@ -64,3 +64,27 @@ body[data-theme="dark"] .food-tabs a[aria-current=page]{color:#102317}
|
||||
|
||||
.inventory-product-card{display:grid;gap:.8rem}.inventory-product-heading{display:flex;align-items:center;gap:1rem;min-width:0}.inventory-product-heading img{width:68px;height:68px;object-fit:contain;background:white;border-radius:.6rem}.inventory-product-heading h2{margin:0}.inventory-product-heading p{margin:.25rem 0;overflow-wrap:anywhere}.inventory-packages summary,.inventory-use summary{cursor:pointer;min-height:44px;align-content:center;font-weight:650}.inventory-package-list{display:grid;gap:.65rem;margin:.6rem 0}.inventory-package{display:flex;align-items:center;gap:.8rem;padding:.65rem;border:1px solid var(--food-border);border-radius:.7rem;min-width:0}.inventory-package>div:last-child{min-width:0}.inventory-package p{margin:.2rem 0}.inventory-package small{color:var(--food-muted)}.inventory-package-fill{flex:none;position:relative;width:42px;height:64px;border:2px solid var(--food-muted);border-radius:.3rem;overflow:hidden;background:var(--food-progress-track)}.inventory-package-fill span{position:absolute;bottom:0;left:0;right:0;background:var(--food-green);transition:height .25s ease}.inventory-use-form{display:flex;flex-wrap:wrap;gap:.6rem;align-items:end}.inventory-use-form label{display:grid;gap:.25rem;flex:1;min-width:100px}.inventory-use-form input,.inventory-use-form select{max-width:100%;min-height:44px}.inventory-use-form button{min-height:44px}.inventory-preview{border:1px solid var(--food-border);border-radius:.7rem;padding:.8rem;margin-top:.7rem}.inventory-preview h3{margin:0}.inventory-preview form{display:flex;align-items:center;gap:.6rem;flex-wrap:wrap}.inventory-preview form button,.inventory-history button{min-height:44px}.inventory-preview [role=alert]{color:#e9aa72}.inventory-history ul{padding-left:1.2rem}.inventory-history li{margin:.4rem 0}.inventory-history li form{display:inline-block;margin-left:.5rem}@media(max-width:480px){.inventory-product-heading{align-items:flex-start}.inventory-use-form{display:grid;grid-template-columns:1fr 1fr}.inventory-use-form label:nth-child(3){grid-column:1/-1}.inventory-use-form button{grid-column:1/-1}}@media(prefers-reduced-motion:reduce){.inventory-package-fill span{transition:none}}
|
||||
.food-entry-actions{display:flex;flex-wrap:wrap;justify-content:flex-end;gap:.3rem;flex:none}.food-entry-actions a{display:inline-flex;align-items:center;min-height:44px;padding:.2rem .35rem}.food-entry-actions a:focus-visible{outline:2px solid var(--food-green);outline-offset:2px}@media(max-width:480px){.food-entry{flex-wrap:wrap}.food-entry-actions{width:100%;justify-content:flex-start}}
|
||||
|
||||
/* Inventory search remains available when additional filters are collapsed. */
|
||||
.inventory-filters{display:block}
|
||||
.inventory-filter-search label{display:block;min-width:0;margin-bottom:.3rem;font-size:.82rem;font-weight:700}
|
||||
.inventory-filter-search>div{display:flex;gap:.6rem;min-width:0}
|
||||
.inventory-filter-search input{flex:1;min-width:0;min-height:44px}
|
||||
.inventory-filter-search button{min-height:44px}
|
||||
.inventory-filter-details{min-width:0;margin-top:.65rem}
|
||||
.inventory-filter-details summary{display:flex;align-items:center;min-height:44px;cursor:pointer;font-weight:700}
|
||||
.inventory-filter-details summary:focus-visible{outline:2px solid var(--food-green);outline-offset:2px;border-radius:.3rem}
|
||||
.inventory-filter-options{display:flex;flex-wrap:wrap;gap:.75rem;align-items:end;padding-top:.4rem}
|
||||
.inventory-filter-options label{min-width:130px}
|
||||
.inventory-filter-options .inventory-check{align-self:center}
|
||||
@media(min-width:821px){.inventory-filter-details[open]>summary{display:none}}
|
||||
@media(max-width:480px){.inventory-filters{padding:.9rem}.inventory-filter-options label{flex-basis:100%;min-width:0}}
|
||||
.inventory-filter-search input{padding:.6rem .75rem;border:1px solid var(--food-border);border-radius:.65rem;color:var(--food-ink);background:var(--food-surface)}
|
||||
.inventory-filter-search input:focus-visible{outline:2px solid var(--food-green);outline-offset:2px}
|
||||
.inventory-filter-details summary::after{content:'⌄';margin-left:auto;font-size:1.2rem;line-height:1}
|
||||
.inventory-filter-details[open] summary::after{transform:rotate(180deg)}
|
||||
.inventory-filter-options select{width:100%;min-height:44px;padding:.55rem .65rem;border:1px solid var(--food-border);border-radius:.65rem;color:var(--food-ink);background:var(--food-surface)}
|
||||
.inventory-filter-options select:focus-visible{outline:2px solid var(--food-green);outline-offset:2px}
|
||||
.inventory-heading-actions{display:flex;align-items:center;justify-content:flex-end;gap:.5rem;flex-wrap:wrap}
|
||||
.inventory-heading-actions .button{min-height:44px}
|
||||
@media(max-width:600px){.inventory-page>.food-heading{align-items:flex-start;flex-wrap:wrap}.inventory-heading-actions{justify-content:flex-start;width:100%}}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{% extends 'planner/base.html' %}{% load static %}
|
||||
{% block title %}Add to Kitchen Inventory · Tasknest{% endblock %}
|
||||
{% block content %}<link rel="stylesheet" href="{% static 'food/food.css' %}">
|
||||
{% block content %}<link rel="stylesheet" href="{% static 'food/food.css' %}?v=20261012-actions">
|
||||
<div class="food-form-page inventory-page"><a href="{% url 'food:inventory' %}">← Kitchen Inventory</a><h1>Add to inventory</h1>
|
||||
{% if product %}
|
||||
<section class="food-card inventory-product">{% if product.image_url %}<img src="{{ product.image_url }}" alt="" loading="lazy">{% endif %}<div><h2>{{ product.product_name }}</h2>{% if product.brand %}<p>{{ product.brand }}</p>{% endif %}{% if product.package_quantity %}<p>{{ product.package_quantity }}</p>{% endif %}{% if off_categories %}<p><small>Open Food Facts: {{ off_categories }}</small></p>{% endif %}</div></section>
|
||||
@@ -11,8 +11,9 @@
|
||||
<button class="button" type="submit">Add to inventory</button></form>
|
||||
<a href="{% url 'food:inventory-add' %}">Choose another product</a>
|
||||
{% else %}
|
||||
{% include 'food/partials/inventory_product_actions.html' %}
|
||||
<form method="get" class="food-search"><label for="inventory-query">Search saved products</label><input id="inventory-query" name="q" type="search" value="{{ query }}" autofocus><button class="button" type="submit">Search</button></form>
|
||||
<ul class="food-product-list">{% for item in products %}<li><a href="{% url 'food:inventory-add' %}?product={{ item.pk }}">{% if item.image_url %}<img src="{{ item.image_url }}" alt="" loading="lazy">{% endif %}<span><strong>{{ item.product_name }}</strong>{% if item.brand %}<small>{{ item.brand }}</small>{% endif %}</span></a></li>{% empty %}<li>No saved products found.</li>{% endfor %}</ul>
|
||||
<div class="food-actions"><a class="button" href="{% url 'food:scanner' %}?mode=inventory">Scan barcode</a><a class="button button--secondary" href="{% url 'food:inventory-external' %}?q={{ query|urlencode }}">Search Open Food Facts</a><a class="button button--secondary" href="{% url 'food:inventory-manual' %}">Create manual product</a></div>
|
||||
{% include 'food/partials/inventory_product_actions.html' %}
|
||||
<form method="post" action="{% url 'food:inventory-lookup' %}" class="food-barcode-form">{% csrf_token %}<label for="inventory-barcode">Enter barcode</label><input id="inventory-barcode" name="barcode" inputmode="numeric" pattern="[0-9]+" required><button class="button button--secondary" type="submit">Look up</button></form>
|
||||
{% endif %}</div><script src="{% static 'food/inventory.js' %}" defer></script>{% endblock %}
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
{% extends 'planner/base.html' %}{% load static %}
|
||||
{% block title %}Kitchen Inventory · Tasknest{% endblock %}
|
||||
{% block content %}<link rel="stylesheet" href="{% static 'food/food.css' %}?v=20261011-packages">
|
||||
<div class="food-page inventory-page"><header class="food-heading"><div><h1>Kitchen Inventory</h1><p>What you have and where it lives.</p></div><a class="button" href="{% url 'food:inventory-add' %}">+ Add item</a></header>
|
||||
<form method="get" class="food-card inventory-filters"><label>Search<input type="search" name="q" value="{{ query }}"></label><label>Location<select name="location"><option value="">All locations</option>{% for location in locations %}<option value="{{ location.pk }}" {% if selected_location == location.pk|stringformat:'s' %}selected{% endif %}>{{ location.name }}</option>{% endfor %}</select></label><label>Category<select name="category"><option value="">All categories</option>{% for category in categories %}<option value="{{ category.pk }}" {% if selected_category == category.pk|stringformat:'s' %}selected{% endif %}>{{ category.name }}</option>{% endfor %}</select></label><label>Opened<select name="opened"><option value="">All</option><option value="yes" {% if opened == 'yes' %}selected{% endif %}>Opened</option><option value="no" {% if opened == 'no' %}selected{% endif %}>Unopened</option></select></label><label>Sort<select name="sort"><option value="location" {% if sort == 'location' %}selected{% endif %}>Location</option><option value="category" {% if sort == 'category' %}selected{% endif %}>Category</option><option value="name" {% if sort == 'name' %}selected{% endif %}>Product name</option><option value="recent" {% if sort == 'recent' %}selected{% endif %}>Recently added</option><option value="best_before" {% if sort == 'best_before' %}selected{% endif %}>Best before</option></select></label><label class="inventory-check"><input type="checkbox" name="use_soon" value="1" {% if use_soon == '1' %}checked{% endif %}> Use soon</label><button class="button" type="submit">Apply</button></form>
|
||||
{% block content %}<link rel="stylesheet" href="{% static 'food/food.css' %}?v=20261012-filters">
|
||||
<div class="food-page inventory-page"><header class="food-heading"><div><h1>Kitchen Inventory</h1><p>What you have and where it lives.</p></div><div class="inventory-heading-actions"><a class="button" href="{% url 'food:inventory-add' %}">+ Add item</a><a class="button button--secondary" href="{% url 'food:scanner' %}?mode=inventory">Scan barcode</a></div></header>
|
||||
<form method="get" class="food-card inventory-filters" role="search" aria-label="Search kitchen inventory">
|
||||
<div class="inventory-filter-search"><label for="inventory-search">Search inventory</label><div><input id="inventory-search" type="search" name="q" value="{{ query }}"><button class="button" type="submit">Search</button></div></div>
|
||||
<details class="inventory-filter-details" data-responsive-filters open><summary>More filters{% if selected_location or selected_category or opened or use_soon == '1' or sort != 'location' %} · Applied{% endif %}</summary><div class="inventory-filter-options"><label>Location<select name="location"><option value="">All locations</option>{% for location in locations %}<option value="{{ location.pk }}" {% if selected_location == location.pk|stringformat:'s' %}selected{% endif %}>{{ location.name }}</option>{% endfor %}</select></label><label>Category<select name="category"><option value="">All categories</option>{% for category in categories %}<option value="{{ category.pk }}" {% if selected_category == category.pk|stringformat:'s' %}selected{% endif %}>{{ category.name }}</option>{% endfor %}</select></label><label>Opened<select name="opened"><option value="">All</option><option value="yes" {% if opened == 'yes' %}selected{% endif %}>Opened</option><option value="no" {% if opened == 'no' %}selected{% endif %}>Unopened</option></select></label><label>Sort<select name="sort"><option value="location" {% if sort == 'location' %}selected{% endif %}>Location</option><option value="category" {% if sort == 'category' %}selected{% endif %}>Category</option><option value="name" {% if sort == 'name' %}selected{% endif %}>Product name</option><option value="recent" {% if sort == 'recent' %}selected{% endif %}>Recently added</option><option value="best_before" {% if sort == 'best_before' %}selected{% endif %}>Best before</option></select></label><label class="inventory-check"><input type="checkbox" name="use_soon" value="1" {% if use_soon == '1' %}checked{% endif %}> Use soon</label><button class="button" type="submit">Apply filters</button></div></details>
|
||||
</form>
|
||||
{% for card in cards %}<article class="food-card inventory-product-card">
|
||||
<div class="inventory-product-heading">{% if card.product.image_url %}<img src="{{ card.product.image_url }}" alt="" loading="lazy">{% endif %}<div><h2>{{ card.product.product_name }}</h2>{% if card.product.brand %}<p>{{ card.product.brand }}</p>{% endif %}<p><strong>{{ card.total|floatformat:-3 }} {% if card.unit == "packs" and card.total == 1 %}pack{% else %}{{ card.unit }}{% endif %} remaining</strong> · {{ card.packages|length }} package{{ card.packages|length|pluralize }}</p></div></div>
|
||||
<details class="inventory-packages"><summary>View packages</summary><div class="inventory-package-list">{% for item in card.packages %}<div class="inventory-package"><div class="inventory-package-fill" role="img" aria-label="{{ item.percentage_remaining }}% remaining"><span style="height:{{ item.percentage_remaining }}%"></span></div><div><strong>Pack {{ forloop.counter }} · {{ item.package_status|title }}</strong><p>{% if item.original_amount %}{{ item.remaining_amount|floatformat:-3 }} / {{ item.original_amount|floatformat:-3 }} {{ item.inventory_unit }} · {{ item.percentage_remaining }}% remaining{% else %}{{ item.quantity }} pack{{ item.quantity|pluralize }} · size unknown{% endif %}</p><small>{{ item.location.name }}{% if item.category %} · {{ item.category.name }}{% endif %}{% if item.best_before %} · Best before {{ item.best_before }}{% endif %}</small><div><a href="{% url 'food:inventory-edit' item.pk %}">Edit package</a></div></div></div>{% endfor %}</div></details>
|
||||
<details class="inventory-use"><summary>Use amount</summary><form method="post" action="{% url 'food:inventory-preview' card.product.pk %}" hx-post="{% url 'food:inventory-preview' card.product.pk %}" hx-target="#inventory-preview-{{ card.product.pk }}-{{ card.unit }}" hx-swap="innerHTML" class="inventory-use-form">{% csrf_token %}<label>Amount<input type="number" name="amount" min="{% if card.count_unit %}1{% else %}0.001{% endif %}" step="{% if card.count_unit %}1{% else %}0.001{% endif %}" required inputmode="decimal"></label><label>Unit<select name="unit">{% for unit in card.units %}<option value="{{ unit }}" {% if unit == card.unit %}selected{% endif %}>{{ unit }}</option>{% endfor %}</select></label><label>Package (optional)<select name="package_id"><option value="">Automatic selection</option>{% for item in card.packages %}<option value="{{ item.api_id }}">Pack {{ forloop.counter }} · {% if item.remaining_amount is not None %}{{ item.remaining_amount|floatformat:-3 }} {{ item.inventory_unit }}{% else %}{{ item.quantity }} pack{{ item.quantity|pluralize }}{% endif %}</option>{% endfor %}</select></label><button class="button button--secondary" type="submit">Preview</button></form><div id="inventory-preview-{{ card.product.pk }}-{{ card.unit }}" aria-live="polite"></div></details>
|
||||
</article>{% empty %}<section class="food-card"><p>No inventory items found.</p><a class="button" href="{% url 'food:inventory-add' %}">Add your first item</a></section>{% endfor %}
|
||||
{% if recent_consumption %}<section class="food-card inventory-history"><h2>Recent use</h2><ul>{% for entry in recent_consumption %}<li>{{ entry.created_at|date:'j M, H:i' }} · {{ entry.product.product_name }} · {{ entry.amount|floatformat:-3 }} {{ entry.unit }}<details><summary>Package changes</summary><ul>{% for line in entry.lines.all %}<li>Pack {{ line.package.pk }}: {{ line.before_amount|floatformat:-3 }} → {{ line.after_amount|floatformat:-3 }} {{ line.unit }}</li>{% endfor %}</ul></details>{% if not entry.reversal %}<form method="post" action="{% url 'food:inventory-undo' entry.pk %}">{% csrf_token %}<button type="submit">Undo</button></form>{% else %} · Undone{% endif %}</li>{% endfor %}</ul></section>{% endif %}
|
||||
</div>{% endblock %}
|
||||
</div><script src="{% static 'planner/responsive_filters.js' %}?v=1" defer></script>{% endblock %}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
<div class="food-actions inventory-product-actions">
|
||||
<a class="button" href="{% url 'food:scanner' %}?mode=inventory">Scan barcode</a>
|
||||
<a class="button button--secondary" href="{% url 'food:inventory-external' %}?q={{ query|urlencode }}">Search Open Food Facts</a>
|
||||
<a class="button button--secondary" href="{% url 'food:inventory-manual' %}">Create manual product</a>
|
||||
</div>
|
||||
Reference in New Issue
Block a user