Fix work order detail modal: hide redundant Cancel button on info-only modals (showCancel param)
This commit is contained in:
+9
-3
@@ -2487,7 +2487,7 @@
|
||||
// MODAL
|
||||
// =========================================================================
|
||||
let modalResolve = null;
|
||||
function showModal(title, body, confirmText = 'Confirm', confirmClass = 'btn-danger') {
|
||||
function showModal(title, body, confirmText = 'Confirm', confirmClass = 'btn-danger', showCancel = true) {
|
||||
document.getElementById('modalTitle').textContent = title;
|
||||
const bodyEl = document.getElementById('modalBody');
|
||||
bodyEl.innerHTML = '';
|
||||
@@ -2499,6 +2499,8 @@
|
||||
const btn = document.getElementById('modalConfirmBtn');
|
||||
btn.textContent = confirmText;
|
||||
btn.className = 'btn btn-sm ' + confirmClass;
|
||||
const cancelBtn = document.querySelector('#modalOverlay .btn-outline');
|
||||
if (cancelBtn) cancelBtn.style.display = showCancel ? '' : 'none';
|
||||
document.getElementById('modalOverlay').classList.add('open');
|
||||
return new Promise(resolve => {
|
||||
modalResolve = resolve;
|
||||
@@ -2506,6 +2508,9 @@
|
||||
}
|
||||
function closeModal(confirmed = false) {
|
||||
document.getElementById('modalOverlay').classList.remove('open');
|
||||
// Show cancel button again for next use
|
||||
const cancelBtn = document.querySelector('#modalOverlay .btn-outline');
|
||||
if (cancelBtn) cancelBtn.style.display = '';
|
||||
if (modalResolve) {
|
||||
modalResolve(confirmed);
|
||||
modalResolve = null;
|
||||
@@ -4880,7 +4885,8 @@
|
||||
'Work Order Details',
|
||||
'<div class="loading-spinner"><span class="spinner"></span> Loading...</div>',
|
||||
'Close',
|
||||
null
|
||||
'btn-outline',
|
||||
false
|
||||
);
|
||||
// Fetch single WO detail using the lookup endpoint
|
||||
api('/api/workorders/lookup', {
|
||||
@@ -5559,7 +5565,7 @@
|
||||
${wo.notes ? `<div style="font-size:11px;color:var(--text3);margin-top:4px;line-height:1.4;max-height:60px;overflow-y:auto;">${esc(wo.notes)}</div>` : ''}
|
||||
</div>`;
|
||||
}).join('');
|
||||
showModal(`Work Orders — ${msfs.work_order_count} total`, items, 'Close', 'btn-outline');
|
||||
showModal(`Work Orders — ${msfs.work_order_count} total`, items, 'Close', 'btn-outline', false);
|
||||
}
|
||||
|
||||
// ── GPS Map Editor ──────────────────────────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user