https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43520

--- Comment #2 from Martin Renvoize (ashimema) 
<[email protected]> ---
Created attachment 205595
  -->
https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=205595&action=edit
Bug 43520: Replace PatronAutoComplete with PatronSelect in FormElement.vue

Migrate FormElement.vue's generic patronAutoComplete driven-form field
type from PatronAutoComplete.vue (jQuery UI autocomplete plus global
window.patron_autocomplete()/patron_autocomplete_render_selection()
functions, untestable in the Cypress component sandbox - \$ is not
defined) onto PatronSelect (bug 43518).

The only current consumer is ILL's Requesting Agency admin screen
(RequestingAgencyResource.vue), picking the 'ILL partner' patron on an
iso18626_requesting_agency record. Its API resource embeds the picked
patron (patronEmbedName: 'ill_partner', a formally documented embed per
iso18626_requesting_agency.yaml), so the create/edit form already has
both the raw patron_id and, when editing, the full embedded patron
side by side.

FormElement.vue now owns:
- Hydrating the field's current selection: prefer the embedded patron
  (patronToOption()) and only fall back to fetching by id
  (resolvePatronOption(), bug 43518) when no embed is present - which
  in practice is only the never-yet-selected/create case.
- Searching: reuses the same global buildPatronSearchQuery() and
  additional-filters merge the legacy jQuery widget used, via
  APIClient.patron.patrons.search(), mapped through patronToOption()
  with { invertName: true, showDiffFirstname, loggedInLibraryId } -
  matching the legacy autocomplete dropdown's own display convention
  (surname-first; the syspref-driven legal-firstname aside; current-
  library highlighting), read from the same js_includes.inc globals
  the legacy widget already relied on.
- Passing the selected option's patron_id back to resource[attr.name],
  and keeping the embed in sync when patronEmbedName is configured.

PatronSelect.vue: made its self-rendered <label> conditional
(v-if="label") and added a hideRequiredMarker prop, so it can be
embedded inside FormElement.vue's own uniform label/Required-marker
layout without producing a duplicate of either.

PatronAutoComplete.vue is now unused anywhere in core (confirmed by a
full-tree search) and has been removed; the PatronAutoComplete syspref
and request.tt's direct window.patron_autocomplete() jQuery call are
unrelated (naming collision only) and untouched.

Test plan:
1. Apply on top of bug 43518.
2. Run: yarn cypress run --component --browser electron
3. Verify all specs pass, including the new patronAutoComplete
   coverage in FormElement_spec.ts and the label/marker coverage in
   PatronSelect_spec.ts.
4. In the staff interface, go to a library with ILL configured and the
   ISO18626 requesting agencies feature enabled. Add a new requesting
   agency: search for and select an ILL partner patron, save, then
   edit the same record and confirm the previously-selected patron is
   shown immediately (no blank picker).

Assisted-by: Sonnet 5 (Anthropic)

-- 
You are receiving this mail because:
You are the assignee for the bug.
You are watching all bug changes.
_______________________________________________
Koha-bugs mailing list -- [email protected]
To unsubscribe send an email to [email protected]
website : http://www.koha-community.org/
git : http://git.koha-community.org/
bugs : http://bugs.koha-community.org/

Reply via email to