Tighten deferred and bulk review states

This commit is contained in:
Joren de Graaf
2026-10-26 01:50:54 +01:00
parent 9c8162bf7e
commit 0e4077d8e3
6 changed files with 67 additions and 15 deletions
+10 -9
View File
@@ -1,9 +1,10 @@
{% 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">
{% block content %}<link rel="stylesheet" href="{% static 'food/food.css' %}?v=20261026-review-2">
<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 %}
<header class="food-heading"><div><a href="{% url 'food:inventory' %}">← Kitchen inventory</a><h1>{% if state == 'processing' %}Processing scan items{% elif state == 'deferred' %}Deferred scan items{% else %}Additional Review Required{% endif %}</h1><p>{{ review_count }} product{{ review_count|pluralize }} {% if state == 'processing' %}are queued or being enriched.{% elif state == 'deferred' %}deferred for later. Fetched and entered information remains saved.{% else %}need review. Fetched and entered information is kept on each staged item.{% endif %}</p></div></header>
{% if state != 'processing' %}<nav class="inventory-review-states" aria-label="Review status"><a href="{% url 'food:inventory-review' %}" {% if state == 'review' %}aria-current="page"{% endif %}>Needs review</a><a href="{% url 'food:inventory-review' %}?state=deferred" {% if state == 'deferred' %}aria-current="page"{% endif %}>Deferred · {{ deferred_count }}</a></nav>{% endif %}
{% 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"><input type="hidden" name="state" value="{{ state }}"><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' %}
@@ -11,19 +12,19 @@
{% 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>
<form class="food-card inventory-bulk-review" method="post" action="{% url 'food:inventory-review' %}" data-bulk-review>
{% csrf_token %}<input type="hidden" name="state" value="{{ state }}"><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>
<fieldset class="inventory-bulk-selection"><legend>Select staged products</legend>{% for item in items %}<label><input type="checkbox" name="item_ids" value="{{ item.pk }}" {% if not item.product_name %}disabled{% endif %}><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 }}{% if not item.product_name %} · add a name in individual review{% endif %}</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>
<p data-review-selection-status role="status" aria-live="polite" hidden></p><button class="button" type="submit" data-bulk-preview-submit {% if not eligible_bulk_count %}disabled{% endif %}>Preview affected products</button>
{% endif %}
</form>
{% endif %}
</main>{% endblock %}
</main><script src="{% static 'food/inventory_review.js' %}?v=20261026-review-1" defer></script>{% endblock %}
@@ -1,6 +1,6 @@
{% 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">
{% block content %}<link rel="stylesheet" href="{% static 'food/food.css' %}?v=20261026-review-2">
<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 %}