Skip to content

UIOR-1492 Add order email template settings - #1889

Merged
thomas-sc merged 7 commits into
masterfrom
UIOR-1492-add-order-email-templates
Nov 2, 2026
Merged

thomas-sc merged 7 commits into
masterfrom
UIOR-1492-add-order-email-templates

Conversation

@thomas-sc

@thomas-sc thomas-sc commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Purpose

Add a settings page for the email templates that mod-data-export-worker uses when it sends orders to a vendor by email (UXPROD-4589). The templates are stored in mod-template-engine like the patron notice templates, so this page is modeled on PatronNotices in ui-circulation. Templates of this page carry scope: "orders-email" (mod-template-engine #126), which keeps them apart from the circulation templates and leaves room for order templates of other channels, such as print, next to them.

Approach

The editor is stripes-template-editor with a token picker whose tokens mirror the context mod-data-export-worker builds for the email export (MODEXPW-635): loops over orders and order lines, and nested loops for contributors, product IDs and funds. The templates are rendered with Handlebars (MODTEMPENG-136), so new templates get templateResolver: "handlebars".

The preview is rendered by the backend through POST /template-request/preview (MODTEMPENG-135) with built-in sample data, because the regex preview of the library does not resolve loops. The editor uses the library's previewRenderer="backend" (STRIPES-1025, STTEDIT-4/5/6), the detail view uses the library's PreviewModal with the same props. That is why template-engine moves to 2.3 and stripes-template-editor to ^3.6.0. Both need a release before the next ui-orders release: the backend preview is only on main of the library, and interface 2.3 is only on master of mod-template-engine (v1.23.0 provides 2.2). Keeping template-engine at 2.0 with a runtime guard was the first idea, but with mod-template-engine installed on every tenant an optional 2.3 blocks the install just like a required one, and a settings page whose preview and dispatch silently do nothing is worse than a clear requirement.

The permissions are a separate set (ui-orders.settings.email-templates.*), added to ui-orders.settings.view and ui-orders.settings.all; the view permission includes template-request.preview.post so that viewers can open the preview.

Screenshots

Order-templates-1 Order-templates-2 Order-templates-3 Order-templates-preview

Refs UIOR-1492, UIOR-1493, UIOR-1495

Pre-Merge Checklist

Before merging this PR, please go through the following list and take appropriate actions.

  • I've added appropriate record to the CHANGELOG.md
  • Does this PR meet or exceed the expected quality standards?
    • Code coverage on new code is 80% or greater
    • Duplications on new code is 3% or less
    • There are no major code smells or security issues
  • Does this introduce breaking changes?
    • If any API-related changes - okapi interfaces and permissions are reviewed/changed correspondingly
      • template-engine required interface floor raised 2.0 to 2.3; new permission set ui-orders.settings.email-templates.*
    • There are no breaking changes in this PR.
      • The breaking part is the raised template-engine 2.3 requirement, currently provided only by mod-template-engine master (v1.23.0 provides 2.2).

Add Settings > Orders > Order email templates: list, detail view and
form for mod-template-engine templates with scope "orders", a token
picker for the Handlebars data model of the EDIFACT email export
(MODEXPW-635) and a backend-rendered preview via
POST /template-request/preview (MODTEMPENG-135).

Refs UIOR-1492, UIOR-1493, UIOR-1495.
Cover the settings page, the detail view with its preview, the form,
the token picker and the validation.

Refs UIOR-1492, UIOR-1493, UIOR-1495.
@github-actions

github-actions Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Jest Unit Test Results

    1 files  ± 0    318 suites  +6   5m 5s ⏱️ - 1m 50s
1 237 tests +41  1 229 ✅ +41  8 💤 ±0  0 ❌ ±0 
1 245 runs  +41  1 237 ✅ +41  8 💤 ±0  0 ❌ ±0 

Results for commit a48e6cd. ± Comparison against base commit 0a365d1.

♻️ This comment has been updated with latest results.

Build the token lists from plain maps: Sonar reported the repeated
token objects as duplicated blocks (4.7 % of the new code, limit 3 %).
Strip tags with a regex that cannot backtrack and use `replaceAll`.

Refs UIOR-1492.
Exclude `<` from the character class, so a run of unclosed `<` is not
rescanned from every position (Sonar S8786).

Refs UIOR-1492.
The README of mod-data-export-worker only describes the export
payload. The Acquisitions SIG page lists all tokens and an example
template, so the tip in the token picker links there instead.
Build the preview values of the token picker from the sample context
instead of keeping a second copy, so the regex fallback and the
backend preview show the same data. Replace the vendor and two
personal names in the sample data with neutral ones.
@thomas-sc
thomas-sc marked this pull request as ready for review October 19, 2026 08:27
The scope names the app and the channel, so order templates for other
channels (e.g. print) can live next to the email templates later
without migrating the existing ones.
@sonarqubecloud

Copy link
Copy Markdown

@NikitaSedyx
NikitaSedyx requested a review from a team October 28, 2026 13:00
@thomas-sc
thomas-sc merged commit 81df586 into master Nov 2, 2026
16 checks passed
@thomas-sc
thomas-sc deleted the UIOR-1492-add-order-email-templates branch November 2, 2026 07:06
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.

3 participants