Bugzilla – Attachment 159344 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), 10.17 KB, created by
Owen Leonard
on 2023-11-29 16:00:24 UTC
(
hide
)
Description:
Bug 35145: Add ability to order patron attribute types
Filename:
MIME Type:
Creator:
Owen Leonard
Created:
2023-11-29 16:00:24 UTC
Size:
10.17 KB
patch
obsolete
>From 5adff413140c2222c398752a31bc9a533ba226b1 Mon Sep 17 00:00:00 2001 >From: Emily-Rose Francoeur <emily-rose.francoeur@inLibro.com> >Date: Tue, 21 Nov 2023 15:13:43 -0500 >Subject: [PATCH] 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> >--- > Koha/Schema/Result/BorrowerAttributeType.pm | 10 ++++++++++ > admin/patron-attr-types.pl | 2 ++ > .../bug_35145_order_patron_attributes.pl | 20 +++++++++++++++++++ > installer/data/mysql/kohastructure.sql | 1 + > .../en/modules/admin/patron-attr-types.tt | 11 ++++++++++ > members/memberentry.pl | 2 +- > opac/opac-memberentry.pl | 2 +- > 7 files changed, 46 insertions(+), 2 deletions(-) > create mode 100755 installer/data/mysql/atomicupdate/bug_35145_order_patron_attributes.pl > >diff --git a/Koha/Schema/Result/BorrowerAttributeType.pm b/Koha/Schema/Result/BorrowerAttributeType.pm >index ad609f0a78..dbf5383459 100644 >--- a/Koha/Schema/Result/BorrowerAttributeType.pm >+++ b/Koha/Schema/Result/BorrowerAttributeType.pm >@@ -137,6 +137,14 @@ defines if this field is copied to anonymized_borrower_attributes (1 for yes, 0 > > defines if the attribute is mandatory or not > >+=head2 number >+ >+ data_type: 'int' >+ default_value: NULL >+ is_nullable: 1 >+ >+ the order in which this attribute type appears in patron form >+ > =cut > > __PACKAGE__->add_columns( >@@ -168,6 +176,8 @@ __PACKAGE__->add_columns( > { data_type => "tinyint", default_value => 0, is_nullable => 0 }, > "mandatory", > { data_type => "tinyint", default_value => 0, is_nullable => 0 }, >+ "number", >+ { data_type => "int", is_nullable => 1 }, > ); > > =head1 PRIMARY KEY >diff --git a/admin/patron-attr-types.pl b/admin/patron-attr-types.pl >index ca5d2fca47..720a929715 100755 >--- a/admin/patron-attr-types.pl >+++ b/admin/patron-attr-types.pl >@@ -124,6 +124,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 $number = $input->param('number') || undef; > > my $attr_type = Koha::Patron::Attribute::Types->find($code); > if ( $op eq 'edit' ) { >@@ -160,6 +161,7 @@ sub add_update_attribute_type { > display_checkout => $display_checkout, > category_code => $category_code, > class => $class, >+ number => $number, > } > )->store; > >diff --git a/installer/data/mysql/atomicupdate/bug_35145_order_patron_attributes.pl b/installer/data/mysql/atomicupdate/bug_35145_order_patron_attributes.pl >new file mode 100755 >index 0000000000..ac5a0520e2 >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/bug_35145_order_patron_attributes.pl >@@ -0,0 +1,20 @@ >+use Modern::Perl; >+ >+return { >+ bug_number => "35145", >+ description => "Add number column to borrower_attribute_types table", >+ up => sub { >+ my ($args) = @_; >+ my ( $dbh, $out ) = @$args{qw(dbh out)}; >+ >+ # Do you stuffs here >+ $dbh->do(q{ >+ ALTER TABLE borrower_attribute_types >+ ADD number int(11); >+ }); >+ >+ # Print useful stuff here >+ # tables >+ say $out "Added column 'borrower_attribute_types.number'"; >+ }, >+}; >diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql >index 09a6adcc47..a1e7ab720d 100644 >--- a/installer/data/mysql/kohastructure.sql >+++ b/installer/data/mysql/kohastructure.sql >@@ -1241,6 +1241,7 @@ CREATE TABLE `borrower_attribute_types` ( > `class` varchar(255) NOT NULL DEFAULT '' COMMENT 'defines a class for an attribute_type', > `keep_for_pseudonymization` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'defines if this field is copied to anonymized_borrower_attributes (1 for yes, 0 for no)', > `mandatory` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'defines if the attribute is mandatory or not', >+ `number` int(11) DEFAULT NULL COMMENT 'the order in which this attribute type appears in patron form', > PRIMARY KEY (`code`), > KEY `auth_val_cat_idx` (`authorised_value_category`), > KEY `category_code` (`category_code`), >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 fe792072b1..d082915b37 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 >@@ -103,6 +103,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="number">Appear in position: </label> >+ [% IF ( attribute_type.number ) %] >+ <input id="number" size="3" name="number" type="text" value="[% attribute_type.number | html %]" /> >+ [% ELSE %] >+ <input id="number" size="3" name="number" type="text" /> >+ [% END %] >+ </li> > > [% IF attribute_type AND attribute_type.repeatable AND NOT can_be_set_to_nonrepeatable %] > <li aria-disabled="true"> >@@ -316,6 +324,7 @@ > <th>Authorized value category</th> > <th>Mandatory</th> > <th>Searching</th> >+ <th>Number</th> > <th class="NoSort noExport">Actions</th> > </tr> > </thead> >@@ -366,6 +375,7 @@ > <span>Not searchable</span> > [% END %] > </td> >+ <td>[% item.number | 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> >@@ -431,6 +441,7 @@ > $(".patron_attributes_types").each(function(){ > var tableid = $(this).attr("id"); > KohaTable( tableid, { >+ "sorting": [[ 6, "asc" ]], > "bPaginate": false, > 'autoWidth': false, > }, null ); >diff --git a/members/memberentry.pl b/members/memberentry.pl >index 57e780cfec..790b47f046 100755 >--- a/members/memberentry.pl >+++ b/members/memberentry.pl >@@ -866,7 +866,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 => 'number' }, $library_id); > if ( $attribute_types->count == 0 ) { > $template->param(no_patron_attribute_types => 1); > return; >diff --git a/opac/opac-memberentry.pl b/opac/opac-memberentry.pl >index a0f5a3ace2..9e6927cd43 100755 >--- a/opac/opac-memberentry.pl >+++ b/opac/opac-memberentry.pl >@@ -670,7 +670,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 => 'number' } )->as_list(); > if ( scalar(@types) == 0 ) { > return []; > } >-- >2.30.2
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