feat: "Enviar nova versão" keeps each item's current final, ticked, so only the corrected file is sent (Marcus, 2026-11-26, #105)
Some checks failed
Build and deploy / Validate source (push) Successful in 6s
Build and deploy / Publish images (push) Has been cancelled
Build and deploy / Secret scan and release gate (push) Has been cancelled
Build and deploy / Integration suite on a real stack (push) Has been cancelled

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Cauê Faleiros
2026-11-27 09:55:53 -03:00
parent 5dc4135562
commit 47f3251d3e

View File

@@ -571,7 +571,7 @@ function finalDialog(order,ready,{replace=false}={}){
if(file){
const use=node('input');use.checked=true;use.dataset.useGenerated=index;input.required=false;drop.hidden=true;
use.onchange=()=>{drop.hidden=use.checked;input.required=!use.checked;};
slot.append(checkbox('Usar: '+file.label,use));input.generated=()=>use.checked?file.files.map(f=>f.upload_id):null;
slot.append(checkbox(file.text||'Usar: '+file.label,use));input.generated=()=>use.checked?file.files.map(f=>f.upload_id):null;
}
slot.append(drop);fields.push(slot);return input;
});
@@ -1129,6 +1129,16 @@ 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;}
// 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)=>{
const files=revisions.filter(f=>f.kind==='final'&&f.active&&!f.expired&&f.item_index===index)
.map(f=>({upload_id:f.upload_id,name:f.name}));
if(!files.length)return null;
const names=files.length>1?files.length+' partes':files[0].name;
return {files,name:files[0].name,source:'final',label:names,text:'Manter o arquivo atual ('+names+')'};
});
}
// Arquivos: every final, current or replaced, and the way to send a new one.
function filesView(order,revisions,view){
const out=[];
@@ -1158,7 +1168,9 @@ function filesView(order,revisions,view){
// Replacing an approved final, while the art is still in Arte recebida or Correção;
// in Arte conferida, the queue, the order goes back to Arte recebida first.
if(may('produce')&&['rec','cor'].includes(order.state)&&finalDone(order)&&!order.cancelled_at&&!order.proof_parent){
const open=button('Enviar nova versão',async()=>finalDialog(order,readyFinals(order).map(()=>null),{replace:true}),'btn');
// Only the item that changed is sent: each other item keeps its current
// final, ticked (Marcus, 2026-11-26, #105).
const open=button('Enviar nova versão',async()=>finalDialog(order,currentFinals(order,revisions),{replace:true}),'btn');
open.prepend(svgIcon(IC.upload,'i m'));open.classList.add('self-start');out.push(open);
}
view.replaceChildren(...out);