Redirect board COMPLETED drop to Details page for full completion flow
Dragging a card to the Completed column on the job board previously called MoveCard directly, skipping email/SMS notifications, CompletedDate, powder deduction, and the completion modal entirely. Now detects the COMPLETED status code on the target column, reverts the visual drag, and navigates to the job Details page with #completeModal in the hash. Details.cshtml auto-opens the Mark Complete modal on arrival, so the user goes through the same code path as the Complete Job button. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -314,6 +314,7 @@
|
||||
|
||||
<div class="board-column"
|
||||
data-status-id="@col.StatusId"
|
||||
data-status-code="@col.StatusCode"
|
||||
data-status-name="@col.DisplayName">
|
||||
|
||||
<div class="board-column-header">
|
||||
@@ -569,15 +570,29 @@
|
||||
dragClass: 'dragging',
|
||||
|
||||
onEnd(evt) {
|
||||
const card = evt.item;
|
||||
const jobId = parseInt(card.dataset.jobId);
|
||||
const newColEl = evt.to;
|
||||
const newStatus = parseInt(newColEl.closest('.board-column').dataset.statusId);
|
||||
const oldColEl = evt.from;
|
||||
const card = evt.item;
|
||||
const jobId = parseInt(card.dataset.jobId);
|
||||
const newColEl = evt.to;
|
||||
const newColWrapper = newColEl.closest('.board-column');
|
||||
const newStatus = parseInt(newColWrapper.dataset.statusId);
|
||||
const newStatusCode = newColWrapper.dataset.statusCode;
|
||||
const oldColEl = evt.from;
|
||||
|
||||
// No-op if dropped in same column
|
||||
if (newColEl === oldColEl && evt.newIndex === evt.oldIndex) return;
|
||||
|
||||
// Completing a job requires the full completion flow (time, powder, email/SMS).
|
||||
// Revert the visual move and send the user to the Details page where the
|
||||
// Mark Complete modal captures all of that.
|
||||
if (newStatusCode === 'COMPLETED') {
|
||||
oldColEl.insertBefore(card, oldColEl.children[evt.oldIndex] ?? null);
|
||||
updateCount(oldColEl);
|
||||
updateCount(newColEl);
|
||||
showToast('Opening job to complete with full details…', true);
|
||||
setTimeout(() => { window.location.href = card.href + '#completeModal'; }, 600);
|
||||
return;
|
||||
}
|
||||
|
||||
// Update column counts immediately
|
||||
updateCount(oldColEl);
|
||||
updateCount(newColEl);
|
||||
|
||||
@@ -2440,6 +2440,13 @@
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
jobPhotoModule.init(@Model.Id, @Html.Raw(ViewBag.PhotoTagSuggestions ?? "[]"));
|
||||
|
||||
// Auto-open the Mark Complete modal when arriving from the job board
|
||||
if (window.location.hash === '#completeModal') {
|
||||
const modal = document.getElementById('completeJobModal');
|
||||
if (modal) new bootstrap.Modal(modal).show();
|
||||
history.replaceState(null, '', window.location.pathname + window.location.search);
|
||||
}
|
||||
|
||||
// ── Auto-submit after wizard saves an item ────────────────────────
|
||||
let itemsModified = false;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user