Pannello visione operatore: zoom, overlay e Salva passano a <tmf-viewer>

Refs #122

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-28 21:58:18 +01:00
parent 43ef22079d
commit 815d49d699
7 changed files with 84 additions and 348 deletions
@@ -1,7 +1,7 @@
"""gitea:Adriano/TieMeasureFlow#96 - l'immagine del task visione sta in fit, senza scorrimento.
"""gitea:Adriano/TieMeasureFlow#96 #122 - l'immagine del task visione sta in fit, senza scorrimento.
Controllo sulle classi del template: pannello overflow-hidden, img/canvas
object-contain sovrapposti, nessun h-auto sull'immagine (era la causa dello scorrimento).
Controllo sulle classi del template: pannello overflow-hidden, riquadro flex-1 min-h-0 che contiene
<tmf-viewer> a tutta altezza (#122: zoom, img e overlay stanno dentro il componente).
"""
from pathlib import Path
@@ -37,28 +37,22 @@ def test_panel_does_not_scroll():
assert "overflow-auto" not in tag
def test_image_is_object_contain_without_h_auto():
def test_image_is_inside_tmf_viewer():
# #122: img, svg overlay, barra zoom e pan sono di <tmf-viewer>: il template non ha piu' img/svg/viewport propri
panel = _panel()
img = _tag_with(panel, 'x-ref="img"')
assert "object-contain" in img
assert "h-auto" not in img
# #121: l'overlay e' un svg (non piu' un canvas) con viewBox naturale e preserveAspectRatio="none":
# riempie il wrapper come l'img (che e' esattamente naturale x zoom), quindi resta allineato
overlay = _tag_with(panel, 'x-ref="overlay"')
assert overlay.startswith("<svg") and "<canvas" not in panel
assert 'preserveAspectRatio="none"' in overlay and "pointer-events-none" in overlay
assert "absolute" in overlay and "inset-0" in overlay and "w-full" in overlay and "h-full" in overlay
viewer = _tag_with(panel, "tmf-viewer class")
assert "block" in viewer and "w-full" in viewer and "h-full" in viewer
assert ':src="shownImage"' in viewer
assert "x-show" not in viewer # mai x-show e :style stringa sullo stesso elemento: x-show sta sul riquadro
assert 'x-ref="img"' not in panel and 'x-ref="overlay"' not in panel and "<canvas" not in panel
assert "<img" not in panel and "<svg" not in panel
def test_zoom_viewport_scrolls_inside_the_box():
# #115: il riquadro resta overflow-hidden (il pannello non scorre); lo scorrimento e' solo del viewport interno
def test_no_own_zoom_viewport_in_template():
# #122: niente piu' viewport/wrapper di zoom del pannello (#115): li fa il componente
panel = _panel()
vp = _tag_with(panel, 'x-ref="vp"')
assert "absolute" in vp and "inset-0" in vp
assert "overflow:auto" in vp # :style stringa del viewport
assert 'style="' not in vp.replace(':style="', "") # niente style statico accanto a :style (Alpine lo cancella)
assert "x-show" not in vp # mai x-show e :style stringa sullo stesso elemento
assert "zSize()" in panel # wrapper naturale x zoom
assert 'x-ref="vp"' not in panel
assert "zSize()" not in panel and "zoomBy(" not in panel and "zFit()" not in panel
def test_image_box_and_outcome_column_can_shrink():
@@ -77,12 +71,11 @@ def test_quote_table_shows_nominal_and_tolerances():
assert "text-measure-fail" in panel and "text-measure-warning" in panel
def test_overlay_script_loaded_before_vision_execute_and_labels_layer():
# #116: vision_overlay.js prima di vision_execute.js; strato etichette dentro il wrapper dello zoom, dopo l'svg
def test_overlay_script_loaded_before_vision_execute_and_viewer():
# #116 #122: vision_overlay.js prima di vision_execute.js; le etichette le disegna <tmf-viewer> (viewerLabels via x-effect)
src = TEMPLATE.read_text(encoding="utf-8")
assert src.index("js/vision_overlay.js") < src.index("js/vision_execute.js")
assert src.index("js/vision_overlay.js") < src.index("js/image_viewer.js")
panel = _panel()
assert panel.index('x-ref="overlay"') < panel.index('x-for="l in overlayLabels"')
label = _tag_with(panel, 'x-text="l.text"')
assert ':style="l.style"' in label and "pointer-events-none" in label
assert 'style="' not in label.replace(':style="', "") # niente style statico accanto a :style
assert "$el.labels = viewerLabels" in panel
assert 'x-for="l in overlayLabels"' not in panel