fix: "Excluir pedido de teste" asks before deleting instead of failing
Some checks failed
Build and deploy / Validate source (push) Successful in 5s
Build and deploy / Integration suite on a real stack (push) Successful in 2m51s
Build and deploy / Secret scan and release gate (push) Successful in 7s
Build and deploy / Publish images (push) Has been cancelled

The order panel kept the "Enviar para correção" button in a variable named
`confirm`, which hid window.confirm from the new delete button ("confirm is
not a function"). It is renamed, as is the same name in the final-files form,
and every question to the operator calls window.confirm explicitly.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Cauê Faleiros
2026-10-02 16:28:40 -03:00
parent 05da6d78ad
commit dfa297d9b5

View File

@@ -463,7 +463,7 @@ function moves(order){
const cancelForm=node('form',undefined,'reason');cancelForm.hidden=true;
if(isTest(order)){
row.append(button('Excluir pedido de teste',async()=>{
if(!confirm('Excluir o pedido de teste #'+order.number+'? Ele some do Kanban, com o histórico.'))return;
if(!window.confirm('Excluir o pedido de teste #'+order.number+'? Ele some do Kanban, com o histórico.'))return;
await api('/orders/'+order.id+'/delete-test',{});closePanel();say('Pedido de teste #'+order.number+' excluído.');await load();
},'btn ghost'));
}else{
@@ -478,9 +478,9 @@ function moves(order){
catch(error){say(error.message,true);go.disabled=false;}};
}
const text=node('textarea');text.placeholder='Motivo da correção';text.setAttribute('aria-label','Motivo da correção');text.maxLength=1000;text.required=true;
const confirm=node('button','Enviar para correção','btn danger');
reason.append(text,confirm);
reason.onsubmit=async e=>{e.preventDefault();confirm.disabled=true;try{await move(order,'cor',text.value.trim());}catch(error){say(error.message,true);confirm.disabled=false;}};
const sendFix=node('button','Enviar para correção','btn danger');
reason.append(text,sendFix);
reason.onsubmit=async e=>{e.preventDefault();sendFix.disabled=true;try{await move(order,'cor',text.value.trim());}catch(error){say(error.message,true);sendFix.disabled=false;}};
box.append(row,reason,backForm,cancelForm);return box;
}
const PRINT_TEXT={pending:'Na fila para gerar',rendering:'Gerando arquivo…',ready:'PDF gerado',manual:'Preparar à mão',failed:'Falhou ao gerar'};
@@ -558,9 +558,9 @@ function finalsSection(order,revisions,section){
});
const note=node('input');note.placeholder='Nota da revisão';note.required=true;note.maxLength=1000;
const check=node('input');check.type='checkbox';check.required=true;check.dataset.confirm='';
const confirm=node('label',undefined,'check');confirm.append(check,'Arquivos conferidos');
const checked=node('label',undefined,'check');checked.append(check,'Arquivos conferidos');
const submit=node('button','Aprovar arquivos finais','btn primary');
form.append(note,confirm,submit);
form.append(note,checked,submit);
form.onsubmit=async event=>{event.preventDefault();submit.disabled=true;try{
const refs=[];
for(const [index,input] of inputs.entries()){
@@ -706,7 +706,7 @@ function review(quote){
foot.append(discardButton(quote));
// Tries the whole production flow without a payment.
foot.append(button('Criar pedido de teste',async()=>{
if(!confirm('Criar um pedido de TESTE para esta cotação? Não cobra nada e não vai para o Tiny nem para o WhatsApp.'))return;
if(!window.confirm('Criar um pedido de TESTE para esta cotação? Não cobra nada e não vai para o Tiny nem para o WhatsApp.'))return;
const order=await api('/quotes/'+quote.id+'/test-order',{});
say('Pedido de teste #'+order.number+' criado em Arte recebida.');await load();
},'btn ghost'));
@@ -735,7 +735,7 @@ function review(quote){
// An unpaid quote leaves the list and can no longer be paid.
function discardButton(quote){
return button('Descartar cotação',async()=>{
if(!confirm('Descartar esta cotação? Ela sai do Kanban e o cliente não consegue mais pagá-la.'))return;
if(!window.confirm('Descartar esta cotação? Ela sai do Kanban e o cliente não consegue mais pagá-la.'))return;
await api('/quotes/'+quote.id+'/discard',{});currentQuote=null;say('Cotação descartada.');await load();
},'btn ghost discard');
}