feat: stroke class, residue per artwork, mixed strokes, sheets split by class
All checks were successful
Build and deploy / Validate source (push) Successful in 1m25s
Build and deploy / Integration suite on a real stack (push) Successful in 4m40s
Build and deploy / Secret scan and release gate (push) Successful in 12s
Build and deploy / Publish images (push) Successful in 1m38s

Round 3, items 9, 4, 16 and 17 (Dropstar, 2026-10-30).

- 9: the Site measures the thinnest stroke of each sheet and loose artwork
  (alpha > 40, chamfer distance in strips, width at local maxima, 1st
  percentile, at 300 DPI) and sends stroke_px and C1/C2/C3 with the item.
  The Kanban shows the class prefilled in the approve step; Produção may
  change it (POST /orders/{id}/contraction, who and when recorded), and the
  manifest carries it.
- 4: the residue check runs on each loose artwork, accepted per artwork; the
  sheet inherits what was accepted.
- 16: fine lines and solid areas in one file. Loose art: a pop-up with
  [Subir separado] [Continuar assim]. Ready sheet: protect the fine lines
  (default), protect the solid areas (stroke_choice client_c3, starts at C3)
  or go back and send two sheets, which holds the order.
- 17: loose art of fine (C1, C2) and solid (C3) strokes goes on separate
  sheets, each its own order item (split group/part/of) with its own file
  and class. Each sheet rounds to 10 cm and the 1 m minimum is charged once
  per group, since the customer did not choose the split. Cart, payment
  summary, portal, receipt and mail show it as such.
- The board loads quote views in two queries instead of two per quote.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Cauê Faleiros
2026-11-03 10:24:29 -03:00
parent 388408d4d6
commit 2615163fd3
23 changed files with 547 additions and 57 deletions

View File

@@ -11,6 +11,9 @@ const FLOW=['rec','tra','imp','rev','fin'];
const FORMER_STATES={fil:'Fila de impressão'};
const stateName=s=>board.states[s]||FORMER_STATES[s]||s;
const PRODUCT={file:'DTF Têxtil · folha montada',avulsa:'DTF Têxtil · artes avulsas',uvfile:'DTF UV · folha montada',uv:'DTF UV · artes avulsas'};
// Loose art the Site split by stroke (item 17): each sheet is an item of its own.
const productName=item=>PRODUCT[item.mode]+(item.split?' · folha '+item.split.part+' de '+item.split.of+
', '+(item.stroke_class==='C3'?'chapado':'traço fino'):'');
const SHORT={file:'Têxtil folha',avulsa:'Têxtil avulsa',uvfile:'UV folha',uv:'UV avulsa'};
const EVENTS={payment_approved:'Pagamento aprovado',production_started:'Produção iniciada',correction_needed:'Correção necessária',ready:'Pedido pronto',cancelled:'Pedido cancelado'};
const LATE_HOURS=4;
@@ -517,7 +520,15 @@ async function downloadQueue(){
await new Promise(r=>setTimeout(r,700));
}
}
function manifest(production){
// What the manifest says about contraction: the class to print with, what the
// Site measured, the customer's choice on a mixed sheet and who changed it.
function contractionRecord(item,chosen){
if(!item.stroke_class&&!chosen)return null;
return {class:chosen?.class||measuredClass(item),measured_class:item.stroke_class||null,measured_px:item.stroke_px||null,
customer_choice:item.stroke_choice||null,chosen_by:chosen?.by||null};
}
function manifest(production,contraction=null){
if(contraction)production={...production,contraction};
const url=URL.createObjectURL(new Blob([JSON.stringify(production,null,2)],{type:'application/json'}));
const link=node('a');link.href=url;link.download='dtf-layout-'+production.sources[0].upload_id.slice(0,8)+'.json';
link.click();setTimeout(()=>URL.revokeObjectURL(url),1000);
@@ -1382,6 +1393,38 @@ function fileRow(name,label,...actions){
const downloadFile=uid=>downloadButton('Baixar',download(uid),'btn');
// The approved final is the way to the queue (Arte conferida): approving it,
// with the files that would be printed, or sending one.
// The contraction class of an item (item 9): the one chosen, else the one the
// browser measured. The FlexiPRINT applies it by the C1, C2 or C3 folder.
const CLASS_NOTE={C1:'traço até 4 px',C2:'traço de 5 a 19 px',C3:'traço de 20 px ou mais'};
// A mixed sheet (item 16) where the customer chose to protect the solid areas starts at C3.
const measuredClass=item=>item.stroke_choice==='client_c3'?'C3':item.stroke_class||null;
const contractionOf=(order,index)=>order.contraction?.[index]?.class||measuredClass(order.snapshot.items[index]);
function contractionControl(order,index){
const item=order.snapshot.items[index], now=contractionOf(order,index), chosen=order.contraction?.[index];
const measured=(item.stroke_class?'medido '+item.stroke_class+', '+item.stroke_px+' px':'sem medida do navegador')+
(item.stroke_choice==='client_c3'?'; o cliente escolheu proteger as áreas chapadas (C3)':'');
const editable=may('produce')&&!order.cancelled_at&&['rec','tra','cor'].includes(order.state);
if(!editable){const t=node('span',now?now+' ('+(chosen?'escolhida':measured)+')':'Sem classe');return t;}
const select=node('select',undefined,'inp sm');select.setAttribute('aria-label','Contração do item '+(index+1));
for(const [value,text] of [['','Escolha'],['C1','C1, '+CLASS_NOTE.C1],['C2','C2, '+CLASS_NOTE.C2],['C3','C3, '+CLASS_NOTE.C3]]){
const o=node('option',text);o.value=value;select.append(o);}
select.value=now||'';
select.onchange=async()=>{try{
await api('/orders/'+order.id+'/contraction',{item_index:index,value:select.value||null});
say('Contração do item '+(index+1)+': '+(select.value||'a medida do navegador')+'.');await load();}
catch(e){say(e.message,true);}};
const box=node('span',undefined,'contr');box.append(select,node('small',chosen?'escolhida por '+chosen.by+'; '+measured:measured,'sub'));
return box;
}
// The approve step's "Está OK?": each item's class, prefilled, to confirm or change.
function contractionList(order){
const box=node('div',undefined,'contrlist');
order.snapshot.items.forEach((item,index)=>{
const row=node('div',undefined,'contrrow');
row.append(node('span',order.snapshot.items.length>1?'Item '+(index+1)+', contração':'Contração','lbl'),contractionControl(order,index));
box.append(row);});
return box;
}
function approveParts(order,main=true){
const ready=readyFinals(order), all=ready.every(Boolean), many=ready.length>1;
const files=node('div',undefined,'files');
@@ -1430,7 +1473,7 @@ function nextBox(order){
if(!finalDone(order)&&trans.includes('tra')){
const lead=st==='rec'||fixed, a=approveParts(order,lead);
if(st==='rec')title='Aprovar o arquivo final';
if(lead){if(a.files)body.push(a.files);note(a.text);main.push(a.approve,...a.extra);}
if(lead){if(a.files)body.push(a.files);note(a.text);body.push(contractionList(order));main.push(a.approve,...a.extra);}
else more.push(a.approve,...a.extra);
}else if(st==='rec'){
title='Mandar para a fila';
@@ -1575,7 +1618,7 @@ function finalDialog(order,ready,{replace=false}={}){
const fields=[];
const inputs=order.snapshot.items.map((item,index)=>{
const slot=node('div',undefined,'fslot');
const label=order.snapshot.items.length>1?'Item '+(index+1)+', '+PRODUCT[item.mode]:PRODUCT[item.mode];
const label=order.snapshot.items.length>1?'Item '+(index+1)+', '+productName(item):productName(item);
slot.append(node('span',label,'lbl'));
const input=node('input');input.multiple=true;input.required=true;input.dataset.finalItem=index;
input.setAttribute('aria-label','Arquivo final, '+label);
@@ -1624,7 +1667,7 @@ function treatDialog(order){
const line=node('div',undefined,'treatline');line.append(path,copy);
const input=node('input');input.dataset.treatItem=index;
input.setAttribute('aria-label','Arte tratada do item '+(index+1));
slot.append(node('span',order.snapshot.items.length>1?'Item '+(index+1)+', '+PRODUCT[item.mode]:PRODUCT[item.mode],'lbl'),line,
slot.append(node('span',order.snapshot.items.length>1?'Item '+(index+1)+', '+productName(item):productName(item),'lbl'),line,
dropField(input,{title:'Arte tratada',hint:'O arquivo salvo depois de tratar.'}));
return {path,copy,input};
});
@@ -1724,7 +1767,7 @@ function itemCard(order,item,index){
const box=node('section',undefined,'item');box.setAttribute('aria-label','Item '+(index+1));
const info=node('div',undefined,'iinfo');
const count=order.snapshot.items.length;
info.append(node('span',count>1?'Item '+(index+1)+' de '+count:'Item','lbl'),node('h3',PRODUCT[item.mode]));
info.append(node('span',count>1?'Item '+(index+1)+' de '+count:'Item','lbl'),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('Folha',sheetSize(spec));pair('Metros cobrados',metres(item.billed_metres));
@@ -1733,10 +1776,13 @@ function itemCard(order,item,index){
const g=node('span',undefined,'gradeline');g.append(gradePill(item.grade));pair('Nota da arte',g);
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);
pair('Contração',contractionControl(order,index));
info.append(dl);
const notes=node('div',undefined,'inotes');
if(item.quality_status==='warning')notes.append(itemNote('O cliente aceitou a ressalva de resolução.','warn'));
if(item.residue_accepted)notes.append(itemNote('Resíduo aceito pelo cliente: '+residueNote(item)+'.','warn'));
if(item.stroke_choice)notes.append(itemNote('Traços finos e áreas chapadas na mesma folha: o cliente escolheu proteger '+
(item.stroke_choice==='client_c3'?'as áreas chapadas (C3); o traço fino pode sumir em tecido escuro.':'os traços finos.'),'warn'));
if(mirroredItem(item))notes.append(itemNote(MIRROR_NOTE+'.','bad'));
// After a customer correction, that file is the artwork: the generated
// print file, or the reason it could not be made, no longer applies.
@@ -1763,7 +1809,7 @@ function itemCard(order,item,index){
if(fix&&!fix.expired)links.append(dl_('Correção',fix.upload_id));
else if(row?.status==='ready'&&row.detail?.source!=='original')links.append(dl_('PDF',row.upload_id));
item.uploads.forEach((uid,i)=>links.append(dl_(item.uploads.length>1?'Original '+(i+1):'Arquivo original',uid)));
if(spec?.placements){const m=button('Manifesto',()=>manifest(spec),'btn');m.prepend(svgIcon(IC.file,'i m'));links.append(m);}
if(spec?.placements){const m=button('Manifesto',()=>manifest(spec,contractionRecord(item,order.contraction?.[index])),'btn');m.prepend(svgIcon(IC.file,'i m'));links.append(m);}
if(may('produce')&&!fix&&['rec','tra'].includes(order.state)&&(!row||row.status==='manual'||row.status==='failed')){
const again=button('Gerar de novo',async()=>{await api('/orders/'+order.id+'/print-files',{});await load();},'btn');again.prepend(svgIcon(IC.refresh,'i m'));links.append(again);}
info.append(links);
@@ -2583,7 +2629,7 @@ function quoteItem(item,fields,priced,index=0,count=1){
tall.append(itemPreview(item));
const info=node('div',undefined,'iinfo');
const spec=item.production;
info.append(node('span',count>1?'Item '+(index+1)+' de '+count:'Item','lbl'),node('h3',PRODUCT[item.mode]));
info.append(node('span',count>1?'Item '+(index+1)+' de '+count:'Item','lbl'),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('Folha',sheetSize(spec));pair('Peças',spec?String(spec.placements.length):null);
@@ -2610,7 +2656,7 @@ function quoteItem(item,fields,priced,index=0,count=1){
}
const links=node('div',undefined,'links');
item.uploads.forEach((uid,i)=>links.append(downloadButton(item.uploads.length>1?'Original '+(i+1):'Arquivo original',download(uid),'btn')));
if(spec?.placements){const b=button('Manifesto',()=>manifest(spec),'btn');b.prepend(svgIcon(IC.file,'i m'));links.append(b);}
if(spec?.placements){const b=button('Manifesto',()=>manifest(spec,contractionRecord(item)),'btn');b.prepend(svgIcon(IC.file,'i m'));links.append(b);}
info.append(links);box.append(tall,info);return box;
}
@@ -2804,7 +2850,7 @@ function paymentDialog(issue){
['Entrega',dest?dest.recipient+', '+dest.street+', '+dest.number+', '+dest.city+'/'+dest.state+', CEP '+dest.postal_code:'Retirada em Franca']]));
const items=q.draft.items;
const list=node('div',undefined,'mlist');
items.forEach(i=>{const r=node('div',undefined,'mli');r.append(artBox([i],'qthumb rart'),node('span',PRODUCT[i.mode],'grow'),node('b',metres(i.billed_metres||i.metres)));list.append(r);});
items.forEach(i=>{const r=node('div',undefined,'mli');r.append(artBox([i],'qthumb rart'),node('span',productName(i),'grow'),node('b',metres(i.billed_metres||i.metres)));list.append(r);});
body.push(node('h4','O que estava comprando','sh'),list,rows([['Cotação',node('span',String(q.id).slice(0,8),'code')],['Feita em',when(q.created_at)],
['Aprovada em',q.approved_at?when(q.approved_at):'ainda não aprovada'],['Total da cotação',q.total_cents!=null?money(q.total_cents):'']]));
}else body.push(node('p','O pagamento não aponta para uma cotação conhecida: confira pelo id no Mercado Pago.','nnote'));