diff --git a/main/food/inventory.py b/main/food/inventory.py index 1ea4c78..093a5fa 100644 --- a/main/food/inventory.py +++ b/main/food/inventory.py @@ -24,6 +24,16 @@ def _owned_items(user): return KitchenInventoryItem.objects.filter(user=user, archived_at__isnull=True).select_related('product', 'location', 'category') +def _inventory_review_counts(user): + review_items = InventoryScanItem.objects.filter(batch__run__user=user) + return { + 'processing_count': review_items.filter(status__in=(InventoryScanItem.Status.QUEUED, + InventoryScanItem.Status.PROCESSING)).count(), + 'needs_review_count': review_items.filter(status__in=(InventoryScanItem.Status.NEEDS_REVIEW, + InventoryScanItem.Status.DEFERRED, InventoryScanItem.Status.FAILED)).count(), + } + + @login_required def overview(request): items = _owned_items(request.user) @@ -74,11 +84,7 @@ def overview(request): if item.inner_packs_per_package and 'inner_packs' not in cards[key]['units']: cards[key]['units'].append('inner_packs') recent = InventoryConsumption.objects.filter(user=request.user, reverses__isnull=True).select_related('product').prefetch_related('lines__package').order_by('-created_at')[:8] - review_items = InventoryScanItem.objects.filter(batch__run__user=request.user) - processing_count = review_items.filter(status__in=(InventoryScanItem.Status.QUEUED, - InventoryScanItem.Status.PROCESSING)).count() - needs_review_count = review_items.filter(status__in=(InventoryScanItem.Status.NEEDS_REVIEW, - InventoryScanItem.Status.DEFERRED, InventoryScanItem.Status.FAILED)).count() + review_counts = _inventory_review_counts(request.user) preference = InventoryReviewPreference.objects.filter(user=request.user).first() return render(request, 'food/inventory_overview.html', { 'items': items, 'cards': list(cards.values()), 'recent_consumption': recent, @@ -87,11 +93,18 @@ def overview(request): 'locations': InventoryLocation.objects.filter(user=request.user), 'categories': InventoryCategory.objects.filter(user=request.user), 'today': timezone.localdate(), 'soon_date': timezone.localdate() + timedelta(days=14), - 'processing_count': processing_count, 'needs_review_count': needs_review_count, + **review_counts, 'review_mode': preference.mode if preference else InventoryReviewPreference.Mode.INDIVIDUAL, }) +@login_required +@require_http_methods(['GET']) +def inventory_staging_counts(request): + return render(request, 'food/partials/inventory_staging_counts.html', + _inventory_review_counts(request.user)) + + @login_required @require_http_methods(['GET', 'POST']) def add(request): diff --git a/main/food/static/food/food.css b/main/food/static/food/food.css index 0583551..5d3ec37 100644 --- a/main/food/static/food/food.css +++ b/main/food/static/food/food.css @@ -189,6 +189,84 @@ body[data-theme="dark"] .food-tabs a[aria-current=page]{color:#102317} .food-quantity-form{display:flex;align-items:center;gap:.35rem}.food-quantity{font-weight:700;white-space:nowrap}.food-quantity-form button{min-width:44px;min-height:44px;border:1px solid var(--food-border);border-radius:50%;background:var(--food-surface);color:var(--food-ink);font:inherit;font-size:1.4rem;cursor:pointer}.food-quantity-form button:focus-visible{outline:2px solid var(--food-green);outline-offset:2px}.food-quantity-form.htmx-request button{opacity:.6;cursor:progress}.food-screen-reader{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0} .food-quantity-controls{display:flex;align-items:center;gap:.35rem;white-space:nowrap}.food-quantity-controls .food-quantity{min-width:2.5ch;text-align:center}.food-quantity-controls .food-quantity-form{margin:0} +/* Bulk scanner surfaces follow the app's dark appearance setting. */ +body[data-theme="dark"] .inventory-staging, +body[data-theme="dark"] .inventory-review-page .food-card, +body[data-theme="dark"] .inventory-scan-start, +body[data-theme="dark"] .inventory-scan-camera, +body[data-theme="dark"] .inventory-scan-active, +body[data-theme="dark"] .inventory-scan-queue {border-color:#3b473f;background:#202923;color:#edf5ef} +body[data-theme="dark"] .inventory-staging {background:#242e27} +body[data-theme="dark"] .inventory-staging-top h2, +body[data-theme="dark"] .inventory-review-page h2, +body[data-theme="dark"] .inventory-review-page .food-heading h1, +body[data-theme="dark"] .inventory-scan-page>.food-heading h1, +body[data-theme="dark"] .inventory-scan-queue-heading h2, +body[data-theme="dark"] .inventory-scan-queue-item-main strong {color:#edf5ef} +body[data-theme="dark"] .inventory-staging-top p:last-child, +body[data-theme="dark"] .inventory-review-page .food-heading p:last-child, +body[data-theme="dark"] .inventory-review-row p, +body[data-theme="dark"] .inventory-bulk-review>p, +body[data-theme="dark"] .inventory-bulk-selection small, +body[data-theme="dark"] .inventory-review-preview span, +body[data-theme="dark"] .inventory-scan-meta, +body[data-theme="dark"] .inventory-scan-hint, +body[data-theme="dark"] .inventory-scan-note, +body[data-theme="dark"] .inventory-scan-empty, +body[data-theme="dark"] .inventory-scan-queue-item-main small, +body[data-theme="dark"] .inventory-scan-queue-item-side small, +body[data-theme="dark"] .inventory-scan-queue-heading>span, +body[data-theme="dark"] .inventory-scan-batch-heading>span {color:#b8c3bb} +body[data-theme="dark"] .inventory-kicker, +body[data-theme="dark"] .inventory-scan-active-heading, +body[data-theme="dark"] .inventory-scan-batch-heading h3 {color:#9bd5ae} +body[data-theme="dark"] .inventory-staging-counts>a, +body[data-theme="dark"] .inventory-review-mode button, +body[data-theme="dark"] .inventory-review-toolbar button, +body[data-theme="dark"] .inventory-review-states a {border-color:#46544b;background:#27312b;color:#edf5ef} +body[data-theme="dark"] .inventory-staging-counts strong {color:#9bd5ae} +body[data-theme="dark"] .inventory-review-mode button.is-selected, +body[data-theme="dark"] .inventory-review-toolbar button.is-selected, +body[data-theme="dark"] .inventory-review-states a[aria-current=page] {border-color:#568466;background:#294332;color:#d9f5e0} +body[data-theme="dark"] .inventory-scan-location {border-color:#568466;background:#263c2e;color:#b9edc8} +body[data-theme="dark"] .inventory-scan-location-panel, +body[data-theme="dark"] .inventory-scan-controls {border-color:#3b473f;background:#26342b;color:#d1ddd4} +body[data-theme="dark"] .inventory-scan-location-form select, +body[data-theme="dark"] .inventory-scan-start-form select, +body[data-theme="dark"] .inventory-scan-next-row select, +body[data-theme="dark"] .inventory-scan-active input, +body[data-theme="dark"] .inventory-scan-active select, +body[data-theme="dark"] .inventory-scan-active textarea, +body[data-theme="dark"] .inventory-review-fields input, +body[data-theme="dark"] .inventory-review-fields select, +body[data-theme="dark"] .inventory-review-fields textarea, +body[data-theme="dark"] .inventory-review-shared-fields input, +body[data-theme="dark"] .inventory-review-shared-fields select, +body[data-theme="dark"] .inventory-review-nutrients input {border-color:#536159;background:#161d19;color:#edf5ef;color-scheme:dark} +body[data-theme="dark"] .inventory-scan-active form>label, +body[data-theme="dark"] .inventory-scan-active .inventory-scan-product-title, +body[data-theme="dark"] .inventory-scan-fields label, +body[data-theme="dark"] .inventory-scan-queue-item-side {color:#d9e4dc} +body[data-theme="dark"] .inventory-scan-more, +body[data-theme="dark"] .inventory-scan-nutrition, +body[data-theme="dark"] .inventory-scan-count-controls button {border-color:#3b473f;background:#27312b;color:#edf5ef} +body[data-theme="dark"] .inventory-scan-batch-heading, +body[data-theme="dark"] .inventory-scan-queue-item, +body[data-theme="dark"] .inventory-scan-manual, +body[data-theme="dark"] .inventory-scan-nutrition dl div, +body[data-theme="dark"] .inventory-bulk-selection, +body[data-theme="dark"] .inventory-bulk-selection label, +body[data-theme="dark"] .inventory-review-preview {border-color:#3b473f} +body[data-theme="dark"] .inventory-scan-nutrition dt {color:#b8c3bb} +body[data-theme="dark"] .inventory-scan-controls .inventory-scan-done {background:#39734e} +body[data-theme="dark"] .inventory-review-error, +body[data-theme="dark"] .inventory-scan-error, +body[data-theme="dark"] .inventory-scan-location-form [data-scan-location-error]:not([hidden]) {color:#ffb4a9} +body[data-theme="dark"] .inventory-review-success {color:#9bd5ae} +body[data-theme="dark"] .inventory-scan-page :focus-visible, +body[data-theme="dark"] .inventory-review-page :focus-visible, +body[data-theme="dark"] .inventory-staging :focus-visible {outline-color:#f2c16d} + /* Shared ring geometry: the outer lap stays complete beneath excess progress. */ .food-ring{position:relative;display:grid;place-items:center;background:none} .food-ring svg{display:block;width:100%;height:100%;transform:rotate(-90deg);overflow:visible} diff --git a/main/food/templates/food/inventory_overview.html b/main/food/templates/food/inventory_overview.html index aab0c66..0d9d7ec 100644 --- a/main/food/templates/food/inventory_overview.html +++ b/main/food/templates/food/inventory_overview.html @@ -1,8 +1,8 @@ {% extends 'planner/base.html' %}{% load static %} {% block title %}Kitchen Inventory · Tasknest{% endblock %} -{% block content %} +{% block content %}
What you have and where it lives.
Bulk scanner
Track background enrichment and finish products that need your input.
Bulk scanner
Track background enrichment and finish products that need your input.