feat: new layout phase E, the order panel and Revisão as on the canvas

Roadmap Novo Layout, phase E (canvas P2, D2, Ph3): the panel without the
empty column (the item preview stays in Cotações and Abrir e conferir),
Próximo passo with its actions together and the primary last, the item
facts in a four-column grid (the secondary facts kept in a second row),
the Cliente, Entrega and Máquina blocks, and the Revisão dialog with the
camera card and the drop area. Every nextBox branch, action and
permission is unchanged. Built by Prensa.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Cauê Faleiros
2026-11-16 11:52:54 -03:00
parent 392a21082e
commit fb23b63090
2 changed files with 95 additions and 59 deletions

View File

@@ -2,7 +2,7 @@
conferir (fronts 2/7). Loaded after kanban.js, which defines $, api, node,
button, svgIcon, IC, badge, money, when, ago, metres, plural, say, may,
mayMove, mayAct, myMachine, board, ME, MODALS, load, render, dialog, modal,
formDialog, field, checkbox, dropField, iconButton, gradePill, itemPreview,
formDialog, field, checkbox, dropField, iconButton, gradePill,
productName, sheetSize, buyer, cnpj, docKind, copyButton, freightWeight,
whatsappLink, download, downloadButton, FOLDER, STAGE_FOLDERS, FLOW, kv,
orderCode, fileCode, stateName, manifest, contractionRecord and cm. */
@@ -41,9 +41,7 @@ function renderPanel(order){
// The head: who, where the order is, and what it is called.
const top=node('div',undefined,'dtop');
const name=node('span',who.title,'dname');name.title=[who.legal,who.mail].filter(Boolean).join(' · ')||who.title;
const stage=node('span',undefined,'stage'+(order.cancelled_at?' bad':''));
stage.append(svgIcon(order.cancelled_at?IC.ban:GLYPH[order.state]||GLYPH.rec,'sg'+(order.state==='cor'||order.cancelled_at?' cor':'')),
order.cancelled_at?'Cancelado':stateName(order.state));
const stage=node('span',order.cancelled_at?'Cancelado':stateName(order.state),'stage'+(order.cancelled_at?' bad':''));
const tools=node('span',undefined,'dtools');
const more=moreMenu(order);if(more)tools.append(more);
tools.append(iconButton(IC.close,'Fechar',closePanel));
@@ -76,7 +74,7 @@ function renderPanel(order){
const head=node('div',undefined,'dhead');head.append(top,sub,steps);
// The phone's head: back, the order and where it is, its menu.
const mhead=node('div',undefined,'mhead phone'),mt=node('span',undefined,'t');
mt.append(node('b','#'+order.number+' '+who.title),node('span',(order.cancelled_at?'Cancelado':stateName(order.state))+', '+money(s.total_cents)+(isTest(order)?' de teste':' pago')));
mt.append(node('b','#'+order.number+' · '+who.title),node('span',(order.cancelled_at?'Cancelado':stateName(order.state))+' · '+money(s.total_cents)+(isTest(order)?' de teste':' pago')));
const phoneMore=moreMenu(order,'mic');
mhead.append(iconButton(IC.left,'Voltar',closePanel,'mic'),mt,...(phoneMore?[phoneMore]:[]));
@@ -295,7 +293,7 @@ function nextBox(order){
return composeNext(title,body,main,more);
}
const fixBtn=()=>{if(!trans.includes('cor')||!can('cor'))return;
const b=node('button','Pedir correção','btn quiet lg');b.type='button';b.dataset.move='cor';b.onclick=()=>correctionDialog(order);more.push(b);};
const b=node('button','Pedir correção','btn ghost lg');b.type='button';b.dataset.move='cor';b.onclick=()=>correctionDialog(order);more.push(b);};
const proofBtn=(className='btn lg')=>{if(!proofPending(order)||order.proof_card||!may('print'))return null;
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.'
@@ -409,8 +407,9 @@ function nextBox(order){
}
function composeNext(title,body,main,more){
const box=node('section',undefined,'nextbox');box.setAttribute('aria-label','Próximo passo');
const info=node('div',undefined,'ninfo');
const head=node('div');head.append(node('span','Próximo passo','lbl'),node('h3',title));
box.append(head,...body);
info.append(head,...body);box.append(info);
if(main.length||more.length){const acts=node('div',undefined,'nact');acts.append(...main,...more);box.append(acts);}
return box;
}
@@ -608,21 +607,33 @@ async function photoSize(file){
}
function reviewDialog(order){
const host=dialogHost();
const video=node('video');video.className='reviewcam';video.muted=true;video.playsInline=true;video.autoplay=true;
const video=node('video');video.className='reviewcam';video.muted=true;video.playsInline=true;video.autoplay=true;video.hidden=true;
video.setAttribute('aria-label','Pré-visualização da câmera');
const timer=node('span','0:00 / 0:30','reviewtime');timer.setAttribute('aria-live','polite');
const controls=node('div',undefined,'reviewcontrols');
const controls=node('div',undefined,'reviewcontrols');controls.hidden=true;
const photoBtn=node('button','Tirar foto','btn pri');photoBtn.type='button';photoBtn.setAttribute('aria-label','Tirar foto');photoBtn.setAttribute('autofocus','');
const videoBtn=node('button','Gravar vídeo','btn');videoBtn.type='button';videoBtn.setAttribute('aria-label','Gravar vídeo');
const input=node('input');input.type='file';input.className='vh';
input.accept='image/jpeg,image/png,image/webp,video/mp4,video/webm,video/quicktime';
const fileLabel=node('label',undefined,'btn');fileLabel.tabIndex=0;
fileLabel.append(svgIcon(IC.upload,'i m'),'Enviar arquivo',input);
const drop=node('label',undefined,'reviewdrop');drop.tabIndex=0;
const dropIco=node('span',undefined,'dropico');dropIco.append(svgIcon(IC.upload));
drop.append(dropIco,node('b','Arraste a foto ou o vídeo'),node('span','ou'),
node('span','Escolher arquivo','btn sm'),input);
const camCard=node('div',undefined,'reviewcamcard');
const camLabel=node('div',undefined,'reviewcamlabel');
const camIco=node('span',undefined,'reviewcamico');camIco.append(svgIcon(IC.camera));
camLabel.append(camIco,node('b','Usar a câmera'),node('span','foto ou vídeo'));
camCard.append(video,camLabel);
const drops=node('div',undefined,'reviewdrops');drops.append(camCard,drop);
const hint=node('p',undefined,'reviewnote');
hint.append(svgIcon(IC.info,'i s'),node('span','A foto precisa de pelo menos '+REVIEW_PHOTO_MIN+' px no lado maior.'));
const nocam=node('p',undefined,'reviewnote bad');nocam.hidden=true;
nocam.append(svgIcon(IC.camera,'i s'),node('span','Este computador não tem câmera. Envie um arquivo, ou faça a revisão pelo celular.'));
const preview=node('div',undefined,'reviewpreview');preview.hidden=true;
const status=node('p','','reviewmsg');status.setAttribute('role','status');status.setAttribute('aria-live','polite');
const save=node('button','Salvar revisão','btn pri');save.type='button';save.disabled=true;
const cancel=node('button','Cancelar','btn ghost right');cancel.type='button';
controls.append(photoBtn,videoBtn,fileLabel);
controls.append(photoBtn,videoBtn,timer);
let stream=null,recorder=null,recordTimer=null,chunks=[],ready=null,objectUrl=null,closed=false,recording=false,recordStart=0;
const fail=text=>{status.textContent=text;status.classList.add('bad');};
const clear=()=>{status.textContent='';status.classList.remove('bad');};
@@ -639,7 +650,7 @@ function reviewDialog(order){
function showReady(file,kind){
ready={file,kind};
endStream();
video.hidden=true;photoBtn.hidden=true;videoBtn.hidden=true;timer.hidden=true;
drops.hidden=true;controls.hidden=true;nocam.hidden=true;
if(objectUrl)URL.revokeObjectURL(objectUrl);
objectUrl=URL.createObjectURL(file);
preview.replaceChildren();
@@ -724,7 +735,13 @@ function reviewDialog(order){
showReady(file,'photo');
}
};
fileLabel.onkeydown=event=>{if(event.key==='Enter'||event.key===' '){event.preventDefault();input.click();}};
drop.onkeydown=event=>{if(event.key==='Enter'||event.key===' '){event.preventDefault();input.click();}};
drop.ondragover=event=>{event.preventDefault();drop.classList.add('over');};
drop.ondragleave=()=>drop.classList.remove('over');
drop.ondrop=event=>{event.preventDefault();drop.classList.remove('over');
if(!event.dataTransfer.files.length)return;
const list=new DataTransfer();list.items.add(event.dataTransfer.files[0]);input.files=list.files;
input.dispatchEvent(new Event('change',{bubbles:true}));};
cancel.onclick=()=>m.close();
save.onclick=async()=>{
if(!ready)return;
@@ -743,22 +760,22 @@ function reviewDialog(order){
}
};
const m=modal('Revisão do #'+order.number,{host,width:640,
text:'Tire uma foto ou grave um vídeo de até 30 s da folha impressa, ou envie um arquivo. '+
'A foto precisa de pelo menos '+REVIEW_PHOTO_MIN+' px no lado maior.',
body:[video,controls,timer,preview],foot:[status,cancel,save],onclose:cleanup});
text:'Uma foto ou um vídeo de até 30 s da folha impressa.',
body:[drops,controls,preview,hint,nocam],foot:[status,cancel,save],onclose:cleanup});
m.box.classList.add('reviewdialog');
(async()=>{
try{
if(!navigator.mediaDevices?.getUserMedia)throw new Error('sem câmera');
stream=await navigator.mediaDevices.getUserMedia({video:{facingMode:'environment',
width:{ideal:1920},height:{ideal:1080}},audio:false});
if(closed){endStream();return;}
video.srcObject=stream;
video.srcObject=stream;video.hidden=false;
await video.play().catch(()=>{});
controls.hidden=false;
photoBtn.focus();
}catch(_){
endStream();video.hidden=true;photoBtn.hidden=true;videoBtn.hidden=true;timer.hidden=true;
fail('Câmera indisponível neste computador. Envie um arquivo.');
fileLabel.focus();
endStream();camCard.classList.add('off');nocam.hidden=false;
drop.focus();
}
})();
}
@@ -964,16 +981,18 @@ function itemCard(order,item,index){
const box=node('section',undefined,'item');box.setAttribute('aria-label','Item '+(index+1));
const info=node('div',undefined,'iinfo');
const count=order.snapshot.items.length;
info.append(node('span',count>1?'Item '+(index+1)+' de '+count:'Item','lbl'),node('h3',productName(item)));
if(count>1)info.append(node('span','Item '+(index+1)+' de '+count,'lbl'));
info.append(node('h3',productName(item)));
const dl=node('dl',undefined,'dl');
const pair=(k,v)=>{if(v===null||v===undefined||v==='')return;const d=node('div');const dd=node('dd');dd.append(v);d.append(node('dt',k),dd);dl.append(d);};
pair('Folha',sheetSize(spec));pair('Metros cobrados',metres(item.billed_metres));
pair('Peças',spec?String(spec.placements.length):null);
pair('Metros cobrados',metres(item.billed_metres));
pair('Valor do metro',item.unit_cents?money(item.unit_cents)+manualExtra(item):null);
const g=node('span',undefined,'gradeline');g.append(gradePill(item.grade));pair('Nota da arte',g);
pair('Contração',contractionControl(order,index));
pair('Folha',sheetSize(spec));
pair('Peças',spec?String(spec.placements.length):null);
pair('Menor resolução',row?.status==='ready'&&row.detail?.min_dpi?row.detail.min_dpi+' DPI':null);
pair('Arquivos',spec&&spec.sources.length>1?String(spec.sources.length):null);
pair('Contração',contractionControl(order,index));
info.append(dl);
const notes=node('div',undefined,'inotes');
if(item.quality_status==='warning')notes.append(itemNote('O cliente aceitou a ressalva de resolução.','warn'));
@@ -1029,7 +1048,7 @@ function itemCard(order,item,index){
if(may('produce')&&!fix&&['rec','tra'].includes(order.state)&&!waitingProof(order)&&(!row||row.status==='manual'||row.status==='failed'||row.timed_out)){
const again=button('Gerar de novo',async()=>{await api('/orders/'+order.id+'/print-files',{});await load();},'btn');again.prepend(svgIcon(IC.refresh,'i m'));links.append(again);}
info.append(links);
box.append(itemPreview(item),info);return box;
box.append(info);return box;
}
// Arquivos: every final, current or replaced, and the way to send a new one.
function filesView(order,revisions,view){