Add a confirm modal to the Move to project dropdown

The dropdown worked but gave zero feedback - no confirmation, nothing
visibly changed - so a successful move looked identical to a no-op
(reported directly by the user). Adds a generic ConfirmModal.vue
(reusable beyond this one call site) triggered on select instead of a
second button next to the dropdown, per request. Switches the select
from a bare :value binding to its own v-model so a cancelled move can
actually revert the visible selection (a plain :value can't re-sync a
<select>'s displayed option). Adds a transient "Moved to {project}"
note and clarifies the label from "Project" to "Move to project".

Verified: npm run build passes; the built bundle contains the new
modal/label/note strings; the app container rebuilt and serves 200.
measure.py unaffected. Not machine-verified: the actual modal
interaction - Claude-in-Chrome still isn't connected this session.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
JasonFraser 2026-10-13 08:17:32 -04:00
parent ca12f2b90d
commit 42d6de1c77
4 changed files with 178 additions and 11 deletions

View File

@ -395,11 +395,15 @@ security only, not the full SaaS-shaped doc — and the judgment call on what co
search box, filters the document list, collapses to an
icon-only rail), LoginView
(Sign In/Sign Up toggle + "Continue with Google"),
ProcessingIndicator, ResultCard (Download + Download All,
best-effort persists the export to R2 via
`documentsService.saveExportFile`), SourceDocumentPanel,
TransactionsTable (now also hosts the "Move to project"
select), TransactionRow, ResizablePanels. `RestoreBanner`
ConfirmModal (NEW 2026-10-13 — generic confirm/cancel
dialog over a dimmed backdrop; built for "Move to project"
but reusable elsewhere), ProcessingIndicator, ResultCard
(Download + Download All, best-effort persists the export
to R2 via `documentsService.saveExportFile`),
SourceDocumentPanel, TransactionsTable (now also hosts the
"Move to project" select + its ConfirmModal, see "Move to
project confirm modal" under Key decisions & lessons),
TransactionRow, ResizablePanels. `RestoreBanner`
was removed in Stage B.2 (see Key decisions & lessons) —
PocketBase being the real backend left no ambiguity for it
to explain. Every button/nav icon site-wide uses
@ -1039,6 +1043,45 @@ connected this session either (tried again, same as every prior UI change in thi
project); this is the one area of this change the user needs to confirm visually
themselves before considering it done.
**"Move to project" confirm modal, 2026-10-13.** The user reported genuine confusion
right after the shell redesign above: the "Move to project" dropdown in
`TransactionsTable.vue` actually worked (PATCHed the document's `project` field via
`documentsService.moveToProject`), but gave **zero visible feedback** - no confirmation,
no change to the document in view, nothing in the sidebar/breadcrumb updating - so a
successful move looked identical to a no-op. Asked for a modal confirm step
specifically "so we don't have to add another button to the actual div."
Built `ConfirmModal.vue` - a small, generic confirm/cancel dialog (dimmed backdrop,
reuses `.card` for its own surface, Esc/backdrop-click both cancel) - rather than a
one-off inline confirmation, since this is exactly the kind of "are you sure" step other
destructive-ish actions in this app (e.g. deleting a project) could reuse later, even
though nothing else is wired to it yet.
**One real subtlety, caught before any code ran:** the `<select>` previously used a bare
`:value` bound straight to `extractionStore.activeDocument?.project`. Switching to a
confirm-before-apply flow requires being able to REVERT the dropdown's own visible
selection when the user cancels - but a plain `:value` binding can't do that reliably,
because the browser already shows whichever option was clicked the instant the user
picks it, and Vue only re-syncs a `<select>` element's displayed value through `v-model`,
not a bare `:value` (a known Vue gotcha, not something encountered by surprise at
runtime here - reasoned through up front). Fixed by giving the dropdown its own local
`selectedProjectId` ref driven by `v-model`, kept in sync with the real active document
via a `watch` (needed now since switching documents via `DocumentNavBar` no longer
auto-updates the select through a direct store binding), and explicitly reset back to
`doc.project` in `cancelMove()` and on a failed move.
Also addressed the original "no feedback" complaint: a `moveConfirmNote` ("Moved to
{project name}") appears next to the dropdown for 3.5s after a successful move. Label
text changed from the bare, ambiguous "Project" to "Move to project" per the earlier
exchange about what this control even does.
Verified: `npm run build` passes; the built JS bundle confirmed to contain the new
`modal-overlay`/`ConfirmModal`/"Moved to "/"Move to project" strings; the `app` container
rebuilt and `curl`-checked serving 200. `measure.py` re-run, unaffected (no backend
touched). **Not machine-verified:** the actual modal interaction (open/confirm/cancel/
Esc/backdrop-click, the dropdown correctly reverting on cancel) - same standing
limitation as every other UI change this session, Claude-in-Chrome did not connect.
**Governing rule: never silently correct or exclude data.** This shows up in several
concrete places, not just as an abstract principle:
- A row with an unusual status (e.g. HSBC's "Cancelled" wires) stays in the output and is

View File

@ -609,6 +609,20 @@ tr.editing td{ background:rgba(37,99,235,.03); }
height:32px; padding:0 8px; background:var(--navy); border:1px solid var(--border-2);
border-radius:7px; font-size:12.5px; color:var(--t1); font-family:var(--fb); outline:none; cursor:pointer;
}
.move-confirm-note{
display:inline-flex; align-items:center; gap:6px; font-size:12px; color:var(--green);
margin-left:2px;
}
/* ── ConfirmModal.vue - a generic confirm/cancel dialog over a dimmed
backdrop. Reuses .card for the dialog's own surface. ──────────────── */
.modal-overlay{
position:fixed; inset:0; z-index:50; background:rgba(13,21,38,.45);
display:flex; align-items:center; justify-content:center; padding:24px; outline:none;
}
.modal-card{ width:100%; max-width:380px; margin-bottom:0; }
.modal-message{ font-size:13.5px; color:var(--t2); line-height:1.6; margin-bottom:22px; }
.modal-actions{ display:flex; align-items:center; justify-content:flex-end; gap:10px; }
/* Icon-prefixed inputs (LoginView's email/password fields). */
.input-icon-wrap{ position:relative; }

View File

@ -0,0 +1,54 @@
<script setup>
/**
* ConfirmModal.vue
*
* A small, generic confirm/cancel modal - built for TransactionsTable's
* "Move to project" dropdown, so picking a different project opens a
* deliberate confirm step instead of moving the document on a single,
* easy-to-misclick `change` event (and instead of adding a second button
* next to the dropdown itself, per the explicit ask). Written generic
* enough to reuse wherever else a confirm step is needed later.
*/
import { nextTick, ref, watch } from 'vue'
const props = defineProps({
visible: { type: Boolean, required: true },
title: { type: String, required: true },
message: { type: String, required: true },
confirmLabel: { type: String, default: 'Confirm' },
cancelLabel: { type: String, default: 'Cancel' },
confirmIcon: { type: String, default: 'fa-check' },
})
const emit = defineEmits(['confirm', 'cancel'])
// The overlay itself holds focus while open (tabindex below) so Esc
// works the moment the modal appears, without needing the caller to
// manage focus.
const overlayRef = ref(null)
watch(() => props.visible, (v) => {
if (v) nextTick(() => overlayRef.value?.focus())
})
</script>
<template>
<div
v-if="visible"
ref="overlayRef"
class="modal-overlay"
tabindex="-1"
@click.self="emit('cancel')"
@keydown.esc="emit('cancel')"
>
<div class="modal-card card" role="dialog" aria-modal="true" :aria-label="title">
<h2>{{ title }}</h2>
<p class="modal-message">{{ message }}</p>
<div class="modal-actions">
<button type="button" class="btn btn-ghost" @click="emit('cancel')">{{ cancelLabel }}</button>
<button type="button" class="btn btn-primary" @click="emit('confirm')">
<i class="fa-solid" :class="confirmIcon"></i>
{{ confirmLabel }}
</button>
</div>
</div>
</div>
</template>

View File

@ -19,7 +19,7 @@
* again by applyCheckResults, while closingCalc's text IS recomputed on
* every recheck).
*/
import { ref, computed } from 'vue'
import { ref, computed, watch } from 'vue'
import { useExtractionStore } from '../stores/extractionStore'
import { useUiStore } from '../stores/uiStore'
import { useProjectsStore } from '../stores/projectsStore'
@ -29,6 +29,7 @@ import * as documentsService from '../services/documentsService'
import { useTransactionFilters } from '../composables/useTransactionFilters'
import TransactionRow from './TransactionRow.vue'
import DocumentNavBar from './DocumentNavBar.vue'
import ConfirmModal from './ConfirmModal.vue'
const extractionStore = useExtractionStore()
const uiStore = useUiStore()
@ -42,19 +43,64 @@ const projectsStore = useProjectsStore()
// view even if it no longer matches an active project filter (a known,
// accepted simplification - the next reload/filter change will reflect
// it correctly).
//
// The <select> is driven by its own local v-model (selectedProjectId),
// not a direct :value binding straight to the document's own project -
// a plain :value binding wouldn't let a cancelled move revert the
// dropdown's visible selection (the browser already shows the clicked
// option; Vue only re-syncs a <select>'s displayed value through
// v-model, not a bare :value). Picking a different project opens a
// confirm step (ConfirmModal) rather than moving immediately - one
// misclick on the dropdown used to silently relocate a document with no
// feedback at all.
const movingProject = ref(false)
async function handleMoveToProject(e) {
const projectId = e.target.value
const selectedProjectId = ref(extractionStore.activeDocument?.project ?? '')
watch(
() => extractionStore.activeDocument?.project,
(v) => { selectedProjectId.value = v ?? '' },
)
const showMoveConfirm = ref(false)
const pendingProjectId = ref(null)
const pendingProjectName = computed(
() => projectsStore.projects.find((p) => p.id === pendingProjectId.value)?.name ?? '',
)
const moveConfirmNote = ref('')
let moveConfirmNoteTimer = null
function handleSelectChange() {
const doc = extractionStore.activeDocument
if (!doc || !projectId || projectId === doc.project) return
if (!doc || !selectedProjectId.value || selectedProjectId.value === doc.project) return
pendingProjectId.value = selectedProjectId.value
showMoveConfirm.value = true
}
function cancelMove() {
showMoveConfirm.value = false
pendingProjectId.value = null
// Revert the dropdown back to the document's actual, unchanged project.
selectedProjectId.value = extractionStore.activeDocument?.project ?? ''
}
async function confirmMove() {
const doc = extractionStore.activeDocument
const projectId = pendingProjectId.value
const projectName = pendingProjectName.value
showMoveConfirm.value = false
if (!doc || !projectId) return
movingProject.value = true
extractionStore.clearError()
try {
await documentsService.moveToProject(doc.pbId, projectId)
extractionStore.setActiveDocumentProject(projectId)
clearTimeout(moveConfirmNoteTimer)
moveConfirmNote.value = `Moved to ${projectName}`
moveConfirmNoteTimer = setTimeout(() => { moveConfirmNote.value = '' }, 3500)
} catch (err) {
extractionStore.setError('Could not move this document: ' + err.message)
selectedProjectId.value = doc.project
}
pendingProjectId.value = null
movingProject.value = false
}
@ -142,11 +188,21 @@ async function handleRecheck() {
<template>
<DocumentNavBar />
<div v-if="result" class="move-to-project">
<label><i class="fa-solid fa-folder-open"></i>Project</label>
<select :value="extractionStore.activeDocument?.project" :disabled="movingProject" @change="handleMoveToProject">
<label><i class="fa-solid fa-folder-open"></i>Move to project</label>
<select v-model="selectedProjectId" :disabled="movingProject" @change="handleSelectChange">
<option v-for="p in projectsStore.projects" :key="p.id" :value="p.id">{{ p.name }}</option>
</select>
<span v-if="moveConfirmNote" class="move-confirm-note"><i class="fa-solid fa-circle-check"></i>{{ moveConfirmNote }}</span>
</div>
<ConfirmModal
:visible="showMoveConfirm"
title="Move document?"
:message="`Move “${extractionStore.activeDocument?.fileName}” to “${pendingProjectName}”?`"
confirm-label="Move"
confirm-icon="fa-folder-open"
@confirm="confirmMove"
@cancel="cancelMove"
/>
<div class="txn-col-head">
<h2>Transactions</h2>
<button class="btn-toggle" type="button" @click="uiStore.togglePdfCol">