fix: correzione ricerca cliente tramite LDAP. fix: vista dettaglio che interrogava l'endpoint sbagliato. PRovocato probabilmente ancora dall'unificazione delle note rapide con le note normali.
This commit is contained in:
1 parent
0b6907969d
commit
abb72d53c9
3 files changed
+136
-55
No files matched your search
@@ -4201,36 +4201,53 @@ const TicketDetailView = {
|
||||
customerSearchInput.addEventListener('input', () => {
|
||||
clearTimeout(customerDebounce);
|
||||
const q = customerSearchInput.value.trim();
|
||||
if (customerUserIdInput) customerUserIdInput.value = '';
|
||||
if (customerIdInput) customerIdInput.value = '';
|
||||
const origCustFirst = (this.originalValues['customer_first'] || '').trim();
|
||||
const origCustLast = (this.originalValues['customer_last'] || '').trim();
|
||||
const origCustName = origCustFirst ? `${origCustFirst} ${origCustLast}`.trim() : (this.originalValues['customer_user_id'] || '').trim();
|
||||
|
||||
if (q !== origCustName) {
|
||||
if (customerUserIdInput) customerUserIdInput.value = '';
|
||||
if (customerIdInput) customerIdInput.value = '';
|
||||
} else {
|
||||
if (customerUserIdInput) customerUserIdInput.value = this.originalValues['customer_user_id'] || '';
|
||||
if (customerIdInput) customerIdInput.value = this.originalValues['customer_id'] || '';
|
||||
}
|
||||
checkChanges();
|
||||
|
||||
customerDebounce = setTimeout(async () => {
|
||||
try {
|
||||
const customers = await App.api(`/api/customers/search?q=${encodeURIComponent(q)}`);
|
||||
if (!customers || customers.length === 0) {
|
||||
const users = await App.api(`/api/customer-users/search?q=${encodeURIComponent(q)}`);
|
||||
if (!users || users.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.innerHTML = users.map(u => {
|
||||
const fullName = (u.first_name || u.last_name) ? `${u.first_name || ''} ${u.last_name || ''}`.trim() : (u.login || '');
|
||||
return `
|
||||
<div class="autocomplete-suggestion-item" data-login="${App.escapeHtml(u.login || '')}" data-customer-id="${App.escapeHtml(u.customer_id || '')}" data-name="${App.escapeHtml(fullName)}" style="padding: 6px 12px; font-size: 0.78rem; cursor: pointer;">
|
||||
<strong>${App.escapeHtml(fullName)}</strong>
|
||||
<span style="color:var(--text-muted); margin-left:6px; font-size:0.75rem;">(Login: ${App.escapeHtml(u.login || '')}${u.customer_id ? ` | ${App.escapeHtml(u.customer_id)}` : ''})</span>
|
||||
${u.email ? `<div style="color:var(--text-secondary); font-size:0.73rem;">${App.escapeHtml(u.email)}</div>` : ''}
|
||||
</div>
|
||||
`;
|
||||
}).join('');
|
||||
customerSuggestionsDiv.style.display = 'block';
|
||||
|
||||
const selectCustomerItem = (item) => {
|
||||
customerSearchInput.value = item.dataset.name;
|
||||
if (customerUserIdInput) customerUserIdInput.value = item.dataset.login;
|
||||
if (customerIdInput) customerIdInput.value = item.dataset.customerId;
|
||||
customerSuggestionsDiv.style.display = 'none';
|
||||
checkChanges();
|
||||
};
|
||||
|
||||
customerSuggestionsDiv.querySelectorAll('.autocomplete-suggestion-item').forEach(item => {
|
||||
if (item.dataset.userId) {
|
||||
if (item.dataset.login) {
|
||||
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();
|
||||
selectCustomerItem(item);
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -4240,6 +4257,18 @@ const TicketDetailView = {
|
||||
}, 150);
|
||||
});
|
||||
|
||||
if (App.setupAutocompleteKeyboardNavigation) {
|
||||
App.setupAutocompleteKeyboardNavigation(customerSearchInput, customerSuggestionsDiv, (item) => {
|
||||
if (item && item.dataset.login) {
|
||||
customerSearchInput.value = item.dataset.name;
|
||||
if (customerUserIdInput) customerUserIdInput.value = item.dataset.login;
|
||||
if (customerIdInput) customerIdInput.value = item.dataset.customerId;
|
||||
customerSuggestionsDiv.style.display = 'none';
|
||||
checkChanges();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
customerSearchInput.addEventListener('focus', () => {
|
||||
customerSearchInput.dispatchEvent(new Event('input'));
|
||||
});
|
||||
@@ -4270,9 +4299,18 @@ const TicketDetailView = {
|
||||
}
|
||||
|
||||
const customerSearch = customerSearchInput ? customerSearchInput.value.trim() : '';
|
||||
if (customerSearch && customerUserIdInput && !customerUserIdInput.value) {
|
||||
customerUserIdInput.value = customerSearch;
|
||||
if (customerIdInput) customerIdInput.value = customerSearch;
|
||||
const origCustFirst = (this.originalValues['customer_first'] || '').trim();
|
||||
const origCustLast = (this.originalValues['customer_last'] || '').trim();
|
||||
const origCustName = origCustFirst ? `${origCustFirst} ${origCustLast}`.trim() : (this.originalValues['customer_user_id'] || '').trim();
|
||||
|
||||
if (customerSearchInput) {
|
||||
if (!customerSearch) {
|
||||
if (customerUserIdInput) customerUserIdInput.value = '';
|
||||
if (customerIdInput) customerIdInput.value = '';
|
||||
} else if (customerSearch === origCustName) {
|
||||
if (customerUserIdInput) customerUserIdInput.value = this.originalValues['customer_user_id'] || '';
|
||||
if (customerIdInput) customerIdInput.value = this.originalValues['customer_id'] || '';
|
||||
}
|
||||
}
|
||||
|
||||
// Check metadata updates
|
||||
|
||||
Reference in new issue
Block a user