fix: separate recipe preview image from task images

Recipe image_path is now used as preview thumbnail only. Removed
auto-creation of "Technical Drawing" task from recipe upload, and
removed recipe image strip from task_execute view. Each task displays
its own file_path independently.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Adriano
2026-02-20 18:29:27 +01:00
parent 22804a609d
commit dbfb5591c5
5 changed files with 6 additions and 38 deletions
-6
View File
@@ -124,21 +124,15 @@ def task_execute(task_id: int):
# Load all task IDs for this recipe (ordered) for auto-advance
recipe_id = task_resp.get("recipe_id")
all_task_ids = []
recipe_resp = {}
if recipe_id:
tasks_resp = api_client.get(f"/api/recipes/{recipe_id}/tasks")
if isinstance(tasks_resp, list):
sorted_tasks = sorted(tasks_resp, key=lambda t: t.get("order_index", 0))
all_task_ids = [t["id"] for t in sorted_tasks]
# Fetch recipe for image_path
resp = api_client.get(f"/api/recipes/{recipe_id}")
if not (isinstance(resp, dict) and resp.get("error")):
recipe_resp = resp
return render_template(
"measure/task_execute.html",
task=task_resp,
recipe=recipe_resp,
lot_number=lot_number,
serial_number=serial_number,
all_task_ids=all_task_ids,
+4 -4
View File
@@ -438,8 +438,8 @@ function recipeEditor() {
versions: {{ (recipe.versions if recipe and recipe.versions else [])|tojson }},
currentVersion: {{ (recipe.current_version.version_number if recipe and recipe.current_version else 0)|tojson }},
// ---- File upload (thumbnail) ----
currentFilePath: {{ (recipe.current_version.tasks[0].file_path if recipe and recipe.current_version and recipe.current_version.tasks and recipe.current_version.tasks|length > 0 and recipe.current_version.tasks[0].file_path else '')|tojson }},
// ---- File upload (preview image) ----
currentFilePath: {{ (recipe.image_path if recipe and recipe.image_path else '')|tojson }},
uploadingFile: false,
dragOver: false,
@@ -459,9 +459,9 @@ function recipeEditor() {
description: this.description.trim(),
};
// Include file_path for thumbnail
// Include image_path for preview thumbnail
if (this.currentFilePath) {
payload.file_path = this.currentFilePath;
payload.image_path = this.currentFilePath;
}
// Include change notes if editing
+2 -2
View File
@@ -153,9 +153,9 @@
<!-- Card Header -->
<div class="flex flex-col sm:flex-row sm:items-start gap-4 mb-4">
<!-- Thumbnail -->
<template x-if="recipe.current_version && recipe.current_version.tasks && recipe.current_version.tasks.find(t => t.file_path && t.file_type === 'image')">
<template x-if="recipe.image_path">
<div class="w-20 h-20 rounded-lg overflow-hidden bg-[var(--bg-secondary)] border border-[var(--border-color)] shrink-0">
<img :src="'/maker/api/files/' + recipe.current_version.tasks.find(t => t.file_path && t.file_type === 'image').file_path"
<img :src="'/maker/api/files/' + recipe.image_path"
class="w-full h-full object-cover"
loading="lazy"
onerror="this.parentElement.style.display='none'">
@@ -55,7 +55,6 @@
window.__taskSubtasks = {{ task.subtasks|tojson if task.subtasks else '[]' }};
window.__taskAnnotations = {{ task.annotations_json|default('null')|tojson }};
window.__allTaskIds = {{ all_task_ids|tojson }};
window.__recipeImagePath = {{ (recipe.image_path or '')|tojson }};
</script>
<div class="h-screen flex flex-col overflow-hidden"
@@ -173,13 +172,6 @@
────────────────────────────────────────────── #}
<div class="flex-1 flex flex-col overflow-hidden bg-[var(--bg-secondary)]">
{# Recipe image strip (small, top, optional) #}
<div x-show="recipeImagePath" class="shrink-0 bg-[var(--bg-card)] border-b border-[var(--border-color)] px-2 py-1 flex items-center justify-center">
<img :src="'/measure/api/files/' + recipeImagePath"
alt="{{ _('Immagine ricetta') }}"
class="max-h-20 object-contain rounded">
</div>
{# Main image area #}
<div class="flex-1 overflow-hidden relative">
@@ -490,8 +482,6 @@ function taskExecute() {
subtasks: window.__taskSubtasks,
lotNumber: '{{ lot_number or '' }}',
serialNumber: '{{ serial_number or '' }}',
recipeImagePath: window.__recipeImagePath || '',
// ---- Measurement state ----
currentIndex: 0,
measurements: [], // [{subtask_id, value, pass_fail, deviation}, ...]
-16
View File
@@ -149,22 +149,6 @@ async def create_recipe(
db.add(version)
await db.flush()
# Create initial task with technical drawing if file was uploaded
if data.file_path:
initial_task = RecipeTask(
version_id=version.id,
order_index=0,
title="Technical Drawing",
file_path=data.file_path,
file_type=data.file_type or (
"pdf" if data.file_path.lower().endswith(".pdf")
else "image"
),
annotations_json=data.annotations_json,
)
db.add(initial_task)
await db.flush()
await _write_audit(
db,
recipe_id=recipe.id,