Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions components/engine/engine-document/CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,17 @@ uploaded). The Print button asks which to use when several exist.
(404 with a clear message when absent), then `DocumentParser → DataBinder → XslFoRenderer →
PDFFacade.generate(fo, "<data/>")`.

**The client supplies the data.** The Harmonia document page POSTs the record + items it already
loaded, with dropdown FKs resolved to display labels (`printPayload()` in
`document-page.js.template`). Deliberate: no server-side entity fetching, no auth forwarding, and
the printout matches exactly what the user sees. The JSON body is parsed with a **plain Gson**
**The client feeds this endpoint from a server-side feeder, not from its own screen state.** The
Harmonia document/manage page first GETs the generated `…PrintFeeder/{id}` (client-Java), which
loads the record + its related graph through the generated repositories and returns the nested
`{ document, items }` payload — so `{{document.<Relation>.<Field>}}` resolves and validations, events
and the **multilingual translation overlay** all apply. The page then POSTs that payload here. The
feeder is called as the logged-in user (auth + tenant are the caller's). **Language:** the print
dialog's chosen language drives BOTH halves — it is the `?lang=` that selects the CMS template folder
(labels) AND is sent as the feeder GET's `Accept-Language` (via `api.get(url, { language: lang })`),
because the repositories' multilingual overlay reads `User.getLanguage()`/`Accept-Language`; without
that pin the nomenclature VALUES would translate to the UI locale while the template is in the print
language (dirigible #6945). The JSON body is parsed with a **plain Gson**
(`ToNumberPolicy.LONG_OR_DOUBLE`) — never `JsonHelper`/`GsonHelper` (the `@Expose` trap; and
LONG_OR_DOUBLE keeps integers integral while decimals arrive as `Double`, which `DataBinder`
formats in the form money pattern `### ### ### ##0.00`).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,10 @@ App.services.api = {
// browser's native login dialog never pops over a background poll.
const headers = { 'Accept': 'application/json', 'X-Requested-With': 'XMLHttpRequest' };
if (!isForm) headers['Content-Type'] = 'application/json';
const language = this.language();
// A caller may pin the request language for THIS call ({ language: 'bg' }) — e.g. Print, where the
// chosen print language must drive the multilingual data overlay, not the UI locale. Absent the
// override, the app's single language flag (the Region & Language store) applies as before.
const language = opts.language !== undefined ? opts.language : this.language();
if (language) headers['Accept-Language'] = language;

let r;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,11 @@ document.addEventListener('alpine:init', () => {
// graph through the repositories and returns the { document, items } payload the template binds
// - so {{document.<Relation>.<Field>}} resolves. It is the auditable source of what a print
// receives; the browser calls it as the logged-in user (auth + tenant + i18n are the caller's).
// Pin the feeder's language to the CHOSEN print language, not the UI locale: the repositories'
// multilingual overlay reads Accept-Language, so without this the nomenclature values (Payment
// Method, Status, ...) would render in the UI locale while the template is in the print language.
const payload = await App.services.api.get(
'/services/java/${projectName}/gen/events/${javaGenFolderName}/${name}PrintFeeder/' + encodeURIComponent(this.id), { baseUrl: '' });
'/services/java/${projectName}/gen/events/${javaGenFolderName}/${name}PrintFeeder/' + encodeURIComponent(this.id), { baseUrl: '', language: lang });
const response = await fetch('/services/print/${name}?lang=' + encodeURIComponent(lang), {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -717,8 +717,11 @@ document.addEventListener('alpine:init', () => {
// graph through the repositories and returns the { document, items } payload the template binds
// - so {{document.<Relation>.<Field>}} resolves. It is called as the logged-in user (auth +
// tenant + i18n are the caller's).
// Pin the feeder's language to the CHOSEN print language, not the UI locale: the repositories'
// multilingual overlay reads Accept-Language, so without this the nomenclature values (Payment
// Method, Status, ...) would render in the UI locale while the template is in the print language.
const payload = await App.services.api.get(
'/services/java/${projectName}/gen/events/${javaGenFolderName}/${name}PrintFeeder/' + encodeURIComponent(this.id), { baseUrl: '' });
'/services/java/${projectName}/gen/events/${javaGenFolderName}/${name}PrintFeeder/' + encodeURIComponent(this.id), { baseUrl: '', language: lang });
const response = await fetch('/services/print/${name}?lang=' + encodeURIComponent(lang), {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
Expand Down
Loading