feat: review photo or video in Revisão (front 2)
All checks were successful
Build and deploy / Validate source (push) Successful in 8s
Build and deploy / Integration suite on a real stack (push) Successful in 6m4s
Build and deploy / Secret scan and release gate (push) Successful in 7s
Build and deploy / Publish images (push) Successful in 1m6s

In Revisão the card gets "Revisar": a photo or a video of up to 30 s of
the printed sheet, from the computer's or the phone's camera in the
browser, or a file already recorded. It is attached to the order as
DTF-<n>-revisao-<seq> with when and who, kept 180 days, and copied by
the computers with the order folders to Kanban/Revisões/. A photo needs
1600 px on its longer side. An order above 1 m cannot reach Finalizado
without one. In Finalizado the customer's order page shows the photo.

The Revisor, Gestão and the administrators take it (capability
"inspect"). Dialogs opened from a card's face or the board (Revisar,
Editar tempos) now show over the page when the order panel is closed;
inside the closed panel they were invisible.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Cauê Faleiros
2026-11-09 11:39:15 -03:00
parent 5aafd9ee91
commit b280e0cfa6
18 changed files with 725 additions and 22 deletions

View File

@@ -273,6 +273,21 @@ main{padding:0}
.card:focus-visible,.mini:focus-visible{outline:2px solid var(--acc);outline-offset:2px}
.card-open{display:inline-flex;align-items:center;justify-content:center;gap:5px;align-self:flex-start;min-height:28px;padding:4px 8px;border:1px solid var(--ln2);border-radius:7px;background:var(--sf3);color:var(--tx);font:inherit;font-size:11px;font-weight:600;cursor:pointer}
.card-open:hover,.card-open:focus-visible{border-color:var(--acc);color:var(--acc)}
.card-open-row{display:flex;flex-wrap:wrap;gap:6px}
/* A review photo or video: live camera, the preview, and the order's list. */
.reviewcam{width:100%;aspect-ratio:16/9;object-fit:contain;background:var(--bg);border:1px solid var(--ln2);border-radius:10px;display:block}
.reviewpreview{width:100%;aspect-ratio:16/9;background:var(--bg);border:1px solid var(--ln2);border-radius:10px;overflow:hidden;display:flex;align-items:center;justify-content:center}
.reviewpreview img,.reviewpreview video{width:100%;height:100%;object-fit:contain;display:block}
.reviewcontrols{display:flex;flex-wrap:wrap;align-items:center;gap:8px}
.reviewcontrols label.btn{cursor:pointer}
.reviewtime{font-size:12px;color:var(--tx3);font-variant-numeric:tabular-nums}
.reviewmsg{flex:1;min-width:0;margin:0;font-size:13px;color:var(--tx2)}
.reviewmsg.bad{color:var(--bad)}
.reviewlist{display:flex;flex-direction:column;max-height:220px;overflow:auto;border-top:1px solid var(--ln)}
.reviewsec{padding-top:22px;border-top:1px solid var(--ln)}
.reviewrow{display:flex;align-items:center;gap:8px;padding:6px 0;border-bottom:1px solid var(--ln)}
.reviewopen{flex:1;min-width:0;padding:5px 2px;border:0;background:none;color:var(--tx);font:inherit;font-size:13px;text-align:left;cursor:pointer}
.reviewopen:hover,.reviewopen:focus-visible{color:var(--acc)}
.ctop{display:grid;grid-template-columns:56px minmax(0,1fr);gap:12px;align-items:center}
.thumb{width:56px;height:56px;border-radius:8px;padding:4px;border:0;box-shadow:inset 0 0 0 1px var(--ln);background:repeating-conic-gradient(var(--chka) 0 25%,var(--chkb) 0 50%) 0 0/8px 8px}
.thumb img{transition:transform .5s cubic-bezier(.2,.8,.2,1)}

View File

@@ -142,6 +142,7 @@ const IC={
logout:'M8 3.25H3.75v13.5H8 M12 6.5l3.5 3.5-3.5 3.5 M15.5 10H7.5',
printer:'M5.75 7.5V3h8.5v4.5 M5.75 14H3V7.5h14V14h-2.75 M5.75 11.25h8.5v5.75h-8.5z',
eye:'M2.5 10s2.75-5.25 7.5-5.25S17.5 10 17.5 10s-2.75 5.25-7.5 5.25S2.5 10 2.5 10z '+C(10,10,2.25),
camera:'M2.75 6.5h3.25l1.25-2.5h5.5l1.25 2.5h3.25v9.5H2.75z '+C(10,11.25,2.75),
edit:'M12.5 4l3.5 3.5L7.5 16H4v-3.5z M10.5 6l3.5 3.5',
user:C(10,6.25,3.25)+' M3.75 17c.6-3.2 3.1-5 6.25-5s5.65 1.8 6.25 5',
link:'M8.5 6.5H6a3.25 3.25 0 0 0 0 6.5h2.5 M11.5 6.5H14a3.25 3.25 0 0 1 0 6.5h-2.5 M7 9.75h6',
@@ -262,6 +263,8 @@ const OLD_FOLDERS=['3. Finalizado'];
const KEEP_FINISHED_DAYS=30;
// The pickup receipts (item 14): the counter's print queue watches this one.
const RECEIPTS_FOLDER='Recibos';
// The review photos and videos (front 2), written once and never removed.
const REVIEWS_FOLDER='Revisões';
const FOLDER={mode:'showDirectoryPicker' in window?'folder':/Firefox\//.test(navigator.userAgent)?'downloads':'none',
brave:!!navigator.brave,handle:null,granted:false,downloads:false,since:null,
saved:new Map(),busy:false,status:'',error:'',last:null,lastSig:null};
@@ -324,7 +327,7 @@ function folderCard(){
: integration({name,state:'Desligada',tone:'off',summary:'No Firefox, baixa sozinho os arquivos que entram em Arte conferida; as pastas do fluxo pedem o Chrome ou o Edge.',
actions:[act('Ligar',()=>setDownloads(true))],details:how});
}else if(!h){
row=integration({name,state:'Desligada',tone:'off',summary:'Salva sozinho os arquivos dos pedidos nas pastas do fluxo, de 1. Arte recebida a 5. Finalizado, e o recibo de cada retirada em Recibos.',
row=integration({name,state:'Desligada',tone:'off',summary:'Salva sozinho os arquivos dos pedidos nas pastas do fluxo, de 1. Arte recebida a 5. Finalizado, o recibo de cada retirada em Recibos e as fotos da revisão em Revisões.',
actions:[act('Escolher pasta',chooseFolder)],
details:[node('p','Escolha uma vez a pasta principal, na rede do servidor: o Kanban cria dentro dela as pastas do fluxo e move o arquivo conforme o card anda. '+
'Os arquivos levam o número do pedido no nome. Funciona neste computador, com o Kanban aberto e um usuário que vê todos os pedidos, como o de Gestão.')]});
@@ -338,7 +341,7 @@ function folderCard(){
['Último',FOLDER.last?FOLDER.last.toLocaleTimeString('pt-BR',{hour:'2-digit',minute:'2-digit'}):'—'],
node('p','Dentro de “'+h.name+'”: o arquivo do pedido chega em '+STAGE_FOLDERS.rec+', passa para '+STAGE_FOLDERS.tra+' quando o card vai para lá '+
'e fica lá enquanto imprime, vai para '+STAGE_FOLDERS.rev+' com o card e para '+STAGE_FOLDERS.fin+' quando o pedido é finalizado, onde fica '+KEEP_FINISHED_DAYS+' dias.'),
node('p','Pedido de retirada que chega em Finalizado: o recibo para a bobina de 80 mm vai para '+RECEIPTS_FOLDER+', uma vez só, por um dos computadores com a pasta ligada.'),
node('p','Pedido de retirada que chega em Finalizado: o recibo para a bobina de 80 mm vai para '+RECEIPTS_FOLDER+', uma vez só, por um dos computadores com a pasta ligada. As fotos da revisão vão para '+REVIEWS_FOLDER+' e não saem de lá.'),
node('p','Pedido cancelado, excluído ou devolvido para correção: o arquivo sai das pastas. Arquivo trocado: a versão antiga sai. '+
'Pedidos que já estavam imprimindo quando a pasta foi escolhida não são baixados. Se este computador ficar desligado, '+
'ao voltar ele busca também o que passou nesse tempo, cada arquivo na pasta da etapa em que o pedido está. Deixe o Kanban aberto neste computador.')],
@@ -399,7 +402,7 @@ async function writeWhole(dir,name,source){
}
const stageDir=name=>FOLDER.handle.getDirectoryHandle(name,{create:true});
// The flow's folders exist from the moment the main one is chosen, empty or not.
const makeStageFolders=()=>Promise.all([...new Set([...Object.values(STAGE_FOLDERS),PRINTING_FOLDER,RECEIPTS_FOLDER])].map(stageDir));
const makeStageFolders=()=>Promise.all([...new Set([...Object.values(STAGE_FOLDERS),PRINTING_FOLDER,RECEIPTS_FOLDER,REVIEWS_FOLDER])].map(stageDir));
// Remove a saved file from its folder; one already gone (someone took it) is fine.
async function removeSaved(rec){
const dir=await stageDir(rec.folder);
@@ -463,13 +466,13 @@ async function syncFolder(force=false){
const stages=FOLDER.mode==='folder';
const follows=stages?['rec','tra','imp','rev','fin','cor']:['tra'];
const sig=board.orders.filter(o=>follows.includes(o.state)||o.cancelled_at)
.map(o=>o.id+':'+o.version+':'+o.state+(o.cancelled_at?':x':'')).join(',');
.map(o=>o.id+':'+o.version+':'+o.state+(o.cancelled_at?':x':'')+':'+(o.reviews?.length||0)).join(',');
if(!force&&sig===FOLDER.lastSig)return;
FOLDER.busy=true;
try{
if(stages)await makeStageFolders();
const held=stages?[...new Set([...FOLDER.saved.values()].map(r=>r.order).filter(Boolean))].slice(-1000):[];
const {files,states,receipts=[]}=await api('/queue/folder',{early:stages,held,since:stages?FOLDER.since||await folderSince():null});
const held=stages?[...new Set([...FOLDER.saved.values()].filter(r=>!r.review).map(r=>r.order).filter(Boolean))].slice(-1000):[];
const {files,states,receipts=[],reviews=[]}=await api('/queue/folder',{early:stages,held,since:stages?FOLDER.since||await folderSince():null});
// By file: an item over 15 m is several parts (item 13), each its own file.
const wanted=new Map(files.map(f=>[f.upload_id,f]));
const where=stages?'“'+FOLDER.handle.name+'”':'a pasta de downloads';
@@ -526,11 +529,26 @@ async function syncFolder(force=false){
await writeWhole(await stageDir(RECEIPTS_FOLDER),r.name,res.body);printed++;
}catch(e){await api('/orders/'+r.order+'/receipt/release',{}).catch(()=>{});throw e;}
}
// The review photos and videos, once each, into Revisões/. They are never
// removed from there: the folder is the room's evidence of the check.
let reviewSaved=0;
if(stages)for(const review of reviews){
const key='review:'+review.upload_id;
if(FOLDER.saved.has(key))continue;
FOLDER.status='Salvando revisão: '+review.name;paintFolder();
const view=await api('/orders/'+review.order+'/reviews/'+review.id+'/view');
const res=await fetch(view.url,{referrerPolicy:'no-referrer'});
if(!res.ok||!res.body)throw new Error('não foi possível baixar '+review.name+' (erro '+res.status+').');
await writeWhole(await stageDir(REVIEWS_FOLDER),review.name,res.body);
FOLDER.saved.set(key,{order:review.order,name:review.name,review:true});
FOLDER.last=new Date();await keepSaved();reviewSaved++;
}
FOLDER.lastSig=sig;FOLDER.error='';
FOLDER.status='';
if(saved)say((stages?'Salvos ':'Baixados ')+saved+' arquivo(s) em '+where+'.');
if(hot)say('Gravados '+hot+' arquivo(s) na hot folder da máquina.');
if(printed)say(printed+' recibo(s) de retirada salvos em '+RECEIPTS_FOLDER+'.');
if(reviewSaved)say(reviewSaved+' foto(s)/vídeo(s) de revisão salvos em '+REVIEWS_FOLDER+'.');
if(moved)say(moved+' arquivo(s) mudaram de pasta com o pedido.');
if(removed)say(removed+' arquivo(s) de pedidos cancelados, excluídos, em correção, trocados ou finalizados há mais de '+KEEP_FINISHED_DAYS+' dias saíram das pastas.');
}catch(e){
@@ -1234,7 +1252,7 @@ function stageLimitsDialog(){
fields.push(field(STAGE_LABELS[state]+' (horas)',hours,state==='fin'?'Use 72 para 3 dias.':''));
fields.push(field('Responsável por '+STAGE_LABELS[state].toLowerCase(),who));
}
formDialog('Tempos aceitáveis por etapa',{host:$('drawer'),width:640,fields,
formDialog('Tempos aceitáveis por etapa',{host:dialogHost(),width:640,fields,
note:'Amarelo ao passar do limite; vermelho no dobro.',
onsave:async()=>{
const limits=Object.entries(inputs).map(([state,{hours,who}])=>({
@@ -1346,6 +1364,10 @@ $('filter-open').onclick=()=>phoneFilters();
// The panel's tab stays while the same order is open.
let panelTab='order';
// A dialog sits over the order's panel when it is open, and over the page
// when it is not: opened from a card's face or the board, inside the closed
// drawer it would be invisible.
const dialogHost=()=>$('drawer').hidden?document.body:$('drawer');
function openPanel(id){if(id!==openOrder)panelTab='order';openOrder=id;const order=board.orders.find(o=>o.id===id);$('drawer').hidden=false;renderPanel(order);renderBoard();}
function closePanel(){
for(const m of [...MODALS])if(m.host===$('drawer'))m.close();
@@ -1687,9 +1709,18 @@ function nextBox(order){
:'Pedido acima de 10 m: imprima a prova, confira e marque Prova OK antes de rodar o resto.')+' '+PROOF_RULE);
const p=proofBtn('btn pri lg');if(p)main.push(p);
}else{
title='Conferir a folha impressa';
note('Confira cores, recorte e a folha inteira contra o arquivo.');
if(can('fin'))main.push(moveBtn('fin','Liberar para Finalizado'));else cannot();
// Above 1 m the photo is required to finish (app/reviews.py): the main
// button takes it instead of releasing the order.
const hasPhoto=(order.reviews||[]).some(review=>review.kind==='photo');
if(!order.proof_parent&&orderMetres(order)>1&&!hasPhoto){
title='Tire a foto da revisão';
note('Pedido acima de 1 m: tire a foto da revisão antes de finalizar.');
if(may('inspect'))main.push(button('Revisar',()=>reviewDialog(order),'btn pri lg'));else cannot();
}else{
title='Conferir a folha impressa';
note('Confira cores, recorte e a folha inteira contra o arquivo.');
if(can('fin'))main.push(moveBtn('fin','Liberar para Finalizado'));else cannot();
}
}
fixBtn();
}else if(st==='fin'){
@@ -1856,8 +1887,169 @@ function checkButton(order,className='btn'){
function cardOpenAction(order){
const action=button('Abrir arquivo',()=>openCheck(order),'card-open');
action.prepend(svgIcon(IC.eye||IC.file,'i s'));
// In Revisão the Revisor also has the photo/video on the card's face, beside
// the file. The click is stopped by button(), as on "Abrir arquivo".
if(order.state==='rev'&&!order.cancelled_at&&may('inspect')){
const review=button('Revisar',()=>reviewDialog(order),'card-open');
review.prepend(svgIcon(IC.camera,'i s'));
const row=node('span',undefined,'card-open-row');row.append(action,review);
return row;
}
return action;
}
// "Revisar" (Fase 2, front 2): the sheet's photo or a video of up to 30 s,
// taken here with the computer's or the phone's camera, or a file already
// recorded. The server names it DTF-<n>-revisao-<seq> and keeps it 180 days.
const REVIEW_VIDEO_MAX=30;
const reviewClock=s=>Math.floor(s/60)+':'+String(s%60).padStart(2,'0');
function reviewDialog(order){
const host=dialogHost();
const video=node('video');video.className='reviewcam';video.muted=true;video.playsInline=true;video.autoplay=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 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 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);
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');};
const endStream=()=>{
if(recordTimer){clearInterval(recordTimer);recordTimer=null;}
if(stream){stream.getTracks().forEach(track=>track.stop());stream=null;}
};
const cleanup=()=>{
closed=true;
if(recorder&&recorder.state!=='inactive'){try{recorder.stop();}catch(_){}}
endStream();
if(objectUrl){URL.revokeObjectURL(objectUrl);objectUrl=null;}
};
function showReady(file,kind){
ready={file,kind};
endStream();
video.hidden=true;photoBtn.hidden=true;videoBtn.hidden=true;timer.hidden=true;
if(objectUrl)URL.revokeObjectURL(objectUrl);
objectUrl=URL.createObjectURL(file);
preview.replaceChildren();
if(kind==='video'){
const shot=node('video');shot.controls=true;shot.playsInline=true;shot.src=objectUrl;
shot.setAttribute('aria-label','Pré-visualização do vídeo gravado');preview.append(shot);
}else{
const shot=node('img');shot.src=objectUrl;shot.alt='Pré-visualização da foto';preview.append(shot);
}
preview.hidden=false;save.disabled=false;clear();save.focus();
}
function checkDuration(file){
return new Promise((resolve,reject)=>{
const probe=document.createElement('video');probe.preload='metadata';
const url=URL.createObjectURL(file);
probe.onloadedmetadata=()=>{
const seconds=probe.duration;URL.revokeObjectURL(url);
if(Number.isFinite(seconds)&&seconds>REVIEW_VIDEO_MAX+0.2)
reject(new Error('O vídeo tem mais de 30 segundos. Grave um de até 30 s ou envie outro menor.'));
else resolve();
};
probe.onerror=()=>{URL.revokeObjectURL(url);resolve();};
probe.src=url;
});
}
function stopRecording(){if(recorder&&recorder.state!=='inactive')recorder.stop();}
photoBtn.onclick=()=>{
clear();
const width=video.videoWidth,height=video.videoHeight;
if(!width||!height){fail('A câmera ainda não está pronta. Espere um instante.');return;}
const canvas=document.createElement('canvas');canvas.width=width;canvas.height=height;
canvas.getContext('2d').drawImage(video,0,0,width,height);
canvas.toBlob(blob=>{
if(!blob){fail('Não foi possível tirar a foto.');return;}
showReady(new File([blob],'revisao.jpg',{type:'image/jpeg'}),'photo');
},'image/jpeg',0.9);
};
videoBtn.onclick=()=>{
clear();
if(recording){stopRecording();return;}
if(!stream){fail('A câmera não está disponível. Envie um arquivo.');return;}
const options=['video/mp4','video/webm;codecs=vp9','video/webm'];
const mime=(window.MediaRecorder&&options.find(type=>MediaRecorder.isTypeSupported(type)))||'';
try{recorder=new MediaRecorder(stream,mime?{mimeType:mime}:undefined);}
catch(_){fail('Este navegador não grava vídeo. Envie um arquivo.');return;}
const type=recorder.mimeType||mime||'video/webm';
chunks=[];recording=true;recordStart=Date.now();
recorder.ondataavailable=event=>{if(event.data&&event.data.size)chunks.push(event.data);};
recorder.onstop=()=>{
recording=false;videoBtn.textContent='Gravar vídeo';
if(recordTimer){clearInterval(recordTimer);recordTimer=null;}
if(closed)return;
const blob=new Blob(chunks,{type});chunks=[];
if(!blob.size){fail('Não foi possível gravar o vídeo.');return;}
showReady(new File([blob],'revisao.'+(type.includes('mp4')?'mp4':'webm'),{type}),'video');
};
recorder.start();videoBtn.textContent='Parar';
const paint=()=>{
const elapsed=Math.min(REVIEW_VIDEO_MAX,Math.floor((Date.now()-recordStart)/1000));
timer.textContent=reviewClock(elapsed)+' / '+reviewClock(REVIEW_VIDEO_MAX);
if(elapsed>=REVIEW_VIDEO_MAX)stopRecording();
};
paint();recordTimer=setInterval(paint,250);
};
input.onchange=async()=>{
const file=input.files[0];if(!file)return;
clear();
const name=file.name.toLowerCase();
const isVideo=file.type.startsWith('video/')||/\.(mp4|webm|mov)$/.test(name);
const isPhoto=file.type.startsWith('image/')||/\.(jpe?g|png|webp)$/.test(name);
if(!isVideo&&!isPhoto){input.value='';fail('Escolha uma foto JPG, PNG ou WebP, ou um vídeo MP4, WebM ou MOV.');return;}
if(isVideo){
try{await checkDuration(file);}catch(error){input.value='';fail(error.message);return;}
if(closed)return;
showReady(file,'video');
}else showReady(file,'photo');
};
fileLabel.onkeydown=event=>{if(event.key==='Enter'||event.key===' '){event.preventDefault();input.click();}};
cancel.onclick=()=>m.close();
save.onclick=async()=>{
if(!ready)return;
save.disabled=true;clear();status.textContent='Enviando '+ready.file.name+'…';
try{
const uid=await dtfUpload(ready.file,{api,startPath:'/orders/'+order.id+'/reviews/uploads',
scope:'operator:review:'+order.id,progress:text=>{if(!closed)status.textContent=text;}});
if(closed)return;
await api('/orders/'+order.id+'/reviews',{upload_id:uid});
m.close();
say('Revisão salva no pedido #'+order.number+'.');
await load();
}catch(error){
if(closed)return;
fail(error.message);save.disabled=false;
}
};
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.',
body:[video,controls,timer,preview],foot:[status,cancel,save],onclose:cleanup});
(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;
await video.play().catch(()=>{});
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();
}
})();
}
async function openCheck(order){
const {files}=await api('/orders/'+order.id+'/view');
if(!files.length){say('Ainda não há arquivo para abrir.',true);return;}
@@ -1962,12 +2154,49 @@ function treatDialog(order){
paint();
})();
}
// The reviews recorded on the order: what was checked, when and by whom. A
// photo opens in the viewer; a video cannot, so it opens in a new tab. In
// Revisão a reviewer may remove one.
function reviewSection(order){
if(!order.reviews?.length)return null;
const box=node('section',undefined,'reviewsec');box.setAttribute('aria-label','Revisões');
const info=node('div',undefined,'iinfo');
info.append(node('span','Revisões','lbl'),node('h3',plural(order.reviews.length,'revisão','revisões')));
const list=node('div',undefined,'reviewlist');
for(const review of order.reviews){
const row=node('div',undefined,'reviewrow');
const open=node('button',undefined,'reviewopen');open.type='button';
open.append(node('span','Revisão · '+(review.kind==='video'?'vídeo':'foto')+' · '+
when(review.created_at)+' · '+review.created_by));
open.onclick=async()=>{
try{
const view=await api('/orders/'+order.id+'/reviews/'+review.id+'/view');
if(review.kind==='photo'&&window.openViewer)openViewer([{name:view.name,picture:view.url}],{title:'Revisão #'+order.number});
else{const link=node('a');link.href=view.url;link.target='_blank';link.rel='noopener noreferrer';link.click();}
}catch(error){say(error.message,true);}
};
row.append(open);
if(order.state==='rev'&&may('inspect')){
const remove=node('button','Remover','btn quiet');remove.type='button';
remove.onclick=async()=>{
if(!await ask('Remover esta revisão?','Ela some do pedido e o arquivo deixa de ficar guardado.','Remover revisão',{tone:'red',host:$('drawer')}))return;
await api('/orders/'+order.id+'/reviews/'+review.id+'/remove',{});
say('Revisão removida do pedido #'+order.number+'.');await load();
};
row.append(remove);
}
list.append(row);
}
info.append(list);box.append(info);
return box;
}
// Pedido: the items, then who, where and on which machine, then any rework.
function orderView(order){
const view=node('div',undefined,'tview');
const s=order.snapshot;
s.items.forEach((item,index)=>view.append(itemCard(order,item,index)));
view.append(orderFacts(order));
const reviews=reviewSection(order);if(reviews)view.append(reviews);
if(order.reworks?.length)view.append(reworkSection(order));
return view;
}
@@ -2326,7 +2555,7 @@ function avatar(u,className='ava'){
// "O que cada perfil faz": Y does it, V only looks; the server's rules (app/core/auth.py).
const ROLE_COLUMNS=['admin','gestao','designer','operador','revisor','vendedor','financeiro'];
const ROLE_MATRIX=[['Aprovar o arquivo final','YYYNNNN'],['Pedir correção','YYYNNNN'],['Puxar da fila e imprimir','YNNYNNN'],
['Liberar para Finalizado','YNNNYNN'],['Voltar uma etapa, com motivo','YYYYYNN'],['Marcar retirado','YYYYYNN'],
['Liberar para Finalizado','YNNNYNN'],['Foto da revisão','YYNNYNN'],['Voltar uma etapa, com motivo','YYYYYNN'],['Marcar retirado','YYYYYNN'],
['Cotações e Números','YYNNNVV'],['Pagamentos','YYNNNNV'],['Pedido pago fora do site','YYNNNNN'],['Prova OK ou reprovada','YYNNNYN'],['Cancelar pedido','YYNNNNY'],
['Abrir retrabalho','NYNNNNN'],['Autorizar retrabalho','YNNNNNN'],['Usuários e máquinas','YNNNNNN']];
let usersData=null;

View File

@@ -134,6 +134,8 @@ button:disabled{opacity:.6;cursor:default}
.arquivo>div{flex:1;min-width:0;display:flex;flex-direction:column}
.arquivo b{overflow-wrap:anywhere;font-size:15px}
.arquivo span{font-size:14px;color:var(--fraco)}
.fotoPed{display:flex;flex-direction:column;align-items:flex-start;gap:10px;margin-bottom:14px}
.fotoPed img{display:block;max-width:100%;height:auto;border:1px solid var(--linha);border-radius:var(--raio2)}
.correcaoForm{display:flex;flex-direction:column;padding:16px;border-radius:var(--raio2);background:var(--cinza)}
.correcaoForm label{margin:10px 0 5px;font-size:14px;font-weight:600;color:var(--texto2)}
.correcaoForm textarea{height:auto;padding:10px 13px;resize:vertical}

View File

@@ -246,6 +246,18 @@ async function details(id,container,criado){
}
container.append(arq);
}
if(order.state==='fin'&&order.reviews?.length){
const sec=node('div',null,'secao fotoPedSec');sec.append(node('h4','Foto do seu pedido'));
for(const review of order.reviews){
const view=await api('/customer/orders/'+id+'/reviews/'+review.id+'/view');
const row=node('div',null,'fotoPed');
const img=node('img');img.alt='Foto da folha impressa do pedido #'+order.number;
img.loading='lazy';img.src=view.url;
const link=node('a','Baixar foto','bSec');link.href=view.url;link.download=view.name;link.target='_blank';link.rel='noopener noreferrer';
row.append(img,link);sec.append(row);
}
container.append(sec);
}
if(order.state==='cor'){
const form=node('form',null,'secao correcaoForm');form.append(node('h4','Enviar arte corrigida'));
const inputs=order.snapshot.items.map((item,index)=>{