fix: a proof card shows the film it prints, the Kanban's tooltips stay whole on screen, and a session that changed is a warning (DTF-WEB-26)

A proof card bills 0 m: the board now carries proof_film_cm per item (the
same measure as Números), the card reads 'prova · 0,15 m', the column
totals count it, and the drawer says 'prova sem custo', the proof's film
and 'Folha do pedido'. The [data-tip] tooltips were CSS boxes inside the
card, cut by the column and over the card below; one box fixed to the
window now sits under the element, or over it near the bottom, inside the
screen. 'Sua conta ou sessão mudou' is guidance shown as a warning, so it
stays out of Sentry.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Cauê Faleiros
2026-11-30 16:45:59 -03:00
parent 1a35dea7a5
commit 885d211ae2
6 changed files with 52 additions and 16 deletions

View File

@@ -519,7 +519,10 @@
$('bPagar').disabled = true;
try {
await ready;
if((await api('/session')).cart_scope !== (await ready).cart_scope) throw new Error('Sua conta ou sessão mudou. Recarregue a página antes de enviar o carrinho.');
// Guidance, not a fault: the customer signed in or out in another tab
// (DTF-WEB-26); a warning, so it stays out of Sentry.
if((await api('/session')).cart_scope !== (await ready).cart_scope){
const changed=new Error('Sua conta ou sessão mudou. Recarregue a página antes de enviar o carrinho.');changed.guidance=true;throw changed;}
const items=[];
pintaEnvio();
// Loose art split by stroke (item 17) is one cart line and one order item
@@ -591,7 +594,7 @@
quotedCart=initialCart;localStorage.setItem('dtf-quote-cart',quotedCart);
draftId=quote.id; localStorage.setItem('dtf-quote',draftId);
await refresh(true);
} catch(error) { message(error.message,couponRefusal(error.status,error.message)?'warn':'error'); }
} catch(error) { message(error.message,error.guidance||couponRefusal(error.status,error.message)?'warn':'error'); }
finally { busy=false; pintaEntrega(); }
};
// `go`: the customer asked to pay, so the cart page moves to the payment page.

View File

@@ -212,7 +212,10 @@ const GLYPH={
cor:'M232,144a64.07,64.07,0,0,1-64,64H80a8,8,0,0,1,0-16h88a48,48,0,0,0,0-96H51.31l34.35,34.34a8,8,0,0,1-11.32,11.32l-48-48a8,8,0,0,1,0-11.32l48-48A8,8,0,0,1,85.66,45.66L51.31,80H168A64.07,64.07,0,0,1,232,144Z',
rev:'M247.31,124.76c-.35-.79-8.82-19.58-27.65-38.41C194.57,61.26,162.88,48,128,48S61.43,61.26,36.34,86.35C17.51,105.18,9,124,8.69,124.76a8,8,0,0,0,0,6.5c.35.79,8.82,19.57,27.65,38.4C61.43,194.74,93.12,208,128,208s66.57-13.26,91.66-38.34c18.83-18.83,27.3-37.61,27.65-38.4A8,8,0,0,0,247.31,124.76ZM128,192c-30.78,0-57.67-11.19-79.93-33.25A133.47,133.47,0,0,1,25,128,133.33,133.33,0,0,1,48.07,97.25C70.33,75.19,97.22,64,128,64s57.67,11.19,79.93,33.25A133.46,133.46,0,0,1,231.05,128C223.84,141.46,192.43,192,128,192Zm0-112a48,48,0,1,0,48,48A48.05,48.05,0,0,0,128,80Zm0,80a32,32,0,1,1,32-32A32,32,0,0,1,128,160Z',
fin:'M173.66,98.34a8,8,0,0,1,0,11.32l-56,56a8,8,0,0,1-11.32,0l-24-24a8,8,0,0,1,11.32-11.32L112,148.69l50.34-50.35A8,8,0,0,1,173.66,98.34ZM232,128A104,104,0,1,1,128,24,104.11,104.11,0,0,1,232,128Zm-16,0a88,88,0,1,0-88,88A88.1,88.1,0,0,0,216,128Z'};
const orderMetres=o=>o.snapshot.items.reduce((t,i)=>t+Number(i.billed_metres),0);
// The film an order takes: what is billed, or, for a free proof card, the film
// its sheets print (proof_film_cm, from the server).
const proofFilmMetres=o=>Object.values(o.proof_film_cm||{}).reduce((t,cm)=>t+Number(cm),0)/100;
const orderMetres=o=>o.snapshot.proof_of?proofFilmMetres(o):o.snapshot.items.reduce((t,i)=>t+Number(i.billed_metres),0);
// On a phone the board shows one stage at a time, picked from the chips above it.
let phoneCol='rec';
// Atrasados (front 11): the cards past the stage limit, with the person
@@ -523,7 +526,7 @@ function card(order,place){
if(special){const tag=node('span',special,'origin');tag.title=special;meta.append(tag);}
if(s.items.some(i=>i.mode==='premium'))meta.append(badge('Premium','','DTF Têxtil Premium: 8 passadas, branco no máximo'));
if(order.machine){const m=node('span',order.machine.name,'mach'+(mine?' mine':''));m.title=mine?'Sua máquina':'Máquina';meta.append(m);}
meta.append(node('b',metres(orderMetres(order)),'mtr'));
meta.append(node('b',(order.snapshot.proof_of?'prova · ':'')+metres(orderMetres(order)),'mtr'));
info.append(row,name,meta);
const art=artBox(s.items,'thumb');top.append(art,info);
c.append(top);

View File

@@ -1112,12 +1112,15 @@ function itemCard(order,item,index){
info.append(node('h3',productName(item)));
const dl=node('dl',undefined,'dl');
const pair=(k,v)=>{if(v===null||v===undefined||v==='')return;const d=node('div');const dd=node('dd');dd.append(v);d.append(node('dt',k),dd);dl.append(d);};
pair('Metros cobrados',metres(item.billed_metres));
const proof=!!order.snapshot.proof_of, proofCm=Number(order.proof_film_cm?.[String(index)]||0);
pair('Metros cobrados',metres(item.billed_metres)+(proof?' · prova sem custo':''));
// A proof prints a stretch of the order's sheet, not the whole of it.
pair('Filme da prova',proof&&proofCm?metres(proofCm/100):null);
pair('Valor do metro',item.unit_cents?money(item.unit_cents)+manualExtra(item):null);
const g=node('span',undefined,'gradeline');g.append(gradePill(item.grade));pair('Nota da arte',g);
pair('Contração',contractionControl(order,index));
pair('Folha',sheetSize(spec));
pair('Peças',spec?String(spec.placements.length):null);
pair(proof?'Folha do pedido':'Folha',sheetSize(spec));
pair('Peças',spec&&!proof?String(spec.placements.length):null);
pair('Menor resolução',row?.status==='ready'&&row.detail?.min_dpi?row.detail.min_dpi+' DPI':null);
pair('Arquivos',spec&&spec.sources.length>1?String(spec.sources.length):null);
info.append(dl);

View File

@@ -385,14 +385,9 @@ main{padding:0}
.card.drop-before{box-shadow:0 -3px 0 0 var(--acc)}
.card.drop-after{box-shadow:0 3px 0 0 var(--acc)}
/* A short note on hover or focus, for what a mark means. */
[data-tip]{position:relative}
[data-tip]::after{content:attr(data-tip);position:absolute;left:50%;top:calc(100% + 8px);transform:translate(-50%,-3px);width:max-content;max-width:280px;padding:7px 10px;border-radius:7px;background:var(--ink);color:var(--onink);font:500 12px/1.4 var(--font);letter-spacing:0;text-align:left;white-space:normal;text-transform:none;opacity:0;pointer-events:none;z-index:40;transition:opacity .15s,transform .15s;box-shadow:0 8px 24px -8px rgba(0,0,0,.5)}
[data-tip]:hover::after,[data-tip]:focus-visible::after{opacity:1;transform:translate(-50%,0);transition-delay:.35s}
[data-tip].tip-l::after{left:auto;right:0;transform:translate(0,-3px)}
[data-tip].tip-l:hover::after,[data-tip].tip-l:focus-visible::after{transform:translate(0,0)}
[data-tip].tip-r::after{left:0;transform:translate(0,-3px)}
[data-tip].tip-r:hover::after{transform:translate(0,0)}
[data-tip='']::after{display:none}
/* The tooltip box (kanban.js): fixed to the window, never cut by a column. */
.tipbox{position:fixed;z-index:200;max-width:min(320px,calc(100vw - 16px));padding:7px 10px;border-radius:7px;background:var(--ink);color:var(--onink);font:500 12px/1.4 var(--font);text-align:left;white-space:normal;pointer-events:none;box-shadow:0 8px 24px -8px rgba(0,0,0,.5)}
.tipbox[hidden]{display:none}
@keyframes drop{from{transform:translateY(-6px);opacity:0}}
@keyframes spin{to{transform:rotate(360deg)}}
@keyframes feedline{from{transform:translateX(-100%)}to{transform:translateX(100%)}}

View File

@@ -1207,5 +1207,30 @@ function paintSync(){
$('sync').onclick=e=>{e.stopPropagation();const m=$('sync-menu');m.hidden=!m.hidden;$('sync').setAttribute('aria-expanded',String(!m.hidden));
if(!m.hidden)document.addEventListener('click',()=>{m.hidden=true;$('sync').setAttribute('aria-expanded','false');},{once:true});};
$('refresh').addEventListener('click',()=>{$('sync-menu').hidden=true;});
// Tooltips ([data-tip]): one box on the page itself, fixed to the window, so
// a card's column never cuts it and it never covers the card below; it sits
// under the element, or over it near the bottom, always inside the screen.
(()=>{
const box=node('div',undefined,'tipbox');box.setAttribute('role','tooltip');box.hidden=true;document.body.append(box);
let target=null,timer=null;
const hide=()=>{clearTimeout(timer);timer=null;target=null;box.hidden=true;};
const place=el=>{
box.textContent=el.dataset.tip;box.hidden=false;
const r=el.getBoundingClientRect(),b=box.getBoundingClientRect(),gap=8,edge=8;
let top=r.bottom+gap;
if(top+b.height>innerHeight-edge&&r.top-gap-b.height>=edge)top=r.top-gap-b.height;
const left=Math.min(Math.max(edge,r.left+r.width/2-b.width/2),innerWidth-edge-b.width);
box.style.top=Math.round(top)+'px';box.style.left=Math.round(left)+'px';
};
const show=el=>{
if(!el||!el.dataset.tip||el===target)return;
clearTimeout(timer);target=el;timer=setTimeout(()=>{if(target===el&&el.isConnected)place(el);},350);
};
document.addEventListener('mouseover',e=>{const el=e.target.closest?.('[data-tip]');if(el)show(el);else if(target)hide();});
document.addEventListener('focusin',e=>{const el=e.target.closest?.('[data-tip]');if(el)show(el);});
document.addEventListener('focusout',hide);
addEventListener('scroll',hide,true);
addEventListener('keydown',e=>{if(e.key==='Escape')hide();});
})();
// The tabs live in later files: wait for all scripts before loading.
addEventListener('DOMContentLoaded',()=>restoreFolder().finally(()=>load()));