feat: a reprint sends only the items chosen to the machine (Marcus, 2026-11-26, #105)
All checks were successful
Build and deploy / Validate source (push) Successful in 11s
Build and deploy / Integration suite on a real stack (push) Successful in 7m55s
Build and deploy / Secret scan and release gate (push) Successful in 6s
Build and deploy / Publish images (push) Successful in 1m34s

An order the machine already printed, back in Arte conferida, sends again
only the items whose final changed since the machine took them; the panel's
"Vai para a máquina" shows and changes the choice, and the card says
"Reimpressão". The order stays one card. The pass to Revisão keeps the
items printed, so the machine's metres count only those.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Cauê Faleiros
2026-11-27 10:00:54 -03:00
parent 47f3251d3e
commit b8496b858f
11 changed files with 165 additions and 14 deletions

View File

@@ -426,6 +426,8 @@ function cardFlags(order){
if(live&&s.items.some(i=>i.quality_status==='warning'))out.push(['warn','Nota '+(lowestGrade(s.items)??'baixa'),'Nota da arte baixa: o cliente aceitou a ressalva de resolução']);
const dots=s.items.reduce((t,i)=>t+(i.residue_accepted||0),0);
if(live&&dots)out.push(['warn','Resíduo','O cliente aceitou imprimir com '+residueNote({residue_accepted:dots})]);
// A reprint: only some items go to the machine again (#105).
if(live&&order.print_items?.length)out.push(['warn','Reimpressão','Vão para a máquina só: '+order.print_items.map(i=>'item '+(i+1)).join(', ')]);
// A ready sheet with pieces closer than 5 mm (Marcus, 2026-11-26, #81).
const close=s.items.reduce((t,i)=>t+(i.close_pieces||0),0);
if(live&&close)out.push(['warn','Peças coladas',closeNote(close)]);

View File

@@ -317,6 +317,9 @@ function nextBox(order){
const b=button('Prova OK',()=>proofOk(order),className);b.dataset.proof='';b.title='A prova foi impressa e conferida';return b;};
const cannot=()=>note(!mayAct(order)?'Pedido da '+(order.machine?.name||'outra máquina')+': só quem está nela move o card.'
:st==='rev'?'A folha impressa é conferida e liberada pelo Revisor.':'Daqui em diante, com a produção.');
// An order the machine already printed: which items go again (#105).
if(['rec','tra','cor'].includes(st)&&order.printed_before&&!order.cancelled_at&&order.snapshot.items.length>1)
body.push(reprintChoice(order));
// The proof was rejected: its reason, and a new proof card when the art is fixed.
if(st==='rec'&&proofRejected(order)){
const p=node('p',undefined,'nnote');p.append(node('b','Prova reprovada: '),order.proof_card.proof_reason);body.push(p);
@@ -1129,6 +1132,30 @@ function itemCard(order,item,index){
}
// A disclosure's summary: the chevron turns when it opens.
function discSummary(text){const s=node('summary');s.append(svgIcon(IC.right,'i s'),node('span',text));return s;}
// "Vai para a máquina" (Marcus, 2026-11-26, #105): the order was printed
// before, so only the items ticked go again. Ticked at first: the choice
// saved, or the items whose final changed since the machine took them.
function reprintChoice(order){
const box=node('div',undefined,'fld');box.append(node('span','Vai para a máquina'));
const chosen=new Set(order.print_items||order.print_suggested||order.snapshot.items.map((_,i)=>i));
const boxes=order.snapshot.items.map((item,index)=>{
const input=node('input');input.checked=chosen.has(index);input.disabled=!may('produce');
box.append(checkbox('Item '+(index+1)+', '+productName(item),input));return input;
});
box.append(node('small',order.print_items?'Só os itens marcados vão para a máquina.'
:order.print_suggested?'Marcados os itens cujo arquivo mudou desde a última impressão.'
:'O pedido já foi impresso: marque só os itens que precisam sair de novo.'));
if(may('produce')){
const save=button('Salvar itens',async()=>{
const items=boxes.map((b,i)=>b.checked?i:null).filter(i=>i!==null);
if(!items.length){say('Marque pelo menos um item para a máquina.');return;}
await api('/orders/'+order.id+'/print-items',{items});await load();
say(items.length===boxes.length?'Todos os itens vão para a máquina.':'Vão para a máquina: '+items.map(i=>'item '+(i+1)).join(', ')+'.');
},'btn');
save.classList.add('self-start');box.append(save);
}
return box;
}
// Each item's current final (one file, or a film's parts), to keep as it is.
function currentFinals(order,revisions){
return order.snapshot.items.map((_,index)=>{