fix: nella pagina di creazione di un nuovo ticket, coda e cliente ora non sono più precompilati dal primo campo della lista.
This commit is contained in:
@@ -331,7 +331,7 @@ const TicketCreateView = {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
setTimeout(async () => {
|
setTimeout(async () => {
|
||||||
// 1. Owner & Responsible pre-population with active agent
|
// Active agent pre-population for Owner & Responsible
|
||||||
const currentAgentId = localStorage.getItem('activeAgentId') || '1';
|
const currentAgentId = localStorage.getItem('activeAgentId') || '1';
|
||||||
const activeAgent = (App.lookups.users || []).find(u => String(u.id) === String(currentAgentId));
|
const activeAgent = (App.lookups.users || []).find(u => String(u.id) === String(currentAgentId));
|
||||||
if (activeAgent) {
|
if (activeAgent) {
|
||||||
@@ -344,41 +344,6 @@ const TicketCreateView = {
|
|||||||
responsibleIdInput.value = activeAgent.id;
|
responsibleIdInput.value = activeAgent.id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. Customer User pre-population with first match
|
|
||||||
try {
|
|
||||||
const companies = await App.api('/api/customer-companies/search?q=');
|
|
||||||
if (companies.length > 0 && customerIdInput && companySearchInput) {
|
|
||||||
const defaultCompany = companies[0];
|
|
||||||
customerIdInput.value = defaultCompany.customer_id;
|
|
||||||
companySearchInput.value = defaultCompany.customer_id;
|
|
||||||
|
|
||||||
// Search users for this company
|
|
||||||
const users = await App.api(`/api/customer-users/search?q=&customer_company_id=${encodeURIComponent(defaultCompany.customer_id)}`);
|
|
||||||
if (users.length > 0 && userSearchInput && customerUserIdInput) {
|
|
||||||
const defaultUser = users[0];
|
|
||||||
userSearchInput.value = `${defaultUser.first_name} ${defaultUser.last_name}`;
|
|
||||||
customerUserIdInput.value = defaultUser.login;
|
|
||||||
} else {
|
|
||||||
// Fallback: use company name as customer user ID
|
|
||||||
userSearchInput.value = defaultCompany.name;
|
|
||||||
customerUserIdInput.value = defaultCompany.customer_id;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Error pre-populating defaults:', err);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 3. Queue pre-population
|
|
||||||
try {
|
|
||||||
const queues = await App.api('/api/queues/search?q=');
|
|
||||||
if (queues.length > 0 && queueSearchInput && queueIdInput) {
|
|
||||||
queueSearchInput.value = queues[0].name;
|
|
||||||
queueIdInput.value = queues[0].id;
|
|
||||||
}
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Error pre-populating queues:', err);
|
|
||||||
}
|
|
||||||
}, 50);
|
}, 50);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user