[Bug 43521] New: Reuse PatronSelect's patron name formatter in patron-format.js
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43521 Bug ID: 43521 Summary: Reuse PatronSelect's patron name formatter in patron-format.js Initiative type: --- Sponsorship --- status: Product: Koha Version: Main Hardware: All OS: All Status: NEW Severity: enhancement Priority: P5 - low Component: Patrons Assignee: koha-bugs@lists.koha-community.org Reporter: martin.renvoize@openfifth.co.uk QA Contact: testopia@bugs.koha-community.org CC: gmcharlt@gmail.com, kyle@bywatersolutions.com Depends on: 43518 Target Milestone: --- Bug 43518 added formatPatronName() (vue/utils/patron-options.js), a pure, framework-free reimplementation of $patron_to_html()'s (patron-format.js) name-assembly rules -- preferred_name/firstname, middle_name, other_name, showDiffFirstname, invertName, hidePatronName, displayCardnumber, and the no-name fallback -- but returning plain text for native Vue rendering instead of an HTML string. That means Koha now has two independent implementations of the same formatting rules: $patron_to_html() (used across ~15+ .tt/.js consumers such as catalogue/detail.tt, holds.js, ill-list-table.js, checkout_renewals_modal.js) and formatPatronName() (used by PatronSelect and anything that calls patronToOption()/resolvePatronOption()). If the formatting rules change, both need updating, and nothing enforces that. This bug tracks having $patron_to_html() delegate its field-by-field decisions to formatPatronName(), so there is exactly one source of truth. The complication: patron-format.js is loaded as a plain, unbundled <script> (via [% Asset.js("js/patron-format.js") %] in js_includes.inc) -- it is not part of the rspack build that compiles the vue/ tree, so it cannot use a normal ES import. The realistic approach is to load the shared formatter via <script type="module"> (natively supported, no bundler needed), with the module assigning itself to window for patron-format.js to call. Given $patron_to_html() is only ever invoked from event handlers/callbacks (not at page-parse time), the deferred nature of module scripts should not introduce a race, but this needs verifying across its real consumers. $patron_to_html() would keep its HTML-building responsibilities (title markup, url wrapping, escaping) and delegate only the name-assembly decisions to formatPatronName(). Test plan: 1. Apply on top of bug 43518. 2. Identify pages using $patron_to_html() with each of: invert_name, hide_patron_name, display_cardnumber, showDiffFirstname, and a patron with no visible name (restricted view). 3. Verify rendered patron names are unchanged before and after this change for each case. 4. Run the existing patronOptions_spec.ts and PatronSelect_spec.ts Cypress component specs. Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43518 [Bug 43518] Add a reusable PatronSelect Vue component with patron search -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org