Skip to content

[feature] Add label-paper sheet printing#95

Draft
akira69 wants to merge 17 commits into
Fire-Devils:develfrom
akira69:feature/label-paper-sheet-printing
Draft

[feature] Add label-paper sheet printing#95
akira69 wants to merge 17 commits into
Fire-Devils:develfrom
akira69:feature/label-paper-sheet-printing

Conversation

@akira69

@akira69 akira69 commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds label-paper sheet printing for users who do not have a dedicated label printer or who want to use partially consumed label sheets.

Why:

  • Current label export is optimized around individual label pages/files.
  • Users printing through normal printers need paper-sized pages with labels arranged into rows/columns.
  • Partially used sheets need a way to skip cells on the first page.

What changed:

  • Added an Output mode control to all four print flows:
    • spool single
    • spool batch
    • filament single
    • filament batch
  • Added reusable LabelSheetOutputSettings UI so the four print pages share one sheet-settings block.
  • Added Label paper settings for paper size, custom dimensions, rows/columns, margins, gaps, skipped cells, copies, grid visibility, and fit-to-cell.
  • Added reusable sheet layout/print/PDF helpers in label-sheet.ts.
  • Browser print now emits paper-sized sheet pages in label-paper mode.
  • PDF export composes labels onto sheet-sized PDF pages in label-paper mode.
  • PDF export reuses duplicate embedded label images where possible to reduce file size while keeping 600 DPI captures.
  • Large sheet preview/PDF jobs prompt before rendering to avoid accidental browser stalls or very large PDFs.
  • Individual PNG/ZIP export behavior remains unchanged.

Stack / Merge Order

#93 and #94 are now merged into devel.

This PR is stacked after #91. Its diff may include #91 changes until #91 lands, then this branch should be rebased onto the updated devel.

The branch has been restacked on the simplified #91 tip and reuses #91's shared standard settings and batch print style components instead of carrying duplicate print-page markup.

Expected remaining merge order:

  1. feat(filaments): add label printing support for filaments #91
  2. This PR

Validation

  • npm run lint passes with existing warnings.
  • npm run check passes with existing project hints.
  • npm run build passes.
  • Local browser smoke test on 127.0.0.1:4325:
    • single spool sheet preview renders one A4 sheet with one source label and one visible sheet label;
    • skipped cells plus copies place labels after the skipped cells;
    • single filament sheet preview renders using the shared saved sheet settings;
    • single spool sheet PDF downloads and has one A4 media box.

Note: npm run build still logs the existing local version.txt warning in this worktree; generated src/version.js was not committed.

Test Checklist

  • Static validation: lint/check/build.
  • Single spool: individual PDF remains label-sized.
  • Single spool: label-paper PDF uses paper-sized pages.
  • Batch spool: label-paper PDF paginates labels into rows/columns.
  • Single filament: label-paper preview uses paper-sized pages.
  • Batch filament: label-paper PDF paginates labels into rows/columns.
  • Skipped cells apply to the first sheet.
  • Copies render correctly in sheet preview.
  • Browser print uses paper-sized pages in label-paper mode.
  • Existing individual PNG/ZIP export remains unchanged.

akira69 added 14 commits June 19, 2026 19:27
… designer

- Add filaments/[id]/print.astro: single-filament label print page
  mirroring spools/[id]/print.astro with filament-specific defaults
  (height=25mm, qrSize=15mm), storage keys, and API mapping
- Add filaments/print.astro: batch filament label print page
  mirroring spools/print.astro with filament API + filament extra fields
- Add Print Label button to filaments/[id]/index.astro (builds URL params
  from filament API data + stores extra fields in sessionStorage)
- Add Print Labels bulk action to filaments/index.astro (bulk-action-bar)
- Add i18n keys: filaments.backToFilament, filaments.showFilamentId,
  filaments.printLabel, filaments.bulkLabel (en + de)
Add optional qrUrl field to StandardLabelData so filament print pages
can specify the correct entity URL for QR codes.
… fields on print pages

- Detail page writes standard fields (extruder_temp, bed_temp, diameter,
  density, weight, finish, price) plus system custom fields to
  filaman-filament-label-extra-fields sessionStorage before navigating
  to the print page, so no extra API fetch is needed

- Single print page fallback (direct navigation): now also shows standard
  filament fields as selectable checkboxes alongside system custom fields;
  parallelizes the two API fetches; no longer early-returns when there are
  no system custom fields

- Batch print page: always shows standard filament fields as selectable
  extra fields (Extruder Temp, Bed Temp, Diameter, Density, Weight,
  Finish, Price) in addition to system-defined custom fields
…designer

Add optional presetsKey to LabelDesignerEditorOptions so each entity type
can use its own preset store. Filament print pages now use
'filaman-filament-label-presets-v1'; spool pages continue using the
default 'filaman-label-presets-v1'. Presets named 'Default' are seeded
separately in each store.
…erEditor

Remove the optional default. Every caller must now explicitly declare
which preset namespace it owns:
  spools/[id]/print     → filaman-spool-label-presets-v1
  spools/print          → filaman-spool-label-presets-v1
  filaments/[id]/print  → filaman-filament-label-presets-v1
  filaments/print       → filaman-filament-label-presets-v1

This makes future entity types impossible to accidentally share presets.
On first use of a spool print page after upgrade, presets stored under
'filaman-label-presets-v1' (the old shared key) are moved to
'filaman-spool-label-presets-v1' and the old key is deleted.

Migration only runs when the effective key is the spool key and the
destination is empty, so it is idempotent and only fires once.
- Entity-locked QR URLs in designer: spool pages encode /spools/{id},
  filament pages encode /filaments/{id}
- Cross-type preset sharing with <optgroup> divider; filament pages show
  spool presets section and vice versa; cross-type presets are read-only
- Entity-specific labels throughout the designer UI: token group header,
  empty extra-fields state, QR pill label, section titles
- Non-system filament custom fields now included in print page sessionStorage
- Filament label defaults match spool defaults (height 40mm, QR 18mm)
- Token area Extra Fields group label uses entity-specific i18n key
- LabelDesignerSettings.info gains marginMm field (default 0)
- Margin is applied as marginTop on the main info/QR row, providing
  vertical spacing between the title blocks and the info area
- Range+number input added to LabelDesignerEditor.astro below the
  text-size row, matching the existing title gap control style
- Editor wired in FIELD_IDS, SLIDER_PAIRS, read/apply/reset/localize
- Preset save/load and reset-section button all handle the new field
Old localStorage (v<2) had height=25mm and QR=15mm from early development.
Adds SETTINGS_VERSION=2; on load, any saved settings without _v>=2 are
discarded so the correct defaults (60x40mm, QR=18mm) take effect.
…overage

- Split DESIGNER_TOKENS into FILAMENT_TOKENS (all pages) + SPOOL_TOKENS (spool
  pages only), adding 5 new filament fields and 13 spool model fields
- Add entityType option to LabelDesignerEditorOptions; spool pages show a
  dedicated 'Spool' token group (lot_number, external_id, rfid_uid, location,
  status, purchase_date, purchase_price, remaining/initial/empty weights,
  stocked_in_at, last_used_at); filament pages omit it
- Extend SpoolData interface and DesignerFlatLabelData with all new fields
- Wire spool model fields through buildSpoolDataFromFlatLabel and
  buildSpoolDataFromApiSpool so tokens resolve correctly at render time
- spool/[id]/index.astro: include all spool model fields in printUrl params
  and efForPrint (so they appear as standard-label checkboxes too)
- spool/[id]/print.astro, filament/[id]/print.astro: read new URL params
- filament pages: add subtype, manufacturer_color_name, default_spool_weight_g,
  spool_outer_diameter_mm, spool_width_mm, spool_material to URL params
- spools/print.astro (batch): add Spool Fields checkbox section for model-level
  fields in the standard label sidebar
- Fix pre-existing TS error: info preset default was missing marginMm
@akira69 akira69 force-pushed the feature/label-paper-sheet-printing branch 2 times, most recently from 1432c48 to 278012e Compare June 19, 2026 23:45
@akira69 akira69 force-pushed the feature/label-paper-sheet-printing branch from 278012e to 561d5e5 Compare June 19, 2026 23:50
@akira69 akira69 force-pushed the feature/label-paper-sheet-printing branch from 561d5e5 to c4160ce Compare June 20, 2026 22:23
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.

1 participant