Bug 39971 - Patron attribute types form logic should be reusable
Summary: Patron attribute types form logic should be reusable
Status: Signed Off
Alias: None
Product: Koha
Classification: Unclassified
Component: Architecture, internals, and plumbing (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement
Assignee: Pedro Amorim
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-05-22 15:22 UTC by Pedro Amorim
Modified: 2025-06-07 01:22 UTC (History)
4 users (show)

See Also:
GIT URL:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments
Bug 39971: Move form rendering to reusable tt block (16.83 KB, patch)
2025-05-22 15:31 UTC, Pedro Amorim
Details | Diff | Splinter Review
Bug 39971: Move patron_attributes_form method to a class (9.44 KB, patch)
2025-05-22 15:31 UTC, Pedro Amorim
Details | Diff | Splinter Review
Bug 39971: Add POD (1.52 KB, patch)
2025-05-22 15:31 UTC, Pedro Amorim
Details | Diff | Splinter Review
Bug 39971: Add query param (1.42 KB, patch)
2025-05-22 15:31 UTC, Pedro Amorim
Details | Diff | Splinter Review
Bug 39971: Move form rendering to reusable tt block (16.87 KB, patch)
2025-06-07 01:20 UTC, David Nind
Details | Diff | Splinter Review
Bug 39971: Move patron_attributes_form method to a class (9.48 KB, patch)
2025-06-07 01:20 UTC, David Nind
Details | Diff | Splinter Review
Bug 39971: Add POD (1.56 KB, patch)
2025-06-07 01:20 UTC, David Nind
Details | Diff | Splinter Review
Bug 39971: Add query param (1.47 KB, patch)
2025-06-07 01:20 UTC, David Nind
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Pedro Amorim 2025-05-22 15:22:59 UTC
Other parts of Koha that need to render this should not be repeating code but instead make use of established DRY logic.
Comment 1 Pedro Amorim 2025-05-22 15:31:17 UTC
Created attachment 182739 [details] [review]
Bug 39971: Move form rendering to reusable tt block
Comment 2 Pedro Amorim 2025-05-22 15:31:20 UTC
Created attachment 182740 [details] [review]
Bug 39971: Move patron_attributes_form method to a class

This makes it reusable, documentable, and testable.

This is changing code without adding a new feature or fixing a bug.
The first test plan should be to just make sure that the existing functionality is kept intact, i.e. rendering and saving the patron attribute types in the form.

As to why we need this, we're maintaining the ILL Actions plugin where we have a feature to quickly add a patron. This is designed to be as minimal as possible, but if there are any mandatory patron attribute types, those need to be considered.
To test this:
1) Apply patches and enable ILLModule syspref.
2) Install the plugin:
https://github.com/openfifth/koha-plugin-ill-actions/releases/tag/v2.4.0
3) Add a mandatory patron attribute type, you can edit the existing one in k-t-d, visit:
   <staff_url>/cgi-bin/koha/admin/patron-attr-types.pl?op=edit_attribute_type&code=SHOW_BCODE
5) Tick the 'Staff interface mandatory' checkbox
6) Create a new ILL request, visit:
   <staff_url>/cgi-bin/koha/ill/ill-requests.pl?method=create&backend=Standard
7) Notice there's a '+Add new user' link next to the cardnumber input at the bottom of the form. Click that.
8) Notice there's a 'Additional attributes and identifiers' section. This is only possible (without writing it again) because of the patches here.
Comment 3 Pedro Amorim 2025-05-22 15:31:23 UTC
Created attachment 182741 [details] [review]
Bug 39971: Add POD
Comment 4 Pedro Amorim 2025-05-22 15:31:26 UTC
Created attachment 182742 [details] [review]
Bug 39971: Add query param
Comment 5 David Nind 2025-06-07 01:20:26 UTC
Created attachment 183087 [details] [review]
Bug 39971: Move form rendering to reusable tt block

Signed-off-by: David Nind <david@davidnind.com>
Comment 6 David Nind 2025-06-07 01:20:29 UTC
Created attachment 183088 [details] [review]
Bug 39971: Move patron_attributes_form method to a class

This makes it reusable, documentable, and testable.

This is changing code without adding a new feature or fixing a bug.
The first test plan should be to just make sure that the existing functionality is kept intact, i.e. rendering and saving the patron attribute types in the form.

As to why we need this, we're maintaining the ILL Actions plugin where we have a feature to quickly add a patron. This is designed to be as minimal as possible, but if there are any mandatory patron attribute types, those need to be considered.
To test this:
1) Apply patches and enable ILLModule syspref.
2) Install the plugin:
https://github.com/openfifth/koha-plugin-ill-actions/releases/tag/v2.4.0
3) Add a mandatory patron attribute type, you can edit the existing one in k-t-d, visit:
   <staff_url>/cgi-bin/koha/admin/patron-attr-types.pl?op=edit_attribute_type&code=SHOW_BCODE
5) Tick the 'Staff interface mandatory' checkbox
6) Create a new ILL request, visit:
   <staff_url>/cgi-bin/koha/ill/ill-requests.pl?method=create&backend=Standard
7) Notice there's a '+Add new user' link next to the cardnumber input at the bottom of the form. Click that.
8) Notice there's a 'Additional attributes and identifiers' section. This is only possible (without writing it again) because of the patches here.

Signed-off-by: David Nind <david@davidnind.com>
Comment 7 David Nind 2025-06-07 01:20:32 UTC
Created attachment 183089 [details] [review]
Bug 39971: Add POD

Signed-off-by: David Nind <david@davidnind.com>
Comment 8 David Nind 2025-06-07 01:20:34 UTC
Created attachment 183090 [details] [review]
Bug 39971: Add query param

Signed-off-by: David Nind <david@davidnind.com>
Comment 9 David Nind 2025-06-07 01:22:17 UTC
Things worked as per the test plan.

In this case, a new patron wasn't created. However, I assume that is because the plugin has to implement that part? (It also let you press submit even if you didn't add a mandatory field.)