From 92ffb679d671997675a9da9a36c5b2ca2d81ea74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cau=C3=AA=20Faleiros?= Date: Mon, 16 Nov 2026 10:37:44 -0300 Subject: [PATCH] =?UTF-8?q?fix:=20the=20review=20photo=20is=20measured=20b?= =?UTF-8?q?efore=20sending,=20and=20a=20drag=20to=20Finalizado=20without?= =?UTF-8?q?=20it=20opens=20Revis=C3=A3o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sentry DTF-WEB-C and DTF-WEB-B (order #24, 16/11): a review photo under 1600 px on its longer side was refused only after the upload (a 1280x720 webcam always is), and dragging the card to Finalizado without the photo got the server's 409. The dialog now says the minimum, the camera shot and a chosen photo are measured in the browser with the same message, and the drop opens Revisão instead of a refused move. Co-Authored-By: Claude Opus 5.5 (1M context) --- web/kanban-board.js | 7 +++++++ web/kanban-order.js | 27 +++++++++++++++++++++++---- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/web/kanban-board.js b/web/kanban-board.js index 7a8ccad..5b1589a 100644 --- a/web/kanban-board.js +++ b/web/kanban-board.js @@ -266,6 +266,13 @@ function renderBoard(){ const order=board.orders.find(o=>o.id===e.dataTransfer.getData('text/plain')); const machine=state==='imp'?laneAt(column,e.clientY):null;markLane(column,null); if(!order)return; + // Above 1 m Finalizado needs the review photo: the drop opens Revisão + // instead of a refused move (Sentry DTF-WEB-B). + if(state==='fin'&&order.state==='rev'&&needsReviewPhoto(order)){ + if(may('inspect')){say('Pedido acima de 1 m: tire a foto da revisão antes de finalizar.');reviewDialog(order);} + else say('Pedido acima de 1 m: falta a foto da revisão antes de finalizar.',true); + clearDrop();return; + } try{ if(order.state!==state)await (state==='imp'?pullTo(order,machine):move(order,state,'',machine)); else if(state!=='fin')await reorder(order,column,e.clientY); diff --git a/web/kanban-order.js b/web/kanban-order.js index d2e12b8..26876d9 100644 --- a/web/kanban-order.js +++ b/web/kanban-order.js @@ -374,8 +374,7 @@ function nextBox(order){ }else{ // Above 1 m the photo is required to finish (app/reviews.py): the main // button takes it instead of releasing the order. - const hasPhoto=(order.reviews||[]).some(review=>review.kind==='photo'); - if(!order.proof_parent&&orderMetres(order)>1&&!hasPhoto){ + if(needsReviewPhoto(order)){ title='Tire a foto da revisão'; note('Pedido acima de 1 m: tire a foto da revisão antes de finalizar.'); if(may('inspect'))main.push(button('Revisar',()=>reviewDialog(order),'btn pri lg'));else cannot(); @@ -595,6 +594,18 @@ function cardOpenAction(order){ // recorded. The server names it DTF--revisao- and keeps it 180 days. const REVIEW_VIDEO_MAX=30; const reviewClock=s=>Math.floor(s/60)+':'+String(s%60).padStart(2,'0'); +// Above 1 m the order finishes only with a review photo (app/reviews.py), of +// at least REVIEW_PHOTO_MIN px on its longer side so the footer can be read. +const REVIEW_PHOTO_MIN=1600; +const needsReviewPhoto=order=>!order.proof_parent&&orderMetres(order)>1&& + !(order.reviews||[]).some(review=>review.kind==='photo'); +const smallPhoto=(width,height)=>'A foto tem '+width+'×'+height+' px; a revisão precisa de pelo menos '+ + REVIEW_PHOTO_MIN+' px no lado maior para ler o rodapé.'; +// The photo's size, read in the browser before the upload (Sentry DTF-WEB-C). +async function photoSize(file){ + try{const bitmap=await createImageBitmap(file);const size=[bitmap.width,bitmap.height];bitmap.close?.();return size;} + catch(_){return null;} +} function reviewDialog(order){ const host=dialogHost(); const video=node('video');video.className='reviewcam';video.muted=true;video.playsInline=true;video.autoplay=true; @@ -659,6 +670,8 @@ function reviewDialog(order){ clear(); const width=video.videoWidth,height=video.videoHeight; if(!width||!height){fail('A câmera ainda não está pronta. Espere um instante.');return;} + if(Math.max(width,height){ @@ -704,7 +717,12 @@ function reviewDialog(order){ try{await checkDuration(file);}catch(error){input.value='';fail(error.message);return;} if(closed)return; showReady(file,'video'); - }else showReady(file,'photo'); + }else{ + const size=await photoSize(file); + if(closed)return; + if(size&&Math.max(...size){if(event.key==='Enter'||event.key===' '){event.preventDefault();input.click();}}; cancel.onclick=()=>m.close(); @@ -725,7 +743,8 @@ function reviewDialog(order){ } }; const m=modal('Revisão do #'+order.number,{host,width:640, - text:'Tire uma foto ou grave um vídeo de até 30 s da folha impressa, ou envie um arquivo.', + text:'Tire uma foto ou grave um vídeo de até 30 s da folha impressa, ou envie um arquivo. '+ + 'A foto precisa de pelo menos '+REVIEW_PHOTO_MIN+' px no lado maior.', body:[video,controls,timer,preview],foot:[status,cancel,save],onclose:cleanup}); (async()=>{ try{