Bugzilla – Attachment 118963 Details for
Bug 19368
Add syspref to ignore words when sorting serials
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 19368 - Ignore words when sorting serial search
Bug-19368---Ignore-words-when-sorting-serial-searc.patch (text/plain), 14.35 KB, created by
Alexis Ripetti
on 2021-03-29 15:05:50 UTC
(
hide
)
Description:
Bug 19368 - Ignore words when sorting serial search
Filename:
MIME Type:
Creator:
Alexis Ripetti
Created:
2021-03-29 15:05:50 UTC
Size:
14.35 KB
patch
obsolete
>From 01e7e37056dc3326c1dbb3fad8c5288b6da58b7a Mon Sep 17 00:00:00 2001 >From: David Bourgault <david.bourgault@inlibro.com> >Date: Tue, 26 Sep 2017 13:43:05 -0400 >Subject: [PATCH] Bug 19368 - Ignore words when sorting serial search >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >This adds the 'SerialSortIgnoreWords' system preference. >It is empty by default, since words to ignore are very much language-specific. > >The functionality is achieved by adding a hidden column to the table, and sorting by this column by default. The downfall of this solution is that if the user sorts by another column, they cannot go back to this sorting without refreshing the page. > >To test: >0) Apply patch >1) Run updatedatabase.pl >2) Add test subscriptions if you have none. > Make sure to have subscriptions starting with "The An A" or similar >3) Go to system preferences and edit the SerialSortIgnoreWords pref > Add the words "The An A" or the ones you used in your subscriptions >4) Go to Serials >5) Search serials (empty field will return all serials) >6) Result table should be sorted ignoring leading "The An A..." > >Followed test plan, patch works as described >Signed-off-by: Alex Buckley <alexbuckley@catalyst.net.nz> > >Signed-off-by: Séverine QUEUNE <severine.queune@bulac.fr> >--- > .../BugUndef-SerialSortIgnoreWords.sql | 1 + > installer/data/mysql/mandatory/sysprefs.sql | 1 + > .../en/modules/admin/preferences/serials.pref | 5 + > .../prog/en/modules/serials/serials-search.tt | 117 +++++++++++++++++- > serials/serials-search.pl | 36 ++++-- > 5 files changed, 151 insertions(+), 9 deletions(-) > create mode 100644 installer/data/mysql/atomicupdate/BugUndef-SerialSortIgnoreWords.sql > >diff --git a/installer/data/mysql/atomicupdate/BugUndef-SerialSortIgnoreWords.sql b/installer/data/mysql/atomicupdate/BugUndef-SerialSortIgnoreWords.sql >new file mode 100644 >index 0000000000..5bcdfda506 >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/BugUndef-SerialSortIgnoreWords.sql >@@ -0,0 +1 @@ >+INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES ('SerialSortIgnoreWords','',NULL,'Words to ignore in serial search','Free'); >\ No newline at end of file >diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql >index 1034313061..73ac110768 100644 >--- a/installer/data/mysql/mandatory/sysprefs.sql >+++ b/installer/data/mysql/mandatory/sysprefs.sql >@@ -600,6 +600,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` > ('SendAllEmailsTo','',NULL,'All emails will be redirected to this email if it is not empty','free'), > ('SeparateHoldings','0',NULL,'Separate current branch holdings from other holdings','YesNo'), > ('SeparateHoldingsBranch','homebranch','homebranch|holdingbranch','Branch used to separate holdings','Choice'), >+('SerialSortIgnoreWords','des du de la le les leur d l an a the',NULL,'Words to ignore in serial search','Free'), > ('SessionRestrictionByIP','1','Check for change in remote IP address for session security. Disable only when remote IP address changes frequently.','','YesNo'), > ('SessionStorage','mysql','mysql|Pg|tmp','Use database or a temporary file for storing session data','Choice'), > ('ShelfBrowserUsesCcode','1','0','Use the item collection code when finding items for the shelf browser.','YesNo'), >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/serials.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/serials.pref >index f6e818827c..a524ccf1a2 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/serials.pref >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/serials.pref >@@ -62,3 +62,8 @@ Serials: > 1: Do > 0: Don't > - prefill the notes from the last 'Arrived' serial when generating the next 'Expected' issue. >+ - >+ - 'Ignore the following words when sorting the serial search result table (separate words with spaces) :' >+ - pref: SerialSortIgnoreWords >+ class: free >+ - >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-search.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-search.tt >index 3a538e1e8e..132c2e1680 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-search.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-search.tt >@@ -289,7 +289,120 @@ > [% ELSE %] > <div id="opened"> > [% IF openedsubscriptions %] >- [% INCLUDE subscriptions_table subscriptions = openedsubscriptions %] >+ <table id="osrlt"> >+ <thead> >+ <tr> >+ <th>Sort</th> >+ <th>ISSN</th> >+ <th class="anti-the">Title</th> >+ <th>Notes</th> >+ <th>Library</th> >+ <th>Location</th> >+ <th>Call number</th> >+ <th class="title-string">Expiration date</th> >+ [% FOR field IN additional_fields_for_subscription %] >+ <th>[% field.name %]</th> >+ [% END %] >+ <th class="NoSort">Actions</th> >+ </tr> >+ </thead> >+ <tfoot> >+ <tr> >+ <td><input type="text" class="dt-filter" data-column_num="0" placeholder="Search ISSN" /></td> >+ <td><input type="text" class="dt-filter" data-column_num="1" placeholder="Search title" /></td> >+ <td><input type="text" class="dt-filter" data-column_num="2" placeholder="Search notes" /></td> >+ <td><input type="text" class="dt-filter" data-column_num="3" placeholder="Search library" /></td> >+ <td><input type="text" class="dt-filter" data-column_num="4" placeholder="Search location" /></td> >+ <td><input type="text" class="dt-filter" data-column_num="5" placeholder="Search callnumber" /></td> >+ <td><input type="text" class="dt-filter" data-column_num="6" placeholder="Search expiration date" /></td> >+ [% FOR field IN additional_fields_for_subscription %] >+ <td><input type="text" class="dt-filter" data-column_num="[% loop.count + 6 %]" placeholder="Search [% field.name %]" /></td> >+ [% END %] >+ <td colspan="2"></td> >+ </tr> >+ </tfoot> >+ <tbody> >+ [% FOREACH subscription IN openedsubscriptions %] >+ [% UNLESS subscription.cannotdisplay %] >+ <tr> >+ <td>[% IF ( subscription.titlesort ) %][% subscription.titlesort %][% END %]</td> >+ <td> >+ [% IF ( subscription.issn ) %][% subscription.issn %] >+ [% END %] >+ </td> >+ <td><a href="/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=[% subscription.subscriptionid %]" class="button" title="subscription detail">[% subscription.title |html %]</a> >+ </td> >+ <td>[% IF ( subscription.publicnotes ) %][% subscription.publicnotes %][% END %] >+ [% IF ( subscription.internalnotes ) %]([% subscription.internalnotes %])[% END %] >+ </td> >+ <td> >+ [% IF ( subscription.branchcode ) %][% Branches.GetName( subscription.branchcode ) %][% END %] >+ </td> >+ <td> >+ [% IF ( subscription.location ) %][% AuthorisedValues.GetByCode( 'LOC', subscription.location ) %][% END %] >+ </td> >+ <td> >+ [% IF ( subscription.callnumber ) %][% subscription.callnumber %][% END %] >+ </td> >+ <td> >+ [% IF ( subscription.enddate ) %] >+ <span title="[% subscription.enddate %]">[% subscription.enddate | $KohaDates %]</span> >+ [% ELSE %] >+ <span title="0000-00-00"></span> >+ [% END %] >+ </td> >+ >+ [% FOR field IN additional_fields_for_subscription %] >+ [% IF field.authorised_value_category %] >+ <td>[% AuthorisedValues.GetByCode( field.authorised_value_category, subscription.additional_fields.${field.name} ) %]</td> >+ [% ELSE %] >+ <td>[% subscription.additional_fields.${field.name} %]</td> >+ [% END %] >+ [% END %] >+ >+ <td> >+ <div class="dropdown"> >+ <div class="btn-group"> >+ [% IF ( CAN_user_serials_receive_serials ) %] >+ [%# There should be no space between these two buttons, it would render badly %] >+ <a class="btn btn-default btn-xs" role="button" >+ href="/cgi-bin/koha/serials/serials-edit.pl?subscriptionid=[% subscription.subscriptionid %]&serstatus=1,3,7"><i >+ class="fa fa-inbox"></i> Serial receive</a><a >+ class="btn btn-default btn-xs dropdown-toggle" id="subactions[% subscription.subscriptionid %]" role="button" >+ data-toggle="dropdown" href="#"><b class="caret"></b></a> >+ [% ELSE %] >+ <a class="btn btn-default btn-xs dropdown-toggle" id="subactions[% subscription.subscriptionid %]" role="button" data-toggle="dropdown" href="#">Actions <b class="caret"></b></a> >+ [% END %] >+ <ul class="dropdown-menu pull-right" role="menu" aria-labelledby="subactions[% subscription.subscriptionid %]"> >+ >+ [% IF ( routing && CAN_user_serials_routing ) %] >+ [% IF ( subscription.cannotedit ) %] >+ [% ELSE %] >+ [% IF ( subscription.routingedit ) %] >+ <li> >+ <a href="/cgi-bin/koha/serials/routing.pl?subscriptionid=[% subscription.subscriptionid %]"><i class="fa fa-pencil"></i> Edit routing list ([% subscription.routingedit %])</a> >+ </li> >+ [% ELSE %] >+ <li> >+ <a href="/cgi-bin/koha/serials/routing.pl?subscriptionid=[% subscription.subscriptionid %]&op=new"> <i class="fa fa-plus"></i> New routing list</a> >+ </li> >+ [% END %] >+ [% END %] >+ [% END # IF ( routing && CAN_user_serials_routing ) %] >+ >+ <li> >+ <a href="/cgi-bin/koha/serials/serials-collection.pl?subscriptionid=[% subscription.subscriptionid %]"><i class="fa fa-list-alt"></i> Issue history</a> >+ </li> >+ </ul> >+ </div> >+ </div> >+ </td> >+ >+ </tr> >+ [% END %] >+ [% END %] >+ </tbody> >+ </table> > [% ELSE %] > <div class="dialog message"> > <p>Your search returned no open subscriptions.</p> >@@ -444,6 +557,8 @@ > "sPaginationType": "full", > "order": [[ 2, "asc" ]], > "aoColumnDefs": [ >+ { 'visible' : false, "targets" : 0}, >+ { "iDataSort" : 0, 'aTargets' : [ 2 ] }, > { 'bSortable': false, "bSearchable": false, 'aTargets': [ 'NoSort' ] }, > { "sType": "title-string", "aTargets" : [ "title-string" ] }, > { 'sType': "anti-the", 'aTargets' : [ 'anti-the'] } >diff --git a/serials/serials-search.pl b/serials/serials-search.pl >index a0723286ca..2917ad53ab 100755 >--- a/serials/serials-search.pl >+++ b/serials/serials-search.pl >@@ -37,6 +37,9 @@ use C4::Output; > use C4::Serials; > use Koha::AdditionalFields; > >+use Encode; >+use Unicode::Normalize; >+ > use Koha::DateUtils; > use Koha::SharedContent; > >@@ -154,16 +157,33 @@ else > } > } > >- my (@openedsubscriptions, @closedsubscriptions); >- for my $sub ( @subscriptions ) { >- unless ( $sub->{closed} ) { >- push @openedsubscriptions, $sub >- unless $sub->{cannotdisplay}; >- } else { >- push @closedsubscriptions, $sub >- unless $sub->{cannotdisplay}; >+#sort stopword by string length >+my @sortedstopword = sort{ length $b <=> length $a } split ( / / ,C4::Context->preference("SerialSortIgnoreWords")); >+my $subsctitle; >+my (@openedsubscriptions, @closedsubscriptions); >+for my $sub ( @subscriptions ) { >+ $subsctitle = $sub->{title} ? ucfirst($sub->{title}): '' ; >+ if ($subsctitle){ >+ $subsctitle = NFKD($subsctitle); >+ $subsctitle =~ s/\p{NonspacingMark}//g; >+ foreach my $stop (@sortedstopword){ >+ my $ucfirststop = ucfirst($stop); >+ $subsctitle =~ s/$ucfirststop'//; >+ $subsctitle =~ s/$ucfirststop //; > } > } >+ $subsctitle =~ s/^\s+//; >+ $sub->{titlesort} = ucfirst($subsctitle); >+ >+ warn $subsctitle; >+ >+ unless ( $sub->{closed} ) { >+ push @openedsubscriptions, $sub >+ unless $sub->{cannotdisplay}; >+ } else { >+ push @closedsubscriptions, $sub >+ unless $sub->{cannotdisplay}; >+ } > > my @branches = Koha::Libraries->search( {}, { order_by => ['branchcode'] } ); > my @branches_loop; >-- >2.25.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 19368
:
67373
|
67447
|
67580
|
67581
|
67612
|
69005
|
70051
|
70052
|
70053
|
70125
|
71962
|
71963
|
71964
|
71965
|
72043
|
72044
|
72045
|
72046
|
72047
|
72655
|
72656
|
72657
|
72658
|
72659
|
74262
|
74263
|
74264
|
74265
|
74266
|
90915
|
90916
|
90918
|
90919
|
90920
|
90921
|
113018
|
113019
|
113020
|
113021
|
113022
|
113023
|
113344
|
113345
|
113346
|
113347
|
113348
|
113349
|
118963
|
118964
|
118965
|
118966
|
118967
|
118968
|
124090
|
124091
|
124092
|
124093
|
124094
|
124095
|
124096
|
124097
|
124104
|
124105
|
124106
|
124107
|
124108
|
124109
|
124110
|
124111