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>
167 lines
8.8 KiB
JavaScript
167 lines
8.8 KiB
JavaScript
/* Site DTF — Cart totals and the order summary.
|
|
Extracted verbatim from the single inline script in web/index.html.
|
|
Loaded as classic scripts in the order listed there: they share one global
|
|
scope and run top to bottom, exactly as the original did. */
|
|
// ── carrinho
|
|
let itemAtual=null;
|
|
function invalidaItemAtual(){
|
|
if(!itemAtual) return;
|
|
itemAtual=null;
|
|
$('atual').style.display='none';
|
|
$('carrLin').innerHTML='';
|
|
pintaPedido();
|
|
}
|
|
function itemPodeEnviar(item){
|
|
return item.qualityStatus==='ok' || item.qualityStatus==='unverified' ||
|
|
(item.qualityStatus==='warning' && item.qualityAcknowledged===true);
|
|
}
|
|
// Os itens marcados no carrinho são os que vão para o pagamento; um item
|
|
// desmarcado fica guardado para depois. O item aberto no produto sempre vai.
|
|
function itensAPagar(){
|
|
return [...pedido.filter(it=>it.marcado!==false),...(itemAtual?[itemAtual]:[])];
|
|
}
|
|
function cartPodeEnviar(){
|
|
const items=itensAPagar();
|
|
return items.length>0 && items.every(itemPodeEnviar);
|
|
}
|
|
function limpaPaineis(){
|
|
invalidaItemAtual();
|
|
['qual','prev'].forEach(id=>$(id).classList.remove('on'));
|
|
if(!pedido.length){ $('carr').classList.remove('on'); }
|
|
}
|
|
|
|
// O carrinho junta itens de produtos diferentes e cobra uma vez só.
|
|
function pintaPedido(){
|
|
$('itens').innerHTML = pedido.map((it,i)=>
|
|
'<div class="item'+(it.marcado===false?' fora':'')+'">'+
|
|
'<label class="marca"><input type="checkbox" data-sel="'+i+'"'+(it.marcado===false?'':' checked')+
|
|
' aria-label="Incluir '+escapeHTML(it.tit)+' no pagamento"></label>'+
|
|
'<span class="miniItem">'+(it.mini ? '<img src="'+escapeHTML(it.mini)+'" alt="">' : '<i>'+escapeHTML(it.ext||'')+'</i>')+
|
|
(it.arquivos>1 ? '<em>+'+(it.arquivos-1)+'</em>' : '')+'</span>'+
|
|
'<div class="nm2"><b>'+escapeHTML(it.tit)+'</b><span>'+escapeHTML(it.desc)+'</span></div>'+
|
|
'<div class="vl2">'+rs(it.total)+'</div>'+
|
|
'<button type="button" class="x" data-rmi="'+i+'" aria-label="Remover '+escapeHTML(it.tit)+'">'+icone('lixeira')+'<span>Remover</span></button></div>').join('');
|
|
$('itens').querySelectorAll('[data-sel]').forEach(c=>c.addEventListener('change',()=>{
|
|
pedido[+c.dataset.sel].marcado=c.checked; pintaPedido();
|
|
}));
|
|
$('itens').querySelectorAll('[data-rmi]').forEach(b=>b.addEventListener('click',()=>{
|
|
const i=+b.dataset.rmi, [item]=pedido.splice(i,1);
|
|
pintaPedido();
|
|
avisaDesfazer(item.tit+' saiu do carrinho.',()=>{
|
|
pedido.splice(Math.min(i,pedido.length),0,item); pintaPedido();
|
|
});
|
|
}));
|
|
$('bEsvaziar').hidden = pedido.length+(itemAtual?1:0) < 2;
|
|
const aPagar = itensAPagar();
|
|
const itens = aPagar.reduce((t,it)=>t+it.total,0);
|
|
const frete = entrega.tipo==='frete' && entrega.cotado ? entrega.valor : 0;
|
|
const soma = itens + frete;
|
|
const n = aPagar.length, noCarrinho = pedido.length + (itemAtual?1:0);
|
|
$('resLin').innerHTML =
|
|
'<div class="l"><span>'+n+(n===1?' item':' itens')+'</span><b>'+rs(itens)+'</b></div>'+
|
|
'<div class="l"><span>Frete'+(entrega.tipo==='frete' && entrega.cotado
|
|
? ' · '+escapeHTML((entrega.opcoes||[]).find(o=>o.service===entrega.servico)?.description||'') : '')+
|
|
'</span><b>'+
|
|
(entrega.tipo==='retira' ? '<span style="color:var(--verde-ml)">Grátis</span>'
|
|
: entrega.cotado ? rs(frete) : 'a cotar')+'</b></div>'+
|
|
'<div class="l"><span>Revisão e reencaixe</span>'+
|
|
'<b><span style="color:var(--verde-ml)">Grátis</span></b></div>';
|
|
$('carrTot').textContent=rs(soma);
|
|
$('bPagarTx').textContent = n>1
|
|
? 'Pagar os '+n+' itens de uma vez'
|
|
: 'Ir para o pagamento';
|
|
// The proof is only for orders above 10 m (Dropstar, 2026-10-28): below it the box is gone.
|
|
const prova=$('fProva');
|
|
if(prova){ const longo=aPagar.reduce((t,it)=>t+(it.cob||0),0)>10; prova.closest('.cxE').hidden=!longo; if(!longo) prova.checked=false; }
|
|
$('bPagar').disabled = !cartPodeEnviar() || !entrega.cotado || !clienteOk() || !enderecoOk();
|
|
if(pedido.length || itemAtual) $('carr').classList.add('on');
|
|
if($('cartN')){ $('cartN').textContent=noCarrinho>99?'99+':noCarrinho; $('cartN').hidden=!noCarrinho;
|
|
$('cartLink').setAttribute('aria-label','Carrinho, '+noCarrinho+(noCarrinho===1?' item':' itens')); }
|
|
window.dispatchEvent(new Event('dtf-cart-changed'));
|
|
}
|
|
|
|
// Um preço por produto (Dropstar, 23/10/2026): a nota aparece, mas não entra na conta.
|
|
// A arte avulsa como fonte da montagem: largura, comprimento, cópias e giro.
|
|
const fonteDaArte=x=>({kind:'artwork',width_cm:x.cm,length_cm:+(x.cm*propDe(x)).toFixed(4),
|
|
copies:x.q,rotation_degrees:x.giro||0,mirrored:!!x.esp,
|
|
measurement:(x.src||x.semPrevia)?'file':'customer'});
|
|
function carrinho(){
|
|
const base=precoMetro(), cob=cobrarMontagem();
|
|
const extra=folhaManual()? TAXA_MANUAL : 0;
|
|
const unit=base+extra, tot=cob*unit, sobra=+(cob-metros).toFixed(2);
|
|
$('carr').classList.add('on');
|
|
let l='<div class="l"><span>'+MODOS[modo].tit+'</span><b>'+rs(base)+'/m</b></div>';
|
|
if(!ehFolha()) l += '<div class="l" style="color:#8D9AB0"><span>'+(montagemFolhas?'Montagem em '+montagemFolhas.length+' folhas, pela espessura do traço':'Montagem da folha')+'</span><b>inclusa</b></div>';
|
|
if(extra) l += '<div class="l"><span>Arquivo aberto na mão</span><b>+'+rs(extra)+'/m</b></div>';
|
|
l += '<div class="l"><span>Metragem'+(sobra>0.001?' · arredondada para 10 cm':'')+
|
|
'</span><b>'+fmtM(cob)+' m</b></div>';
|
|
l += '<div class="l"><span>Preço final do metro</span><b>'+rs(unit)+'</b></div>'+
|
|
'<div class="l" style="color:var(--laranja2)"><span>Revisão e reencaixe</span><b>grátis</b></div>';
|
|
$('carrLin').innerHTML=l;
|
|
$('atual').style.display='';
|
|
const sources=(ehFolha()?folhas:artes).map(x=>ehFolha()
|
|
? {kind:'sheet',width_cm:x.med?.larg||larguraFilme(),length_cm:+(x.m*100).toFixed(4),
|
|
copies:x.rep||1,rotation_degrees:0,mirrored:false,
|
|
measurement:x.med?'file':'customer'}
|
|
: fonteDaArte(x));
|
|
let layout, partes=null;
|
|
if(ehFolha()){
|
|
let y=0;
|
|
const placements=[];
|
|
sources.forEach((source,source_index)=>{
|
|
for(let copy_index=0;copy_index<source.copies;copy_index++){
|
|
placements.push({source_index,copy_index,x_cm:0,y_cm:+y.toFixed(4),
|
|
width_cm:source.width_cm,length_cm:source.length_cm,
|
|
rotation_degrees:0,mirrored:false});
|
|
y+=source.length_cm;
|
|
}
|
|
});
|
|
layout={height_cm:+y.toFixed(4),placements};
|
|
}else if(montagemFolhas){
|
|
// Item 17: one order item per sheet, each with its files, layout and class.
|
|
partes=montagemFolhas.map((f,i)=>({rotulo:'Folha '+(i+1)+' · '+f.nome,
|
|
localFiles:f.artes.map(x=>x.f), fotos:f.artes.map(x=>x.fotoSrc||null),
|
|
metros:+(f.layout.height_cm/100).toFixed(4),
|
|
production:{version:3,film_width_cm:larguraFilme(),sources:f.artes.map(fonteDaArte),...f.layout},
|
|
residueAccepted:residuosDasArtes(f.artes), ...tracoDoItem(f.artes)}));
|
|
layout=null;
|
|
}else{
|
|
if(!montagemLayout) return;
|
|
layout=montagemLayout;
|
|
}
|
|
itemAtual={modo, tit:MODOS[modo].tit, nota, metros, cob, unit, extra, total:tot,
|
|
localFiles:(ehFolha()?folhas:artes).map(x=>x.f),
|
|
mini:(ehFolha()?folhas:artes).map(x=>x.miniSrc).find(Boolean)||null,
|
|
fotos:(ehFolha()?folhas:artes).map(x=>x.fotoSrc||null),
|
|
ext:extDe(((ehFolha()?folhas:artes)[0]||{f:{name:''}}).f.name),
|
|
arquivos:(ehFolha()?folhas:artes).length,
|
|
production:layout?{version:3,film_width_cm:larguraFilme(),sources,...layout}:null,
|
|
partes,
|
|
qualityStatus:$('ciente').classList.contains('recusa')?'rejected':
|
|
$('ciente').classList.contains('on')?'warning':nota===0?'unverified':'ok',
|
|
qualityAcknowledged:false,
|
|
// The residue dots the customer accepted printing (Dropstar, 2026-10-29).
|
|
residueAccepted:residuosAceitos(),
|
|
// The thinnest stroke and its contraction class (item 9), for the room.
|
|
...tracoDoItem(),
|
|
desc:(partes?partes.length+' folhas · ':'')+fmtM(cob)+' m · '+rs(unit)+'/m · nota '+nota};
|
|
pintaPedido();
|
|
previa();
|
|
}
|
|
// Removing is one click, and a wrong click is undone from the notice that follows.
|
|
let desfazerAcao=null, desfazerTimer=null;
|
|
function avisaDesfazer(texto,acao){
|
|
desfazerAcao=acao; clearTimeout(desfazerTimer);
|
|
$('desfazerTxt').textContent=texto; $('desfazer').hidden=false;
|
|
desfazerTimer=setTimeout(fechaDesfazer,8000);
|
|
}
|
|
function fechaDesfazer(){ clearTimeout(desfazerTimer); desfazerAcao=null; $('desfazer').hidden=true; }
|
|
addEventListener('dtf-page-changed',fechaDesfazer);
|
|
$('desfazerBtn').addEventListener('click',()=>{ const acao=desfazerAcao; fechaDesfazer(); if(acao) acao(); });
|
|
$('bEsvaziar').addEventListener('click',()=>{
|
|
const antes=pedido.slice();
|
|
pedido=[]; invalidaItemAtual(); pintaPedido();
|
|
avisaDesfazer('Carrinho esvaziado.',()=>{ pedido=antes; pintaPedido(); });
|
|
});
|
|
function qm(t,c){ const m=$('qmsg'); m.style.display='block'; m.style.color=c||'var(--verde)'; m.innerHTML=t; }
|