Add document delete/rename, merge Result into the transactions top bar
Five related UX fixes from one request:
- DocumentNavBar's filename is now clickable (hover state + a trailing
ellipsis-icon hint) and renders for any loaded document, not just
once there's more than one - opens DocumentOptionsModal to rename, or
hands off to a ConfirmModal to delete (now with danger/busy props:
red confirm button, stays open with a spinner mid-request). Lets a
user delete a document they don't want before downloading.
- Every .btn-toggle button (Hide/Show, Recheck, Download, Results) is a
consistent 36px tall by construction now, not by each call site
matching a number.
- The separate "Download All" button is gone - the single Download
button opens DownloadChoiceModal (current vs. all) once more than one
document is loaded, same as before with exactly one.
- ResultCard.vue is deleted; its content (status banner, checks list,
Download) merges into TransactionsTable's own top bar: a Results
toggle (left) opens a hover-sticky dropdown - stays open while the
mouse is over the trigger or panel, closes the moment it leaves both,
via one shared @mouseleave rather than separate hover-tracking state
- DocumentNavBar sits truly centered (CSS Grid, not flex
space-between) in the middle, Download on the right.
- New shared useModalFocus composable, factored out once three modals
needed the same "focus on open so Esc works" logic.
Verified: npm run build passes; every new icon class confirmed against
the installed FontAwesome CSS; the app container rebuilt and the served
bundle confirmed to contain the new component/class names.
extractionStore.removeDocument/setActiveDocumentFileName executed
directly against a real Pinia instance across five scenarios (earlier
removal, active-document removal mid-list and as the last entry,
emptying to zero, a plain rename) - all correct.
documentsService.updateDocument(id,{fileName})/deleteDocument executed
directly against the real running PocketBase container - rename
persisted and re-fetched correctly, delete correctly 404s afterward.
measure.py re-run, unaffected. Not machine-verified: the actual
interactive behavior - Claude-in-Chrome did not connect this session.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
parent
42d6de1c77
commit
461b399d74
205
CLAUDE.md
205
CLAUDE.md
|
|
@ -319,8 +319,18 @@ security only, not the full SaaS-shaped doc — and the judgment call on what co
|
||||||
`setActiveDocumentProject(projectId)` (added for Stage B.3)
|
`setActiveDocumentProject(projectId)` (added for Stage B.3)
|
||||||
updates just the active document entry's `project` field
|
updates just the active document entry's `project` field
|
||||||
locally after a successful "Move to project" call, rather
|
locally after a successful "Move to project" call, rather
|
||||||
than reloading the whole list.
|
than reloading the whole list. `setActiveDocumentFileName`/
|
||||||
uiStore.js — resultExpanded, pdfColHidden, pdfColWidthPct,
|
`removeDocument(pbId)` (NEW 2026-10-13, for
|
||||||
|
DocumentNavBar's rename/delete) - `removeDocument` also
|
||||||
|
re-settles `activeIndex` to keep pointing at the right
|
||||||
|
document after a splice, see "Document delete/rename..."
|
||||||
|
under Key decisions & lessons for the exact rules.
|
||||||
|
uiStore.js — `resultsOpen`/`toggleResultsOpen()`/`closeResultsOpen()`
|
||||||
|
(renamed from `resultExpanded`/`toggleResultExpanded` -
|
||||||
|
2026-10-13, now drives TransactionsTable's own Results
|
||||||
|
dropdown, kept in the store rather than a component-local
|
||||||
|
ref so useBatchExtraction.js can still reset it closed
|
||||||
|
after every fresh extraction), pdfColHidden, pdfColWidthPct,
|
||||||
layoutVersion (an incrementing counter every
|
layoutVersion (an incrementing counter every
|
||||||
TransactionRow's own description textarea watches to
|
TransactionRow's own description textarea watches to
|
||||||
re-measure its height - replaces the original's global
|
re-measure its height - replaces the original's global
|
||||||
|
|
@ -383,33 +393,45 @@ security only, not the full SaaS-shaped doc — and the judgment call on what co
|
||||||
composable just prefixes its text with "Extracting N/M:
|
composable just prefixes its text with "Extracting N/M:
|
||||||
filename —"), useRowEditing (saveEdit() now calls
|
filename —"), useRowEditing (saveEdit() now calls
|
||||||
`documentsService.updateDocument`, best-effort), useImageZoom,
|
`documentsService.updateDocument`, best-effort), useImageZoom,
|
||||||
useAutoGrow
|
useAutoGrow, useModalFocus (NEW 2026-10-13 — shared by every
|
||||||
|
modal component below: focuses the overlay the instant it
|
||||||
|
becomes visible, so Esc closes it immediately)
|
||||||
/components — AppHeader (sticky top bar — brand mark, active-project
|
/components — AppHeader (sticky top bar — brand mark, active-project
|
||||||
breadcrumb, account menu with email + sign out; added
|
breadcrumb, account menu with email + sign out; added
|
||||||
2026-10-13, see "Enterprise app-shell redesign" under Key
|
2026-10-13, see "Enterprise app-shell redesign" under Key
|
||||||
decisions & lessons), AppFooter (slim bottom bar, same
|
decisions & lessons), AppFooter (slim bottom bar, same
|
||||||
entry), FileUploadZone (multi-select input), DocumentNavBar
|
entry), FileUploadZone (multi-select input), DocumentNavBar
|
||||||
(prev/next between completed documents), ProjectSidebar
|
(the active document's filename — click to rename/delete
|
||||||
|
it via DocumentOptionsModal below — plus prev/next; renders
|
||||||
|
for ANY loaded document as of 2026-10-13, not just once
|
||||||
|
there's more than one, so delete is reachable with just one
|
||||||
|
document loaded), ProjectSidebar
|
||||||
(the app's primary left nav as of 2026-10-13 — project
|
(the app's primary left nav as of 2026-10-13 — project
|
||||||
list/select/create/rename/delete, a client-side project
|
list/select/create/rename/delete, a client-side project
|
||||||
search box, filters the document list, collapses to an
|
search box, filters the document list, collapses to an
|
||||||
icon-only rail), LoginView
|
icon-only rail), LoginView
|
||||||
(Sign In/Sign Up toggle + "Continue with Google"),
|
(Sign In/Sign Up toggle + "Continue with Google"),
|
||||||
ConfirmModal (NEW 2026-10-13 — generic confirm/cancel
|
ConfirmModal (generic confirm/cancel dialog over a dimmed
|
||||||
dialog over a dimmed backdrop; built for "Move to project"
|
backdrop; `danger`/`busy` props added 2026-10-13 for the
|
||||||
but reusable elsewhere), ProcessingIndicator, ResultCard
|
delete-document flow — red confirm button, stays open with
|
||||||
(Download + Download All, best-effort persists the export
|
a spinner mid-request), DocumentOptionsModal (NEW
|
||||||
to R2 via `documentsService.saveExportFile`),
|
2026-10-13 — inline rename + hands off to a second
|
||||||
SourceDocumentPanel, TransactionsTable (now also hosts the
|
ConfirmModal for delete), DownloadChoiceModal (NEW
|
||||||
"Move to project" select + its ConfirmModal, see "Move to
|
2026-10-13 — "current document" vs. "all N documents",
|
||||||
project confirm modal" under Key decisions & lessons),
|
replacing a separate always-visible Download All button),
|
||||||
TransactionRow, ResizablePanels. `RestoreBanner`
|
ProcessingIndicator, SourceDocumentPanel, TransactionsTable
|
||||||
was removed in Stage B.2 (see Key decisions & lessons) —
|
(now also hosts its own top bar — a Results dropdown,
|
||||||
PocketBase being the real backend left no ambiguity for it
|
DocumentNavBar, and the Download button; this is
|
||||||
to explain. Every button/nav icon site-wide uses
|
ResultCard.vue's old content, merged in and that file
|
||||||
FontAwesome solid icons now (`@fortawesome/fontawesome-free`)
|
deleted outright, 2026-10-13 — see "Document delete/
|
||||||
in place of the original vanilla-JS build's unicode
|
rename..." under Key decisions & lessons — plus the "Move
|
||||||
entities (✎/✓/✕/←/→/▶/−/▲▼).
|
to project" select + its own ConfirmModal), 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 FontAwesome solid icons
|
||||||
|
(`@fortawesome/fontawesome-free`) in place of the original
|
||||||
|
vanilla-JS build's unicode entities.
|
||||||
/views/ExtractorView.vue — the extraction page itself: upload, result, document
|
/views/ExtractorView.vue — the extraction page itself: upload, result, document
|
||||||
navigation, side-by-side review. No longer owns a page-level
|
navigation, side-by-side review. No longer owns a page-level
|
||||||
layout wrapper or ProjectSidebar (both moved up to App.vue's
|
layout wrapper or ProjectSidebar (both moved up to App.vue's
|
||||||
|
|
@ -1082,6 +1104,115 @@ touched). **Not machine-verified:** the actual modal interaction (open/confirm/c
|
||||||
Esc/backdrop-click, the dropdown correctly reverting on cancel) - same standing
|
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.
|
limitation as every other UI change this session, Claude-in-Chrome did not connect.
|
||||||
|
|
||||||
|
**Document delete/rename, consistent button heights, Download-choice modal, and
|
||||||
|
ResultCard merged into TransactionsTable's top bar - all 2026-10-13, one combined
|
||||||
|
request.** Five distinct asks landed together:
|
||||||
|
|
||||||
|
1. **A way to delete a loaded document before downloading it**, with "a better visual
|
||||||
|
UI clue that it's possible." `DocumentNavBar.vue`'s filename is a real `<button>`
|
||||||
|
now (`.doc-nav-label-btn`), not inert text - a hover state plus a trailing muted
|
||||||
|
`fa-ellipsis` icon (`.doc-nav-options-hint`) signal it's clickable. Clicking it opens
|
||||||
|
`DocumentOptionsModal.vue` (NEW) - an inline rename field + a "Delete this document"
|
||||||
|
button - and delete hands off to a SECOND, separate `ConfirmModal` (the same
|
||||||
|
two-step "pick an action, then confirm the destructive one" pattern "Move to
|
||||||
|
project" already established), now with a `danger` prop (red confirm button) and a
|
||||||
|
`busy` prop (keeps the modal open with a spinner mid-request, disables Esc/backdrop/
|
||||||
|
both buttons until it resolves, instead of closing immediately with no feedback
|
||||||
|
during the network call).
|
||||||
|
|
||||||
|
**DocumentNavBar itself had to change its own visibility gate** to make this
|
||||||
|
possible: it used to only render once `documents.length > 1` (prev/next needed a
|
||||||
|
second document to mean anything), which meant a SINGLE loaded document had no
|
||||||
|
filename shown anywhere and thus no way to delete it. Now it renders for any
|
||||||
|
`length > 0`; prev/next arrows and the "(N of M)" position text stay gated behind
|
||||||
|
`length > 1`, but the filename - and the delete affordance - are always there once
|
||||||
|
there's anything loaded at all.
|
||||||
|
|
||||||
|
`extractionStore` gained two actions for this: `setActiveDocumentFileName(name)`
|
||||||
|
(mirrors `setActiveDocumentProject`) and `removeDocument(pbId)` - finds the document
|
||||||
|
by its PocketBase id, splices it out, and re-settles `activeIndex`: a removal
|
||||||
|
EARLIER than the active index decrements it (keeps pointing at the same logical
|
||||||
|
document, which just shifted left); a removal AT OR AFTER it leaves the number
|
||||||
|
alone, then clamps to the new last index if that's now out of range (covers
|
||||||
|
deleting the active document itself, including when it was the last one, and
|
||||||
|
deleting the very last document in the list down to zero). `documentsService
|
||||||
|
.updateDocument(id, patch)` was generalized from a hardcoded `{result}` destructure
|
||||||
|
to accept any plain-object patch, so the same function serves both a row-edit save
|
||||||
|
and a rename (`{fileName}`) without a second, near-duplicate service function.
|
||||||
|
|
||||||
|
2. **Consistent blue-button height.** `.btn-toggle` (Hide/Show Source Doc, Recheck
|
||||||
|
Balance, Download, the Results toggle) now has `height:36px` baked into the base
|
||||||
|
rule instead of `.btn-recheck` carrying its own one-off override - every blue toggle
|
||||||
|
button is the same height by construction now, not by each call site separately
|
||||||
|
matching a number.
|
||||||
|
|
||||||
|
3. **"Download All" button removed; the single Download button asks when it matters.**
|
||||||
|
With more than one document loaded (and no batch still mid-flight - same gate the
|
||||||
|
old standalone button used, so "all documents" can't be offered before every file in
|
||||||
|
the batch has actually finished), clicking Download opens `DownloadChoiceModal.vue`
|
||||||
|
(NEW) - "Current document only" vs. "All N documents" - instead of needing a second,
|
||||||
|
permanently-visible button competing for space. With exactly one document, it just
|
||||||
|
downloads immediately, unchanged from before.
|
||||||
|
|
||||||
|
4. **ResultCard.vue deleted outright; its content merged into TransactionsTable's own
|
||||||
|
top bar**, replacing the old bare `<DocumentNavBar />` line with a 3-part row: a
|
||||||
|
"Results" toggle (left) opens the status banner + checks list in a dropdown panel;
|
||||||
|
`DocumentNavBar` (center); the Download button (right, see #3). Centering is CSS
|
||||||
|
Grid (`grid-template-columns:1fr auto 1fr`), not flex `space-between` - the latter
|
||||||
|
only truly centers the middle item when the left and right content happen to be
|
||||||
|
equal width, which Results-toggle vs. Download button never reliably are. The
|
||||||
|
filename's own `max-width` was tightened from 360px to 240px to match - sharing a
|
||||||
|
row with two other controls now, not the whole width to itself.
|
||||||
|
|
||||||
|
`uiStore.resultExpanded`/`toggleResultExpanded` were renamed to `resultsOpen`/
|
||||||
|
`toggleResultsOpen`, plus a new `closeResultsOpen()` - kept in the STORE, not a
|
||||||
|
component-local ref, specifically so `useBatchExtraction.js` can keep resetting it
|
||||||
|
closed after every fresh extraction (`uiStore.closeResultsOpen()`), the same
|
||||||
|
behavior `resultExpanded = false` always provided.
|
||||||
|
|
||||||
|
**Hover-sticky dropdown, per explicit spec** ("stays visible as long as their mouse
|
||||||
|
remains on it... collapse when they move their mouse away"): the trigger button and
|
||||||
|
the dropdown panel both live inside one wrapper div
|
||||||
|
(`.results-trigger-wrap`) with a single `@mouseleave` closing it - `mouseleave`
|
||||||
|
doesn't fire when the pointer moves between a parent's own children (only `mouseout`
|
||||||
|
does, which bubbles), so moving from the toggle button down onto the panel beneath
|
||||||
|
it doesn't close it, but leaving the wrapper's combined bounding box entirely does,
|
||||||
|
with no separate "is the panel itself hovered" state-tracking needed. A click still
|
||||||
|
toggles it open/closed independent of hover, for anyone navigating by keyboard/touch
|
||||||
|
rather than a mouse.
|
||||||
|
|
||||||
|
`.result-head`/`.result-head-left`/`.result-head-actions`/`.collapse-arrow`/
|
||||||
|
`.result-details` (ResultCard's old block-accordion styling) and the long-dead,
|
||||||
|
unreferenced `#resultSection{display:none}` rule (leftover from the original
|
||||||
|
vanilla-JS build, confirmed via grep to match nothing in any `.vue` file) were all
|
||||||
|
removed from `main.css` rather than left unused.
|
||||||
|
|
||||||
|
5. **New shared composable, `useModalFocus.js`** - every modal (`ConfirmModal`,
|
||||||
|
`DocumentOptionsModal`, `DownloadChoiceModal`) was duplicating the same "focus the
|
||||||
|
overlay the instant it becomes visible, so Esc works immediately" watcher; factored
|
||||||
|
out once three call sites existed, not speculatively ahead of need.
|
||||||
|
|
||||||
|
**Verified:** `npm run build` passes; every new icon class name checked against the
|
||||||
|
installed FontAwesome CSS (`fa-ellipsis`, `fa-circle-question`, `fa-minus`,
|
||||||
|
`fa-chevron-down`, confirmed present alongside everything already verified in the prior
|
||||||
|
entry). The `app` container rebuilt and the served JS bundle confirmed to contain the
|
||||||
|
new component/class names (`txn-top-bar`, `results-toggle`, `doc-nav-options-hint`,
|
||||||
|
`DocumentOptionsModal`, `DownloadChoiceModal`, `modal-danger-btn`, `btn-danger`).
|
||||||
|
**`extractionStore.removeDocument`/`setActiveDocumentFileName` executed directly**
|
||||||
|
against a real Pinia instance (not re-implemented, the actual store) across five
|
||||||
|
scenarios - removing a document earlier than the active one, removing the active
|
||||||
|
document itself (both mid-list and as the last one), emptying the list down to zero,
|
||||||
|
and a plain rename - all five came back correct, including the index-shift arithmetic.
|
||||||
|
**`documentsService.updateDocument(id, {fileName})` and `deleteDocument(id)` executed
|
||||||
|
directly** against the real running PocketBase container (the actual service functions
|
||||||
|
DocumentNavBar now calls, not reimplementations): created a document, renamed it,
|
||||||
|
re-fetched to confirm the rename actually persisted (not just that the response echoed
|
||||||
|
it), deleted it, and confirmed a subsequent fetch correctly 404s. `measure.py` re-run,
|
||||||
|
unaffected (no backend touched). **Not machine-verified:** the actual interactive
|
||||||
|
behavior - the hover-sticky dropdown's timing, the delete/rename modals' click-through,
|
||||||
|
whether the 3-column header truly centers the nav at various widths - Claude-in-Chrome
|
||||||
|
still did not connect this session; this is the user's own check before calling it done.
|
||||||
|
|
||||||
**Governing rule: never silently correct or exclude data.** This shows up in several
|
**Governing rule: never silently correct or exclude data.** This shows up in several
|
||||||
concrete places, not just as an abstract principle:
|
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
|
- A row with an unusual status (e.g. HSBC's "Cancelled" wires) stays in the output and is
|
||||||
|
|
@ -1347,18 +1478,30 @@ restructure; the behavior itself predates it and is unchanged:
|
||||||
- A Hide/Show toggle in the Transactions header (`TransactionsTable.vue`, driven by
|
- A Hide/Show toggle in the Transactions header (`TransactionsTable.vue`, driven by
|
||||||
`uiStore.pdfColHidden`, labeled "Hide Source Doc"/"Show Source Doc") collapses the
|
`uiStore.pdfColHidden`, labeled "Hide Source Doc"/"Show Source Doc") collapses the
|
||||||
source-doc column so Transactions fills the row.
|
source-doc column so Transactions fills the row.
|
||||||
- The Result card (`ResultCard.vue`) is collapsible: a chevron + "Result" heading on the
|
- `TransactionsTable.vue`'s own top bar (replacing the old standalone `ResultCard.vue`,
|
||||||
left toggle the status banner/checks list (`uiStore.resultExpanded`); Download Excel
|
deleted 2026-10-13) is a 3-part row: a "Results" toggle on the left opens a
|
||||||
stays on the right, always visible; every fresh extraction starts collapsed. A Download
|
hover-sticky dropdown (click to open; closes automatically once the mouse leaves the
|
||||||
All button (added 2026-10-13) sits beside it, shown only once a multi-file batch has
|
trigger+panel area, via `uiStore.resultsOpen`/`toggleResultsOpen`/`closeResultsOpen`)
|
||||||
actually finished (`!isBatchProcessing && documents.length > 1`) - loops every loaded
|
showing the status banner + checks list; `DocumentNavBar` sits truly centered in the
|
||||||
document through the same per-document export, triggering N sequential browser
|
middle (CSS Grid, not flex `space-between`); the Download button is on the right.
|
||||||
downloads rather than a zip bundle (some browsers prompt to allow multiple downloads
|
Every fresh extraction starts with the dropdown closed. With more than one document
|
||||||
from one click - a known, minor wrinkle, not worth a new backend endpoint + dependency
|
loaded (and no batch still running), Download opens `DownloadChoiceModal` -
|
||||||
for a v1). As of 2026-10-13, every download also persists that same file to PocketBase/
|
"current document" vs. "all N documents" - instead of a permanently-visible second
|
||||||
R2 (`documentsService.saveExportFile`, best-effort - a failure there is reported but
|
"Download All" button; with exactly one document it downloads immediately. "All"
|
||||||
never blocks the browser download itself) - the latest export only, overwritten each
|
loops every loaded document through the same per-document export, triggering N
|
||||||
time, not a history (no retention policy has been decided yet).
|
sequential browser downloads rather than a zip bundle (some browsers prompt to allow
|
||||||
|
multiple downloads from one click - a known, minor wrinkle, not worth a new backend
|
||||||
|
endpoint + dependency for a v1). Every download also persists that same file to
|
||||||
|
PocketBase/R2 (`documentsService.saveExportFile`, best-effort - a failure there is
|
||||||
|
reported but never blocks the browser download itself) - the latest export only,
|
||||||
|
overwritten each time, not a history (no retention policy has been decided yet).
|
||||||
|
- `DocumentNavBar.vue`'s filename is clickable (a hover state + trailing muted
|
||||||
|
ellipsis icon signal it, since it looks like plain text otherwise) - opens
|
||||||
|
`DocumentOptionsModal` to rename it, or hands off to a second `ConfirmModal` to
|
||||||
|
delete it (red confirm button, stays open with a spinner until the request
|
||||||
|
resolves). Renders for any loaded document, not just once there's more than one -
|
||||||
|
deleting a single loaded document before downloading it doesn't require a second
|
||||||
|
document to exist first.
|
||||||
- Opening/closing balance inputs always start blank (never auto-filled) — a separate
|
- Opening/closing balance inputs always start blank (never auto-filled) — a separate
|
||||||
read-only "Calculated: $X" readout below each one shows the auto-detected or typed value,
|
read-only "Calculated: $X" readout below each one shows the auto-detected or typed value,
|
||||||
turning green when the `statement_balance` check outcome is "pass". Deliberate, to reduce
|
turning green when the `statement_balance` check outcome is "pass". Deliberate, to reduce
|
||||||
|
|
|
||||||
|
|
@ -102,10 +102,10 @@ h1{ font-family:var(--fd); font-weight:800; font-size:30px; letter-spacing:-.01e
|
||||||
either height to the browser's own font-metric-driven "auto". */
|
either height to the browser's own font-metric-driven "auto". */
|
||||||
.recheck-wrap{ display:flex; flex-direction:column; flex-shrink:0; }
|
.recheck-wrap{ display:flex; flex-direction:column; flex-shrink:0; }
|
||||||
.recheck-spacer{ font-size:11.5px; line-height:1; margin-bottom:6px; visibility:hidden; }
|
.recheck-spacer{ font-size:11.5px; line-height:1; margin-bottom:6px; visibility:hidden; }
|
||||||
.btn-recheck{
|
/* height/display/align now come from .btn-toggle itself (every blue
|
||||||
flex-shrink:0; white-space:nowrap; height:36px; padding-top:0; padding-bottom:0;
|
toggle-style button is a consistent 36px tall) - this just keeps the
|
||||||
display:inline-flex; align-items:center; justify-content:center;
|
button from wrapping or shrinking in its own flex row. */
|
||||||
}
|
.btn-recheck{ flex-shrink:0; white-space:nowrap; }
|
||||||
.fields{ display:flex; flex-wrap:wrap; gap:16px; }
|
.fields{ display:flex; flex-wrap:wrap; gap:16px; }
|
||||||
.fields > div{ flex:1 1 180px; min-width:160px; }
|
.fields > div{ flex:1 1 180px; min-width:160px; }
|
||||||
.fields label{ font-size:11.5px; color:var(--t3); display:block; margin-bottom:6px; white-space:normal; }
|
.fields label{ font-size:11.5px; color:var(--t3); display:block; margin-bottom:6px; white-space:normal; }
|
||||||
|
|
@ -127,6 +127,9 @@ h1{ font-family:var(--fd); font-weight:800; font-size:30px; letter-spacing:-.01e
|
||||||
.btn-primary{ background:var(--blue); color:var(--navy-2); box-shadow:0 4px 18px rgba(37,99,235,.18); }
|
.btn-primary{ background:var(--blue); color:var(--navy-2); box-shadow:0 4px 18px rgba(37,99,235,.18); }
|
||||||
.btn-primary:hover{ background:var(--blue-b); }
|
.btn-primary:hover{ background:var(--blue-b); }
|
||||||
.btn-primary:disabled{ opacity:.35; cursor:not-allowed; box-shadow:none; }
|
.btn-primary:disabled{ opacity:.35; cursor:not-allowed; box-shadow:none; }
|
||||||
|
.btn-danger{ background:var(--red); color:var(--navy-2); box-shadow:0 4px 18px rgba(220,38,38,.18); }
|
||||||
|
.btn-danger:hover{ background:#B91C1C; }
|
||||||
|
.btn-danger:disabled{ opacity:.35; cursor:not-allowed; box-shadow:none; }
|
||||||
.btn-ghost{
|
.btn-ghost{
|
||||||
background:transparent; color:var(--t1); border:1px solid var(--border-2);
|
background:transparent; color:var(--t1); border:1px solid var(--border-2);
|
||||||
}
|
}
|
||||||
|
|
@ -152,19 +155,6 @@ h1{ font-family:var(--fd); font-weight:800; font-size:30px; letter-spacing:-.01e
|
||||||
|
|
||||||
.period-note{ font-size:12.5px; color:var(--t3); margin-bottom:18px; }
|
.period-note{ font-size:12.5px; color:var(--t3); margin-bottom:18px; }
|
||||||
|
|
||||||
.result-head{ display:flex; align-items:center; justify-content:space-between; gap:12px; }
|
|
||||||
.result-head-left{ display:flex; align-items:center; gap:10px; cursor:pointer; }
|
|
||||||
.result-head-actions{ display:flex; align-items:center; gap:10px; }
|
|
||||||
.result-head-left h2{ margin-bottom:0; }
|
|
||||||
.collapse-arrow{
|
|
||||||
display:inline-flex; align-items:center; justify-content:center;
|
|
||||||
width:20px; height:20px; background:transparent; border:none; cursor:pointer;
|
|
||||||
color:var(--blue); font-size:12px; line-height:1; transition:transform .2s; transform:rotate(0deg);
|
|
||||||
}
|
|
||||||
.collapse-arrow.expanded{ transform:rotate(90deg); }
|
|
||||||
.result-details{ display:none; margin-top:18px; }
|
|
||||||
.result-details.expanded{ display:block; }
|
|
||||||
|
|
||||||
.checks-list{ list-style:none; }
|
.checks-list{ list-style:none; }
|
||||||
.checks-list li{
|
.checks-list li{
|
||||||
display:flex; gap:12px; align-items:flex-start; padding:11px 0; border-bottom:1px solid var(--border);
|
display:flex; gap:12px; align-items:flex-start; padding:11px 0; border-bottom:1px solid var(--border);
|
||||||
|
|
@ -262,27 +252,70 @@ td.amt .cell-input{ text-align:right; font-family:var(--fm); }
|
||||||
.row-btn.cancel{ color:var(--t4); }
|
.row-btn.cancel{ color:var(--t4); }
|
||||||
tr.editing td{ background:rgba(37,99,235,.03); }
|
tr.editing td{ background:rgba(37,99,235,.03); }
|
||||||
|
|
||||||
|
/* ── Top bar: Results (left) / DocumentNavBar (center, TRUE center via
|
||||||
|
grid - not flex space-between, which would only center it when the
|
||||||
|
left/right content happens to be equal width) / Download (right).
|
||||||
|
Sits across the top of the transactions card - no border/background
|
||||||
|
box of its own since it's already inside the card's; a bottom border
|
||||||
|
is enough to separate it from the move-to-project/title rows beneath. */
|
||||||
|
.txn-top-bar{
|
||||||
|
display:grid; grid-template-columns:1fr auto 1fr; align-items:center; gap:12px;
|
||||||
|
padding-bottom:12px; margin-bottom:14px; border-bottom:1px solid var(--border-2);
|
||||||
|
flex-shrink:0;
|
||||||
|
}
|
||||||
|
.txn-download-btn{ justify-self:end; }
|
||||||
|
|
||||||
|
.results-trigger-wrap{ position:relative; justify-self:start; }
|
||||||
|
.results-toggle{
|
||||||
|
display:inline-flex; align-items:center; gap:8px; height:36px;
|
||||||
|
background:transparent; border:1px solid var(--border-2); color:var(--t2); font-family:var(--fb);
|
||||||
|
font-weight:600; font-size:12.5px; padding:0 13px; border-radius:8px; cursor:pointer; transition:all .15s;
|
||||||
|
}
|
||||||
|
.results-toggle:hover{ border-color:var(--blue); color:var(--blue); }
|
||||||
|
.results-toggle:disabled{ opacity:.45; cursor:not-allowed; }
|
||||||
|
.results-toggle .fa-chevron-down{ font-size:10px; color:var(--t4); transition:transform .15s; }
|
||||||
|
.results-toggle .fa-chevron-down.open{ transform:rotate(180deg); }
|
||||||
|
.results-status-dot{ width:8px; height:8px; border-radius:50%; flex-shrink:0; }
|
||||||
|
.results-status-dot.Verified{ background:var(--green); }
|
||||||
|
.results-status-dot.Needs-review{ background:var(--amber); }
|
||||||
|
.results-status-dot.Failed{ background:var(--red); }
|
||||||
|
/* Floats below the toggle without pushing the top bar's own height
|
||||||
|
around - position:absolute inside the trigger wrap's position:relative,
|
||||||
|
closed by the wrap's own @mouseleave (TransactionsTable.vue) the
|
||||||
|
instant the pointer leaves the trigger+panel zone entirely (mouseleave
|
||||||
|
doesn't fire when moving between a parent's own children, only when
|
||||||
|
truly exiting it - no separate "is the panel itself hovered" tracking
|
||||||
|
needed). */
|
||||||
|
.results-dropdown{
|
||||||
|
position:absolute; top:calc(100% + 8px); left:0; z-index:15; width:340px; max-width:90vw; margin-bottom:0;
|
||||||
|
}
|
||||||
|
|
||||||
/* Sits across the top of the transactions card, above the Hide Source
|
/* Sits across the top of the transactions card, above the Hide Source
|
||||||
Doc row (TransactionsTable.vue renders it first) - no border/
|
Doc row (TransactionsTable.vue renders it first) - no border/
|
||||||
background box of its own since it's already inside the card's; a
|
background box of its own since it's already inside the card's; a
|
||||||
bottom border is enough to separate it from the title row beneath. */
|
bottom border is enough to separate it from the title row beneath. */
|
||||||
.doc-nav{
|
.doc-nav{ display:flex; align-items:center; gap:14px; min-width:0; justify-self:center; }
|
||||||
display:flex; align-items:center; justify-content:center; gap:14px;
|
|
||||||
padding-bottom:12px; margin-bottom:14px; border-bottom:1px solid var(--border-2);
|
|
||||||
flex-shrink:0;
|
|
||||||
}
|
|
||||||
.doc-nav-arrow{
|
.doc-nav-arrow{
|
||||||
background:transparent; border:1px solid var(--border-2); color:var(--t2); width:28px; height:28px;
|
background:transparent; border:1px solid var(--border-2); color:var(--t2); width:28px; height:28px;
|
||||||
border-radius:7px; cursor:pointer; font-size:14px; line-height:1; transition:all .15s;
|
border-radius:7px; cursor:pointer; font-size:14px; line-height:1; transition:all .15s; flex-shrink:0;
|
||||||
}
|
}
|
||||||
.doc-nav-arrow:hover:not(:disabled){ border-color:var(--blue); color:var(--blue); }
|
.doc-nav-arrow:hover:not(:disabled){ border-color:var(--blue); color:var(--blue); }
|
||||||
.doc-nav-arrow:disabled{ opacity:.35; cursor:not-allowed; }
|
.doc-nav-arrow:disabled{ opacity:.35; cursor:not-allowed; }
|
||||||
.doc-nav-label{ display:flex; align-items:baseline; gap:8px; font-size:13px; min-width:0; }
|
/* The filename is a real <button> now (click opens DocumentOptionsModal
|
||||||
|
- rename/delete), not inert text - styled to read as plain text at
|
||||||
|
rest, with a hover state and a trailing ellipsis-icon hint so it's
|
||||||
|
discoverable as clickable rather than looking like a static label. */
|
||||||
|
.doc-nav-label-btn{
|
||||||
|
display:flex; align-items:baseline; gap:8px; min-width:0; background:transparent; border:none;
|
||||||
|
cursor:pointer; font:inherit; padding:3px 6px; border-radius:6px; transition:background .15s;
|
||||||
|
}
|
||||||
|
.doc-nav-label-btn:hover{ background:rgba(37,99,235,.06); }
|
||||||
.doc-nav-file-icon{ color:var(--t4); font-size:11px; align-self:center; }
|
.doc-nav-file-icon{ color:var(--t4); font-size:11px; align-self:center; }
|
||||||
.doc-nav-name{ font-weight:600; color:var(--t1); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; max-width:360px; }
|
.doc-nav-name{ font-weight:600; color:var(--t1); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; max-width:240px; }
|
||||||
|
.doc-nav-label-btn:hover .doc-nav-name{ color:var(--blue); }
|
||||||
.doc-nav-position{ color:var(--t4); font-family:var(--fm); font-size:11.5px; flex-shrink:0; }
|
.doc-nav-position{ color:var(--t4); font-family:var(--fm); font-size:11.5px; flex-shrink:0; }
|
||||||
|
.doc-nav-options-hint{ color:var(--t4); font-size:10px; align-self:center; transition:color .15s; }
|
||||||
#resultSection{ display:none; }
|
.doc-nav-label-btn:hover .doc-nav-options-hint{ color:var(--blue); }
|
||||||
|
|
||||||
/* Sticky on the GROUP, not on pdf-col alone - keeps the source PDF and
|
/* Sticky on the GROUP, not on pdf-col alone - keeps the source PDF and
|
||||||
transactions cards moving together as one unit while the main page
|
transactions cards moving together as one unit while the main page
|
||||||
|
|
@ -385,9 +418,9 @@ tr.editing td{ background:rgba(37,99,235,.03); }
|
||||||
.txn-col-head h2{ margin-bottom:0; }
|
.txn-col-head h2{ margin-bottom:0; }
|
||||||
.txn-col .fields, .txn-col .note{ flex-shrink:0; }
|
.txn-col .fields, .txn-col .note{ flex-shrink:0; }
|
||||||
.btn-toggle{
|
.btn-toggle{
|
||||||
display:inline-flex; align-items:center; gap:7px;
|
display:inline-flex; align-items:center; justify-content:center; gap:7px; height:36px;
|
||||||
background:var(--blue); border:none; color:var(--navy-2); font-family:var(--fd); font-weight:700;
|
background:var(--blue); border:none; color:var(--navy-2); font-family:var(--fd); font-weight:700;
|
||||||
font-size:12px; padding:7px 15px; border-radius:8px; cursor:pointer; transition:all .15s; flex-shrink:0;
|
font-size:12px; padding:0 15px; border-radius:8px; cursor:pointer; transition:all .15s; flex-shrink:0;
|
||||||
box-shadow:0 2px 10px rgba(37,99,235,.18);
|
box-shadow:0 2px 10px rgba(37,99,235,.18);
|
||||||
}
|
}
|
||||||
.btn-toggle:hover{ background:var(--blue-b); }
|
.btn-toggle:hover{ background:var(--blue-b); }
|
||||||
|
|
@ -440,6 +473,15 @@ tr.editing td{ background:rgba(37,99,235,.03); }
|
||||||
.recheck-spacer{ display:none; }
|
.recheck-spacer{ display:none; }
|
||||||
.btn-recheck{ align-self:flex-end; }
|
.btn-recheck{ align-self:flex-end; }
|
||||||
}
|
}
|
||||||
|
/* The 3-column Results/nav/Download grid gets cramped before the fields
|
||||||
|
row above does (three separate controls, not two) - stacks top-to-
|
||||||
|
bottom (DOM order: Results, then the nav, then Download) once this
|
||||||
|
column narrows past a comfortable width for all three side by side. */
|
||||||
|
@container txncol (max-width: 620px){
|
||||||
|
.txn-top-bar{ grid-template-columns:1fr; justify-items:stretch; gap:10px; }
|
||||||
|
.results-trigger-wrap, .doc-nav{ justify-self:center; }
|
||||||
|
.txn-download-btn{ justify-self:stretch; }
|
||||||
|
}
|
||||||
|
|
||||||
.login-page{ min-height:100vh; display:flex; align-items:center; justify-content:center; padding:24px; }
|
.login-page{ min-height:100vh; display:flex; align-items:center; justify-content:center; padding:24px; }
|
||||||
.login-card{ width:100%; max-width:360px; margin-bottom:0; }
|
.login-card{ width:100%; max-width:360px; margin-bottom:0; }
|
||||||
|
|
@ -614,15 +656,40 @@ tr.editing td{ background:rgba(37,99,235,.03); }
|
||||||
margin-left:2px;
|
margin-left:2px;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ── ConfirmModal.vue - a generic confirm/cancel dialog over a dimmed
|
/* ── ConfirmModal.vue / DocumentOptionsModal.vue / DownloadChoiceModal.vue
|
||||||
backdrop. Reuses .card for the dialog's own surface. ──────────────── */
|
- every modal in the app shares this surface/overlay. Reuses .card for
|
||||||
|
the dialog's own surface. ──────────────────────────────────────────── */
|
||||||
.modal-overlay{
|
.modal-overlay{
|
||||||
position:fixed; inset:0; z-index:50; background:rgba(13,21,38,.45);
|
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;
|
display:flex; align-items:center; justify-content:center; padding:24px; outline:none;
|
||||||
}
|
}
|
||||||
.modal-card{ width:100%; max-width:380px; margin-bottom:0; }
|
.modal-card{ width:100%; max-width:380px; margin-bottom:0; }
|
||||||
|
.modal-card h2{ display:flex; align-items:center; gap:9px; }
|
||||||
.modal-message{ font-size:13.5px; color:var(--t2); line-height:1.6; margin-bottom:22px; }
|
.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; }
|
.modal-actions{ display:flex; align-items:center; justify-content:flex-end; gap:10px; }
|
||||||
|
/* DownloadChoiceModal's two primary choices, stacked full-width above
|
||||||
|
the usual Cancel row rather than crowded beside it. */
|
||||||
|
.modal-actions-stack{ flex-direction:column; align-items:stretch; margin-bottom:10px; }
|
||||||
|
.modal-actions-stack .btn{ width:100%; }
|
||||||
|
|
||||||
|
/* DocumentOptionsModal's rename field + its own destructive delete
|
||||||
|
button - a shared, generic enough shape other modals can reuse later. */
|
||||||
|
.modal-field{ margin-bottom:18px; }
|
||||||
|
.modal-field label{ font-size:11.5px; color:var(--t3); display:block; margin-bottom:6px; }
|
||||||
|
.modal-field-row{ display:flex; gap:8px; }
|
||||||
|
.modal-input{
|
||||||
|
flex:1 1 auto; min-width:0; height:36px; padding:0 11px; background:var(--navy); border:1px solid var(--border-2);
|
||||||
|
border-radius:8px; font-size:13px; color:var(--t1); font-family:var(--fb); outline:none; transition:border-color .2s;
|
||||||
|
}
|
||||||
|
.modal-input:focus{ border-color:var(--blue); }
|
||||||
|
.modal-input:disabled{ opacity:.6; cursor:not-allowed; }
|
||||||
|
.modal-danger-btn{
|
||||||
|
width:100%; display:flex; align-items:center; gap:9px; background:transparent;
|
||||||
|
border:1px solid rgba(220,38,38,.35); color:var(--red); padding:10px 12px; border-radius:8px;
|
||||||
|
cursor:pointer; font-size:13px; font-family:var(--fb); margin-bottom:18px; transition:all .15s;
|
||||||
|
}
|
||||||
|
.modal-danger-btn:hover:not(:disabled){ background:var(--red-l); }
|
||||||
|
.modal-danger-btn:disabled{ opacity:.45; cursor:not-allowed; }
|
||||||
|
|
||||||
/* Icon-prefixed inputs (LoginView's email/password fields). */
|
/* Icon-prefixed inputs (LoginView's email/password fields). */
|
||||||
.input-icon-wrap{ position:relative; }
|
.input-icon-wrap{ position:relative; }
|
||||||
|
|
|
||||||
|
|
@ -2,32 +2,29 @@
|
||||||
/**
|
/**
|
||||||
* ConfirmModal.vue
|
* ConfirmModal.vue
|
||||||
*
|
*
|
||||||
* A small, generic confirm/cancel modal - built for TransactionsTable's
|
* A small, generic confirm/cancel modal - originally built for
|
||||||
* "Move to project" dropdown, so picking a different project opens a
|
* TransactionsTable's "Move to project" dropdown, now also reused for
|
||||||
* deliberate confirm step instead of moving the document on a single,
|
* destructive document deletion (see DocumentNavBar.vue's "Delete this
|
||||||
* easy-to-misclick `change` event (and instead of adding a second button
|
* document" flow) - `danger` swaps the confirm button to the red/danger
|
||||||
* next to the dropdown itself, per the explicit ask). Written generic
|
* treatment for that case.
|
||||||
* enough to reuse wherever else a confirm step is needed later.
|
|
||||||
*/
|
*/
|
||||||
import { nextTick, ref, watch } from 'vue'
|
import { toRef } from 'vue'
|
||||||
|
import { useModalFocus } from '../composables/useModalFocus'
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
visible: { type: Boolean, required: true },
|
visible: { type: Boolean, required: true },
|
||||||
title: { type: String, required: true },
|
title: { type: String, required: true },
|
||||||
|
titleIcon: { type: String, default: 'fa-circle-question' },
|
||||||
message: { type: String, required: true },
|
message: { type: String, required: true },
|
||||||
confirmLabel: { type: String, default: 'Confirm' },
|
confirmLabel: { type: String, default: 'Confirm' },
|
||||||
cancelLabel: { type: String, default: 'Cancel' },
|
cancelLabel: { type: String, default: 'Cancel' },
|
||||||
confirmIcon: { type: String, default: 'fa-check' },
|
confirmIcon: { type: String, default: 'fa-check' },
|
||||||
|
danger: { type: Boolean, default: false },
|
||||||
|
busy: { type: Boolean, default: false },
|
||||||
})
|
})
|
||||||
const emit = defineEmits(['confirm', 'cancel'])
|
const emit = defineEmits(['confirm', 'cancel'])
|
||||||
|
|
||||||
// The overlay itself holds focus while open (tabindex below) so Esc
|
const { overlayRef } = useModalFocus(toRef(props, 'visible'))
|
||||||
// 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>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|
@ -36,16 +33,16 @@ watch(() => props.visible, (v) => {
|
||||||
ref="overlayRef"
|
ref="overlayRef"
|
||||||
class="modal-overlay"
|
class="modal-overlay"
|
||||||
tabindex="-1"
|
tabindex="-1"
|
||||||
@click.self="emit('cancel')"
|
@click.self="!busy && emit('cancel')"
|
||||||
@keydown.esc="emit('cancel')"
|
@keydown.esc="!busy && emit('cancel')"
|
||||||
>
|
>
|
||||||
<div class="modal-card card" role="dialog" aria-modal="true" :aria-label="title">
|
<div class="modal-card card" role="dialog" aria-modal="true" :aria-label="title">
|
||||||
<h2>{{ title }}</h2>
|
<h2><i class="fa-solid" :class="titleIcon"></i>{{ title }}</h2>
|
||||||
<p class="modal-message">{{ message }}</p>
|
<p class="modal-message">{{ message }}</p>
|
||||||
<div class="modal-actions">
|
<div class="modal-actions">
|
||||||
<button type="button" class="btn btn-ghost" @click="emit('cancel')">{{ cancelLabel }}</button>
|
<button type="button" class="btn btn-ghost" :disabled="busy" @click="emit('cancel')">{{ cancelLabel }}</button>
|
||||||
<button type="button" class="btn btn-primary" @click="emit('confirm')">
|
<button type="button" class="btn" :class="danger ? 'btn-danger' : 'btn-primary'" :disabled="busy" @click="emit('confirm')">
|
||||||
<i class="fa-solid" :class="confirmIcon"></i>
|
<i class="fa-solid" :class="busy ? 'fa-spinner fa-spin' : confirmIcon"></i>
|
||||||
{{ confirmLabel }}
|
{{ confirmLabel }}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -2,42 +2,122 @@
|
||||||
/**
|
/**
|
||||||
* DocumentNavBar.vue
|
* DocumentNavBar.vue
|
||||||
*
|
*
|
||||||
* Prev/next between completed documents - visible only once there's
|
* The active document's filename (click to rename or delete it - see
|
||||||
* more than one to browse. Switches extractionStore.activeIndex, which
|
* DocumentOptionsModal.vue) plus prev/next between completed documents.
|
||||||
* is what SourceDocumentPanel/TransactionsTable/ResultCard all read
|
* Prev/next only show once there's more than one document to browse,
|
||||||
* through (see extractionStore.js's getters), so this is the only place
|
* but the filename itself - and the ability to delete it - is available
|
||||||
* that needs to know navigation exists at all.
|
* from the very first document, not just once a batch exists (deleting
|
||||||
|
* before download was the actual ask; it shouldn't require a second
|
||||||
|
* document to be loaded first). Switches extractionStore.activeIndex,
|
||||||
|
* which is what SourceDocumentPanel/TransactionsTable all read through
|
||||||
|
* (see extractionStore.js's getters), so this is the only place that
|
||||||
|
* needs to know navigation exists at all.
|
||||||
*/
|
*/
|
||||||
import { computed } from 'vue'
|
import { computed, ref } from 'vue'
|
||||||
import { useExtractionStore } from '../stores/extractionStore'
|
import { useExtractionStore } from '../stores/extractionStore'
|
||||||
|
import * as documentsService from '../services/documentsService'
|
||||||
|
import DocumentOptionsModal from './DocumentOptionsModal.vue'
|
||||||
|
import ConfirmModal from './ConfirmModal.vue'
|
||||||
|
|
||||||
const extractionStore = useExtractionStore()
|
const extractionStore = useExtractionStore()
|
||||||
|
|
||||||
const positionText = computed(
|
const positionText = computed(
|
||||||
() => `${extractionStore.activeIndex + 1} of ${extractionStore.documents.length}`,
|
() => `${extractionStore.activeIndex + 1} of ${extractionStore.documents.length}`,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const showOptions = ref(false)
|
||||||
|
const showDeleteConfirm = ref(false)
|
||||||
|
const renaming = ref(false)
|
||||||
|
const deleting = ref(false)
|
||||||
|
|
||||||
|
function openOptions() {
|
||||||
|
if (!extractionStore.activeDocument) return
|
||||||
|
showOptions.value = true
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleRename(name) {
|
||||||
|
const doc = extractionStore.activeDocument
|
||||||
|
if (!doc) return
|
||||||
|
renaming.value = true
|
||||||
|
extractionStore.clearError()
|
||||||
|
try {
|
||||||
|
await documentsService.updateDocument(doc.pbId, { fileName: name })
|
||||||
|
extractionStore.setActiveDocumentFileName(name)
|
||||||
|
showOptions.value = false
|
||||||
|
} catch (err) {
|
||||||
|
extractionStore.setError('Could not rename this document: ' + err.message)
|
||||||
|
}
|
||||||
|
renaming.value = false
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleDeleteRequest() {
|
||||||
|
showOptions.value = false
|
||||||
|
showDeleteConfirm.value = true
|
||||||
|
}
|
||||||
|
|
||||||
|
async function confirmDelete() {
|
||||||
|
const doc = extractionStore.activeDocument
|
||||||
|
if (!doc) return
|
||||||
|
deleting.value = true
|
||||||
|
extractionStore.clearError()
|
||||||
|
try {
|
||||||
|
await documentsService.deleteDocument(doc.pbId)
|
||||||
|
extractionStore.removeDocument(doc.pbId)
|
||||||
|
showDeleteConfirm.value = false
|
||||||
|
} catch (err) {
|
||||||
|
extractionStore.setError('Could not delete this document: ' + err.message)
|
||||||
|
showDeleteConfirm.value = false
|
||||||
|
}
|
||||||
|
deleting.value = false
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div v-if="extractionStore.documents.length > 1" class="doc-nav">
|
<div v-if="extractionStore.documents.length > 0" class="doc-nav">
|
||||||
<button
|
<button
|
||||||
|
v-if="extractionStore.documents.length > 1"
|
||||||
class="doc-nav-arrow"
|
class="doc-nav-arrow"
|
||||||
type="button"
|
type="button"
|
||||||
title="Previous document"
|
title="Previous document"
|
||||||
:disabled="extractionStore.activeIndex === 0"
|
:disabled="extractionStore.activeIndex === 0"
|
||||||
@click="extractionStore.prev()"
|
@click="extractionStore.prev()"
|
||||||
><i class="fa-solid fa-chevron-left"></i></button>
|
><i class="fa-solid fa-chevron-left"></i></button>
|
||||||
<div class="doc-nav-label">
|
|
||||||
|
<button type="button" class="doc-nav-label-btn" title="Rename or delete this document" @click="openOptions">
|
||||||
<i class="fa-solid fa-file-lines doc-nav-file-icon"></i>
|
<i class="fa-solid fa-file-lines doc-nav-file-icon"></i>
|
||||||
<span class="doc-nav-name">{{ extractionStore.activeDocument?.fileName }}</span>
|
<span class="doc-nav-name">{{ extractionStore.activeDocument?.fileName }}</span>
|
||||||
<span class="doc-nav-position">({{ positionText }})</span>
|
<span v-if="extractionStore.documents.length > 1" class="doc-nav-position">({{ positionText }})</span>
|
||||||
</div>
|
<i class="fa-solid fa-ellipsis doc-nav-options-hint"></i>
|
||||||
|
</button>
|
||||||
|
|
||||||
<button
|
<button
|
||||||
|
v-if="extractionStore.documents.length > 1"
|
||||||
class="doc-nav-arrow"
|
class="doc-nav-arrow"
|
||||||
type="button"
|
type="button"
|
||||||
title="Next document"
|
title="Next document"
|
||||||
:disabled="extractionStore.activeIndex === extractionStore.documents.length - 1"
|
:disabled="extractionStore.activeIndex === extractionStore.documents.length - 1"
|
||||||
@click="extractionStore.next()"
|
@click="extractionStore.next()"
|
||||||
><i class="fa-solid fa-chevron-right"></i></button>
|
><i class="fa-solid fa-chevron-right"></i></button>
|
||||||
|
|
||||||
|
<DocumentOptionsModal
|
||||||
|
:visible="showOptions"
|
||||||
|
:file-name="extractionStore.activeDocument?.fileName ?? ''"
|
||||||
|
:renaming="renaming"
|
||||||
|
@rename="handleRename"
|
||||||
|
@delete="handleDeleteRequest"
|
||||||
|
@cancel="showOptions = false"
|
||||||
|
/>
|
||||||
|
<ConfirmModal
|
||||||
|
:visible="showDeleteConfirm"
|
||||||
|
title="Delete document?"
|
||||||
|
title-icon="fa-trash"
|
||||||
|
:message="`Delete “${extractionStore.activeDocument?.fileName}”? This removes it permanently and can't be undone.`"
|
||||||
|
confirm-label="Delete"
|
||||||
|
confirm-icon="fa-trash"
|
||||||
|
:danger="true"
|
||||||
|
:busy="deleting"
|
||||||
|
@confirm="confirmDelete"
|
||||||
|
@cancel="showDeleteConfirm = false"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,72 @@
|
||||||
|
<script setup>
|
||||||
|
/**
|
||||||
|
* DocumentOptionsModal.vue
|
||||||
|
*
|
||||||
|
* Opens when the active document's filename (DocumentNavBar.vue) is
|
||||||
|
* clicked - rename inline here, or hand off to a second, separate
|
||||||
|
* ConfirmModal for the actual delete (DocumentNavBar owns that step -
|
||||||
|
* same two-modal "pick an action, then confirm the destructive one"
|
||||||
|
* pattern already established by "Move to project").
|
||||||
|
*/
|
||||||
|
import { ref, toRef, watch } from 'vue'
|
||||||
|
import { useModalFocus } from '../composables/useModalFocus'
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
visible: { type: Boolean, required: true },
|
||||||
|
fileName: { type: String, default: '' },
|
||||||
|
renaming: { type: Boolean, default: false },
|
||||||
|
})
|
||||||
|
const emit = defineEmits(['rename', 'delete', 'cancel'])
|
||||||
|
|
||||||
|
const { overlayRef } = useModalFocus(toRef(props, 'visible'))
|
||||||
|
|
||||||
|
const draft = ref(props.fileName)
|
||||||
|
watch(() => props.visible, (v) => { if (v) draft.value = props.fileName })
|
||||||
|
|
||||||
|
const trimmedDraft = () => draft.value.trim()
|
||||||
|
function handleRename() {
|
||||||
|
const name = trimmedDraft()
|
||||||
|
if (!name || name === props.fileName || props.renaming) return
|
||||||
|
emit('rename', name)
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div
|
||||||
|
v-if="visible"
|
||||||
|
ref="overlayRef"
|
||||||
|
class="modal-overlay"
|
||||||
|
tabindex="-1"
|
||||||
|
@click.self="!renaming && emit('cancel')"
|
||||||
|
@keydown.esc="!renaming && emit('cancel')"
|
||||||
|
>
|
||||||
|
<div class="modal-card card" role="dialog" aria-modal="true" aria-label="Document options">
|
||||||
|
<h2><i class="fa-solid fa-file-lines"></i>Document options</h2>
|
||||||
|
|
||||||
|
<div class="modal-field">
|
||||||
|
<label>File name</label>
|
||||||
|
<div class="modal-field-row">
|
||||||
|
<input v-model="draft" type="text" class="modal-input" :disabled="renaming" @keyup.enter="handleRename">
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="btn-toggle"
|
||||||
|
:disabled="renaming || !trimmedDraft() || trimmedDraft() === fileName"
|
||||||
|
@click="handleRename"
|
||||||
|
>
|
||||||
|
<i class="fa-solid" :class="renaming ? 'fa-spinner fa-spin' : 'fa-check'"></i>
|
||||||
|
Save
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<button type="button" class="modal-danger-btn" :disabled="renaming" @click="emit('delete')">
|
||||||
|
<i class="fa-solid fa-trash"></i>
|
||||||
|
Delete this document
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<div class="modal-actions">
|
||||||
|
<button type="button" class="btn btn-ghost" :disabled="renaming" @click="emit('cancel')">Close</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
@ -0,0 +1,49 @@
|
||||||
|
<script setup>
|
||||||
|
/**
|
||||||
|
* DownloadChoiceModal.vue
|
||||||
|
*
|
||||||
|
* Shown by the single Download button (TransactionsTable.vue) only when
|
||||||
|
* more than one document is loaded - replaces the old separate "Download
|
||||||
|
* All" button with one Download button that asks which, rather than
|
||||||
|
* needing a second button in the UI for the "all" case.
|
||||||
|
*/
|
||||||
|
import { toRef } from 'vue'
|
||||||
|
import { useModalFocus } from '../composables/useModalFocus'
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
visible: { type: Boolean, required: true },
|
||||||
|
count: { type: Number, default: 0 },
|
||||||
|
})
|
||||||
|
const emit = defineEmits(['current', 'all', 'cancel'])
|
||||||
|
|
||||||
|
const { overlayRef } = useModalFocus(toRef(props, 'visible'))
|
||||||
|
</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="Download">
|
||||||
|
<h2><i class="fa-solid fa-download"></i>Download</h2>
|
||||||
|
<p class="modal-message">{{ count }} documents are loaded. Which would you like to download?</p>
|
||||||
|
<div class="modal-actions modal-actions-stack">
|
||||||
|
<button type="button" class="btn btn-ghost" @click="emit('current')">
|
||||||
|
<i class="fa-solid fa-file-excel"></i>
|
||||||
|
Current document only
|
||||||
|
</button>
|
||||||
|
<button type="button" class="btn btn-primary" @click="emit('all')">
|
||||||
|
<i class="fa-solid fa-download"></i>
|
||||||
|
All {{ count }} documents
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="modal-actions">
|
||||||
|
<button type="button" class="btn btn-ghost" @click="emit('cancel')">Cancel</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
@ -5,9 +5,9 @@
|
||||||
* Drop zone, file picker, and the Extract button. Also hosts the SINGLE
|
* Drop zone, file picker, and the Extract button. Also hosts the SINGLE
|
||||||
* shared error-note area - in the original vanilla-JS version this one
|
* shared error-note area - in the original vanilla-JS version this one
|
||||||
* element shows upload-validation errors, process errors, AND download
|
* element shows upload-validation errors, process errors, AND download
|
||||||
* errors (even though downloading happens from ResultCard, visually
|
* errors (even though downloading happens from TransactionsTable's own
|
||||||
* elsewhere on the page) - a pre-existing UX quirk, preserved exactly
|
* top bar, visually elsewhere on the page) - a pre-existing UX quirk,
|
||||||
* rather than "fixed" unprompted.
|
* preserved exactly rather than "fixed" unprompted.
|
||||||
*
|
*
|
||||||
* Presentational - file-selection/extraction state and handlers come
|
* Presentational - file-selection/extraction state and handlers come
|
||||||
* from ExtractorView (which owns useFileUpload/useBatchExtraction once,
|
* from ExtractorView (which owns useFileUpload/useBatchExtraction once,
|
||||||
|
|
|
||||||
|
|
@ -1,165 +0,0 @@
|
||||||
<script setup>
|
|
||||||
/**
|
|
||||||
* ResultCard.vue
|
|
||||||
*
|
|
||||||
* The collapsible Result card: a chevron + "Result" heading on the left
|
|
||||||
* toggle the status banner/checks list; Download Excel stays on the
|
|
||||||
* right, always visible and independently clickable.
|
|
||||||
*/
|
|
||||||
import { ref, computed } from 'vue'
|
|
||||||
import { useExtractionStore } from '../stores/extractionStore'
|
|
||||||
import { useUiStore } from '../stores/uiStore'
|
|
||||||
import * as extractionService from '../services/extractionService'
|
|
||||||
import * as documentsService from '../services/documentsService'
|
|
||||||
import * as formatService from '../services/formatService'
|
|
||||||
|
|
||||||
const extractionStore = useExtractionStore()
|
|
||||||
const uiStore = useUiStore()
|
|
||||||
|
|
||||||
const result = computed(() => extractionStore.currentResult)
|
|
||||||
const statusClass = computed(() => 'status-banner ' + (result.value?.status || '').replace(' ', '-'))
|
|
||||||
const periodText = computed(() => (result.value?.period ? `Statement period: ${result.value.period}` : ''))
|
|
||||||
const statusIcon = computed(() => {
|
|
||||||
const s = result.value?.status
|
|
||||||
if (s === 'Verified') return 'fa-circle-check'
|
|
||||||
if (s === 'Needs review') return 'fa-triangle-exclamation'
|
|
||||||
if (s === 'Failed') return 'fa-circle-xmark'
|
|
||||||
return 'fa-circle-info'
|
|
||||||
})
|
|
||||||
const outcomeIcon = {
|
|
||||||
pass: 'fa-check', fail: 'fa-xmark', needs_review: 'fa-triangle-exclamation', not_available: 'fa-minus',
|
|
||||||
}
|
|
||||||
|
|
||||||
const downloading = ref(false)
|
|
||||||
const downloadingAll = ref(false)
|
|
||||||
// Download All only makes sense once a multi-file batch has actually
|
|
||||||
// finished - mid-batch, documents.length already grows as each one
|
|
||||||
// completes, but isBatchProcessing stays true until the whole thing is
|
|
||||||
// done, so this only lights up once there's nothing left running.
|
|
||||||
const showDownloadAll = computed(() => !extractionStore.isBatchProcessing && extractionStore.documents.length > 1)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Triggers one browser save for a given {pbId, result, openingBalance,
|
|
||||||
* closingBalance}, then best-effort persists the SAME blob to R2 (via
|
|
||||||
* PocketBase's own file storage - documentsService.saveExportFile,
|
|
||||||
* overwriting whatever export was there before, see that function's own
|
|
||||||
* comment for why only the latest). The Blob is immutable and reusable,
|
|
||||||
* so the one fetch serves both the browser download and the R2 upload -
|
|
||||||
* no second request. A failure saving to R2 is reported but never
|
|
||||||
* blocks or undoes the download the user actually asked for.
|
|
||||||
*/
|
|
||||||
async function downloadOne({ pbId, result: r, openingBalance, closingBalance }) {
|
|
||||||
const blob = await extractionService.exportWorkbook(r, openingBalance, closingBalance)
|
|
||||||
const fileName = (r.title || 'Statement_Extraction').replace(/\.pdf$/i, '') + '.xlsx'
|
|
||||||
|
|
||||||
const url = URL.createObjectURL(blob)
|
|
||||||
const a = document.createElement('a')
|
|
||||||
a.href = url
|
|
||||||
a.download = fileName
|
|
||||||
document.body.appendChild(a)
|
|
||||||
a.click()
|
|
||||||
a.remove()
|
|
||||||
URL.revokeObjectURL(url)
|
|
||||||
|
|
||||||
try {
|
|
||||||
await documentsService.saveExportFile(pbId, blob, fileName)
|
|
||||||
} catch (e) {
|
|
||||||
extractionStore.setError('Downloaded, but could not save a copy for later: ' + e.message)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Requests the current (possibly edited) workbook and triggers a browser
|
|
||||||
* save - the same recheck-then-export round trip the backend's own
|
|
||||||
* /api/export route performs, so a downloaded file always reflects
|
|
||||||
* whatever is currently on screen. Errors go through the shared
|
|
||||||
* extractionStore.errorMessage, same single error-note area the upload
|
|
||||||
* and process flows use - not a separate one per component.
|
|
||||||
*/
|
|
||||||
async function handleDownload() {
|
|
||||||
if (!result.value) return
|
|
||||||
downloading.value = true
|
|
||||||
extractionStore.clearError()
|
|
||||||
try {
|
|
||||||
await downloadOne({
|
|
||||||
pbId: extractionStore.activeDocument?.pbId,
|
|
||||||
result: result.value,
|
|
||||||
openingBalance: extractionStore.effectiveOpeningBalance,
|
|
||||||
closingBalance: extractionStore.effectiveClosingBalance,
|
|
||||||
})
|
|
||||||
} catch (e) {
|
|
||||||
extractionStore.setError('Could not generate the export: ' + e.message)
|
|
||||||
}
|
|
||||||
downloading.value = false
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Exports every loaded document in turn - the same per-document export
|
|
||||||
* call `handleDownload` makes, just looped. Each document's own typed
|
|
||||||
* balance inputs (not just the active one's) are used, same fallback
|
|
||||||
* logic as effectiveOpeningBalance/effectiveClosingBalance. Triggers N
|
|
||||||
* sequential browser downloads, not a zip - some browsers prompt to
|
|
||||||
* allow multiple downloads from one click, a minor known wrinkle, not a
|
|
||||||
* reason to stand up a zip-export endpoint for this.
|
|
||||||
*/
|
|
||||||
async function handleDownloadAll() {
|
|
||||||
downloadingAll.value = true
|
|
||||||
extractionStore.clearError()
|
|
||||||
const failures = []
|
|
||||||
for (const doc of extractionStore.documents) {
|
|
||||||
try {
|
|
||||||
await downloadOne({
|
|
||||||
pbId: doc.pbId,
|
|
||||||
result: doc.result,
|
|
||||||
openingBalance: extractionService.effectiveBalance(
|
|
||||||
formatService.parseNum(doc.openingBalanceInput), doc.result?.opening_balance,
|
|
||||||
),
|
|
||||||
closingBalance: extractionService.effectiveBalance(
|
|
||||||
formatService.parseNum(doc.closingBalanceInput), doc.result?.closing_balance,
|
|
||||||
),
|
|
||||||
})
|
|
||||||
} catch (e) {
|
|
||||||
failures.push(`${doc.fileName}: ${e.message}`)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (failures.length) extractionStore.setError('Could not generate every export: ' + failures.join('; '))
|
|
||||||
downloadingAll.value = false
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<div class="card">
|
|
||||||
<div class="result-head">
|
|
||||||
<div class="result-head-left" @click="uiStore.toggleResultExpanded">
|
|
||||||
<button
|
|
||||||
class="collapse-arrow"
|
|
||||||
:class="{ expanded: uiStore.resultExpanded }"
|
|
||||||
type="button"
|
|
||||||
:aria-expanded="String(uiStore.resultExpanded)"
|
|
||||||
:title="uiStore.resultExpanded ? 'Hide details' : 'Show details'"
|
|
||||||
><i class="fa-solid fa-chevron-right"></i></button>
|
|
||||||
<h2>Result</h2>
|
|
||||||
</div>
|
|
||||||
<div class="result-head-actions">
|
|
||||||
<button class="btn-toggle" type="button" :disabled="downloading" @click="handleDownload">
|
|
||||||
<i class="fa-solid" :class="downloading ? 'fa-spinner fa-spin' : 'fa-file-excel'"></i>
|
|
||||||
{{ downloading ? 'Preparing…' : 'Download Excel' }}
|
|
||||||
</button>
|
|
||||||
<button v-if="showDownloadAll" class="btn-toggle" type="button" :disabled="downloadingAll" @click="handleDownloadAll">
|
|
||||||
<i class="fa-solid" :class="downloadingAll ? 'fa-spinner fa-spin' : 'fa-download'"></i>
|
|
||||||
{{ downloadingAll ? 'Preparing…' : 'Download All' }}
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="result-details" :class="{ expanded: uiStore.resultExpanded }">
|
|
||||||
<div :class="statusClass"><i class="fa-solid" :class="statusIcon"></i>{{ result.status }}</div>
|
|
||||||
<div class="period-note">{{ periodText }}</div>
|
|
||||||
<ul class="checks-list">
|
|
||||||
<li v-for="check in result.checks" :key="check.name">
|
|
||||||
<span class="tag" :class="check.outcome"><i class="fa-solid" :class="outcomeIcon[check.outcome]"></i>{{ check.outcome.replace('_', ' ') }}</span>
|
|
||||||
<span><strong>{{ check.name.replace(/_/g, ' ') }}</strong> — {{ check.detail }}</span>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
@ -23,18 +23,162 @@ import { ref, computed, watch } from 'vue'
|
||||||
import { useExtractionStore } from '../stores/extractionStore'
|
import { useExtractionStore } from '../stores/extractionStore'
|
||||||
import { useUiStore } from '../stores/uiStore'
|
import { useUiStore } from '../stores/uiStore'
|
||||||
import { useProjectsStore } from '../stores/projectsStore'
|
import { useProjectsStore } from '../stores/projectsStore'
|
||||||
import { fmtMoney } from '../services/formatService'
|
import { fmtMoney, parseNum } from '../services/formatService'
|
||||||
import * as extractionService from '../services/extractionService'
|
import * as extractionService from '../services/extractionService'
|
||||||
import * as documentsService from '../services/documentsService'
|
import * as documentsService from '../services/documentsService'
|
||||||
import { useTransactionFilters } from '../composables/useTransactionFilters'
|
import { useTransactionFilters } from '../composables/useTransactionFilters'
|
||||||
import TransactionRow from './TransactionRow.vue'
|
import TransactionRow from './TransactionRow.vue'
|
||||||
import DocumentNavBar from './DocumentNavBar.vue'
|
import DocumentNavBar from './DocumentNavBar.vue'
|
||||||
import ConfirmModal from './ConfirmModal.vue'
|
import ConfirmModal from './ConfirmModal.vue'
|
||||||
|
import DownloadChoiceModal from './DownloadChoiceModal.vue'
|
||||||
|
|
||||||
const extractionStore = useExtractionStore()
|
const extractionStore = useExtractionStore()
|
||||||
const uiStore = useUiStore()
|
const uiStore = useUiStore()
|
||||||
const projectsStore = useProjectsStore()
|
const projectsStore = useProjectsStore()
|
||||||
|
|
||||||
|
// ── Results dropdown + Download (formerly ResultCard.vue - moved into
|
||||||
|
// this top bar alongside DocumentNavBar per explicit request, rather
|
||||||
|
// than its own separate card further down the page). ──────────────────
|
||||||
|
const result = computed(() => extractionStore.currentResult)
|
||||||
|
const statusClass = computed(() => 'status-banner ' + (result.value?.status || '').replace(' ', '-'))
|
||||||
|
const statusDotClass = computed(() => 'results-status-dot ' + (result.value?.status || '').replace(' ', '-'))
|
||||||
|
const periodText = computed(() => (result.value?.period ? `Statement period: ${result.value.period}` : ''))
|
||||||
|
const statusIcon = computed(() => {
|
||||||
|
const s = result.value?.status
|
||||||
|
if (s === 'Verified') return 'fa-circle-check'
|
||||||
|
if (s === 'Needs review') return 'fa-triangle-exclamation'
|
||||||
|
if (s === 'Failed') return 'fa-circle-xmark'
|
||||||
|
return 'fa-circle-info'
|
||||||
|
})
|
||||||
|
const outcomeIcon = {
|
||||||
|
pass: 'fa-check', fail: 'fa-xmark', needs_review: 'fa-triangle-exclamation', not_available: 'fa-minus',
|
||||||
|
}
|
||||||
|
|
||||||
|
// Click opens the dropdown; moving the mouse off the whole trigger+panel
|
||||||
|
// zone closes it again (mouseleave on the wrapper only fires once the
|
||||||
|
// pointer truly leaves both, not when moving from the button onto the
|
||||||
|
// panel beneath it) - "stays open while hovered, closes when you move
|
||||||
|
// away," per the explicit ask. uiStore.resultsOpen (not a local ref) so
|
||||||
|
// useBatchExtraction.js can still reset it closed after every fresh
|
||||||
|
// extraction, same as it always has.
|
||||||
|
function toggleResults() {
|
||||||
|
if (!result.value) return
|
||||||
|
uiStore.toggleResultsOpen()
|
||||||
|
}
|
||||||
|
|
||||||
|
const downloading = ref(false)
|
||||||
|
const showDownloadChoice = ref(false)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Triggers one browser save for a given {pbId, result, openingBalance,
|
||||||
|
* closingBalance}, then best-effort persists the SAME blob to R2 (via
|
||||||
|
* PocketBase's own file storage - documentsService.saveExportFile,
|
||||||
|
* overwriting whatever export was there before, see that function's own
|
||||||
|
* comment for why only the latest). The Blob is immutable and reusable,
|
||||||
|
* so the one fetch serves both the browser download and the R2 upload -
|
||||||
|
* no second request. A failure saving to R2 is reported but never
|
||||||
|
* blocks or undoes the download the user actually asked for.
|
||||||
|
*/
|
||||||
|
async function downloadOne({ pbId, result: r, openingBalance, closingBalance }) {
|
||||||
|
const blob = await extractionService.exportWorkbook(r, openingBalance, closingBalance)
|
||||||
|
const fileName = (r.title || 'Statement_Extraction').replace(/\.pdf$/i, '') + '.xlsx'
|
||||||
|
|
||||||
|
const url = URL.createObjectURL(blob)
|
||||||
|
const a = document.createElement('a')
|
||||||
|
a.href = url
|
||||||
|
a.download = fileName
|
||||||
|
document.body.appendChild(a)
|
||||||
|
a.click()
|
||||||
|
a.remove()
|
||||||
|
URL.revokeObjectURL(url)
|
||||||
|
|
||||||
|
try {
|
||||||
|
await documentsService.saveExportFile(pbId, blob, fileName)
|
||||||
|
} catch (e) {
|
||||||
|
extractionStore.setError('Downloaded, but could not save a copy for later: ' + e.message)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The currently active document's export, via /api/export + a browser save. */
|
||||||
|
async function handleDownloadCurrent() {
|
||||||
|
if (!result.value) return
|
||||||
|
downloading.value = true
|
||||||
|
extractionStore.clearError()
|
||||||
|
try {
|
||||||
|
await downloadOne({
|
||||||
|
pbId: extractionStore.activeDocument?.pbId,
|
||||||
|
result: result.value,
|
||||||
|
openingBalance: extractionStore.effectiveOpeningBalance,
|
||||||
|
closingBalance: extractionStore.effectiveClosingBalance,
|
||||||
|
})
|
||||||
|
} catch (e) {
|
||||||
|
extractionStore.setError('Could not generate the export: ' + e.message)
|
||||||
|
}
|
||||||
|
downloading.value = false
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Exports every loaded document in turn - the same per-document export
|
||||||
|
* call handleDownloadCurrent makes, just looped. Each document's own
|
||||||
|
* typed balance inputs (not just the active one's) are used, same
|
||||||
|
* fallback logic as effectiveOpeningBalance/effectiveClosingBalance.
|
||||||
|
* Triggers N sequential browser downloads, not a zip - some browsers
|
||||||
|
* prompt to allow multiple downloads from one click, a minor known
|
||||||
|
* wrinkle, not a reason to stand up a zip-export endpoint for this.
|
||||||
|
*/
|
||||||
|
async function handleDownloadAll() {
|
||||||
|
downloading.value = true
|
||||||
|
extractionStore.clearError()
|
||||||
|
const failures = []
|
||||||
|
for (const doc of extractionStore.documents) {
|
||||||
|
try {
|
||||||
|
await downloadOne({
|
||||||
|
pbId: doc.pbId,
|
||||||
|
result: doc.result,
|
||||||
|
openingBalance: extractionService.effectiveBalance(
|
||||||
|
parseNum(doc.openingBalanceInput), doc.result?.opening_balance,
|
||||||
|
),
|
||||||
|
closingBalance: extractionService.effectiveBalance(
|
||||||
|
parseNum(doc.closingBalanceInput), doc.result?.closing_balance,
|
||||||
|
),
|
||||||
|
})
|
||||||
|
} catch (e) {
|
||||||
|
failures.push(`${doc.fileName}: ${e.message}`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (failures.length) extractionStore.setError('Could not generate every export: ' + failures.join('; '))
|
||||||
|
downloading.value = false
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The single Download button's own click: with only one document loaded
|
||||||
|
* there's nothing to choose between, so it downloads immediately, same
|
||||||
|
* as before. With more than one, asks which via DownloadChoiceModal -
|
||||||
|
* replaces the old separate "Download All" button (one button, one
|
||||||
|
* choice step, instead of two buttons competing for space).
|
||||||
|
*/
|
||||||
|
function handleDownloadClick() {
|
||||||
|
if (!result.value) return
|
||||||
|
// Only offers the "all documents" choice once a batch has actually
|
||||||
|
// finished - mid-batch, documents.length already grows as each file
|
||||||
|
// completes, so asking "all" too early would silently leave out
|
||||||
|
// whatever's still processing. Same gate the old standalone Download
|
||||||
|
// All button used.
|
||||||
|
if (!extractionStore.isBatchProcessing && extractionStore.documents.length > 1) {
|
||||||
|
showDownloadChoice.value = true
|
||||||
|
} else {
|
||||||
|
handleDownloadCurrent()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function handleDownloadChoiceCurrent() {
|
||||||
|
showDownloadChoice.value = false
|
||||||
|
handleDownloadCurrent()
|
||||||
|
}
|
||||||
|
function handleDownloadChoiceAll() {
|
||||||
|
showDownloadChoice.value = false
|
||||||
|
handleDownloadAll()
|
||||||
|
}
|
||||||
|
|
||||||
// Reassigns the ACTIVE document to a different project - independent of
|
// Reassigns the ACTIVE document to a different project - independent of
|
||||||
// DocumentNavBar's own visibility (that's gated on there being more than
|
// DocumentNavBar's own visibility (that's gated on there being more than
|
||||||
// one document; moving a single document to a project should still work
|
// one document; moving a single document to a project should still work
|
||||||
|
|
@ -104,7 +248,6 @@ async function confirmMove() {
|
||||||
movingProject.value = false
|
movingProject.value = false
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = computed(() => extractionStore.currentResult)
|
|
||||||
const transactions = computed(() => result.value?.transactions || [])
|
const transactions = computed(() => result.value?.transactions || [])
|
||||||
|
|
||||||
// openingBalanceInput/closingBalanceInput now live per-document
|
// openingBalanceInput/closingBalanceInput now live per-document
|
||||||
|
|
@ -186,7 +329,49 @@ async function handleRecheck() {
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<DocumentNavBar />
|
<!--
|
||||||
|
The former ResultCard.vue, merged into this top bar: a Results
|
||||||
|
toggle (left) opens a hover-sticky dropdown with the status/checks
|
||||||
|
detail; DocumentNavBar (center, truly centered via the grid below
|
||||||
|
regardless of how wide the left/right content is) carries the active
|
||||||
|
document's filename - click it to rename or delete; Download (right)
|
||||||
|
exports the current document, or opens DownloadChoiceModal to ask
|
||||||
|
"current vs. all" once more than one document is loaded.
|
||||||
|
-->
|
||||||
|
<div v-if="extractionStore.documents.length > 0" class="txn-top-bar">
|
||||||
|
<div class="results-trigger-wrap" @mouseleave="uiStore.closeResultsOpen">
|
||||||
|
<button type="button" class="results-toggle" :disabled="!result" @click="toggleResults">
|
||||||
|
<span v-if="result" :class="statusDotClass"></span>
|
||||||
|
<span>Results</span>
|
||||||
|
<i class="fa-solid fa-chevron-down" :class="{ open: uiStore.resultsOpen }"></i>
|
||||||
|
</button>
|
||||||
|
<div v-if="uiStore.resultsOpen && result" class="results-dropdown card">
|
||||||
|
<div :class="statusClass"><i class="fa-solid" :class="statusIcon"></i>{{ result.status }}</div>
|
||||||
|
<div class="period-note">{{ periodText }}</div>
|
||||||
|
<ul class="checks-list">
|
||||||
|
<li v-for="check in result.checks" :key="check.name">
|
||||||
|
<span class="tag" :class="check.outcome"><i class="fa-solid" :class="outcomeIcon[check.outcome]"></i>{{ check.outcome.replace('_', ' ') }}</span>
|
||||||
|
<span><strong>{{ check.name.replace(/_/g, ' ') }}</strong> — {{ check.detail }}</span>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<DocumentNavBar />
|
||||||
|
|
||||||
|
<button type="button" class="btn-toggle txn-download-btn" :disabled="!result || downloading" @click="handleDownloadClick">
|
||||||
|
<i class="fa-solid" :class="downloading ? 'fa-spinner fa-spin' : 'fa-file-excel'"></i>
|
||||||
|
{{ downloading ? 'Preparing…' : 'Download' }}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<DownloadChoiceModal
|
||||||
|
:visible="showDownloadChoice"
|
||||||
|
:count="extractionStore.documents.length"
|
||||||
|
@current="handleDownloadChoiceCurrent"
|
||||||
|
@all="handleDownloadChoiceAll"
|
||||||
|
@cancel="showDownloadChoice = false"
|
||||||
|
/>
|
||||||
|
|
||||||
<div v-if="result" class="move-to-project">
|
<div v-if="result" class="move-to-project">
|
||||||
<label><i class="fa-solid fa-folder-open"></i>Move to project</label>
|
<label><i class="fa-solid fa-folder-open"></i>Move to project</label>
|
||||||
<select v-model="selectedProjectId" :disabled="movingProject" @change="handleSelectChange">
|
<select v-model="selectedProjectId" :disabled="movingProject" @change="handleSelectChange">
|
||||||
|
|
@ -197,6 +382,7 @@ async function handleRecheck() {
|
||||||
<ConfirmModal
|
<ConfirmModal
|
||||||
:visible="showMoveConfirm"
|
:visible="showMoveConfirm"
|
||||||
title="Move document?"
|
title="Move document?"
|
||||||
|
title-icon="fa-folder-open"
|
||||||
:message="`Move “${extractionStore.activeDocument?.fileName}” to “${pendingProjectName}”?`"
|
:message="`Move “${extractionStore.activeDocument?.fileName}” to “${pendingProjectName}”?`"
|
||||||
confirm-label="Move"
|
confirm-label="Move"
|
||||||
confirm-icon="fa-folder-open"
|
confirm-icon="fa-folder-open"
|
||||||
|
|
|
||||||
|
|
@ -86,7 +86,7 @@ export function useBatchExtraction() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (failures.length) extractionStore.setError(failures.join('; '))
|
if (failures.length) extractionStore.setError(failures.join('; '))
|
||||||
uiStore.resultExpanded = false
|
uiStore.closeResultsOpen()
|
||||||
extractionStore.endBatch()
|
extractionStore.endBatch()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
import { nextTick, ref, watch } from 'vue'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shared by every modal component (ConfirmModal, DocumentOptionsModal,
|
||||||
|
* DownloadChoiceModal): focuses the overlay element the moment it
|
||||||
|
* becomes visible, so Esc closes the modal immediately without the
|
||||||
|
* caller having to manage focus itself.
|
||||||
|
*
|
||||||
|
* `visibleRef` must be a ref/computed, not a plain boolean - pass the
|
||||||
|
* prop itself via `toRef(props, 'visible')` from the calling component.
|
||||||
|
*/
|
||||||
|
export function useModalFocus(visibleRef) {
|
||||||
|
const overlayRef = ref(null)
|
||||||
|
watch(visibleRef, (v) => {
|
||||||
|
if (v) nextTick(() => overlayRef.value?.focus())
|
||||||
|
})
|
||||||
|
return { overlayRef }
|
||||||
|
}
|
||||||
|
|
@ -45,13 +45,14 @@ export async function saveDocument({
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates an existing document's result (e.g. after a row edit) - no
|
* Updates an existing document with a plain-object patch (e.g.
|
||||||
|
* {result} after a row edit, or {fileName} after a rename) - no
|
||||||
* sourceFile re-upload, so this goes through as a plain JSON body, not
|
* sourceFile re-upload, so this goes through as a plain JSON body, not
|
||||||
* multipart - confirmed via a real curl test that PocketBase accepts
|
* multipart - confirmed via a real curl test that PocketBase accepts
|
||||||
* `result` as a native object in that case, unlike the FormData path.
|
* `result` as a native object in that case, unlike the FormData path.
|
||||||
*/
|
*/
|
||||||
export async function updateDocument(id, { result }) {
|
export async function updateDocument(id, patch) {
|
||||||
return pb.collection('documents').update(id, { result })
|
return pb.collection('documents').update(id, patch)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The logged-in user's own documents, optionally filtered to one project, newest first. */
|
/** The logged-in user's own documents, optionally filtered to one project, newest first. */
|
||||||
|
|
@ -80,8 +81,8 @@ export async function moveToProject(id, projectId) {
|
||||||
* history. A real retention policy (how long to keep exports - or
|
* history. A real retention policy (how long to keep exports - or
|
||||||
* anything else - at all) hasn't been decided yet; this is the interim
|
* anything else - at all) hasn't been decided yet; this is the interim
|
||||||
* shape until it is. Best-effort from the caller's side (see
|
* shape until it is. Best-effort from the caller's side (see
|
||||||
* ResultCard.vue) - a failure here shouldn't block the browser download
|
* TransactionsTable.vue's downloadOne) - a failure here shouldn't block
|
||||||
* the user actually asked for.
|
* the browser download the user actually asked for.
|
||||||
*/
|
*/
|
||||||
export async function saveExportFile(id, blob, fileName) {
|
export async function saveExportFile(id, blob, fileName) {
|
||||||
const formData = new FormData()
|
const formData = new FormData()
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ export const useExtractionStore = defineStore('extraction', {
|
||||||
// Batch-progress fields live here, not in a composable-local ref -
|
// Batch-progress fields live here, not in a composable-local ref -
|
||||||
// ephemeral, never itself written to PocketBase (only `documents`'
|
// ephemeral, never itself written to PocketBase (only `documents`'
|
||||||
// own fields are, via documentsService), and being store state (not
|
// own fields are, via documentsService), and being store state (not
|
||||||
// composable-local) is what lets ResultCard's Download All button
|
// composable-local) is what lets TransactionsTable's Download button
|
||||||
// react to isBatchProcessing without a prop from a sibling component.
|
// react to isBatchProcessing without a prop from a sibling component.
|
||||||
isBatchProcessing: false,
|
isBatchProcessing: false,
|
||||||
batchTotal: 0,
|
batchTotal: 0,
|
||||||
|
|
@ -195,6 +195,30 @@ export const useExtractionStore = defineStore('extraction', {
|
||||||
if (doc) doc.project = projectId
|
if (doc) doc.project = projectId
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/** Updates the active document's own `fileName` after a successful DocumentOptionsModal rename. */
|
||||||
|
setActiveDocumentFileName(fileName) {
|
||||||
|
const doc = this.activeDocument
|
||||||
|
if (doc) doc.fileName = fileName
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes a document (by its PocketBase id) after a successful
|
||||||
|
* delete, and re-settles activeIndex to keep pointing at a sensible
|
||||||
|
* document rather than an out-of-range or stale one: everything
|
||||||
|
* after the removed slot shifts left by one, so an EARLIER removal
|
||||||
|
* decrements activeIndex to track the same logical document; a
|
||||||
|
* removal at or after activeIndex leaves the number alone (it now
|
||||||
|
* naturally points at whichever document shifted into that slot, or
|
||||||
|
* needs clamping if the removed one was active and last).
|
||||||
|
*/
|
||||||
|
removeDocument(pbId) {
|
||||||
|
const idx = this.documents.findIndex((d) => d.pbId === pbId)
|
||||||
|
if (idx === -1) return
|
||||||
|
this.documents.splice(idx, 1)
|
||||||
|
if (idx < this.activeIndex) this.activeIndex -= 1
|
||||||
|
this.activeIndex = this.documents.length ? Math.min(this.activeIndex, this.documents.length - 1) : 0
|
||||||
|
},
|
||||||
|
|
||||||
/** Clears every loaded document from view, back to the empty state. */
|
/** Clears every loaded document from view, back to the empty state. */
|
||||||
clearAll() {
|
clearAll() {
|
||||||
this.documents = []
|
this.documents = []
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,11 @@ import { defineStore } from 'pinia'
|
||||||
|
|
||||||
export const useUiStore = defineStore('ui', {
|
export const useUiStore = defineStore('ui', {
|
||||||
state: () => ({
|
state: () => ({
|
||||||
resultExpanded: false,
|
// Whether the Results dropdown (TransactionsTable.vue's top bar) is
|
||||||
|
// open - lives here, not as a component-local ref, so
|
||||||
|
// useBatchExtraction.js can reset it closed after every fresh
|
||||||
|
// extraction, same as the old resultExpanded this replaced.
|
||||||
|
resultsOpen: false,
|
||||||
pdfColHidden: false,
|
pdfColHidden: false,
|
||||||
pdfColWidthPct: 40, // matches .pdf-col's own CSS default (flex: 0 0 40%)
|
pdfColWidthPct: 40, // matches .pdf-col's own CSS default (flex: 0 0 40%)
|
||||||
sidebarHidden: false,
|
sidebarHidden: false,
|
||||||
|
|
@ -21,8 +25,11 @@ export const useUiStore = defineStore('ui', {
|
||||||
layoutVersion: 0,
|
layoutVersion: 0,
|
||||||
}),
|
}),
|
||||||
actions: {
|
actions: {
|
||||||
toggleResultExpanded() {
|
toggleResultsOpen() {
|
||||||
this.resultExpanded = !this.resultExpanded
|
this.resultsOpen = !this.resultsOpen
|
||||||
|
},
|
||||||
|
closeResultsOpen() {
|
||||||
|
this.resultsOpen = false
|
||||||
},
|
},
|
||||||
togglePdfCol() {
|
togglePdfCol() {
|
||||||
this.pdfColHidden = !this.pdfColHidden
|
this.pdfColHidden = !this.pdfColHidden
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,6 @@ import { useFileUpload } from '../composables/useFileUpload'
|
||||||
import { useBatchExtraction } from '../composables/useBatchExtraction'
|
import { useBatchExtraction } from '../composables/useBatchExtraction'
|
||||||
import { useDocuments } from '../composables/useDocuments'
|
import { useDocuments } from '../composables/useDocuments'
|
||||||
import FileUploadZone from '../components/FileUploadZone.vue'
|
import FileUploadZone from '../components/FileUploadZone.vue'
|
||||||
import ResultCard from '../components/ResultCard.vue'
|
|
||||||
import ResizablePanels from '../components/ResizablePanels.vue'
|
import ResizablePanels from '../components/ResizablePanels.vue'
|
||||||
import SourceDocumentPanel from '../components/SourceDocumentPanel.vue'
|
import SourceDocumentPanel from '../components/SourceDocumentPanel.vue'
|
||||||
import TransactionsTable from '../components/TransactionsTable.vue'
|
import TransactionsTable from '../components/TransactionsTable.vue'
|
||||||
|
|
@ -78,8 +77,6 @@ onMounted(async () => {
|
||||||
@extract="handleExtract"
|
@extract="handleExtract"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<ResultCard v-if="extractionStore.documents.length > 0" />
|
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
Source Document and Transactions (and the opening/closing balance
|
Source Document and Transactions (and the opening/closing balance
|
||||||
fields that live in the latter) are always visible, even before a
|
fields that live in the latter) are always visible, even before a
|
||||||
|
|
@ -89,9 +86,9 @@ onMounted(async () => {
|
||||||
something to display - see SourceDocumentPanel.vue/
|
something to display - see SourceDocumentPanel.vue/
|
||||||
TransactionsTable.vue. Both read the ACTIVE document
|
TransactionsTable.vue. Both read the ACTIVE document
|
||||||
(extractionStore.activeDocument), not the staged-but-unprocessed
|
(extractionStore.activeDocument), not the staged-but-unprocessed
|
||||||
chosenFiles. DocumentNavBar (and the "Move to project" control
|
chosenFiles. The Results dropdown, DocumentNavBar, and Download
|
||||||
beside it) lives INSIDE TransactionsTable now (across its own
|
button (formerly a separate ResultCard above this section) all live
|
||||||
top, above the Hide Source Doc button), not here.
|
INSIDE TransactionsTable's own top bar now, not here.
|
||||||
-->
|
-->
|
||||||
<ResizablePanels>
|
<ResizablePanels>
|
||||||
<template #source>
|
<template #source>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue