diff --git a/app.js b/app.js index 14363768..281011d8 100644 --- a/app.js +++ b/app.js @@ -6459,7 +6459,8 @@ function projectContentSig(data,venueSig){ /* classifica l'origine dell'evento: separa il traffico reale (prod) dallo sviluppo (localhost) nei dati */ function analyticsEnv(h){ h=(h!=null?h:location.hostname); return /(^|\.)stageplot\.it$/.test(h)?"prod":((h==="localhost"||h==="127.0.0.1"||h==="[::1]"||!h)?"localhost":"other"); } function track(event, props){ - try{ if(event==="export") exportNudgeSegna("fatto"); }catch(e){} /* chi esporta ha trovato il pulsante: l'invito non serve più */ + try{ if(event==="export") exportNudgeSegna("fatto"); }catch(e){} + if(event==="export" && window.__pdfDaBarra && props && props.format==="pdf"){ props={format:"pdf", from:"barra"}; window.__pdfDaBarra=false; } /* PDF partito dalla barra «palco pronto» (P2, 30/11): `from` è già nell'allowlist 0035 */ /* chi esporta ha trovato il pulsante: l'invito non serve più */ try{ if(/[?&](view|export)=/.test(location.search) || foreignDoc()) return; usoConta(event, props); /* contatore aggregato anonimo, fire-and-forget: mai un errore, mai un ritardo */ @@ -6556,6 +6557,7 @@ function exportNudgeDecidi(o){ if(!o || o.altrui || o.mobile) return false; var s=String(o.stato==null?"":o.stato); if(s==="fatto" || s==="no") return false; + if(o.barraInSessione) return false; /* la barra «palco pronto» è già comparsa in questa sessione: il contatore è uno solo (3 sessioni in tutto), l'invito non si aggiunge */ if(o.bannerVisibile) return false; /* una riga alla volta: se un banner è a schermo (cavi, vista, «stai riaprendo») l'invito aspetta (C-3) */ if(!(o.elementi>=EXPNUDGE_MIN)) return false; var n=parseInt(s,10); if(!(n>=0)) n=0; @@ -6577,7 +6579,7 @@ function exportNudgeSegna(azione){ if(azione==="fatto" || azione==="no") exportNudgeNascondi(); } function bannerCanvasVisibile(){ - return ["funzBanner","vistaBanner","riapriBanner"].some(function(id){ var e=document.getElementById(id); return !!e && e.hidden===false; }); + return ["funzBanner","vistaBanner","riapriBanner","pdfPronto"].some(function(id){ var e=document.getElementById(id); return !!e && e.hidden===false; }); } function exportNudgeNascondi(){ var el=document.getElementById("expNudge"); if(el) el.hidden=true; @@ -6586,7 +6588,7 @@ function exportNudgeNascondi(){ function exportNudgeAggiorna(){ try{ var b=document.getElementById("bExportHdr"); if(!b) return; - var ok=exportNudgeDecidi({ altrui:foreignDoc(), mobile:isMobile(), stato:exportNudgeLeggi(), elementi:(state.items||[]).length, giaInSessione:exportNudgeInSessione, bannerVisibile:bannerCanvasVisibile() }); + var ok=exportNudgeDecidi({ altrui:foreignDoc(), mobile:isMobile(), stato:exportNudgeLeggi(), elementi:(state.items||[]).length, giaInSessione:exportNudgeInSessione, barraInSessione:pdfProntoInSessione, bannerVisibile:bannerCanvasVisibile() }); var pdf=document.getElementById("pdfModal"); if(ok && b.offsetParent===null) ok=false; /* pulsante non visibile: niente invito */ if(!ok || (pdf && !pdf.hidden)){ exportNudgeNascondi(); return; } @@ -6624,6 +6626,79 @@ function titoloSegnapostoAggiorna(){ if(i.placeholder!==t) i.placeholder=t; }catch(e){} } +/* «PALCO PRONTO» — PDF IN UN CLIC (30/11/2026, onboarding P2: dal palco al PDF si perde il 64 % delle sessioni attivate, mediana ~24 min). + Una barra in basso, fissa e piccola: «Il tuo palco è pronto · [Scarica il PDF] · Cosa c'è nel PDF ›». «Scarica il PDF» apre la finestra + Esporta GIÀ preimpostata (palco + scheda tecnica quando c'è, formato e scala di serie) e avvia il download: il gate sugli errori critici + resta quello di sempre (pdfGateErrori), la finestra resta aperta sul «✓ PDF scaricato». «Cosa c'è nel PDF ›» apre la finestra senza + scaricare, per chi vuole scegliere. NON è un popup: non copre il palco, non blocca, «✕» la spegne per sempre. + Regole: desktop (sul telefono l'Esporta è nel dock: onboarding P3); ≥3 elementi; mai su un documento altrui; si spegne da sola dopo il + primo PDF su questo dispositivo (stessa chiave dell'invito su Esporta: «fatto») o con «✕» («no»); una riga alla volta (aspetta i banner + del canvas e la finestra Esporta). Preferenza dell'interfaccia: all'uscita dall'account si tiene (come l'invito). */ +var PDFPRONTO_MIN=3; +function pdfProntoDecidi(o){ + if(!o || o.altrui || o.mobile) return false; + var s=String(o.stato==null?"":o.stato); + if(s==="fatto" || s==="no") return false; + var _n=parseInt(s,10); if(!(_n>=0)) _n=0; + if(!(_n=PDFPRONTO_MIN; +} +/* La frase dice la cosa più utile che manca, una sola: senza nome il file esce «stage-plot.pdf» e il cartiglio resta vuoto. */ +function pdfProntoTesto(o){ + if(o && !String(o.titolo||"").trim()) return {testo:"Il tuo palco è pronto", nota:"manca il nome del palco (in alto)", daNome:true}; + return {testo:"Il tuo palco è pronto", nota:"", daNome:false}; +} +var pdfProntoInSessione=false; +function pdfProntoNascondi(){ var el=document.getElementById("pdfPronto"); if(el) el.hidden=true; } +function pdfProntoAggiorna(){ + try{ + var el=document.getElementById("pdfPronto"); + var mod=document.getElementById("pdfModal"), pk=document.getElementById("pkgModal"); + var aperta=!!((mod && !mod.hidden) || (pk && !pk.hidden) || document.body.classList.contains("area-edit") || document.body.classList.contains("export-menu") || document.querySelector(".modal:not([hidden])")); + /* ingombro: «Cosa manca?» aperta (la barra dice «pronto» accanto a «Palco da sistemare»), suggerimento di primo uso e messaggio in basso (si pestano con la barra) */ + var ingombro=!!((typeof auditActive!=="undefined" && auditActive) || document.getElementById("dragHint") || (function(){ var ct=document.getElementById("cloudToast"); return !!ct && ct.hidden===false; })()); + var ok=pdfProntoDecidi({ altrui:foreignDoc(), mobile:isMobile(), stato:exportNudgeLeggi(), elementi:(state.items||[]).length, esportato:!!state.pdfEsportato, ingombro:ingombro, giaInSessione:pdfProntoInSessione, + bannerVisibile:["funzBanner","vistaBanner","riapriBanner"].some(function(id){ var e=document.getElementById(id); return !!e && e.hidden===false; }), finestraAperta:aperta }); + var bx=document.getElementById("bExportHdr"); + if(ok && (!bx || bx.offsetParent===null)) ok=false; /* senza il pulsante Esporta in vista (viste speciali, editor «Crea elemento») niente scorciatoia */ + if(!ok){ if(el) el.hidden=true; return; } + var t=pdfProntoTesto({titolo:state.titolo}); + if(!pdfProntoInSessione){ pdfProntoInSessione=true; if(!exportNudgeInSessione){ exportNudgeInSessione=true; exportNudgeSegna("mostrato"); } } /* conta UNA sessione, la prima volta che compare (stesso contatore dell'invito) */ + if(!el){ + el=document.createElement("div"); el.id="pdfPronto"; el.setAttribute("role","status"); + el.innerHTML='' + +'' + +'' + +''; + el.querySelector(".pp-go").addEventListener("click", function(){ + if(typeof window.preloadRespData==="function") window.preloadRespData(); + if(typeof window.openPdfExportModal==="function") window.openPdfExportModal(); + window.__pdfDaBarra=true; /* DOPO l'apertura (che lo azzera): il prossimo evento «export» porta from:"barra" (chiave già nell'allowlist 0035: nessuna migrazione) */ + var go=document.getElementById("pdfGo"); if(go && !go.disabled) go.click(); + pdfProntoNascondi(); + try{ var pc=document.getElementById("pdfCancel"); if(pc) pc.focus(); }catch(_e){} /* il pulsante sparisce: il fuoco passa alla finestra, non resta sul body */ + }); + el.querySelector(".pp-vedi").addEventListener("click", function(){ var h=document.getElementById("bHdrPdf"); if(h) h.click(); pdfProntoNascondi(); }); + el.querySelector(".pp-x").addEventListener("click", function(){ exportNudgeSegna("no"); pdfProntoNascondi(); }); + document.body.appendChild(el); + } + var tt=el.querySelector(".pp-t"), nn=el.querySelector(".pp-n"); + if(tt.textContent!==t.testo) tt.textContent=t.testo; + if(nn.textContent!==t.nota) nn.textContent=t.nota ? " · "+t.nota : ""; + /* centrata sull'area del palco, non sulla finestra: tra ~880 e ~1150 px i pannelli laterali stanno sotto la barra («Specchia», «In fondo», scheda «Pedana») */ + var mq=document.querySelector("main"); if(mq){ var q=mq.getBoundingClientRect(); if(q.width>0){ el.style.left=Math.round(q.left+q.width/2)+"px"; el.style.maxWidth=Math.max(0,Math.round(q.width-24))+"px"; } } + exportNudgeNascondi(); + el.hidden=false; + /* area del palco stretta (~880–1000 px): se il titolo non ci sta si toglie il link secondario, «Scarica il PDF» e «✕» restano */ + el.classList.remove("pp-stretta"); + var _tc=el.querySelector(".pp-t"), _tx=el.querySelector(".pp-txt"); + if(_tc && _tx && _tc.getBoundingClientRect().right>_tx.getBoundingClientRect().right+1) el.classList.add("pp-stretta"); + }catch(e){} +} +window.pdfProntoAggiorna=pdfProntoAggiorna; +try{ setInterval(pdfProntoAggiorna, 1500); window.addEventListener("resize", pdfProntoAggiorna); setTimeout(pdfProntoAggiorna, 400); }catch(e){} /* prima dell'invito su Esporta (2,5 s): quando la barra c'è, l'invito aspetta */ window.exportNudgeAggiorna=exportNudgeAggiorna; try{ setInterval(function(){ exportNudgeAggiorna(); titoloSegnapostoAggiorna(); }, 2500); window.addEventListener("resize", function(){ exportNudgeAggiorna(); titoloSegnapostoAggiorna(); }); setTimeout(titoloSegnapostoAggiorna, 300); }catch(e){} (function(){ try{ var b=document.getElementById("bExportHdr"); if(b) b.addEventListener("click", function(){ exportNudgeSegna("fatto"); }); }catch(e){} })(); @@ -46438,7 +46513,7 @@ function pdfGateErrori(run){ confirmText:"Esporta comunque", cancelText:"Apri «Cosa manca?»" }).then(function(ok){ if(ok){ run(); return; } - var _pm=document.getElementById("pdfModal"), _pk=document.getElementById("pkgModal"); if(_pm) _pm.hidden=true; if(_pk) _pk.hidden=true; window.__pdfScope="full"; + var _pm=document.getElementById("pdfModal"), _pk=document.getElementById("pkgModal"); if(_pm) _pm.hidden=true; if(_pk) _pk.hidden=true; window.__pdfScope="full"; window.__pdfDaBarra=false; /* export non partito: niente etichetta «barra» sul prossimo */ if(typeof toggleAuditView==="function" && typeof auditActive!=="undefined" && !auditActive) toggleAuditView(); else if(typeof techAccordionOpen==="function") techAccordionOpen("audit"); }); @@ -47866,6 +47941,7 @@ function pdfChannelPage(doc, L, paperKey){ invitoSalvaNascondi(); /* l'invito vale per l'export appena fatto: riaprendo la finestra non resta lì */ rigaProgettoNascondi(); /* idem la riga «dove resta il progetto» (P2) */ pdfScalettaInit(); pdfQrInit(); /* scaletta spuntata se c'è; QR sempre spento all'apertura (10/10) */ + window.__pdfDaBarra=false; /* ogni apertura riparte da zero: un export da «Esporta» non eredita l'etichetta «barra» */ /* Il nome del progetto si rilegge dallo STATO ogni volta che la finestra si apre. Un modello scrive state.titolo («Band pop/rock») e l'header lo mostrava, ma questo campo restava vuoto e la riga sotto prometteva «stage-plot.pdf»: due verità nella stessa schermata. Chi imposta il diff --git a/app/index.html b/app/index.html index cc7d3e72..6ea90c52 100644 --- a/app/index.html +++ b/app/index.html @@ -24,7 +24,7 @@ due release nello stesso giorno restano distinguibili in telemetria e supporto. In locale/dev resta il placeholder. La sentinella del VALORE è distinta dall'identificatore window.__BUILD_ID__ così il sed della CI non tocca il nome della variabile. --> - + diff --git a/index.template.html b/index.template.html index b5e6edf1..6a146eb6 100644 --- a/index.template.html +++ b/index.template.html @@ -8552,7 +8552,8 @@

⟦esporta.esportaPdfInScala⟧

/* classifica l'origine dell'evento: separa il traffico reale (prod) dallo sviluppo (localhost) nei dati */ function analyticsEnv(h){ h=(h!=null?h:location.hostname); return /(^|\.)stageplot\.it$/.test(h)?"prod":((h==="localhost"||h==="127.0.0.1"||h==="[::1]"||!h)?"localhost":"other"); } function track(event, props){ - try{ if(event==="export") exportNudgeSegna("fatto"); }catch(e){} /* chi esporta ha trovato il pulsante: l'invito non serve più */ + try{ if(event==="export") exportNudgeSegna("fatto"); }catch(e){} + if(event==="export" && window.__pdfDaBarra && props && props.format==="pdf"){ props={format:"pdf", from:"barra"}; window.__pdfDaBarra=false; } /* PDF partito dalla barra «palco pronto» (P2, 30/11): `from` è già nell'allowlist 0035 */ /* chi esporta ha trovato il pulsante: l'invito non serve più */ try{ if(/[?&](view|export)=/.test(location.search) || foreignDoc()) return; usoConta(event, props); /* contatore aggregato anonimo, fire-and-forget: mai un errore, mai un ritardo */ @@ -8649,6 +8650,7 @@

⟦esporta.esportaPdfInScala⟧

if(!o || o.altrui || o.mobile) return false; var s=String(o.stato==null?"":o.stato); if(s==="fatto" || s==="no") return false; + if(o.barraInSessione) return false; /* la barra «palco pronto» è già comparsa in questa sessione: il contatore è uno solo (3 sessioni in tutto), l'invito non si aggiunge */ if(o.bannerVisibile) return false; /* una riga alla volta: se un banner è a schermo (cavi, vista, «stai riaprendo») l'invito aspetta (C-3) */ if(!(o.elementi>=EXPNUDGE_MIN)) return false; var n=parseInt(s,10); if(!(n>=0)) n=0; @@ -8670,7 +8672,7 @@

⟦esporta.esportaPdfInScala⟧

if(azione==="fatto" || azione==="no") exportNudgeNascondi(); } function bannerCanvasVisibile(){ - return ["funzBanner","vistaBanner","riapriBanner"].some(function(id){ var e=document.getElementById(id); return !!e && e.hidden===false; }); + return ["funzBanner","vistaBanner","riapriBanner","pdfPronto"].some(function(id){ var e=document.getElementById(id); return !!e && e.hidden===false; }); } function exportNudgeNascondi(){ var el=document.getElementById("expNudge"); if(el) el.hidden=true; @@ -8679,7 +8681,7 @@

⟦esporta.esportaPdfInScala⟧

function exportNudgeAggiorna(){ try{ var b=document.getElementById("bExportHdr"); if(!b) return; - var ok=exportNudgeDecidi({ altrui:foreignDoc(), mobile:isMobile(), stato:exportNudgeLeggi(), elementi:(state.items||[]).length, giaInSessione:exportNudgeInSessione, bannerVisibile:bannerCanvasVisibile() }); + var ok=exportNudgeDecidi({ altrui:foreignDoc(), mobile:isMobile(), stato:exportNudgeLeggi(), elementi:(state.items||[]).length, giaInSessione:exportNudgeInSessione, barraInSessione:pdfProntoInSessione, bannerVisibile:bannerCanvasVisibile() }); var pdf=document.getElementById("pdfModal"); if(ok && b.offsetParent===null) ok=false; /* pulsante non visibile: niente invito */ if(!ok || (pdf && !pdf.hidden)){ exportNudgeNascondi(); return; } @@ -8717,6 +8719,79 @@

⟦esporta.esportaPdfInScala⟧

if(i.placeholder!==t) i.placeholder=t; }catch(e){} } +/* «PALCO PRONTO» — PDF IN UN CLIC (30/11/2026, onboarding P2: dal palco al PDF si perde il 64 % delle sessioni attivate, mediana ~24 min). + Una barra in basso, fissa e piccola: «Il tuo palco è pronto · [Scarica il PDF] · Cosa c'è nel PDF ›». «Scarica il PDF» apre la finestra + Esporta GIÀ preimpostata (palco + scheda tecnica quando c'è, formato e scala di serie) e avvia il download: il gate sugli errori critici + resta quello di sempre (pdfGateErrori), la finestra resta aperta sul «✓ PDF scaricato». «Cosa c'è nel PDF ›» apre la finestra senza + scaricare, per chi vuole scegliere. NON è un popup: non copre il palco, non blocca, «✕» la spegne per sempre. + Regole: desktop (sul telefono l'Esporta è nel dock: onboarding P3); ≥3 elementi; mai su un documento altrui; si spegne da sola dopo il + primo PDF su questo dispositivo (stessa chiave dell'invito su Esporta: «fatto») o con «✕» («no»); una riga alla volta (aspetta i banner + del canvas e la finestra Esporta). Preferenza dell'interfaccia: all'uscita dall'account si tiene (come l'invito). */ +var PDFPRONTO_MIN=3; +function pdfProntoDecidi(o){ + if(!o || o.altrui || o.mobile) return false; + var s=String(o.stato==null?"":o.stato); + if(s==="fatto" || s==="no") return false; + var _n=parseInt(s,10); if(!(_n>=0)) _n=0; + if(!(_n=PDFPRONTO_MIN; +} +/* La frase dice la cosa più utile che manca, una sola: senza nome il file esce «stage-plot.pdf» e il cartiglio resta vuoto. */ +function pdfProntoTesto(o){ + if(o && !String(o.titolo||"").trim()) return {testo:"Il tuo palco è pronto", nota:"manca il nome del palco (in alto)", daNome:true}; + return {testo:"Il tuo palco è pronto", nota:"", daNome:false}; +} +var pdfProntoInSessione=false; +function pdfProntoNascondi(){ var el=document.getElementById("pdfPronto"); if(el) el.hidden=true; } +function pdfProntoAggiorna(){ + try{ + var el=document.getElementById("pdfPronto"); + var mod=document.getElementById("pdfModal"), pk=document.getElementById("pkgModal"); + var aperta=!!((mod && !mod.hidden) || (pk && !pk.hidden) || document.body.classList.contains("area-edit") || document.body.classList.contains("export-menu") || document.querySelector(".modal:not([hidden])")); + /* ingombro: «Cosa manca?» aperta (la barra dice «pronto» accanto a «Palco da sistemare»), suggerimento di primo uso e messaggio in basso (si pestano con la barra) */ + var ingombro=!!((typeof auditActive!=="undefined" && auditActive) || document.getElementById("dragHint") || (function(){ var ct=document.getElementById("cloudToast"); return !!ct && ct.hidden===false; })()); + var ok=pdfProntoDecidi({ altrui:foreignDoc(), mobile:isMobile(), stato:exportNudgeLeggi(), elementi:(state.items||[]).length, esportato:!!state.pdfEsportato, ingombro:ingombro, giaInSessione:pdfProntoInSessione, + bannerVisibile:["funzBanner","vistaBanner","riapriBanner"].some(function(id){ var e=document.getElementById(id); return !!e && e.hidden===false; }), finestraAperta:aperta }); + var bx=document.getElementById("bExportHdr"); + if(ok && (!bx || bx.offsetParent===null)) ok=false; /* senza il pulsante Esporta in vista (viste speciali, editor «Crea elemento») niente scorciatoia */ + if(!ok){ if(el) el.hidden=true; return; } + var t=pdfProntoTesto({titolo:state.titolo}); + if(!pdfProntoInSessione){ pdfProntoInSessione=true; if(!exportNudgeInSessione){ exportNudgeInSessione=true; exportNudgeSegna("mostrato"); } } /* conta UNA sessione, la prima volta che compare (stesso contatore dell'invito) */ + if(!el){ + el=document.createElement("div"); el.id="pdfPronto"; el.setAttribute("role","status"); + el.innerHTML='' + +'' + +'' + +''; + el.querySelector(".pp-go").addEventListener("click", function(){ + if(typeof window.preloadRespData==="function") window.preloadRespData(); + if(typeof window.openPdfExportModal==="function") window.openPdfExportModal(); + window.__pdfDaBarra=true; /* DOPO l'apertura (che lo azzera): il prossimo evento «export» porta from:"barra" (chiave già nell'allowlist 0035: nessuna migrazione) */ + var go=document.getElementById("pdfGo"); if(go && !go.disabled) go.click(); + pdfProntoNascondi(); + try{ var pc=document.getElementById("pdfCancel"); if(pc) pc.focus(); }catch(_e){} /* il pulsante sparisce: il fuoco passa alla finestra, non resta sul body */ + }); + el.querySelector(".pp-vedi").addEventListener("click", function(){ var h=document.getElementById("bHdrPdf"); if(h) h.click(); pdfProntoNascondi(); }); + el.querySelector(".pp-x").addEventListener("click", function(){ exportNudgeSegna("no"); pdfProntoNascondi(); }); + document.body.appendChild(el); + } + var tt=el.querySelector(".pp-t"), nn=el.querySelector(".pp-n"); + if(tt.textContent!==t.testo) tt.textContent=t.testo; + if(nn.textContent!==t.nota) nn.textContent=t.nota ? " · "+t.nota : ""; + /* centrata sull'area del palco, non sulla finestra: tra ~880 e ~1150 px i pannelli laterali stanno sotto la barra («Specchia», «In fondo», scheda «Pedana») */ + var mq=document.querySelector("main"); if(mq){ var q=mq.getBoundingClientRect(); if(q.width>0){ el.style.left=Math.round(q.left+q.width/2)+"px"; el.style.maxWidth=Math.max(0,Math.round(q.width-24))+"px"; } } + exportNudgeNascondi(); + el.hidden=false; + /* area del palco stretta (~880–1000 px): se il titolo non ci sta si toglie il link secondario, «Scarica il PDF» e «✕» restano */ + el.classList.remove("pp-stretta"); + var _tc=el.querySelector(".pp-t"), _tx=el.querySelector(".pp-txt"); + if(_tc && _tx && _tc.getBoundingClientRect().right>_tx.getBoundingClientRect().right+1) el.classList.add("pp-stretta"); + }catch(e){} +} +window.pdfProntoAggiorna=pdfProntoAggiorna; +try{ setInterval(pdfProntoAggiorna, 1500); window.addEventListener("resize", pdfProntoAggiorna); setTimeout(pdfProntoAggiorna, 400); }catch(e){} /* prima dell'invito su Esporta (2,5 s): quando la barra c'è, l'invito aspetta */ window.exportNudgeAggiorna=exportNudgeAggiorna; try{ setInterval(function(){ exportNudgeAggiorna(); titoloSegnapostoAggiorna(); }, 2500); window.addEventListener("resize", function(){ exportNudgeAggiorna(); titoloSegnapostoAggiorna(); }); setTimeout(titoloSegnapostoAggiorna, 300); }catch(e){} (function(){ try{ var b=document.getElementById("bExportHdr"); if(b) b.addEventListener("click", function(){ exportNudgeSegna("fatto"); }); }catch(e){} })(); @@ -47493,7 +47568,7 @@

⟦esporta.esportaPdfInScala⟧

confirmText:"Esporta comunque", cancelText:"Apri «Cosa manca?»" }).then(function(ok){ if(ok){ run(); return; } - var _pm=document.getElementById("pdfModal"), _pk=document.getElementById("pkgModal"); if(_pm) _pm.hidden=true; if(_pk) _pk.hidden=true; window.__pdfScope="full"; + var _pm=document.getElementById("pdfModal"), _pk=document.getElementById("pkgModal"); if(_pm) _pm.hidden=true; if(_pk) _pk.hidden=true; window.__pdfScope="full"; window.__pdfDaBarra=false; /* export non partito: niente etichetta «barra» sul prossimo */ if(typeof toggleAuditView==="function" && typeof auditActive!=="undefined" && !auditActive) toggleAuditView(); else if(typeof techAccordionOpen==="function") techAccordionOpen("audit"); }); @@ -48921,6 +48996,7 @@

⟦esporta.esportaPdfInScala⟧

invitoSalvaNascondi(); /* l'invito vale per l'export appena fatto: riaprendo la finestra non resta lì */ rigaProgettoNascondi(); /* idem la riga «dove resta il progetto» (P2) */ pdfScalettaInit(); pdfQrInit(); /* scaletta spuntata se c'è; QR sempre spento all'apertura (10/10) */ + window.__pdfDaBarra=false; /* ogni apertura riparte da zero: un export da «Esporta» non eredita l'etichetta «barra» */ /* Il nome del progetto si rilegge dallo STATO ogni volta che la finestra si apre. Un modello scrive state.titolo («Band pop/rock») e l'header lo mostrava, ma questo campo restava vuoto e la riga sotto prometteva «stage-plot.pdf»: due verità nella stessa schermata. Chi imposta il diff --git a/src/styles.css b/src/styles.css index 2eeae444..badfc0a8 100644 --- a/src/styles.css +++ b/src/styles.css @@ -4619,3 +4619,22 @@ body.dark #caviLegenda{box-shadow:0 6px 20px rgba(0,0,0,.4)} #layerRows .cu-lriga .layer-cnt{margin-left:auto} #layerRows .cu-lriga .cu-dot{background:conic-gradient(#0d9488 0 25%,#4f46e5 0 50%,#d97706 0 75%,#db2777 0)} + +/* «Palco pronto — PDF in un clic» (30/11/2026, onboarding P2): barra fissa in basso, non copre il palco, solo desktop */ +#pdfPronto{position:fixed;left:50%;bottom:16px;transform:translateX(-50%);z-index:40;display:flex;align-items:center;gap:10px;max-width:calc(100vw - 24px);padding:6px 6px 6px 16px;border:1px solid var(--accent-soft);border-radius:999px;background:var(--surface,#fff);color:var(--text);font-size:13px;line-height:1.3;box-shadow:0 6px 20px rgba(38,33,24,.16)} +#pdfPronto[hidden]{display:none} +#pdfPronto .pp-txt{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap} +#pdfPronto .pp-n{color:var(--text-2)} +#pdfPronto .pp-go{flex:none;white-space:nowrap;display:inline-flex;align-items:center;gap:6px;border:1px solid var(--accent-strong);background:var(--accent-strong);color:#fff;font:inherit;font-weight:600;padding:7px 14px;border-radius:999px;cursor:pointer} +#pdfPronto .pp-go:hover{background:var(--accent-deep);border-color:var(--accent-deep)} +body.dark #pdfPronto .pp-go{background:#0b7a70;border-color:#0b7a70} /* in scuro --accent-strong è chiaro: col testo bianco 1,48:1. Teal scuro come .btn.primary: 5,21:1 */ +body.dark #pdfPronto .pp-go:hover{background:#096a61;border-color:#096a61} +#pdfPronto .pp-vedi{flex:none;white-space:nowrap;border:0;background:transparent;color:var(--accent-strong);font:inherit;padding:6px 8px;border-radius:8px;cursor:pointer} +#pdfPronto .pp-vedi:hover{background:var(--accent-tint)} +#pdfPronto.pp-stretta .pp-vedi{display:none} /* area del palco stretta: il titolo non si tronca, il link secondario cede */ +#pdfPronto .pp-x{flex:none;border:0;background:transparent;color:var(--text-2);font-size:14px;line-height:1;padding:6px 9px;border-radius:999px;cursor:pointer} +#pdfPronto .pp-x:hover{background:var(--accent-tint);color:var(--text)} +#pdfPronto button:focus-visible{outline:2px solid var(--accent);outline-offset:2px} +body.dark #pdfPronto{box-shadow:0 6px 20px rgba(0,0,0,.4)} +@media (max-width:880px){ #pdfPronto{display:none} } +@media print{ #pdfPronto{display:none} } diff --git a/test/e2e-esporta/pronto.mjs b/test/e2e-esporta/pronto.mjs new file mode 100644 index 00000000..60473a03 --- /dev/null +++ b/test/e2e-esporta/pronto.mjs @@ -0,0 +1,64 @@ +/* Banco di prova nel browser (FUORI dalla CI): barra «Il tuo palco è pronto · Scarica il PDF» (onboarding P2, 30/11/2026). + Uso: node test/e2e-esporta/pronto.mjs */ +import { chromium, pagina, VISTE } from "./comune.mjs"; +let ko = 0; const ok = (c, m) => { console.log((c ? " ✓ " : " ✗ ") + m); if (!c) ko++; }; +const b = await chromium.launch(); +const stato = (p) => p.evaluate(() => { window.pdfProntoAggiorna(); const e = document.getElementById("pdfPronto"); return { visibile: !!(e && !e.hidden && e.getClientRects().length), testo: e ? e.innerText : "" }; }); +const pon = (p, n) => p.evaluate((n) => { state.titolo = ""; state.stage = { w: 1400, d: 900, blocks: [{ x: 0, y: 0, w: 1400, d: 900 }] }; recalcStageBBox(); state.items = []; + const t = ["batteria", "cantante", "wedge", "bassamp", "cantante"]; for (let i = 0; i < n; i++) { const it = addItem(t[i % t.length], { x: 300 + i * 120, y: 400 }, true); if (it) Object.assign(it, { x: 300 + i * 120, y: 400 }); } fit(); render(); }, n); +// desktop: 2 elementi no, 3 sì +{ const { ctx, p } = await pagina(b, VISTE.pc); await p.evaluate(() => localStorage.removeItem("sp_exportNudge")); + await pon(p, 2); ok(!(await stato(p)).visibile, "2 elementi: barra assente"); + await pon(p, 3); let s = await stato(p); ok(s.visibile && /Il tuo palco è pronto/.test(s.testo) && /Scarica il PDF/.test(s.testo) && /Cosa c.è nel PDF/.test(s.testo), "3 elementi: barra con le due azioni (" + s.testo.replace(/\n/g, " | ") + ")"); + ok(/manca il nome/.test(s.testo), "senza nome lo dice"); + const r = await p.evaluate(() => { const e = document.getElementById("pdfPronto").getBoundingClientRect(); return { bottom: innerHeight - e.bottom, w: e.width, h: e.height }; }); + ok(r.bottom >= 8 && r.h < 60, "in basso, piccola (" + Math.round(r.w) + "×" + Math.round(r.h) + ", a " + Math.round(r.bottom) + " px dal fondo)"); + // UN clic: finestra aperta + download + const dl = p.waitForEvent("download", { timeout: 25000 }).catch(() => null); + await p.click("#pdfProntoGo"); const d = await dl; + ok(!!d && /\.pdf$/i.test(d.suggestedFilename()), "un clic → scarica un PDF (" + (d && d.suggestedFilename()) + ")"); + await p.waitForTimeout(800); + const f = await p.evaluate(() => ({ modal: !document.getElementById("pdfModal").hidden, info: (document.getElementById("pdfInfo") || document.querySelector("#pdfModal .mstatus") || {}).textContent || "", pagine: document.getElementById("pdfScRiepilogo").textContent })); + ok(f.modal && /PDF scaricato/.test(f.info), "la finestra resta aperta sul «✓ PDF scaricato» (" + f.info.slice(0, 60) + ")"); + ok(/palco/i.test(f.pagine), "pagine preimpostate: " + f.pagine); + await p.evaluate(() => { document.getElementById("pdfModal").hidden = true; }); + s = await stato(p); ok(!s.visibile, "dopo il primo PDF la barra si spegne (stato «fatto»)"); + ok(p.__err.length === 0, "console pulita " + p.__err.join(" | ")); await ctx.close(); } +// «Cosa c'è nel PDF ›» apre senza scaricare; «✕» spegne per sempre +{ const { ctx, p } = await pagina(b, VISTE.pc); await p.evaluate(() => localStorage.removeItem("sp_exportNudge")); await pon(p, 4); await stato(p); + let scaricato = false; p.on("download", () => { scaricato = true; }); + await p.click("#pdfProntoVedi"); await p.waitForTimeout(700); + ok(await p.evaluate(() => !document.getElementById("pdfModal").hidden) && !scaricato, "«Cosa c'è nel PDF ›»: apre la finestra, non scarica"); + await p.evaluate(() => { document.getElementById("pdfModal").hidden = true; }); ok((await stato(p)).visibile, "chiusa la finestra senza esportare, la barra torna"); + await p.click("#pdfPronto .pp-x"); ok(!(await stato(p)).visibile && (await p.evaluate(() => localStorage.getItem("sp_exportNudge"))) === "no", "«✕»: sparisce e resta «no»"); + await ctx.close(); } +// correzioni della rilettura (01/12): «Cosa manca?» aperta, progetto già esportato, misura pulita, contrasto in scuro, larghezze intermedie +{ const { ctx, p } = await pagina(b, VISTE.pc); await p.evaluate(() => localStorage.removeItem("sp_exportNudge")); await pon(p, 4); await stato(p); + await p.evaluate(() => { if (!auditActive) toggleAuditView(); }); ok(!(await stato(p)).visibile, "D3: con «Cosa manca?» aperta la barra tace"); + await p.evaluate(() => { if (auditActive) toggleAuditView(); }); ok((await stato(p)).visibile, "D3: chiusa «Cosa manca?», la barra torna"); + await p.evaluate(() => { state.pdfEsportato = { at: "2026-10-01T10:00:00Z", firma: "x" }; }); ok(!(await stato(p)).visibile, "D6: progetto già esportato: barra assente"); + await p.evaluate(() => { delete state.pdfEsportato; document.body.classList.add("dark"); }); + const c = await p.evaluate(() => { const L = (x) => { const m = x.match(/[\d.]+/g).map(Number).slice(0, 3).map((v) => { v /= 255; return v <= 0.03928 ? v / 12.92 : Math.pow((v + 0.055) / 1.055, 2.4); }); return 0.2126 * m[0] + 0.7152 * m[1] + 0.0722 * m[2]; }; const e = document.querySelector("#pdfPronto .pp-go"), cs = getComputedStyle(e); const a = L(cs.color), g = L(cs.backgroundColor); return (Math.max(a, g) + 0.05) / (Math.min(a, g) + 0.05); }); + ok(c >= 4.5, "D1: «Scarica il PDF» in scuro leggibile (contrasto " + c.toFixed(2) + ":1)"); + await ctx.close(); } +{ const { ctx, p } = await pagina(b, [1024, 768, false]); await p.evaluate(() => localStorage.removeItem("sp_exportNudge")); await pon(p, 4); await stato(p); + const r = await p.evaluate(() => { const R = document.getElementById("pdfPronto").getBoundingClientRect(), M = document.querySelector("main").getBoundingClientRect(); return { l: R.left - M.left, r: M.right - R.right }; }); + ok(r.l >= 0 && r.r >= 0, "D4: a 1024 px la barra sta dentro l'area del palco (margini " + Math.round(r.l) + " / " + Math.round(r.r) + " px)"); await ctx.close(); } +{ const { ctx, p } = await pagina(b, VISTE.pc); await p.evaluate(() => { localStorage.removeItem("sp_exportNudge"); window.__log = []; const u = window.usoConta; window.usoConta = function (e, pr) { window.__log.push({ e, pr: JSON.parse(JSON.stringify(pr || {})) }); }; }); + await pon(p, 4); await stato(p); await p.evaluate(() => { window.__pdfDaBarra = true; }); /* stato sporco lasciato da un export non partito */ + await p.click("#bExportHdr"); await p.waitForTimeout(600); ok(await p.evaluate(() => window.__pdfDaBarra === false), "D2/M4: aprire Esporta azzera l'etichetta «barra»"); + const dl = p.waitForEvent("download", { timeout: 25000 }).catch(() => null); await p.click("#pdfGo"); await dl; await p.waitForTimeout(400); + ok(await p.evaluate(() => JSON.stringify(window.__log.filter((x) => x.e === "export").map((x) => x.pr)) === '[{"format":"pdf"}]'), "D2: l'export da «Esporta» dopo un percorso interrotto esce senza from:\"barra\""); await ctx.close(); } +// tetto di 3 sessioni (decisione di Simone 01/12): la prima volta che compare conta una sessione; alla quarta apertura non compare +{ const { ctx, p } = await pagina(b, VISTE.pc); await p.evaluate(() => localStorage.setItem("sp_exportNudge", "2")); await pon(p, 4); + ok((await stato(p)).visibile, "tetto: con 2 sessioni già contate compare ancora"); + ok(await p.evaluate(() => localStorage.getItem("sp_exportNudge")) === "3", "tetto: compare → il contatore passa a 3 (una volta sola)"); + await stato(p); await stato(p); ok(await p.evaluate(() => localStorage.getItem("sp_exportNudge")) === "3", "tetto: ricalcoli nella stessa sessione non contano di nuovo"); + await p.evaluate(() => { document.getElementById("pdfModal").hidden = false; }); await stato(p); await p.evaluate(() => { document.getElementById("pdfModal").hidden = true; }); + ok((await stato(p)).visibile, "tetto: nella sessione in cui è comparsa resta anche dopo aver aperto/chiuso una finestra"); + await ctx.close(); } +{ const { ctx, p } = await pagina(b, VISTE.pc); await p.evaluate(() => localStorage.setItem("sp_exportNudge", "3")); await pon(p, 4); + ok(!(await stato(p)).visibile, "tetto: dopo 3 sessioni la barra non compare più"); await ctx.close(); } +// telefono: mai +{ const { ctx, p } = await pagina(b, VISTE.iphone); await pon(p, 5); ok(!(await stato(p)).visibile, "telefono: barra assente"); await ctx.close(); } +await b.close(); console.log(ko ? "\n" + ko + " KO" : "\ntutto ok"); process.exit(ko ? 1 : 0); diff --git a/test/engines.test.mjs b/test/engines.test.mjs index 2b5ebf75..2ccb67e2 100644 --- a/test/engines.test.mjs +++ b/test/engines.test.mjs @@ -28825,9 +28825,77 @@ t("exportNudgeDecidi: chi lo vede, quando e quante volte", () => { ok(d({ stato: "3", giaInSessione: true }), "ma nella sessione in cui è comparso resta, non sparisce da solo"); ok(!d({ stato: "fatto", giaInSessione: true }), "esportato: mai più, nemmeno in sessione"); ok(!d({ stato: "no", giaInSessione: true }), "«✕»: mai più, nemmeno in sessione"); + ok(!d({ barraInSessione: true }) && !d({ stato: "1", giaInSessione: true, barraInSessione: true }), "la barra «palco pronto» è già comparsa in questa sessione: l'invito non si aggiunge (tetto unico)"); ok(d({ stato: "rotto" }), "valore illeggibile = zero"); ok(!A.exportNudgeDecidi(null), "senza dati: no"); }); +/* «Palco pronto — PDF in un clic» (30/11/2026, onboarding P2) */ +t("pdfProntoDecidi: chi vede la barra «Scarica il PDF» e quando", () => { + const d = (o) => A.pdfProntoDecidi(Object.assign({ altrui: false, mobile: false, stato: null, elementi: 5, bannerVisibile: false, finestraAperta: false }, o)); + eq(A.PDFPRONTO_MIN, 3, "soglia 3 elementi (come «attivato»)"); + ok(d({}), "desktop, 5 elementi, mai esportato: sì"); + ok(d({ elementi: 3 }), "esattamente 3: sì"); + ok(!d({ elementi: 2 }) && !d({ elementi: 0 }) && !d({ elementi: undefined }), "meno di 3 o dato mancante: no"); + ok(!d({ mobile: true }), "mai su telefono (dock, P3)"); + ok(!d({ altrui: true }), "mai su un documento altrui o in consulenza"); + ok(!d({ stato: "fatto" }), "dopo il primo PDF: si spegne"); + ok(!d({ stato: "no" }), "«✕»: mai più"); + ok(d({ stato: "2" }) && d({ stato: "1" }) && d({ stato: null }), "sotto il tetto: sì (stesso contatore dell'invito su Esporta)"); + ok(!d({ stato: "3" }) && !d({ stato: "7" }), "tetto di 3 sessioni: dalla quarta apertura non compare più (decisione di Simone 01/12)"); + ok(d({ stato: "3", giaInSessione: true }), "ma nella sessione in cui è comparsa resta, non sparisce da sola"); + ok(!d({ stato: "fatto", giaInSessione: true }) && !d({ stato: "no", giaInSessione: true }), "esportata o «✕»: mai più, nemmeno in sessione"); + ok(d({ stato: "rotto" }), "valore illeggibile = zero sessioni"); + ok(!d({ bannerVisibile: true }), "una riga alla volta: aspetta i banner"); + ok(!d({ finestraAperta: true }), "con la finestra Esporta (o altra) aperta: no"); + ok(!A.pdfProntoDecidi(null), "senza dati: no"); + ok(!d({ ingombro: true }), "«Cosa manca?» aperta, suggerimento o messaggio in basso: no (D3/D5)"); + ok(!d({ esportato: true }) && d({ esportato: false }), "progetto già esportato (altro dispositivo, prima del 14/11): niente «è pronto» (D6)"); +}); +t("pdfProntoTesto: senza nome lo dice, con nome tace", () => { + ok(A.pdfProntoTesto({ titolo: "" }).daNome && /manca il nome/.test(A.pdfProntoTesto({ titolo: " " }).nota), "titolo vuoto: nota sul nome"); + ok(!A.pdfProntoTesto({ titolo: "Teatro Sociale v1" }).daNome && A.pdfProntoTesto({ titolo: "X" }).nota === "", "con titolo: niente nota"); +}); +t("barra «palco pronto»: sorgenti (no popup, no mobile, gate invariato, no evento nuovo)", () => { + ok(/#pdfPronto\{position:fixed/.test(stylesCss) && /@media \(max-width:880px\)\{ #pdfPronto\{display:none\} \}/.test(stylesCss), "fissa in basso, nascosta su telefono"); + ok(/@media print\{ #pdfPronto\{display:none\} \}/.test(stylesCss), "mai in stampa"); + ok(/\["funzBanner","vistaBanner","riapriBanner","pdfPronto"\]/.test(appjs), "l'invito su Esporta aspetta la barra (una riga alla volta)"); + ok(!/track\("export_pronto"/.test(appjs), "nessun evento nuovo: l'allowlist 0035 lo rifiuterebbe"); + ok(/from:"barra"/.test(appjs) && /props\.format==="pdf"/.test(appjs), "l'export dalla barra porta from:\"barra\" (chiave già in allowlist)"); + ok(/pp-go[\s\S]{0,400}openPdfExportModal\(\)[\s\S]{0,260}getElementById\("pdfGo"\)/.test(appjs), "scarica passando dal bottone della finestra, quindi dal gate sugli errori critici"); +}); +/* Correzioni della rilettura Opus (01/12/2026): ogni test uccide una mutazione provata (M4, M6, M7, M8, M9) o un difetto (D1-D7) */ +t("barra «palco pronto»: correzioni D1-D7 e mutazioni M4/M6/M7/M8/M9 (testo dei sorgenti)", () => { + const bar = appjs.slice(appjs.indexOf("function pdfProntoAggiorna"), appjs.indexOf("window.pdfProntoAggiorna=pdfProntoAggiorna")); + const core = appjs.slice(appjs.indexOf("function _pdfExportModalCore"), appjs.indexOf("function _pdfExportModalCore") + 3500); + /* D1: «Scarica il PDF» leggibile anche in scuro (bianco su #0b7a70 = 5,21:1; su --accent-strong chiaro era 1,48:1) */ + ok(/body\.dark #pdfPronto \.pp-go\{background:#0b7a70;border-color:#0b7a70\}/.test(stylesCss) && /body\.dark #pdfPronto \.pp-go:hover\{background:#096a61;border-color:#096a61\}/.test(stylesCss), "D1: in scuro il pulsante è teal scuro, come .btn.primary"); + /* M4 / D2: l'etichetta «barra» non sopravvive all'apertura della finestra né al gate */ + ok(/window\.__pdfDaBarra=false;/.test(core), "M4/D2: ogni apertura di Esporta azzera __pdfDaBarra"); + ok(/cancelText:"Apri «Cosa manca\?»"[\s\S]{0,600}window\.__pdfDaBarra=false/.test(appjs), "D2: «Apri Cosa manca?» azzera __pdfDaBarra"); + ok(/props=\{format:"pdf", from:"barra"\}; window\.__pdfDaBarra=false;/.test(appjs), "M4: dopo l'evento l'etichetta si azzera (una volta sola)"); + ok(bar.indexOf("openPdfExportModal()") < bar.indexOf("window.__pdfDaBarra=true"), "D2: l'etichetta si imposta DOPO l'apertura (che la azzera)"); + /* M7: «Scarica il PDF» preme davvero il bottone della finestra */ + ok(/var go=document\.getElementById\("pdfGo"\); if\(go && !go\.disabled\) go\.click\(\);/.test(bar), "M7: pp-go chiama go.click() sul bottone della finestra"); + /* M9: «✕» scrive «no» */ + ok(/\.pp-x"\)\.addEventListener\("click", function\(\)\{ exportNudgeSegna\("no"\); pdfProntoNascondi\(\); \}\)/.test(bar), "M9: ✕ salva «no» e nasconde"); + /* M8: la finestra Esporta aperta (e quella del pacchetto) nasconde la barra */ + ok(/var mod=document\.getElementById\("pdfModal"\), pk=document\.getElementById\("pkgModal"\);\s*var aperta=!!\(\(mod && !mod\.hidden\) \|\| \(pk && !pk\.hidden\)/.test(bar), "M8: aperta legge pdfModal e pkgModal"); + /* M6: senza «Esporta» in vista niente scorciatoia */ + ok(/var bx=document\.getElementById\("bExportHdr"\);\s*if\(ok && \(!bx \|\| bx\.offsetParent===null\)\) ok=false;/.test(bar), "M6: controllo del pulsante Esporta in vista"); + /* D3/D5/D6: contesto */ + ok(/typeof auditActive!=="undefined" && auditActive/.test(bar) && /getElementById\("dragHint"\)/.test(bar) && /getElementById\("cloudToast"\)/.test(bar), "D3/D5: «Cosa manca?», dragHint e toast fanno tacere la barra"); + ok(/esportato:!!state\.pdfEsportato/.test(bar), "D6: il progetto già esportato non la mostra"); + /* D4: centrata sull'area del palco */ + ok(/document\.querySelector\("main"\)[\s\S]{0,300}el\.style\.left=[\s\S]{0,200}el\.style\.maxWidth=[\s\S]{0,120}el\.hidden=false/.test(bar), "D4: left e maxWidth dall'area del palco prima di mostrarla"); + ok(/#pdfPronto\.pp-stretta \.pp-vedi\{display:none\}/.test(stylesCss) && /classList\.add\("pp-stretta"\)/.test(bar), "D4: se il titolo non ci sta il link secondario cede (niente «Il tuo palco è pro…»)"); + /* tetto di 3 sessioni (01/12): la prima volta che compare conta UNA sessione sul contatore dell'invito; barra e invito non si sommano */ + ok(/if\(!pdfProntoInSessione\)\{ pdfProntoInSessione=true; if\(!exportNudgeInSessione\)\{ exportNudgeInSessione=true; exportNudgeSegna\("mostrato"\); \} \}/.test(bar) && /giaInSessione:pdfProntoInSessione/.test(bar), "tetto: conta una sola volta per sessione e passa giaInSessione"); + ok(/barraInSessione:pdfProntoInSessione/.test(appjs), "tetto: l'invito su Esporta sa se la barra è già comparsa"); + /* R1 (01/12): quando la barra compare l'invito su Esporta si ritira subito, mai insieme */ + ok(/exportNudgeNascondi\(\);[^\n]*\n\s*el\.hidden=false;/.test(bar), "R1: barra che compare → invito nascosto subito prima di el.hidden=false"); + /* D7: il fuoco non resta sul body */ + ok(/pdfProntoNascondi\(\);\s*try\{ var pc=document\.getElementById\("pdfCancel"\); if\(pc\) pc\.focus\(\); \}/.test(bar), "D7: dopo «Scarica» il fuoco passa alla finestra"); +}); t("exportNudgeStatoDopo: conta, «fatto» e «no» restano", () => { const f = A.exportNudgeStatoDopo; eq(f(null, "mostrato"), "1"); eq(f("2", "mostrato"), "3"); eq(f("x", "mostrato"), "1");