feat: "Tratar a arte" on an order in Arte recebida (Dropstar's third round, item 8)
All checks were successful
Build and deploy / Integration suite on a real stack (push) Successful in 3m36s
Build and deploy / Secret scan and release gate (push) Successful in 8s
Build and deploy / Publish images (push) Successful in 59s
Build and deploy / Validate source (push) Successful in 5s
All checks were successful
Build and deploy / Integration suite on a real stack (push) Successful in 3m36s
Build and deploy / Secret scan and release gate (push) Successful in 8s
Build and deploy / Publish images (push) Successful in 59s
Build and deploy / Validate source (push) Successful in 5s
The order panel shows where each item's file is in the orders folder,
with Copiar: 1. Arte recebida\DTF-N-item-K, named as the automatic
folders save it (GET /api/operator/orders/{id}/folder-files). The browser
knows only the folder's name, so each computer is told once where it is
and the whole path is copied. "Subir arte tratada" sends the file saved
over; it becomes the item's final, "Arte tratada" lights and the order
can move to Arte conferida.
Only the treated item changes: the others keep their approved final,
which the server now accepts beside a new one (still refused when
nothing is new).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -190,6 +190,8 @@ main{padding:0 24px 24px}
|
||||
.finalform input[type=file]{color:var(--muted);font:inherit;font-size:13.5px;font-weight:500}
|
||||
.finalform input[type=file]::file-selector-button{height:34px;padding:0 12px;margin-right:10px;border-radius:8px;border:1px solid var(--line2);background:var(--card2);color:var(--tx);font:inherit;font-size:13.5px;font-weight:600;cursor:pointer}
|
||||
.finalform .slot{display:flex;flex-direction:column;gap:6px;font-size:14px;font-weight:600}
|
||||
.treatline{display:flex;align-items:center;gap:8px}
|
||||
.treatpath{flex:1;min-width:0;padding:7px 10px;border-radius:8px;background:var(--card2);font-family:var(--mono);font-size:13px;font-weight:500;color:var(--tx);word-break:break-all}
|
||||
.timeline{margin:0;padding:0;list-style:none;display:flex;flex-direction:column;gap:10px}
|
||||
.timeline li::before{content:"";width:8px;height:8px;margin-top:6px;border-radius:999px;background:var(--c,var(--muted));flex-shrink:0}
|
||||
|
||||
|
||||
@@ -972,11 +972,17 @@ function moves(order){
|
||||
const actions=node('div',undefined,'stepactions');
|
||||
const b=button(all?'Aprovar arquivo final':'Enviar arquivo final',all?()=>approveReady(order,ready):async()=>toggle(upload),'btn primary');
|
||||
b.dataset.approve='';actions.append(b);
|
||||
// In Arte recebida the art may need work first (Dropstar, 2026-10-29).
|
||||
const treat=order.state==='rec'&&may('produce')?treatForm(order):null;
|
||||
if(treat){forms.unshift(treat);
|
||||
const t=node('button','Tratar a arte','btn ghost');t.type='button';t.dataset.treat='';
|
||||
t.onclick=async()=>{toggle(treat);if(!treat.hidden)await treat.load();};actions.append(t);
|
||||
const close=node('button','Cancelar','linkbtn');close.type='button';close.onclick=()=>toggle(treat);treat.append(close);}
|
||||
if(all){const other=node('button','Enviar outro arquivo','btn ghost');other.type='button';other.onclick=()=>toggle(upload);actions.append(other);}
|
||||
// The upload form opens inside the step, in place of its buttons.
|
||||
// The upload forms open inside the step, in place of its buttons.
|
||||
const cancel=node('button','Cancelar','linkbtn');cancel.type='button';cancel.onclick=()=>toggle(upload);
|
||||
upload.append(cancel);sync=()=>{actions.hidden=!upload.hidden;};
|
||||
text.append(actions,upload);
|
||||
upload.append(cancel);sync=()=>{actions.hidden=!upload.hidden||!!treat&&!treat.hidden;};
|
||||
text.append(actions,upload,...(treat?[treat]:[]));
|
||||
step=node('div',undefined,'nextstep lead');step.append(node('span','!','nextmark'),text);
|
||||
}else if(next==='fin'&&proofPending(order)){
|
||||
// Finalizado waits for the proof: printing it and checking it is the next step.
|
||||
@@ -1005,6 +1011,12 @@ function moves(order){
|
||||
backForm.append(why,go);
|
||||
backForm.onsubmit=async e=>{e.preventDefault();go.disabled=true;try{await move(order,previous,why.value.trim());}catch(error){say(error.message,true);go.disabled=false;}};
|
||||
}
|
||||
// Approved already, the art can still be treated while in Arte recebida.
|
||||
if(order.state==='rec'&&finalDone(order)&&may('produce')&&!order.cancelled_at){
|
||||
const treat=treatForm(order);forms.push(treat);
|
||||
const b=node('button','Tratar a arte','linkbtn');b.type='button';b.dataset.treat='';
|
||||
b.onclick=async()=>{toggle(treat);if(!treat.hidden)await treat.load();};sub.append(b);
|
||||
}
|
||||
// The proof is checked by the room, in the queue (Arte conferida) or while printing.
|
||||
if(['tra','imp'].includes(order.state)&&proofPending(order)&&may('print')){
|
||||
const b=button('✓ Prova OK',()=>proofOk(order),'linkbtn');b.title='A prova foi impressa e conferida';sub.append(b);
|
||||
@@ -1148,6 +1160,78 @@ function finalForm(order,ready){
|
||||
}catch(error){say(error.message,true);submit.disabled=false;}};
|
||||
return form;
|
||||
}
|
||||
// "Tratar a arte" (Dropstar, 2026-10-29): where each item's file is in the
|
||||
// orders folder, to open it, treat it and save it over with the same name;
|
||||
// then the treated file sent here becomes the item's final, "Arte tratada".
|
||||
// The browser only knows the folder's name, so each computer is told once
|
||||
// where the folder is, to copy the whole path.
|
||||
const TREAT_NOTE='Arte tratada';
|
||||
const FOLDER_PATH_KEY='folder-path';
|
||||
function treatForm(order){
|
||||
const form=node('form',undefined,'finalform');form.hidden=true;
|
||||
form.append(node('b','Tratar a arte'),node('span','Copie o caminho e abra o arquivo. Trate e salve por cima, com o mesmo nome. Depois suba aqui o arquivo tratado.','faint'));
|
||||
const base=node('input');base.placeholder='Ex.: D:\\'+(FOLDER.handle?.name||'Pedidos');
|
||||
const baseField=node('label',undefined,'slot');baseField.append('Pasta dos pedidos neste computador',base);
|
||||
const names={};
|
||||
const rows=order.snapshot.items.map((item,index)=>{
|
||||
const slot=node('div',undefined,'slot');
|
||||
const path=node('code','Procurando o arquivo…','treatpath');
|
||||
const copy=node('button','Copiar','btn ghost small');copy.type='button';copy.disabled=true;
|
||||
const line=node('div',undefined,'treatline');line.append(path,copy);
|
||||
const input=node('input');input.type='file';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]),line,input);
|
||||
return {path,copy,input};
|
||||
});
|
||||
// Windows paths unless the folder was written the other way.
|
||||
const where=name=>{const b=base.value.trim().replace(/[\\/]+$/,''),sep=b.includes('/')&&!b.includes('\\')?'/':'\\';
|
||||
return (b?b+sep:'')+STAGE_FOLDERS[order.state]+sep+name;};
|
||||
const paint=()=>rows.forEach((row,index)=>{
|
||||
const name=names[index+1];
|
||||
row.path.textContent=name?(base.value.trim()?'':'…\\')+where(name):'Este item ainda não tem arquivo na pasta.';
|
||||
row.copy.disabled=!name;
|
||||
row.copy.onclick=async()=>{try{await navigator.clipboard.writeText(where(name));
|
||||
say(base.value.trim()?'Caminho copiado.':'Caminho copiado a partir da pasta dos pedidos: informe onde ela fica neste computador para copiar o caminho inteiro.');}
|
||||
catch(_){say('Não foi possível copiar.',true);}};
|
||||
});
|
||||
base.onchange=()=>{kv.set(FOLDER_PATH_KEY,base.value.trim()).catch(()=>{});paint();};
|
||||
const submit=node('button','Subir arte tratada','btn primary');
|
||||
form.append(...rows.map(r=>r.input.parentNode),baseField,submit);
|
||||
// Filled when it opens: the names the automatic folders give the files.
|
||||
form.load=async()=>{
|
||||
base.value=await kv.get(FOLDER_PATH_KEY).catch(()=>'')||'';
|
||||
try{for(const f of (await api('/orders/'+order.id+'/folder-files')).files)names[f.item]=names[f.item]||f.name;}
|
||||
catch(error){say(error.message,true);}
|
||||
paint();
|
||||
};
|
||||
form.onsubmit=async event=>{event.preventDefault();
|
||||
// Each item keeps its approved final, or else the file ready to approve,
|
||||
// unless a treated one is sent for it.
|
||||
const ready=readyFinals(order);
|
||||
const plan=rows.map((row,index)=>{
|
||||
const file=row.input.files[0];
|
||||
if(file)return {file};
|
||||
const kept=(order.finals||[]).filter(f=>f.item_index===index).map(f=>f.upload_id);
|
||||
return {ids:kept.length?kept:ready[index]?[ready[index].upload_id]:[]};
|
||||
});
|
||||
if(!plan.some(p=>p.file)){say('Escolha o arquivo tratado.',true);return;}
|
||||
const empty=plan.findIndex(p=>!p.file&&!p.ids.length);
|
||||
if(empty>=0){say('O item '+(empty+1)+' ainda não tem arquivo: suba a arte tratada dele também.',true);return;}
|
||||
submit.disabled=true;
|
||||
try{
|
||||
const refs=[];
|
||||
for(const [index,p] of plan.entries()){
|
||||
if(!p.file){refs.push(...p.ids.map(upload_id=>({item_index:index,upload_id})));continue;}
|
||||
const uid=await dtfUpload(p.file,{api,startPath:'/orders/'+order.id+'/uploads',scope:'operator:'+order.id+':'+order.version,progress:text=>say(text)});
|
||||
refs.push({item_index:index,upload_id:uid});
|
||||
}
|
||||
await api('/orders/'+order.id+'/final-files',{version:order.version,files:refs,note:TREAT_NOTE});
|
||||
await load();
|
||||
say(mayMove(order.state,'tra')?'Arte tratada aprovada como arquivo final. Agora é só mover para Arte conferida.':'Arte tratada aprovada como arquivo final.');
|
||||
}catch(error){say(error.message,true);submit.disabled=false;}
|
||||
};
|
||||
return form;
|
||||
}
|
||||
const PRINT_TEXT={pending:'Na fila para gerar',rendering:'Gerando arquivo…',ready:'PDF gerado',manual:'Preparar à mão',failed:'Falhou ao gerar'};
|
||||
function itemCard(order,item,index){
|
||||
const row=(order.print_files||[]).find(r=>r.item_index===index);
|
||||
|
||||
Reference in New Issue
Block a user