fix: corretto selettore coda nella pagina di riepilogo del ticket.
This commit is contained in:
1 parent
e94ef9a38c
commit
c1dc86d6cd
1 file changed
+125
@@ -3565,6 +3565,131 @@ const TicketDetailView = {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Queue Search Autocomplete
|
||||||
|
const queueSuggestionsDiv = document.getElementById('qe-queue-suggestions');
|
||||||
|
let queueDebounce;
|
||||||
|
|
||||||
|
if (queueSearchInput && queueSuggestionsDiv) {
|
||||||
|
queueSearchInput.addEventListener('input', () => {
|
||||||
|
clearTimeout(queueDebounce);
|
||||||
|
const q = queueSearchInput.value.trim();
|
||||||
|
if (queueIdInput) queueIdInput.value = '';
|
||||||
|
checkChanges();
|
||||||
|
|
||||||
|
queueDebounce = setTimeout(async () => {
|
||||||
|
try {
|
||||||
|
const queues = await App.api(`/api/queues/search?q=${encodeURIComponent(q)}`);
|
||||||
|
if (!queues || queues.length === 0) {
|
||||||
|
queueSuggestionsDiv.innerHTML = '<div class="autocomplete-suggestion-item" style="color:var(--text-muted); cursor:default; padding: 6px 12px; font-size:0.78rem;">Nessuna coda trovata</div>';
|
||||||
|
queueSuggestionsDiv.style.display = 'block';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
queueSuggestionsDiv.innerHTML = queues.map(qObj => {
|
||||||
|
const displayName = qObj.name.replace(/::/g, ' › ');
|
||||||
|
return `
|
||||||
|
<div class="autocomplete-suggestion-item" data-id="${App.escapeHtml(qObj.id)}" data-name="${App.escapeHtml(qObj.name)}" style="padding: 6px 12px; font-size: 0.78rem; line-height: 1.25; cursor: pointer;">
|
||||||
|
${App.escapeHtml(displayName)}
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
}).join('');
|
||||||
|
queueSuggestionsDiv.style.display = 'block';
|
||||||
|
|
||||||
|
queueSuggestionsDiv.querySelectorAll('.autocomplete-suggestion-item').forEach(item => {
|
||||||
|
if (item.dataset.id) {
|
||||||
|
item.addEventListener('mousedown', (e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
queueSearchInput.value = item.dataset.name;
|
||||||
|
if (queueIdInput) queueIdInput.value = item.dataset.id;
|
||||||
|
queueSuggestionsDiv.style.display = 'none';
|
||||||
|
checkChanges();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Queue search error:', err);
|
||||||
|
}
|
||||||
|
}, 150);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (App.setupAutocompleteKeyboardNavigation) {
|
||||||
|
App.setupAutocompleteKeyboardNavigation(queueSearchInput, queueSuggestionsDiv, (item) => {
|
||||||
|
if (item && item.dataset.id) {
|
||||||
|
queueSearchInput.value = item.dataset.name;
|
||||||
|
if (queueIdInput) queueIdInput.value = item.dataset.id;
|
||||||
|
queueSuggestionsDiv.style.display = 'none';
|
||||||
|
checkChanges();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
queueSearchInput.addEventListener('focus', () => {
|
||||||
|
queueSearchInput.dispatchEvent(new Event('input'));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Customer Search Autocomplete
|
||||||
|
const customerSuggestionsDiv = document.getElementById('qe-customer-suggestions');
|
||||||
|
let customerDebounce;
|
||||||
|
|
||||||
|
if (customerSearchInput && customerSuggestionsDiv) {
|
||||||
|
customerSearchInput.addEventListener('input', () => {
|
||||||
|
clearTimeout(customerDebounce);
|
||||||
|
const q = customerSearchInput.value.trim();
|
||||||
|
if (customerUserIdInput) customerUserIdInput.value = '';
|
||||||
|
if (customerIdInput) customerIdInput.value = '';
|
||||||
|
checkChanges();
|
||||||
|
|
||||||
|
customerDebounce = setTimeout(async () => {
|
||||||
|
try {
|
||||||
|
const customers = await App.api(`/api/customers/search?q=${encodeURIComponent(q)}`);
|
||||||
|
if (!customers || customers.length === 0) {
|
||||||
|
customerSuggestionsDiv.innerHTML = '<div class="autocomplete-suggestion-item" style="color:var(--text-muted); cursor:default; padding: 6px 12px; font-size:0.78rem;">Nessun cliente trovato</div>';
|
||||||
|
customerSuggestionsDiv.style.display = 'block';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
customerSuggestionsDiv.innerHTML = customers.map(c => `
|
||||||
|
<div class="autocomplete-suggestion-item" data-user-id="${App.escapeHtml(c.customer_user_id)}" data-customer-id="${App.escapeHtml(c.customer_id || c.customer_user_id)}" data-name="${App.escapeHtml(c.first_name ? `${c.first_name} ${c.last_name}` : c.customer_user_id)}" style="padding: 6px 12px; font-size: 0.78rem; cursor: pointer;">
|
||||||
|
<strong>${App.escapeHtml(c.first_name ? `${c.first_name} ${c.last_name}` : c.customer_user_id)}</strong>
|
||||||
|
${c.email ? `<span style="color:var(--text-muted); margin-left:6px;">(${App.escapeHtml(c.email)})</span>` : ''}
|
||||||
|
</div>
|
||||||
|
`).join('');
|
||||||
|
customerSuggestionsDiv.style.display = 'block';
|
||||||
|
|
||||||
|
customerSuggestionsDiv.querySelectorAll('.autocomplete-suggestion-item').forEach(item => {
|
||||||
|
if (item.dataset.userId) {
|
||||||
|
item.addEventListener('mousedown', (e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
customerSearchInput.value = item.dataset.name;
|
||||||
|
if (customerUserIdInput) customerUserIdInput.value = item.dataset.userId;
|
||||||
|
if (customerIdInput) customerIdInput.value = item.dataset.customerId;
|
||||||
|
customerSuggestionsDiv.style.display = 'none';
|
||||||
|
checkChanges();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Customer search error:', err);
|
||||||
|
}
|
||||||
|
}, 150);
|
||||||
|
});
|
||||||
|
|
||||||
|
customerSearchInput.addEventListener('focus', () => {
|
||||||
|
customerSearchInput.dispatchEvent(new Event('input'));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Close suggestions on click outside
|
||||||
|
document.addEventListener('click', (e) => {
|
||||||
|
if (queueSearchInput && queueSuggestionsDiv && e.target !== queueSearchInput && !queueSuggestionsDiv.contains(e.target)) {
|
||||||
|
queueSuggestionsDiv.style.display = 'none';
|
||||||
|
}
|
||||||
|
if (customerSearchInput && customerSuggestionsDiv && e.target !== customerSearchInput && !customerSuggestionsDiv.contains(e.target)) {
|
||||||
|
customerSuggestionsDiv.style.display = 'none';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Unified Save Quick Edit & Send Note action
|
// Unified Save Quick Edit & Send Note action
|
||||||
if (saveBtn) {
|
if (saveBtn) {
|
||||||
saveBtn.addEventListener('click', async () => {
|
saveBtn.addEventListener('click', async () => {
|
||||||
|
|||||||
Reference in new issue
Block a user