feat: add direct Ny kontakt / Søg / Firma buttons on telefoni rows
This commit is contained in:
parent
31fa771626
commit
86b3b3be15
@ -630,6 +630,47 @@ function openLinkContactModal(callId, mode = 'contact') {
|
|||||||
}, 200);
|
}, 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function quickNewContact(callId, number) {
|
||||||
|
// Open the link-contact modal but scroll to / pre-fill the 'opret ny kontakt' form.
|
||||||
|
linkContactState.callId = Number(callId);
|
||||||
|
linkContactState.number = String(number || '').trim();
|
||||||
|
linkContactState.mode = 'contact';
|
||||||
|
|
||||||
|
const ctx = document.getElementById('linkContactContext');
|
||||||
|
const phoneInput = document.getElementById('newContactPhone');
|
||||||
|
const firstNameInput = document.getElementById('newContactFirstName');
|
||||||
|
const lastNameInput = document.getElementById('newContactLastName');
|
||||||
|
const emailInput = document.getElementById('newContactEmail');
|
||||||
|
const titleInput = document.getElementById('newContactTitle');
|
||||||
|
const searchInput = document.getElementById('linkContactSearch');
|
||||||
|
const companySearchInput = document.getElementById('linkCompanySearch');
|
||||||
|
|
||||||
|
if (ctx) ctx.textContent = `Opkald: ${linkContactState.number || ('#' + callId)}`;
|
||||||
|
if (phoneInput) phoneInput.value = linkContactState.number;
|
||||||
|
if (firstNameInput) firstNameInput.value = '';
|
||||||
|
if (lastNameInput) lastNameInput.value = '';
|
||||||
|
if (emailInput) emailInput.value = '';
|
||||||
|
if (titleInput) titleInput.value = '';
|
||||||
|
if (searchInput) searchInput.value = '';
|
||||||
|
if (companySearchInput) companySearchInput.value = '';
|
||||||
|
setLinkContactSelected(null, '');
|
||||||
|
setLinkCompanySelected(null, '');
|
||||||
|
renderLinkContactResults([]);
|
||||||
|
renderCompanyResults([]);
|
||||||
|
|
||||||
|
const modal = getLinkContactModalInstance();
|
||||||
|
if (modal) modal.show();
|
||||||
|
|
||||||
|
// Scroll to the "Opret ny kontakt" section after modal opens
|
||||||
|
setTimeout(() => {
|
||||||
|
const newSection = document.getElementById('newContactFirstName');
|
||||||
|
if (newSection) {
|
||||||
|
newSection.scrollIntoView({ behavior: 'smooth', block: 'center' });
|
||||||
|
newSection.focus();
|
||||||
|
}
|
||||||
|
}, 300);
|
||||||
|
}
|
||||||
|
|
||||||
async function unlinkContact(callId) {
|
async function unlinkContact(callId) {
|
||||||
if (!confirm('Fjern link til kontakt for dette opkald?')) return;
|
if (!confirm('Fjern link til kontakt for dette opkald?')) return;
|
||||||
try {
|
try {
|
||||||
@ -951,9 +992,17 @@ async function loadCalls() {
|
|||||||
<button type="button" class="btn btn-sm btn-outline-danger" onclick="unlinkContact(${Number(r.id)})">Fjern</button>
|
<button type="button" class="btn btn-sm btn-outline-danger" onclick="unlinkContact(${Number(r.id)})">Fjern</button>
|
||||||
</div>
|
</div>
|
||||||
${r.contact_company ? `<div class="text-muted small">${escapeHtml(r.contact_company)}</div>` : ''}`
|
${r.contact_company ? `<div class="text-muted small">${escapeHtml(r.contact_company)}</div>` : ''}`
|
||||||
: `<button type="button" class="btn btn-sm btn-outline-secondary" onclick="openLinkContactModal(${Number(r.id)})" title="Vælg kontakt/firma">
|
: `<div class="d-flex gap-1 flex-wrap">
|
||||||
<i class="bi bi-three-dots"></i>
|
<button type="button" class="btn btn-sm btn-outline-primary" onclick="quickNewContact(${Number(r.id)}, '${escapeHtml(numberRaw)}')">
|
||||||
</button>`;
|
<i class="bi bi-person-plus"></i> Ny kontakt
|
||||||
|
</button>
|
||||||
|
<button type="button" class="btn btn-sm btn-outline-secondary" onclick="openLinkContactModal(${Number(r.id)})">
|
||||||
|
<i class="bi bi-search"></i> Søg
|
||||||
|
</button>
|
||||||
|
<button type="button" class="btn btn-sm btn-outline-warning" onclick="openLinkContactModal(${Number(r.id)}, 'company')">
|
||||||
|
<i class="bi bi-building"></i> Firma
|
||||||
|
</button>
|
||||||
|
</div>`;
|
||||||
|
|
||||||
const numberForTitle = (r.display_number || r.ekstern_nummer || '').trim();
|
const numberForTitle = (r.display_number || r.ekstern_nummer || '').trim();
|
||||||
const createQs = new URLSearchParams();
|
const createQs = new URLSearchParams();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user