Add inventory scan staging and review workflows
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
{% extends 'planner/base.html' %}{% load static %}
|
||||
{% block title %}Kitchen Inventory · Tasknest{% endblock %}
|
||||
{% block content %}<link rel="stylesheet" href="{% static 'food/food.css' %}?v=20261026-nested">
|
||||
{% block content %}<link rel="stylesheet" href="{% static 'food/food.css' %}?v=20261026-review-1">
|
||||
<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>
|
||||
<section class="food-card inventory-staging" id="inventory-review" aria-labelledby="inventory-staging-title"><div class="inventory-staging-top"><div><p class="inventory-kicker">Bulk scanner</p><h2 id="inventory-staging-title">Staged scan items</h2><p>Track background enrichment and finish products that need your input.</p></div><a class="button" href="{% url 'food:inventory-review' %}">Open review</a></div><div class="inventory-staging-counts"><a href="{% url 'food:inventory-review' %}?state=processing"><strong>{{ processing_count }}</strong><span>Processing</span></a><a href="{% url 'food:inventory-review' %}"><strong>{{ needs_review_count }}</strong><span>Needs Review</span></a></div><form method="post" action="{% url 'food:inventory-review' %}" class="inventory-review-mode">{% csrf_token %}<input type="hidden" name="action" value="mode"><span>Review mode</span><button name="mode" value="individual" aria-pressed="{% if review_mode == 'individual' %}true{% else %}false{% endif %}" class="{% if review_mode == 'individual' %}is-selected{% endif %}">Individual</button><button name="mode" value="bulk" aria-pressed="{% if review_mode == 'bulk' %}true{% else %}false{% endif %}" class="{% if review_mode == 'bulk' %}is-selected{% endif %}">Bulk review</button></form></section>
|
||||
<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>
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
{% extends 'planner/base.html' %}{% load static %}
|
||||
{% block title %}Inventory review · Tasknest{% endblock %}
|
||||
{% block content %}<link rel="stylesheet" href="{% static 'food/food.css' %}?v=20261026-review-1">
|
||||
<main class="food-page inventory-review-page">
|
||||
<header class="food-heading"><div><a href="{% url 'food:inventory' %}">← Kitchen inventory</a><h1>{% if state == 'processing' %}Processing scan items{% else %}Additional Review Required{% endif %}</h1><p>{{ review_count }} product{{ review_count|pluralize }} {% if state == 'processing' %}are queued or being enriched.{% else %}need review. Fetched and entered information is kept on each staged item.{% endif %}</p></div></header>
|
||||
{% if state != 'processing' %}<div class="inventory-review-toolbar"><div><form method="post" action="{% url 'food:inventory-review' %}">{% csrf_token %}<input type="hidden" name="action" value="mode"><button name="mode" value="individual" class="{% if mode == 'individual' %}is-selected{% endif %}" aria-pressed="{% if mode == 'individual' %}true{% else %}false{% endif %}">Individual</button><button name="mode" value="bulk" class="{% if mode == 'bulk' %}is-selected{% endif %}" aria-pressed="{% if mode == 'bulk' %}true{% else %}false{% endif %}">Bulk review</button></form></div><a href="{% url 'food:inventory' %}#inventory-review">Processing and review counts</a></div>{% endif %}
|
||||
{% if approved_count %}<p class="inventory-review-success" role="status">{{ approved_count }} product{{ approved_count|pluralize }} added to inventory.</p>{% endif %}
|
||||
{% if review_error %}<p class="inventory-review-error" role="alert">{{ review_error }}</p>{% endif %}
|
||||
{% if mode == 'individual' or state == 'processing' %}
|
||||
<section class="inventory-review-list" aria-label="Products requiring individual review">
|
||||
{% for item in items %}<article class="food-card inventory-review-row"><div><p class="inventory-kicker">{{ item.get_status_display }} · {{ item.location.name }}</p><h2>{{ item.product_name|default:'Product details needed' }}</h2><p>{{ item.brand }}{% if item.brand %} · {% endif %}Barcode {{ item.barcode }}</p>{% if item.last_error %}<p class="inventory-review-error">{{ item.last_error }}</p>{% endif %}<p>{{ item.package_count }} package{{ item.package_count|pluralize }}{% if item.package_amount %} · {{ item.package_amount }} {{ item.package_unit }}{% endif %}</p></div>{% if state != 'processing' %}<a class="button" href="{% url 'food:inventory-review-item' item.pk %}">Review product</a>{% endif %}</article>{% empty %}<section class="food-card"><h2>{% if state == 'processing' %}No items processing{% else %}Nothing needs review{% endif %}</h2><p>{% if state == 'processing' %}Submitted scan batches will appear here while the worker enriches them.{% else %}Products that could not be matched or need corrections will appear here.{% endif %}</p></section>{% endfor %}
|
||||
</section>
|
||||
{% elif state != 'processing' %}
|
||||
<form class="food-card inventory-bulk-review" method="post" action="{% url 'food:inventory-review' %}">
|
||||
{% csrf_token %}<input type="hidden" name="action" value="{% if preview %}approve{% else %}preview{% endif %}">
|
||||
<h2>{% if preview %}Preview selected products{% else %}Select products to review together{% endif %}</h2>
|
||||
<p>{% if preview %}Review the affected rows before adding them to inventory. Individual product fields and nutrition stay unchanged.{% else %}Apply a shared storage location or category, then preview the exact products before approval.{% endif %}</p>
|
||||
{% if preview %}
|
||||
{% for item in preview_items %}<input type="hidden" name="item_ids" value="{{ item.pk }}"><div class="inventory-review-row inventory-review-preview"><div><strong>{{ item.product_name|default:'Product details needed' }}</strong><span>{{ item.barcode }} · {{ item.package_count }} package{{ item.package_count|pluralize }}</span></div><span>{{ shared_location_name|default:item.location.name }}{% if shared_category %} · {{ shared_category }}{% elif item.category_name %} · {{ item.category_name }}{% endif %}</span></div>{% endfor %}
|
||||
<input type="hidden" name="location_id" value="{{ shared_location_id }}"><input type="hidden" name="category_name" value="{{ shared_category }}">
|
||||
<div class="inventory-review-actions"><button class="button" type="submit">Approve selected products</button><a class="button button--secondary" href="{% url 'food:inventory-review' %}?mode=bulk">Back to selection</a></div>
|
||||
{% else %}
|
||||
<fieldset class="inventory-bulk-selection"><legend>Select staged products</legend>{% for item in items %}<label><input type="checkbox" name="item_ids" value="{{ item.pk }}"><span><strong>{{ item.product_name|default:'Product details needed' }}</strong><small>{{ item.barcode }} · {{ item.get_status_display }} · {{ item.location.name }} · {{ item.package_count }} package{{ item.package_count|pluralize }}</small></span></label>{% empty %}<p>No staged products need review.</p>{% endfor %}</fieldset>
|
||||
<div class="inventory-review-shared-fields"><label>Shared location<select name="location_id"><option value="">Keep each product's location</option>{% for location in locations %}<option value="{{ location.pk }}">{{ location.name }}</option>{% endfor %}</select></label><label>Shared category<input name="category_name" maxlength="100" placeholder="Leave blank to keep each category"></label></div>
|
||||
<button class="button" type="submit" {% if not items %}disabled{% endif %}>Preview affected products</button>
|
||||
{% endif %}
|
||||
</form>
|
||||
{% endif %}
|
||||
</main>{% endblock %}
|
||||
@@ -0,0 +1,12 @@
|
||||
{% extends 'planner/base.html' %}{% load static %}
|
||||
{% block title %}Review {{ item.product_name|default:'scanned product' }} · Tasknest{% endblock %}
|
||||
{% block content %}<link rel="stylesheet" href="{% static 'food/food.css' %}?v=20261026-review-1">
|
||||
<main class="food-page inventory-review-page"><header class="food-heading"><div><a href="{% url 'food:inventory-review' %}">← Additional Review Required</a><p class="inventory-kicker">{{ item.get_status_display }} · Barcode {{ item.barcode }}</p><h1>Review scanned product</h1><p>Unknown nutrition values stay blank. You can approve without filling optional nutrition fields.</p></div></header>
|
||||
{% if error %}<p class="inventory-review-error" role="alert">{{ error }}</p>{% endif %}{% if values.saved %}<p class="inventory-review-success" role="status">Your changes were saved.</p>{% endif %}
|
||||
<form method="post" class="food-card inventory-review-form">{% csrf_token %}
|
||||
<div class="inventory-review-toolbar"><span>Review mode</span><button type="submit" name="action" value="mode" class="{% if mode == 'individual' %}is-selected{% endif %}" aria-pressed="{% if mode == 'individual' %}true{% else %}false{% endif %}" onclick="this.form.querySelector('[name=mode]').value='individual'">Individual</button><button type="submit" name="action" value="mode" class="{% if mode == 'bulk' %}is-selected{% endif %}" aria-pressed="{% if mode == 'bulk' %}true{% else %}false{% endif %}" onclick="this.form.querySelector('[name=mode]').value='bulk'">Bulk review</button><input type="hidden" name="mode" value="{{ mode }}"></div>
|
||||
<div class="inventory-review-fields"><label>Product name<input name="product_name" maxlength="255" required value="{{ values.product_name }}"></label><label>Brand<input name="brand" maxlength="255" value="{{ values.brand }}"></label><label>Storage location<select name="location_id" required>{% for location in locations %}<option value="{{ location.pk }}" {% if item.location_id == location.pk or values.location_id|stringformat:'s' == location.pk|stringformat:'s' %}selected{% endif %}>{{ location.name }}</option>{% endfor %}</select></label><label>Category<input name="category_name" maxlength="100" value="{{ values.category_name }}"></label>
|
||||
<label>Number of packages<input type="number" name="package_count" min="1" max="10000" value="{{ values.package_count }}" required></label><label>Amount per package<input type="number" name="package_amount" min="0.001" step="0.001" value="{{ values.package_amount }}" placeholder="Unknown"></label><label>Package unit<input name="package_unit" maxlength="8" value="{{ values.package_unit }}" placeholder="e.g. g, ml, pieces"></label><label>Notes<textarea name="notes" rows="3">{{ values.notes }}</textarea></label></div>
|
||||
<details class="inventory-scan-nutrition" open><summary>Nutrition per 100 g/ml (optional)</summary><p>Blank means unknown; entering 0 records a known zero.</p><div class="inventory-review-nutrients">{% for nutrient in nutrients %}<label>{{ nutrient.label }}<input type="number" min="0" step="0.001" name="{{ nutrient.field }}" value="{{ nutrient.value }}" placeholder="Unknown"></label>{% endfor %}</div></details>
|
||||
<div class="inventory-review-actions"><button class="button" type="submit" name="action" value="save">Save changes</button><button class="button" type="submit" name="action" value="approve">Approve and add to inventory</button><button class="button button--secondary" type="submit" name="action" value="defer">Skip for now</button></div>
|
||||
</form></main>{% endblock %}
|
||||
@@ -1,7 +1,7 @@
|
||||
{% extends 'planner/base.html' %}{% load static %}
|
||||
{% block title %}Bulk scan inventory · Tasknest{% endblock %}
|
||||
{% block content %}
|
||||
<link rel="stylesheet" href="{% static 'food/food.css' %}?v=20261026-bulk-2">
|
||||
<link rel="stylesheet" href="{% static 'food/food.css' %}?v=20261026-bulk-3">
|
||||
<main class="food-page inventory-scan-page">
|
||||
<header class="food-heading">
|
||||
<div><a href="{% url 'food:inventory' %}">← Kitchen inventory</a><h1>Bulk scan inventory</h1><p>Scan packages into a location, then review your session queue.</p></div>
|
||||
@@ -65,5 +65,5 @@
|
||||
</div>
|
||||
{% endif %}
|
||||
</main>
|
||||
<script src="{% static 'food/scanner.js' %}?v=20261026-bulk-2" defer></script>
|
||||
<script src="{% static 'food/scanner.js' %}?v=20261026-bulk-3" defer></script>
|
||||
{% endblock %}
|
||||
|
||||
Reference in New Issue
Block a user