fix: note temporanee che non funzionavano. feat: le note possono essere inviate ad otrs senza numero di ticket. style: rivisti alcuni nomi e colore per invio di una nota temporanea in otrs.

This commit is contained in:
Gabriele Cimaschi committed 2026-09-07 17:58:13 +02:00
1 parent b828d60bb2
commit f21be0abcb
9 files changed
+216 -70

No files matched your search

+32 -20
View File
@@ -23,7 +23,7 @@ const NoteTemporaneeView = {
<div style="display:flex; align-items:center; gap: 10px;">
<div style="display:inline-flex; align-items:center; justify-content:center; width:36px; height:36px; background: linear-gradient(135deg, rgba(79, 70, 229, 0.2), rgba(16, 185, 129, 0.2)); border-radius: 50%; color: var(--accent-primary); font-size:1.2rem; font-weight:bold;">📝</div>
<div>
<h2 style="margin:0; font-size:1.2rem; font-weight:700; color:var(--text-primary);" id="editor-title-text">Nuova Nota Temporanea</h2>
<h2 style="margin:0; font-size:1.2rem; font-weight:700; color:var(--text-primary);" id="editor-title-text">Nuova Nota</h2>
<p style="margin:2px 0 0 0; font-size:0.82rem; color:var(--text-secondary);">
Le note vengono mantenute in locale finché non le elimini con il cestino 🗑️ o le invii a OTRS 🚀.
</p>
@@ -173,6 +173,14 @@ const NoteTemporaneeView = {
}
}
});
// Prevent tab navigation on Quill toolbar items
const toolbar = document.querySelector('#note-body-editor-wrapper .ql-toolbar');
if (toolbar) {
toolbar.querySelectorAll('button, select, span[role="button"], input').forEach(el => {
el.setAttribute('tabindex', '-1');
});
}
}
},
@@ -364,9 +372,8 @@ const NoteTemporaneeView = {
</div>
<div style="display:flex; align-items:center; gap:4px;">
<button class="btn btn-ghost btn-xs btn-edit-note" data-id="${n.id}" title="Carica ed modifica nota" style="padding:2px 5px; font-size:0.75rem;">✏️</button>
<button class="btn btn-ghost btn-xs btn-submit-note" data-id="${n.id}" title="Invia direttamente a OTRS" style="padding:2px 5px; font-size:0.75rem; color:var(--accent-primary);">🚀</button>
<button class="btn btn-ghost btn-xs btn-delete-note" data-id="${n.id}" title="Elimina definitivamente dal DB locale" style="padding:2px 5px; font-size:0.75rem; color:var(--error);">🗑️</button>
<button class="btn btn-ghost btn-xs btn-submit-note" data-id="${n.id}" title="Invia direttamente a OTRS" style="padding:2px 5px; font-size:0.75rem; color:var(--accent-primary);">🚀</button>
</div>
</div>
@@ -375,10 +382,10 @@ const NoteTemporaneeView = {
}).join('');
// Bind item actions
listContainer.querySelectorAll('.btn-edit-note').forEach(btn => {
listContainer.querySelectorAll('.btn-delete-note').forEach(btn => {
btn.addEventListener('click', (e) => {
e.stopPropagation();
this.loadNoteIntoForm(parseInt(btn.dataset.id, 10));
this.deleteNote(parseInt(btn.dataset.id, 10));
});
});
@@ -389,13 +396,6 @@ const NoteTemporaneeView = {
});
});
listContainer.querySelectorAll('.btn-delete-note').forEach(btn => {
btn.addEventListener('click', (e) => {
e.stopPropagation();
this.deleteNote(parseInt(btn.dataset.id, 10));
});
});
listContainer.querySelectorAll('.saved-note-card').forEach(card => {
card.addEventListener('click', () => {
this.loadNoteIntoForm(parseInt(card.dataset.noteId, 10));
@@ -447,7 +447,7 @@ const NoteTemporaneeView = {
const deleteBtn = document.getElementById('note-delete-current-btn');
const ticketClearBtn = document.getElementById('note-ticket-clear-btn');
if (editorTitle) editorTitle.textContent = 'Nuova Nota Temporanea';
if (editorTitle) editorTitle.textContent = 'Nuova Nota';
if (ticketInput) ticketInput.value = '';
if (ticketClearBtn) ticketClearBtn.style.display = 'none';
if (subjectInput) subjectInput.value = '';
@@ -487,7 +487,7 @@ const NoteTemporaneeView = {
try {
const res = await App.api('/api/notes', {
method: 'POST',
body: payload
body: JSON.stringify(payload)
});
Toast.success('Nota temporanea salvata nel database locale!');
@@ -518,12 +518,19 @@ const NoteTemporaneeView = {
const note = this.savedNotes.find(n => n.id === noteId);
if (!note) return;
if (!note.ticket_tn && !note.ticket_id) {
Toast.error('Inserisci un ticket di riferimento (TN o ID) prima di inviare a OTRS');
return;
}
const hasTicket = Boolean(note.ticket_tn || note.ticket_id);
const modalTitle = hasTicket ? 'Invia Nota a OTRS' : 'Crea Nuovo Ticket da Nota';
const confirmMsg = hasTicket
? `Sei sicuro di voler inviare questa nota a OTRS per il ticket #${note.ticket_tn || note.ticket_id}? La nota verrà poi rimossa dal database locale.`
: `Non hai specificato un ticket. Vuoi creare un NUOVO ticket a partire da questa nota ed inviarla a OTRS?`;
if (!confirm(`Sei sicuro di voler inviare questa nota a OTRS per il ticket #${note.ticket_tn || note.ticket_id}? La nota verrà poi rimossa dal database locale.`)) {
const ok = await App.confirm(modalTitle, confirmMsg, {
confirmText: hasTicket ? 'Invia a OTRS' : 'Crea Ticket e Invia',
confirmClass: 'btn-success',
cancelText: 'Annulla'
});
if (!ok) {
return;
}
@@ -549,7 +556,12 @@ const NoteTemporaneeView = {
},
async deleteNote(noteId) {
if (!confirm('Sei sicuro di voler eliminare questa nota temporanea dal database locale?')) {
const ok = await App.confirm(
'Elimina Nota Temporanea',
'Sei sicuro di voler eliminare questa nota temporanea dal database locale?',
{ confirmText: 'Elimina', cancelText: 'Annulla' }
);
if (!ok) {
return;
}