Bugzilla – Attachment 170332 Details for
Bug 35145
Add ability to order patron attributes
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 35145: Add ability to order patron attribute types
Bug-35145-Add-ability-to-order-patron-attribute-ty.patch (text/plain), 8.40 KB, created by
Hammat wele
on 2024-08-14 20:12:17 UTC
(
hide
)
Description:
Bug 35145: Add ability to order patron attribute types
Filename:
MIME Type:
Creator:
Hammat wele
Created:
2024-08-14 20:12:17 UTC
Size:
8.40 KB
patch
obsolete
>From 784e6192a0e0591c11c46b10b35348a3ae8447fb Mon Sep 17 00:00:00 2001 >From: Hammat Wele <hammat.wele@inlibro.com> >Date: Wed, 14 Aug 2024 20:06:43 +0000 >Subject: [PATCH] Bug 35145: Add ability to order patron attribute types > >Here is a summary of the changes: > - Added the new column 'display_order' 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 'Display order' for > '/cgi-bin/koha/admin/patron-attr-types.pl' table > ---> The table now defaults to sorting based on the 'display_order' 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 > display_order > >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 'Display order' 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 > display_order 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 >--- > admin/patron-attr-types.pl | 2 ++ > .../prog/en/modules/admin/patron-attr-types.tt | 10 ++++++++++ > members/memberentry.pl | 2 +- > members/moremember.pl | 7 +++++-- > opac/opac-memberentry.pl | 2 +- > 5 files changed, 19 insertions(+), 4 deletions(-) > >diff --git a/admin/patron-attr-types.pl b/admin/patron-attr-types.pl >index d591383e48..fc3d391bf0 100755 >--- a/admin/patron-attr-types.pl >+++ b/admin/patron-attr-types.pl >@@ -125,6 +125,7 @@ sub add_update_attribute_type { > my $display_checkout = $input->param('display_checkout') ? 1 : 0; > my $category_code = $input->param('category_code') || undef; > my $class = $input->param('class'); >+ my $display_order = $input->param('display_order') || undef; > > my $attr_type = Koha::Patron::Attribute::Types->find($code); > if ( $op eq 'edit' ) { >@@ -162,6 +163,7 @@ sub add_update_attribute_type { > display_checkout => $display_checkout, > category_code => $category_code, > class => $class, >+ display_order => $display_order, > } > )->store; > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/patron-attr-types.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/patron-attr-types.tt >index 1a6d2a7460..9fac4c1bed 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/patron-attr-types.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/patron-attr-types.tt >@@ -105,6 +105,14 @@ > <input type="text" id="description" name="description" required="required" class="required" size="50" maxlength="250" value="[% attribute_type.description |html %]" /> > <span class="required">Required</span> > </li> >+ <li> >+ <label for="display_order">Appear in position: </label> >+ [% IF ( attribute_type.display_order ) %] >+ <input id="display_order" size="3" name="display_order" type="text" value="[% attribute_type.display_order | html %]" /> >+ [% ELSE %] >+ <input id="display_order" size="3" name="display_order" type="text" /> >+ [% END %] >+ </li> > > [% IF attribute_type AND attribute_type.repeatable AND NOT can_be_set_to_nonrepeatable %] > <li aria-disabled="true"> >@@ -326,6 +334,7 @@ > <th>Authorized value category</th> > <th>Mandatory</th> > <th>Searching</th> >+ <th>Display order</th> > <th class="NoSort noExport">Actions</th> > </tr> > </thead> >@@ -376,6 +385,7 @@ > <span>Not searchable</span> > [% END %] > </td> >+ <td>[% item.display_order | html %]</td> > <td class="actions"> > <a class="btn btn-default btn-xs" href="[% script_name | url %]?op=edit_attribute_type&code=[% item.code | uri %]"><i class="fa-solid fa-pencil" aria-hidden="true"></i> Edit</a> > <a class="btn btn-default btn-xs" href="[% script_name | url %]?op=delete_attribute_type&code=[% item.code | uri %]"><i class="fa fa-trash-can"></i> Delete</a> >diff --git a/members/memberentry.pl b/members/memberentry.pl >index f647234691..b62d8bbe64 100755 >--- a/members/memberentry.pl >+++ b/members/memberentry.pl >@@ -856,7 +856,7 @@ sub patron_attributes_form { > my $op = shift; > > my $library_id = C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef; >- my $attribute_types = Koha::Patron::Attribute::Types->search_with_library_limits({}, {}, $library_id); >+ my $attribute_types = Koha::Patron::Attribute::Types->search_with_library_limits({}, { order_by => 'display_order' }, $library_id); > if ( $attribute_types->count == 0 ) { > $template->param(no_patron_attribute_types => 1); > return; >diff --git a/members/moremember.pl b/members/moremember.pl >index 773bc4190d..934e0cce9d 100755 >--- a/members/moremember.pl >+++ b/members/moremember.pl >@@ -140,14 +140,17 @@ unless ( Koha::Patron::Categories->search_with_library_limits( { 'me.categorycod > > if (C4::Context->preference('ExtendedPatronAttributes')) { > my @attributes = $patron->extended_attributes->as_list; # FIXME Must be improved! >+ my $attribute_types = Koha::Patron::Attribute::Types->search({}, { order_by => 'display_order' }); > my @classes = uniq( map {$_->type->class} @attributes ); > @classes = sort @classes; > > my @attributes_loop; > for my $class (@classes) { > my @items; >- for my $attr (@attributes) { >- push @items, $attr if $attr->type->class eq $class >+ while ( my ( $attr_type ) = $attribute_types->next ) { >+ for my $attr (@attributes) { >+ push @items, $attr if ($attr->type->class eq $class && $attr_type->code() eq $attr->type->code) >+ } > } > my $av = Koha::AuthorisedValues->search({ category => 'PA_CLASS', authorised_value => $class }); > my $lib = $av->count ? $av->next->lib : $class; >diff --git a/opac/opac-memberentry.pl b/opac/opac-memberentry.pl >index b671dde7c0..12364b864a 100755 >--- a/opac/opac-memberentry.pl >+++ b/opac/opac-memberentry.pl >@@ -651,7 +651,7 @@ sub GeneratePatronAttributesForm { > > # Get all attribute types and the values for this patron (if applicable) > my @types = grep { $_->opac_editable() or $_->opac_display } # FIXME filter using DBIC >- Koha::Patron::Attribute::Types->search()->as_list(); >+ Koha::Patron::Attribute::Types->search( {}, { order_by => 'display_order' } )->as_list(); > if ( scalar(@types) == 0 ) { > return []; > } >-- >2.34.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 35145
:
159182
|
159193
|
159344
|
159345
|
162347
|
162348
|
162619
|
162620
|
162621
|
162622
|
162676
|
166473
|
166519
|
166520
|
166521
|
169256
|
169257
|
169258
|
170330
|
170331
|
170332
|
170627
|
170628
|
170629
|
176756
|
176757
|
176758
|
176760
|
176761
|
176762
|
176763
|
176764
|
176765
|
177119