Skip to content

feat(mock): compilation field sheet pages 1-2 review build (BDMS-1504, BDMS-1507) - #428

Closed
RSBalchII wants to merge 96 commits into
stagingfrom
preview-compilation
Closed

RSBalchII wants to merge 96 commits into
stagingfrom
preview-compilation

Conversation

@RSBalchII

@RSBalchII RSBalchII commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Title: feat(mock): compilation field sheet pages 1-2 review build (BDMS-1504, BDMS-1507)

Review-only branch — please do not merge. It exists so Liz and the team can
comment on the compilation field-sheet mockup while it is being built. Nothing
here reads the API: all data is fixture-only, and both mock routes are unlinked.

Branch strategy
All work happens on preview-compilation, which is never merged. Ticket-specific
code is ported to that ticket's own feature/BDMS-XXXX branch before its PR — the
ones cut so far are feature/BDMS-1503, -1504, -1507 and -1513. So this PR
is the fast-feedback surface for the mockup, and each ticket's PR carries the
version that actually merges.

Review surfaces — both are expected to be reviewed

  • Page 1, field sheet (BDMS-1504) — /mock/field-sheet/page-1
    ?photos=0|1|3|5 picks the photo fixture (default: full set);
    ?notes=column moves the notes block.
  • Page 2, owner leave-behind (BDMS-1507) — /mock/field-sheet/page-2
    ?ose=0 renders the no-OSE variant (the OSE #: cell omitted).

Both pages open without signing in, and both are reachable in this preview build
and in local dev only — they will 404 on staging/production URLs. Every reviewer
question is a query parameter, so a comment can carry the exact URL that shows it.

What else is in the branch

  • react-pdf worker and build fixes so both sheets render in dev and in a built preview
  • Page 1: column layout, photo column, date toggle, one 9 pt type scale
  • Page 2: the QR code is generated for real as a data URL, not stubbed

Jira: BDMS-1504 (page 1), BDMS-1507 (page 2). The branch also carries BDMS-1503,
1508 and 1509 in support of these two.

Known gap: the photo toggle's with/without-photo layout swap is not verified yet.


Theme & PDF refactor stack (this turn) — one review surface for a large, staged
refactor of the field-compilation PDF:

  • Monolith -> modules. The ~1542-line single page.tsx was decomposed into 12 focused
    modules (pages/, layout/PdfTable, primitives/NoteSection, shared helpers + a public
    barrel), so each piece reads in isolation. Nothing here changes the rendered output.
  • PDF palette -> tokens.ts. The PDF's own colour tokens were extracted from the PDF code
    into a single tokens.ts source of truth, decoupled from the render pipeline.
  • Consolidated neutrals -> palette.ts. Shared neutral tones were consolidated into
    palette.ts and gained a snapshot test (pinned floor) to guard them.
  • Theme tests. The snapshot test was made falsifiable (F1: pinned against shipped values, so
    it actually fails), and a palette-parity suite (E2) converts the CSS design tokens to the TS
    palette and maps each — proving --background, --success, etc., resolve across both systems.

All refactors are output-neutral where they touch rendering; only test/palette/token files moved.

Rob Balch and others added 30 commits October 19, 2026 19:16
…DMS-1503 stub)

FieldCompilationNotesPdf takes density?: IPdfDensity (default 'standard') and
builds its stylesheet through createFieldCompilationStyles, so the one template
serves comfortable / standard / compact the way the old per-document styles did.
PdfTable and NoteSection receive the stylesheet as a prop. scaleForDensity is a
pure exported helper, covered by a unit test.

No content, page order or page count change. Batch export byte-identical: it
passes no density and gets 'standard'.
…-1503 stub)

WellPDFDownload, WellPDFActions and the PDF preview route now render
FieldCompilationNotesPdf instead of WellPDF, passing density from the existing
options state. sample/options have no equivalent on the unified template yet, so
they are dropped at these call sites; well.tsx and IPdfOptions stay in place
until the mock is accepted and the text diff is empty.

WellPDFActions.test.tsx mocks @/components, so its mock gains the new export.
The Method column of the Last Measurements table rendered '-' on every
single-well sheet because the three single-well render sites never passed
sampleMethodsBySampleId, leaving the template's public default of {}.

Derive the map from the sample the well page already loads (id +
sample_method) in src/utils/sampleMethods.ts and pass it at all three
sites: the well page header download, its PDF preview, and the download
button on the standalone preview route.

Batch export still keys its own map the same way (well-batch-export.tsx:784),
so both paths now print the same method text; a blank method stays '-'.

Gates: tsc 0; vitest 795 passed (integration contracts excluded - they need
the mock API server); biome exit 0.
Renders FieldCompilationNotesPdf to /tmp/bdms1244/W-01-base.pdf so the PDF
can be rasterised with pdftoppm and inspected against the mock-ups when a
PR's evidence packet is assembled. It asserts only that a non-trivial buffer
is produced; the document itself is the thing under review.

Moved out of the staging checkout, where it had been sitting untracked.
The render harness called note() with three arguments; note() takes four. Pre-existing on the train since the harness was added, caught when the page-2 lane ran tsc.
…l (BDMS-1504)

- fieldSheetSlotPlan: 3-photo cap, ruled fill for unused slots (AC3)
- notesPlacement query toggle for Q5, both positions on one page (AC7)
- showDate/emptyPlaceholder so the mock prints blank fields, no stamp (AC1)
- firstPageOnly keeps the review URL to page 1 until BDMS-1507 lands
- unlinked route /mock/field-sheet/page-1 driven only by src/mock fixture (AC6)
Page 2 of the field sheet, per tasks/BDMS-1507/PAGE-2-SPEC.md: header with a
placeholder logo block and the 'Your Well' title, well-info grid (Site Name /
Point ID / Well Depth / optional OSE #), a reserved 200pt hydrograph block with
no chart, a five-row manual-measurements table using the '-' empty convention,
the hand-writable 'Today's Measurement' box labelled 'Depth to water (DTW):',
the footer (QR placeholder, online link, nmbg-waterlevels@nmt.edu) and the staff
line. One LETTER react-pdf Page, 10pt / line-height 1.35, accent #1a5276, tables
built from View rows.

Omissions by scope: no chart, QR is a grey placeholder block (no asset, no
fetch), logo is an in-block wordmark placeholder. buildFieldSheetPageTwoFixture
({ withOse }) drops the OSE cell entirely when withOse is false; the mock route
reads ?ose=0 and carries no density toggle. Unlinked route
/mock/field-sheet/page-2 added in App.tsx.

Verified by rendering: one page, no content past the 28pt margin (max y 734 of
764 usable, max x 584 of 584), which took tightening the table rows to
lineHeight 1.15 and rebalancing the columns to 26/18/18/38.
BDMS-1504 settles on one type scale, so the review surface no longer
carries a control that changes it. The sheet now prints at the component
default, which is what a real print does (AC3).
PDFViewer requires a Document child. FieldSheetPageTwo is a bare Page (the
page 1 component is self-documenting), so /mock/field-sheet/page-2 rendered an
empty viewer while page 1 worked. The test already wrapped the component itself,
which is why it stayed green; the route now matches the test and a source-level
assertion guards the wrapper.
- New 'Direction notes' NoteSection between Location Notes and Measurement
  Notes; value comes only from the directionNotes prop, never parsed or
  inferred from another well field (Q17 source still open).
- directionNotesValue() trims and collapses undefined/null/blank to '' so the
  label prints with nothing beneath it, never a placeholder.
- 6 unit tests in src/test/components/fieldSheetDirectionNotes.test.ts.
… export toggle

- parseIds splits on commas, newlines and slashes so a calendar loop like
  'AB-0002 / AB-0003' yields both wells instead of silently dropping one.
- pagesForWell(well, includeOwnerPage) is the single place that decides a
  well's page set; page 2 (FieldSheetPageTwo) renders only when toggled on.
- ExportDialog gains an 'Include owner page' checkbox, default on.
- 8 unit tests in src/test/utils/wellBatchExport.test.ts.
Shared scaffolding for the mock-up alignment work: the field sheet and the
owner page each own a style sheet, so the footer takes its two styles as a
prop. This react-pdf build's render() exposes pageNumber but no page count,
so totalPages is an optional caller prop; omitted, it prints 'Page n'.

ALIGNMENT A12/B11.
react-pdf ignores `bottom` on this page's absolute child, so the footer is
anchored from the top (LETTER 792 - 28 padding - 2). Test asserts the printed
`Well ID: <point> | Page n` line.
- contentColumn 60% → 59.33%, photoColumn 33.33% → 40.67% (sum = 100%)
- Removed notePad blocks after each photo in photo column
- Removed ruledSlot filler loop for empty photo slots
- StyleSheet notePad defs kept — still used by top placement mode
…t test

- notePadLine: 16px → 10px (saves 6px per ruled line across all placements)
- Top notes block: 8 ruled lines → 4 (saves ~64px of vertical space)
- Pre-visit pad: unchanged (3 lines × 10px = 30px, already fits)

Fixes: fieldSheetPageOneMock.test.ts 'keeps one page with the notes block at the top'
All 92 test files pass (882 tests). TSC clean. Build clean.
…n widths

- Remove separate Site Notes sections (Row 1 and Row 7)
- Add Site Notes as a bottom field inside the table structure
- Replace fixed percentage widths with flex:3/2 ratio for content/photo columns
- Fix gap causing white space on right side
Rob Balch added 4 commits November 9, 2026 03:21
…t (PR #428 item 1)

Review item 1: "Make photos smaller, max 3 (it's okay to have a placeholder
for >1<3 photos, < 1 should collapse the placeholders and justify the
text/tables)". Approved 2026-11-08.

- Photo frame height 140 -> 100 pt (one constant, PHOTO_CELL_HEIGHT), so
  three frames plus captions fit the right strip.
- With one or two photos the strip keeps the empty slots as dashed frames
  captioned "No photo"; zero photos still collapses the strip entirely.
- Gate: src/test/gate/pr428-photos.gate.test.ts (fails on the previous tree
  at "photo pitch 151 pt must be at most 130 pt" and "the third slot must
  keep a caption", passes here).

Not touched: mock golden fixture and the signoff PDFs.
The mock fixture shipped observations: [] and site_notes: [], so the deployed
review build printed an empty Previous Measurements block and an empty Site
Notes column. Liz was reviewing items 11 and 14 against a blank sheet.

Three observations and three site notes now feed the fixture; the sheet shows
the last two of each, which is what item 14 asks for. pr428-reviewfixture gate
renders the page and asserts both blocks carry data on one page.
The Notes row under New Measurement had a single 16 pt fill line, leaving
~38 pt between the label and Installed Equipment. Stack three lines with a
1 pt gap, keeping the same left/right edges, and add the item 13 gate that
measures the gap (>= 60 pt) and pins page count 1 at photos 0 and 3.
Label on its own line, value under Date and observation date under Time, so the block aligns at both photo widths. Gate: src/test/gate/pr428-prevdtw.gate.test.ts 4/4.
The docker preview build runs tsc over src, where the two gate files did not typecheck: OPS.paintJpegXObject is not in this pdfjs build, and the site_notes literal omitted the note envelope. Gates unchanged in intent: 8/8 pass.
@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown

@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown

Rob Balch added 8 commits November 10, 2026 08:46
Slice S3 of the D28 slice plan. src/App.tsx and src/routes/ocotillo.tsx
carry the /print/packet route used by the L2/L3/L8 gates. The pages
themselves land in S2.

D28 (Rob, 2026-11-10 08:41): commit locally in slice order, push nothing.
Slice S2. PacketPrintPage + packetData render the packet PDF; pdf.tsx is
the single density/format config; scripts/packet-pdf.mjs drives it. Gates:
pr428-liznotes-L2, pr428-liznotes-L3, pr428-packet-tailwind, pr428-pageframe
(4 files / 26 tests green under CI, 2 artifact tests skipped by isCI).

D28 (Rob, 2026-11-10 08:41): commit locally in slice order, push nothing.
- FieldCompilationNotesPdf, density/format/tables, styles (index, scale)
- IdentityPage renderer; page-one fixture
- component, styles and fixture tests; golden fixture baseline
- pr428-liznotes-L1.gate.test.ts (10 assertions)

Gate: pr428-liznotes-L1 10/10 green. Local only - not pushed, PR #428
stays review-only.
- PDF_DENSITIES carries only "comfortable"; no density selector remains
- FieldSheetPageTwo, well.tsx, Equipment and export buttons follow the
  narrowed IPdfDensity type
- pr428-liznotes-L9.gate.test.ts (8 assertions)

Gate: pr428-liznotes-L9 8/8 green, including the live two-page capture.
Local only - not pushed.
pr428-sitenotes and pr428-reviewfixture asserted notes blocks and a review
fixture surface that D2(a) removed; pr428-prevdtw was never committed.
They are mutually exclusive with pr428-liznotes-L1, which forbids those
blocks. Retired by D26 (2026-11-10 08:14:38); copies and shas live in
/Users/robbalch/workspace/archive/gates-D26-2026-11-10/MANIFEST.md.
The two /mock/field-sheet routes and their components were the pre-render
specimen for the paper sheet. The live Field Sheets export, its route, nav,
resource and RBAC checks stay; only the mock pages, their dev-only routes and
the page-two mock test are removed.

- src/App.tsx: drop the two mock imports and their dev/preview routes
- src/pages/mock/FieldSheetPageOneMock.tsx, FieldSheetPageTwoMock.tsx: deleted
- src/test/components/fieldSheetPageTwoMock.test.ts: deleted
…arification

The -302.6/-285.5 pair is measured in the lower half, below any possible
photo. The strip fills one third for three 100 pt frames and nothing below
them, so the lower tables must keep flowing left into that band. Adds the
third assertion (Installed Equipment's Notes header x >= 440) and records
the pre-fix anchors; the footer-clearance retarget is unchanged.
… (r7)

L6 round 7 remediation of PR #428 review findings, plus the carried
field-sheet/print work from r3-r6. Unpushed, per standing rule.

- IdentityPage: Installed Equipment row gets its own 516pt content span
  (alignSelf flex-start) so its Notes header clears the 440pt floor at
  photos=3 without dragging Site Notes out of the 260-300 band.
  Measured: 384.6 (photos=0), 273.1 / 521.3 (photos=3).
- FieldSheetPageTwo / PacketPrintPage / tables.ts / format.ts: page-2
  Depth to Water as a description-grid field with the depth label in
  Today's Measurement (D35), MP Ht explicit (ft), chemistry palette
  alignment, identity block on the print page.
- renderFieldCompilationPdf.test.ts: density union collapsed to
  IPdfDensity and CONFIGS indexed as the A/B/D set (D30).
- pr428-liznotes-L3.gate.test.ts: page-2 label assertion follows D23/D35.
- fieldCompilation-golden.json: one mint at 48/564 on the final tree (554 B).

Gate: sections 1-5 PASS (frozen hashes, page-2 labels, tsc, notes space
6/6, page frame 5/5 at 564, golden shape A/B/D). Section 6 has one red,
pr428-liznotes-L9.gate.test.ts:110 timing out at 5s on a ~17s tsc call -
a frozen-test timing defect, recorded as a named exemption and folded
into the round rather than a new lane.
@TylerAdamMartinez
TylerAdamMartinez self-requested a review November 12, 2026 21:04
Rob Balch and others added 2 commits November 14, 2026 22:33
…L print path

- page 1: full-width table band under the photo strip, New Measurement as a
  real PdfTable (write-in row + M1-M5 grid), notes lines as full-width stack
- page 2: OwnerSheetPage + ownerSheetData, QR/sign-off moved under the sheet
- PdfTable: optional per-table title, column widths, zebra/rule bands
- retire PacketPrintPage, PacketMock and packet-pdf.mjs with their gates;
  add render harnesses for page 1, page 2 and the two-page sheet
- .gitignore: session *_TODO.md notes

tsc: no errors in fieldCompilation/test-tools; vitest render_two_page exit 0
The field-compilation tables carried fixed percentage widths per column,
so long well IDs and measurement strings wrapped badly or overflowed the
container on page 1 and the page-2 owner sheet.

Drop the width overrides from measurementGridColumns /
newMeasurementColumns and let PdfTable size cells from their content,
with the container style doing the page-level layout. Page-2 spacing moves
into styles/pageTwo.ts.

Verified: render_two_page.test.ts -> 2 pages / 18509 B (page 1 10857 B);
fieldCompilationStyles.test.ts 3/3 pass.
@github-actions

Copy link
Copy Markdown

@RSBalchII
RSBalchII requested a review from jirhiker November 16, 2026 17:18
@RSBalchII

RSBalchII commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor Author

my preference @jirhiker @lizalino @TylerAdamMartinez is to break this out into 4ish other tickets me and liz have been puzzling over. the mock up itself is not ever meant to be on the actual repo so there is nothing techically to push in that regard. however the mockup is currently mostly implemented in code since the biggest hurdle was just getting css right inside the pdf render boundary.

so as it is I would rather not have these 80 ish commits since in reality the actual ticket branches will get cherry picked commits and ported code from the preview compilation branch in order to make clean clear tickets PR's with clean clear code changes (way easier to review). I will defer to better ideas for this happily!

to clarify - in its current state I consider the feature to be 85% done. the remainder is getting fields right, hooking up the backend connections that remain disconnected, and CSS adjustments.

@RSBalchII

RSBalchII commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor Author

@jirhiker @TylerAdamMartinez for this mockup mainly needing GUI render feedback. for the implementation I have mostly unified everything and pulled some of the UI elements off of the preview page that we are likely or definitely no longer using.
I do not intend to merge this branch so I know the file diffs look crazy but the actual ticket branches will be far less terrifying and scoped down to their individual code sans multiple iterative commits that are not needed in the final push

to test select https://preview-preview-compilation-auejgdbofq-uc.a.run.app/ ->
click wells ->
click any well ->
click preview view ->
page 1 and owner sheet will render. most fields using dummy data for the moment

This branch was successfully deployed

1 active deployment
staging — d4828062 Deployed Nov 17, 2026 by RSBalchII via teardown / teardown #796
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants