Bug 35145 - Add ability to order patron attributes
Summary: Add ability to order patron attributes
Status: Signed Off
Alias: None
Product: Koha
Classification: Unclassified
Component: OPAC (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement (vote)
Assignee: Emily-Rose Francoeur
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-10-24 16:47 UTC by Caroline Cyr La Rose
Modified: 2024-05-13 23:00 UTC (History)
9 users (show)

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


Attachments
Bug 35145: Add ability to order patron attribute types (10.14 KB, patch)
2023-11-21 21:30 UTC, Emily-Rose Francoeur
Details | Diff | Splinter Review
Bug 35145: Add ability to order patron attribute types (10.05 KB, patch)
2023-11-22 13:40 UTC, Emily-Rose Francoeur
Details | Diff | Splinter Review
Bug 35145: Add ability to order patron attribute types (10.17 KB, patch)
2023-11-29 16:00 UTC, Owen Leonard
Details | Diff | Splinter Review
Bug 35145: (follow-up) Quiet perltidy warnings (1.70 KB, patch)
2023-11-29 16:00 UTC, Owen Leonard
Details | Diff | Splinter Review
Bug 35145: Add ability to order patron attribute types (10.23 KB, patch)
2024-02-22 21:29 UTC, Phan Tung Bui
Details | Diff | Splinter Review
Bug 35145: (follow-up) Quiet perltidy warnings (1.70 KB, patch)
2024-02-22 21:29 UTC, Phan Tung Bui
Details | Diff | Splinter Review
- Seperate DBIC file (9.33 KB, patch)
2024-02-29 21:23 UTC, Phan Tung Bui
Details | Diff | Splinter Review
Bug 35145: (follow-up) Quiet perltidy warnings (1.06 KB, patch)
2024-02-29 21:23 UTC, Phan Tung Bui
Details | Diff | Splinter Review
Bug 35145 : Schema file (1.15 KB, patch)
2024-02-29 21:23 UTC, Phan Tung Bui
Details | Diff | Splinter Review
Bug 35145 : (follow-up) Rename number to display_order (6.88 KB, patch)
2024-02-29 21:23 UTC, Phan Tung Bui
Details | Diff | Splinter Review
Bug 35145 : (follow-up) Rename number to display_order (6.58 KB, patch)
2024-03-01 15:51 UTC, Phan Tung Bui
Details | Diff | Splinter Review
Bug 35145: (follow-up) Fix atomicupdate file and display_order's data type (1.72 KB, patch)
2024-05-09 20:10 UTC, Hammat wele
Details | Diff | Splinter Review
Bug 35145: Schema file (1.24 KB, patch)
2024-05-10 09:43 UTC, Pedro Amorim
Details | Diff | Splinter Review
Bug 35145: (follow-up) Rename number to display_order (6.67 KB, patch)
2024-05-10 09:43 UTC, Pedro Amorim
Details | Diff | Splinter Review
Bug 35145: (follow-up) Fix atomicupdate file and display_order's data type (2.03 KB, patch)
2024-05-10 09:43 UTC, Pedro Amorim
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Caroline Cyr La Rose 2023-10-24 16:47:32 UTC
Right now, patron attributes are presented in code order. It would be nice to have a way to choose the order in which they are presented.

I put this in OPAC because I noticed this in the self-registration form. But I guess it would be true for the staff interface too.

My actual use case was for birth details of a baby. I had the birthdate, the number of weeks and the number of days of pregnancy, the weight of the baby, the surname of the baby, etc. I had specifically added them in the order I wanted because I thought the creation order would be the display order. But they were displayed in code order, and the order made no sense (file number, number of days of pregnancy, birth date of the baby, surname of the baby, weight at birth, number of weeks of pregnancy).

I thought something like a "Display order" field like the ones we have in serial patterns and numbering and in the additional contents would be useful.

To recreate:
1. Create several patron attributes with various codes
   1.1. Go to Administration > Patron attribute types > New patron attribute type
   1.2. Fill out the form
        - Code: enter any code, for example WEIGHT
        - Description: enter any description
        - Display in OPAC: check
        - Editable in OPAC: check
   1.3. Click Save
   1.4. Repeat to add a second code with a code alphabetically "before" the previous one, for example SURNAME
   1.5. Optionnally, add more to really view the order

2. Enable self-registration
   2.1. Go to Administration > System preferences
   2.2. Search for selfreg
   2.3. Set PatronSelfRegistration to Allow
   2.4. Set a category in PatronSelfRegistrationDefaultCategory
   2.5. Click Save all OPAC preferences

3. View self-registration form
   3.1. Go to the OPAC
   3.2. Click on Don't have an account? Register here.
   3.3. Go to the bottom of the form
        --> Note that the patron attribute fields are presented in alphabetical order of the code.
Comment 1 Emily-Rose Francoeur 2023-11-21 21:30:34 UTC Comment hidden (obsolete)
Comment 2 Emily-Rose Francoeur 2023-11-22 13:40:38 UTC
Created attachment 159193 [details] [review]
Bug 35145: Add ability to order patron attribute types

Here is a summary of the changes:
 - Added the new column 'number' to 'borrower_attribute_types' table
     ---> Created an atomic update file (bug_35145_order_patron_attributes.pl)
     ---> Updated the kohastructure.sql file
 - Added the new column 'number' for '/cgi-bin/koha/admin/patron-attr-types.pl' table
     ---> The table now defaults to sorting based on the 'number' column
 - Added the field 'Appear in position' in the patron attribute types create/edit form
 - Changed the order of patron attribute types in the patron create/edit form (OPAC and staff interfcce) so it's now sorted by the assigned number

TEST PLAN
1) Go to 'Koha administration > Patron attribute types > + New patron attribute type'
2) Fill out the form
    ---> Code: Enter any code, for example 'WEIGHT'
    ---> Description: Enter any description
    ---> Display in OPAC: Check
    ---> Editable in OPAC: Check
    ---> Class: Keep it empty
3) Click 'Save'
4) Repeat to add a second code with a code alphabetically "before" the previous one, for example SURNAME
5) Optionally, add more to really view the order
6) Go to 'Koha administration > System preferences'
7) Search for 'selfreg'
8) Set 'PatronSelfRegistration' to 'Allow'
9) Set a category in 'PatronSelfRegistrationDefaultCategory'
10) Click on the 'Save all OPAC preferences' button
11) Go to the OPAC and click on the 'Create an account' button
12) Go to the bottom of the form
    ---> Note that the patron attribute fields are presented in alphabetical order of code
13) Apply the patch
14) Perform an atomic update (./installer/data/mysql/updatedatabase.pl)
15) Return to 'Koha administration > Patron attribute types'
    ---> Notice the new 'number' column in the tables
16) Choose one of the attribute types you created earlier and click on the 'edit' button
    ---> You should now see the 'Appear in position' field
17) Enter a number in the 'Appear in position' field and click on 'Save'
18) Repeat the last two steps for each attribute type you created
    ---> Notice that the patron attribute types tables are sorted by number by default
19) In the staff interface, go to 'Patrons > + New patron'
    ---> In the 'Additional attributes and identifiers' section, notice that the fields are in the given number order
20) In the OPAC, return to the patron creation form (step 11)
    ---> At the end of the form, notice that the fields are in the given number order
Comment 3 Owen Leonard 2023-11-29 15:20:26 UTC
This looks like it's working well, but I think we should think about what happens to attributes which are not given a number. In my test system I have a lot of attributes, and if I add position numbers to just a few of them those attributes appear at the end of the list of attributes because nothing comes before something.

I'm concerned that is counterintuitive to the general user. If so, we could consider applying automatic numbering to existing attributes? Or tell the display to put attributes with an empty number value after the numbered values?

What do others think?
Comment 4 Owen Leonard 2023-11-29 15:39:46 UTC
On IRC it was pointed out that this ordering scheme matches news and serial numbering, so it might not be completely new to the user, and we should definitely keep things consistent.
Comment 5 Owen Leonard 2023-11-29 16:00:24 UTC
Created attachment 159344 [details] [review]
Bug 35145: Add ability to order patron attribute types

Here is a summary of the changes:
 - Added the new column 'number' to 'borrower_attribute_types' table
     ---> Created an atomic update file
          (bug_35145_order_patron_attributes.pl)
     ---> Updated the kohastructure.sql file
 - Added the new column 'number' for
   '/cgi-bin/koha/admin/patron-attr-types.pl' table
     ---> The table now defaults to sorting based on the 'number' column
 - Added the field 'Appear in position' in the patron attribute types
   create/edit form
 - Changed the order of patron attribute types in the patron create/edit
   form (OPAC and staff interfcce) so it's now sorted by the assigned
   number

TEST PLAN
1) Go to 'Koha administration > Patron attribute types > + New patron
   attribute type'
2) Fill out the form
    ---> Code: Enter any code, for example 'WEIGHT'
    ---> Description: Enter any description
    ---> Display in OPAC: Check
    ---> Editable in OPAC: Check
    ---> Class: Keep it empty
3) Click 'Save'
4) Repeat to add a second code with a code alphabetically "before" the
   previous one, for example SURNAME
5) Optionally, add more to really view the order
6) Go to 'Koha administration > System preferences'
7) Search for 'selfreg'
8) Set 'PatronSelfRegistration' to 'Allow'
9) Set a category in 'PatronSelfRegistrationDefaultCategory'
10) Click on the 'Save all OPAC preferences' button
11) Go to the OPAC and click on the 'Create an account' button
12) Go to the bottom of the form
    ---> Note that the patron attribute fields are presented in
         alphabetical order of code
13) Apply the patch
14) Perform an atomic update (./installer/data/mysql/updatedatabase.pl)
15) Return to 'Koha administration > Patron attribute types'
    ---> Notice the new 'number' column in the tables
16) Choose one of the attribute types you created earlier and click on
    the 'edit' button
    ---> You should now see the 'Appear in position' field
17) Enter a number in the 'Appear in position' field and click on
    'Save'
18) Repeat the last two steps for each attribute type you created
    ---> Notice that the patron attribute types tables are sorted by
         number by default
19) In the staff interface, go to 'Patrons > + New patron'
    ---> In the 'Additional attributes and identifiers' section, notice
         that the fields are in the given number order
20) In the OPAC, return to the patron creation form (step 11)
    ---> At the end of the form, notice that the fields are in the
         given number order

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Comment 6 Owen Leonard 2023-11-29 16:00:27 UTC
Created attachment 159345 [details] [review]
Bug 35145: (follow-up) Quiet perltidy warnings

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Comment 7 Jonathan Druart 2024-01-12 10:32:59 UTC
1. DBIC schema file must NOT be part of a patch (or submitted separately)

2. Can we consider renaming the column with something more meaningful and less generic than "number"?

item_groups has "display_order".
Comment 8 Phan Tung Bui 2024-02-22 21:29:33 UTC
Created attachment 162347 [details] [review]
Bug 35145: Add ability to order patron attribute types

Here is a summary of the changes:
 - Added the new column 'number' to 'borrower_attribute_types' table
     ---> Created an atomic update file
          (bug_35145_order_patron_attributes.pl)
     ---> Updated the kohastructure.sql file
 - Added the new column 'number' for
   '/cgi-bin/koha/admin/patron-attr-types.pl' table
     ---> The table now defaults to sorting based on the 'number' column
 - Added the field 'Appear in position' in the patron attribute types
   create/edit form
 - Changed the order of patron attribute types in the patron create/edit
   form (OPAC and staff interfcce) so it's now sorted by the assigned
   number

TEST PLAN
1) Go to 'Koha administration > Patron attribute types > + New patron
   attribute type'
2) Fill out the form
    ---> Code: Enter any code, for example 'WEIGHT'
    ---> Description: Enter any description
    ---> Display in OPAC: Check
    ---> Editable in OPAC: Check
    ---> Class: Keep it empty
3) Click 'Save'
4) Repeat to add a second code with a code alphabetically "before" the
   previous one, for example SURNAME
5) Optionally, add more to really view the order
6) Go to 'Koha administration > System preferences'
7) Search for 'selfreg'
8) Set 'PatronSelfRegistration' to 'Allow'
9) Set a category in 'PatronSelfRegistrationDefaultCategory'
10) Click on the 'Save all OPAC preferences' button
11) Go to the OPAC and click on the 'Create an account' button
12) Go to the bottom of the form
    ---> Note that the patron attribute fields are presented in
         alphabetical order of code
13) Apply the patch
14) Perform an atomic update (./installer/data/mysql/updatedatabase.pl)
15) Return to 'Koha administration > Patron attribute types'
    ---> Notice the new 'number' column in the tables
16) Choose one of the attribute types you created earlier and click on
    the 'edit' button
    ---> You should now see the 'Appear in position' field
17) Enter a number in the 'Appear in position' field and click on
    'Save'
18) Repeat the last two steps for each attribute type you created
    ---> Notice that the patron attribute types tables are sorted by
         number by default
19) In the staff interface, go to 'Patrons > + New patron'
    ---> In the 'Additional attributes and identifiers' section, notice
         that the fields are in the given number order
20) In the OPAC, return to the patron creation form (step 11)
    ---> At the end of the form, notice that the fields are in the
         given number order

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Comment 9 Phan Tung Bui 2024-02-22 21:29:36 UTC
Created attachment 162348 [details] [review]
Bug 35145: (follow-up) Quiet perltidy warnings

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Comment 10 Phan Tung Bui 2024-02-22 21:32:47 UTC
I have successfully resolved the merge conflict.
Comment 11 Pedro Amorim 2024-02-26 09:49:50 UTC
Jonathan's reasons for FQA have not been addressed.
Comment 12 Phan Tung Bui 2024-02-29 21:23:37 UTC
Created attachment 162619 [details] [review]
- Seperate DBIC file

- Rename “number” to “display_order”
Comment 13 Phan Tung Bui 2024-02-29 21:23:39 UTC
Created attachment 162620 [details] [review]
Bug 35145: (follow-up) Quiet perltidy warnings

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Comment 14 Phan Tung Bui 2024-02-29 21:23:42 UTC
Created attachment 162621 [details] [review]
Bug 35145 : Schema file
Comment 15 Phan Tung Bui 2024-02-29 21:23:44 UTC
Created attachment 162622 [details] [review]
Bug 35145 : (follow-up) Rename number to display_order
Comment 16 Phan Tung Bui 2024-02-29 21:58:46 UTC
Hello, 
So per request of the QA, i renamed number to display_order and separate the DBIC schema file. However, I seem to have accidentally reattached the patch made by Emily-Rose and Owen Leonard while trying to resolve a merge conflict earlier, as you can see in my previous comment. Now I'm not sure what to do. 

Please verify that and proceed accordingly. Thank you for your understanding
Comment 17 Pedro Amorim 2024-03-01 10:19:29 UTC
Applying: Bug 35145 : Schema file
Using index info to reconstruct a base tree...
M       Koha/Schema/Result/BorrowerAttributeType.pm
Falling back to patching base and 3-way merge...
Auto-merging Koha/Schema/Result/BorrowerAttributeType.pm
CONFLICT (content): Merge conflict in Koha/Schema/Result/BorrowerAttributeType.pm
error: Failed to merge in the changes.
Patch failed at 0001 Bug 35145 : Schema file

Patches don't apply on current master.
Can you please submit a squashed version of the patches or make obsolete those not needed.
Reach out on IRC, we can help with this if needed.
Comment 18 Phan Tung Bui 2024-03-01 15:51:38 UTC
Created attachment 162676 [details] [review]
Bug 35145 : (follow-up) Rename number to display_order

- Seperate DBIC file

- Rename “number” to “display_order”
Comment 19 Pedro Amorim 2024-05-03 10:12:17 UTC
Failing QA here:

1) Atomicupdate is not idempotent (look at unless( column_exists) from other db_revs entries).
If you run updatedatabase twice in a row you get the following error:
Duplicate column name 'display_order

2) Tests need to be added/updated, e.g.
prove t/db_dependent/Koha/Patron/Attribute.t
is failing with the message Unknown type int for display_order in BorrowerAttributeType.

Look at bug 32610 for a starting point on where to add/check stuff.

Reach out on mattermost if you need additional help.
Comment 20 Hammat wele 2024-05-09 20:10:25 UTC
Created attachment 166473 [details] [review]
Bug 35145: (follow-up) Fix atomicupdate file and display_order's data type
Comment 21 Pedro Amorim 2024-05-10 09:43:15 UTC
Created attachment 166519 [details] [review]
Bug 35145: Schema file

PA amended: Fix commit title

Signed-off-by: Pedro Amorim <pedro.amorim@ptfs-europe.com>
Comment 22 Pedro Amorim 2024-05-10 09:43:18 UTC
Created attachment 166520 [details] [review]
Bug 35145: (follow-up) Rename number to display_order

PA amended: Fix commit title

Signed-off-by: Pedro Amorim <pedro.amorim@ptfs-europe.com>
Comment 23 Pedro Amorim 2024-05-10 09:43:21 UTC
Created attachment 166521 [details] [review]
Bug 35145: (follow-up) Fix atomicupdate file and display_order's data type

PA amended: Added DEFAULT NULL COMMENT 'the order in which this attribute type appears in patron form'
to column entry to match what's in kohastructure.sql

Signed-off-by: Pedro Amorim <pedro.amorim@ptfs-europe.com>
Comment 24 Lucas Gass 2024-05-13 23:00:19 UTC
The schema stuff was separated but then there is a follow-up where it is again included with the DB update stuff. Should the schema ( Schema/Result/BorrowerAttributeType.pm ) stuff be completely separated?