Skip to content

feat(printing): add template tag modifiers and syntax help#876

Open
akira69 wants to merge 1 commit intoDonkie:masterfrom
akira69:tmp/pr876-template-filters
Open

feat(printing): add template tag modifiers and syntax help#876
akira69 wants to merge 1 commit intoDonkie:masterfrom
akira69:tmp/pr876-template-filters

Conversation

@akira69
Copy link
Copy Markdown

@akira69 akira69 commented Mar 5, 2026

Summary

This PR is a focused fix for label-template formatting ergonomics (issues #795 and #669) on top of Donkie/Spoolman master.

It adds formatter modifiers directly to existing template tags:

  • Datetime modifiers: date, time, date_local, time_local, datetime_short, datetime_short_local
  • Date-order suffixes for date-based datetime output: :ymd, :mdy, :dmy
  • Numeric modifiers: round, fixed1, fixed2

Examples:

  • {first_used|date:dmy}
  • {first_used|datetime_short_local:mdy}
  • {remaining_weight|fixed2}

Code Quality Compliance ✅

Per https://github.com/Donkie/Spoolman/wiki/Contribute#style

  • ESLint (frontend) ✓
  • Prettier (frontend) ✓
  • Ruff (backend) N/A, frontend-only PR
  • Pre-commit hooks validated ✓

Included In This PR

  • Shared template-renderer support in client/src/pages/printing/printing.tsx
    • adds |modifier parsing to existing spool label templates
  • Spool-label authoring UX in client/src/pages/printing/spoolQrCodePrintingDialog.tsx
    • Available Tags... button
    • one-click tag / modifier copy
    • help link to /help#template-syntax
    • modifier syntax comes from code constants, not translated strings
  • Help-page documentation in client/src/pages/help/index.tsx
    • centralized template syntax examples
    • hash-anchor retry/focus fix for /help#template-syntax
    • i18n-backed help content instead of hardcoded English-only JSX

Scope Boundary

  • This PR changes spool label authoring only.
  • Any filament-label benefit from the shared renderer still depends on #846, because without #846 there is no filament label printing surface upstream.
  • Filament dialog parity is intentionally deferred to a follow-up PR.
  • This PR is separate from #875.
  • This PR is adjacent to #885, but does not depend on it.

Relationship To Other PRs

  • #846 is the prerequisite for any filament-label benefit from this PR.
  • The filament dialog parity follow-up currently lives in akira69/Spoolman_Labels as PR #12, because GitHub cannot stack that branch directly onto this fork branch in Donkie/Spoolman.

Issues

Fixes #795
Fixes #669

Validation Completed

  • npm ci
  • npx eslint src/pages/help/index.tsx src/pages/printing/printing.tsx src/pages/printing/spoolQrCodePrintingDialog.tsx
  • client/node_modules/.bin/prettier --check client/src/pages/help/index.tsx client/src/pages/printing/printing.tsx client/src/pages/printing/spoolQrCodePrintingDialog.tsx client/public/locales/en/common.json
  • VITE_APIURL=/api/v1 npm run build
  • uv run lefthook run pre-commit
  • Interactive local verification on PR876 app with populated DB (6957 filaments, 3 spools)

Screenshots

Before: raw values without modifiers

image

After: formatted values with |fixed2 and |date

image

Available Tags dialog with modifier chooser

image

Template syntax help page

image

Test Checklist

Core Functionality

  • Clicking Available Tags... opens the tag/modifier dialog from spool label printing
  • Clicking a tag copies a ready-to-paste {tag} value and closes the dialog
  • Clicking a modifier copies a ready-to-paste {tag|modifier} value and closes the dialog
  • Datetime modifiers render correctly in preview, including date-order suffixes such as {last_used|date:dmy}
  • Number modifiers render correctly in preview, including {remaining_weight|fixed2}

Integration

  • The dialog lists spool, related filament, and related vendor fields in the correct prefixed form
  • Schema-defined extra fields appear in the available-tags list with the correct extra.* paths
  • The help link navigates to /help#template-syntax and lands on the Template Syntax section

Regression

  • Spool print preview and QR rendering still display correctly after the modifier changes
  • Save Presets succeeds from the spool print dialog
  • Existing spool label templates without modifiers still render unchanged

@akira69 akira69 force-pushed the tmp/pr876-template-filters branch from 9874181 to be550cd Compare March 27, 2026 04:25
@akira69 akira69 force-pushed the tmp/pr876-template-filters branch 2 times, most recently from 4d6e109 to aea7b56 Compare March 27, 2026 05:46
@akira69 akira69 marked this pull request as ready for review March 27, 2026 06:37
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.

Labels: Date formatting Show less decimals in label template values

1 participant