Bug 19909

Summary: Show attributes in patron search results
Product: Koha Reporter: Julian Maurice <julian.maurice>
Component: PatronsAssignee: Julian Maurice <julian.maurice>
Status: Failed QA --- QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low CC: axelle.clarisse, fridolin.somers, gmcharlt, jonathan.druart, katrin.fischer, kyle.m.hall, sandboxes, victor
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: Trivial patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Attachments: Bug 19909: Show attributes in patron search results
Bug 19909: Show attributes in patron search results
Bug 19909: Show attributes in patron search results
Bug 19909: Show attributes in patron search results
Bug 19909: Show attributes in patron search results
Bug 19909: Show attributes in patron search results
Bug 19909: Show attributes in patron search results

Description Julian Maurice 2018-01-03 11:14:29 UTC
This will add a new column (hidden by default) in the results table to
displays all attributes associated to the corresponding patron.
Comment 1 Julian Maurice 2018-01-03 11:15:01 UTC
Created attachment 70243 [details] [review]
Bug 19909: Show attributes in patron search results

Add a new column (hidden by default) in the results table which
displays all attributes associated to the corresponding patron.

New subroutine Koha::Patron::Attribute::display_value that
returns the authorised value description and defaults to the raw value
if the attribute's type is not associated to an authorised value
category

Test plan:
1. Create some patron attribute types, with and without an associated
authorised value category
2. Choose an existing patron and set a value for each attribute
3. Go to patron search and do a search that will return your patron (and
some others to avoid the redirection)
4. Show column 'Extended attributes' by clicking on 'Column visibility'
button
5. Note that all attributes are displayed correctly
6. prove t/db_dependent/Koha/Patron/Attributes.t
Comment 2 Axelle Aix-Marseille Université 2018-03-12 11:16:07 UTC
Patch doesn't apply on sandbox biblibre n°1
Comment 3 Victor Grousset/tuxayo 2018-03-12 11:36:12 UTC
conflicts:
~/d/koha ❯❯❯ git bz apply 19909                                                                                                                                                        ✘ 141 
Bug 19909 - Show attributes in patron search results

70243 - Bug 19909: Show attributes in patron search results

Apply? [(y)es, (n)o, (i)nteractive] y
Application de  Bug 19909: Show attributes in patron search results
Utilisation de l'information de l'index pour reconstruire un arbre de base...
M	C4/Utils/DataTables/Members.pm
M	admin/columns_settings.yml
M	koha-tmpl/intranet-tmpl/prog/en/modules/members/member.tt
.git/rebase-apply/patch:182: new blank line at EOF.
+
warning: 1 ligne a ajouté des erreurs d'espace.
Retour à un patch de la base et fusion à 3 points...
Fusion automatique de koha-tmpl/intranet-tmpl/prog/en/modules/members/member.tt
CONFLIT (contenu) : Conflit de fusion dans koha-tmpl/intranet-tmpl/prog/en/modules/members/member.tt
Fusion automatique de admin/columns_settings.yml
Fusion automatique de C4/Utils/DataTables/Members.pm
error: Échec d'intégration des modifications.
le patch a échoué à 0001 Bug 19909: Show attributes in patron search results
La copie du patch qui a échoué se trouve dans : .git/rebase-apply/patch
When you have resolved this problem run "git bz apply --continue".
If you would prefer to skip this patch, instead run "git bz apply --skip".
To restore the original branch and stop patching run "git bz apply --abort".
Patch left in /tmp/Bug-19909-Show-a
Comment 4 Fridolin Somers 2018-07-20 12:44:53 UTC
Created attachment 77161 [details] [review]
Bug 19909: Show attributes in patron search results

Add a new column (hidden by default) in the results table which
displays all attributes associated to the corresponding patron.

New subroutine Koha::Patron::Attribute::display_value that
returns the authorised value description and defaults to the raw value
if the attribute's type is not associated to an authorised value
category

Test plan:
1. Create some patron attribute types, with and without an associated
authorised value category
2. Choose an existing patron and set a value for each attribute
3. Go to patron search and do a search that will return your patron (and
some others to avoid the redirection)
4. Show column 'Extended attributes' by clicking on 'Column visibility'
button
5. Note that all attributes are displayed correctly
6. prove t/db_dependent/Koha/Patron/Attributes.t
Comment 5 Fridolin Somers 2018-07-20 12:46:07 UTC
Nice enhancement, rebased master.
Comment 6 Biblibre Sandboxes 2018-08-03 10:56:12 UTC
Patch tested with a sandbox, by Cab Vinton <bibliwho@gmail.com>
Comment 7 Biblibre Sandboxes 2018-08-03 10:56:36 UTC
Created attachment 77467 [details] [review]
Bug 19909: Show attributes in patron search results

Add a new column (hidden by default) in the results table which
displays all attributes associated to the corresponding patron.

New subroutine Koha::Patron::Attribute::display_value that
returns the authorised value description and defaults to the raw value
if the attribute's type is not associated to an authorised value
category

Test plan:
1. Create some patron attribute types, with and without an associated
authorised value category
2. Choose an existing patron and set a value for each attribute
3. Go to patron search and do a search that will return your patron (and
some others to avoid the redirection)
4. Show column 'Extended attributes' by clicking on 'Column visibility'
button
5. Note that all attributes are displayed correctly
6. prove t/db_dependent/Koha/Patron/Attributes.t

Signed-off-by: Cab Vinton <bibliwho@gmail.com>
Comment 8 Jonathan Druart 2018-08-06 17:35:53 UTC
(just linking similar stuffs - https://gitlab.com/joubu/Koha/blob/bug_20443/Koha/Patron/Attribute.pm)
Comment 9 Katrin Fischer 2018-08-28 06:26:07 UTC
This is working well for me and is a really nice addition.

Wondering 2 things:
- We got a system preference for turning on/off patron attributes. Should the column not be visible when the pref is turned off? (ExtendedPatronAttributes)
- The display_value method somehow looks not quite right to me. I think this may be what Jonathan was trying to point out in his comment, that there could be another way of doing it. Could you take a look and comment?

I rebased the patch for testing, I will attach the rebased patch.
Comment 10 Katrin Fischer 2018-08-28 06:26:37 UTC
Created attachment 78213 [details] [review]
Bug 19909: Show attributes in patron search results

Add a new column (hidden by default) in the results table which
displays all attributes associated to the corresponding patron.

New subroutine Koha::Patron::Attribute::display_value that
returns the authorised value description and defaults to the raw value
if the attribute's type is not associated to an authorised value
category

Test plan:
1. Create some patron attribute types, with and without an associated
authorised value category
2. Choose an existing patron and set a value for each attribute
3. Go to patron search and do a search that will return your patron (and
some others to avoid the redirection)
4. Show column 'Extended attributes' by clicking on 'Column visibility'
button
5. Note that all attributes are displayed correctly
6. prove t/db_dependent/Koha/Patron/Attributes.t

Signed-off-by: Cab Vinton <bibliwho@gmail.com>
Comment 11 Julian Maurice 2020-05-22 13:36:45 UTC
Created attachment 105267 [details] [review]
Bug 19909: Show attributes in patron search results

Add a new column (hidden by default) in the results table which
displays all attributes associated to the corresponding patron.

Test plan:
1. Enable ExtendedPatronAttributes
2. Create some patron attribute types, with and without an associated
authorised value category
3. Choose an existing patron and set a value for each attribute
4. Go to patron search and do a search that will return your patron (and
some others to avoid the redirection)
5. Show column 'Extended attributes' by clicking on 'Column visibility'
button
6. Note that all attributes are displayed correctly
7. prove t/db_dependent/Koha/Patron/Attributes.t
8. Disable syspref ExtendedPatronAttributes and verify that the column
   is not displayed

Signed-off-by: Cab Vinton <bibliwho@gmail.com>
Comment 12 Julian Maurice 2020-05-22 13:43:44 UTC
(In reply to Katrin Fischer from comment #9)
> This is working well for me and is a really nice addition.
> 
> Wondering 2 things:
> - We got a system preference for turning on/off patron attributes. Should
> the column not be visible when the pref is turned off?
> (ExtendedPatronAttributes)

I added checks for this syspref. The column should be hidden now when syspref is disabled

> - The display_value method somehow looks not quite right to me. I think this
> may be what Jonathan was trying to point out in his comment, that there
> could be another way of doing it. Could you take a look and comment?

I removed it. There is now a 'description' method which does the same thing.
Comment 13 Lucas Gass 2020-05-22 21:02:49 UTC
Created attachment 105281 [details] [review]
Bug 19909: Show attributes in patron search results

Add a new column (hidden by default) in the results table which
displays all attributes associated to the corresponding patron.

Test plan:
1. Enable ExtendedPatronAttributes
2. Create some patron attribute types, with and without an associated
authorised value category
3. Choose an existing patron and set a value for each attribute
4. Go to patron search and do a search that will return your patron (and
some others to avoid the redirection)
5. Show column 'Extended attributes' by clicking on 'Column visibility'
button
6. Note that all attributes are displayed correctly
7. prove t/db_dependent/Koha/Patron/Attributes.t
8. Disable syspref ExtendedPatronAttributes and verify that the column
   is not displayed

Signed-off-by: Cab Vinton <bibliwho@gmail.com>

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Comment 14 Katrin Fischer 2020-07-04 21:27:51 UTC
Created attachment 106528 [details] [review]
Bug 19909: Show attributes in patron search results

Add a new column (hidden by default) in the results table which
displays all attributes associated to the corresponding patron.

Test plan:
1. Enable ExtendedPatronAttributes
2. Create some patron attribute types, with and without an associated
authorised value category
3. Choose an existing patron and set a value for each attribute
4. Go to patron search and do a search that will return your patron (and
some others to avoid the redirection)
5. Show column 'Extended attributes' by clicking on 'Column visibility'
button
6. Note that all attributes are displayed correctly
7. prove t/db_dependent/Koha/Patron/Attributes.t
8. Disable syspref ExtendedPatronAttributes and verify that the column
   is not displayed

Signed-off-by: Cab Vinton <bibliwho@gmail.com>

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 15 Jonathan Druart 2020-07-20 13:42:51 UTC
Salut Julian,

Could you add a unit test and replace 
+            $patron->{attributes} = Koha::Patron::Attributes->search({ borrowernumber => $patron_object->borrowernumber });

with a call to $patron->extended_attributes?


Also a question:
  const extendedAttributesColumnIndex = columns_settings.findIndex(column => column.columnname === 'extended_attributes');
  columns_settings.splice(extendedAttributesColumnIndex, 1);

findIndex returns -1 if not found. It should not happen I'd say, but should not we prevent side-effects and check if extendedAttributesColumnIndex != -1?