|
|
@@ -72,6 +72,7 @@
|
|
|
const jobId = row.dataset.jobId;
|
|
|
const action = btn.dataset.action;
|
|
|
if (action === 'partial_ship') return onPartialShip(btn, row, jobId);
|
|
|
+ if (action === 'delete') return onDelete(btn, row, jobId);
|
|
|
|
|
|
btn.disabled = true;
|
|
|
postForm('bin/jobs_update.php', { job_id: jobId, action })
|
|
|
@@ -85,6 +86,22 @@
|
|
|
.catch(err => alert('Network error: ' + err.message));
|
|
|
}
|
|
|
|
|
|
+ function onDelete(btn, row, jobId) {
|
|
|
+ const jobCell = row.querySelector('[data-column="job"]');
|
|
|
+ const label = jobCell ? (jobCell.textContent.trim() || '#' + jobId) : '#' + jobId;
|
|
|
+ if (!window.confirm('Delete job ' + label + '? This cannot be undone from the UI.')) return;
|
|
|
+ btn.disabled = true;
|
|
|
+ postForm('bin/jobs_delete.php', { job_id: jobId })
|
|
|
+ .then(r => r.text().then(t => ({ ok: r.ok, body: t })))
|
|
|
+ .then(res => {
|
|
|
+ if (!res.ok || res.body.trim() !== 'Success') {
|
|
|
+ alert('Delete failed: ' + res.body);
|
|
|
+ }
|
|
|
+ return reloadTable();
|
|
|
+ })
|
|
|
+ .catch(err => alert('Network error: ' + err.message));
|
|
|
+ }
|
|
|
+
|
|
|
function onPartialShip(btn, row, jobId) {
|
|
|
const currentQty = parseInt(btn.dataset.qty, 10);
|
|
|
const raw = window.prompt(
|
|
|
@@ -272,6 +289,12 @@
|
|
|
const jobId = parseInt(rowEl.dataset.jobId, 10);
|
|
|
composeRowId = jobId;
|
|
|
|
|
|
+ // Pull the row's delete button out of the tab order so Tab from the last
|
|
|
+ // field doesn't land on it. (The table reload after finishCompose
|
|
|
+ // rebuilds the row without this attribute, restoring normal tabbing.)
|
|
|
+ const deleteBtn = rowEl.querySelector('.btn-delete');
|
|
|
+ if (deleteBtn) deleteBtn.setAttribute('tabindex', '-1');
|
|
|
+
|
|
|
const cells = Array.from(rowEl.querySelectorAll('.editable'));
|
|
|
const inputs = cells.map(span => {
|
|
|
const col = span.dataset.column;
|
|
|
@@ -304,6 +327,10 @@
|
|
|
} else {
|
|
|
finishCompose(rowEl, true);
|
|
|
}
|
|
|
+ } else if (e.key === 'Tab' && !e.shiftKey && i === inputs.length - 1) {
|
|
|
+ // Tabbing forward off the last field (Due) commits the new row.
|
|
|
+ e.preventDefault();
|
|
|
+ finishCompose(rowEl, true);
|
|
|
}
|
|
|
});
|
|
|
});
|