[FIX] Widget Segnalazioni: cap descrizione 1900 char + contatore, evita errore 'Data too long operative_summary' (ticket #430)

La colonna operative_summary lato ticket-ms e' VARCHAR(2000): descrizioni
lunghe causavano l'errore SQL grezzo a video. Aggiunto maxlength + contatore
live + guard al submit nel widget locale public/js/bug-reporter.js.
Cache-buster: bug-reporter.js?v=20260624 in common.js + common.js?v=20260624
su tutte le pagine. Causa radice (dimensione colonna) inoltrata ad AgileHub.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
DevEnv nis2-agile
2026-06-24 03:11:19 +02:00
co-authored by Claude Opus 4.8
parent 08d4ac0cc4
commit e5f7a7d3a6
42 changed files with 66 additions and 43 deletions
+25 -2
View File
@@ -27,6 +27,10 @@
const script = document.currentScript || document.querySelector('script[data-product]');
const WIDGET_VERSION = '1.4.15';
const WIDGET_BUILD = '20260415d';
// Limite descrizione: la colonna operative_summary lato ticket-ms e' VARCHAR(2000);
// alla descrizione viene aggiunto il tag versione (~30 char) prima dell'invio,
// quindi cappiamo a 1900 per evitare l'errore "Data too long for column 'operative_summary'".
const NX_DESC_MAX = 1900;
const CFG = {
apiUrl: (script && script.dataset.apiUrl) || 'http://localhost',
apiKey: (script && script.dataset.apiKey) || '',
@@ -471,7 +475,8 @@
<option value="URGENT">Urgente</option>
</select>
</div>
<textarea class="nx-textarea" id="nx-desc" placeholder="Descrivi il problema... (puoi incollare screenshot con Ctrl+V)"></textarea>
<textarea class="nx-textarea" id="nx-desc" maxlength="${NX_DESC_MAX}" placeholder="Descrivi il problema... (puoi incollare screenshot con Ctrl+V)"></textarea>
<div id="nx-desc-counter" aria-live="polite" style="font-size:11px;color:#6b7280;text-align:right;margin-top:-2px;margin-bottom:4px">0 / ${NX_DESC_MAX}</div>
<div class="nx-att-list" id="nx-att-list"></div>
<div class="nx-row">
<button class="nx-btn" id="nx-voice-btn" onclick="window._nxVoice()">🎤 Parla</button>
@@ -487,6 +492,16 @@
// Paste handler
const desc = document.getElementById('nx-desc');
// Contatore caratteri live (limite colonna operative_summary)
const counter = document.getElementById('nx-desc-counter');
const updateCounter = () => {
if (!counter) return;
const n = desc.value.length;
counter.textContent = n + ' / ' + NX_DESC_MAX;
counter.style.color = n >= NX_DESC_MAX ? '#dc2626' : '#6b7280';
};
desc.addEventListener('input', updateCounter);
updateCounter();
desc.addEventListener('paste', handlePaste);
// Drag & drop
desc.addEventListener('dragover', (e) => { e.preventDefault(); desc.classList.add('drag-over'); });
@@ -613,7 +628,8 @@
btn.style.background = '#fee2e2';
recognition.onresult = (e) => {
const desc = document.getElementById('nx-desc');
desc.value += (desc.value ? '\n' : '') + e.results[0][0].transcript;
desc.value = (desc.value + (desc.value ? '\n' : '') + e.results[0][0].transcript).slice(0, NX_DESC_MAX);
desc.dispatchEvent(new Event('input'));
btn.textContent = '🎤 Parla'; btn.style.background = '';
};
recognition.onerror = recognition.onend = () => { btn.textContent = '🎤 Parla'; btn.style.background = ''; };
@@ -629,6 +645,13 @@
const result = document.getElementById('nx-result');
if (!desc && _attachments.length === 0) { alert('Descrivi il problema o allega uno screenshot'); return; }
if (desc && desc.length > NX_DESC_MAX) {
const result0 = document.getElementById('nx-result');
result0.className = 'nx-result err';
result0.style.display = 'block';
result0.textContent = `❌ Descrizione troppo lunga: massimo ${NX_DESC_MAX} caratteri (ne hai ${desc.length}). Accorcia il testo o allega un file.`;
return;
}
submitBtn.disabled = true;
submitBtn.textContent = 'Invio in corso...';