Bugzilla – Attachment 112585 Details for
Bug 17515
Advanced Editor - Rancor - Z39 sources not sorted properly
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17515: Order Z3950 server by rank and preserve ordering
Bug-17515-Order-Z3950-server-by-rank-and-preserve-.patch (text/plain), 8.40 KB, created by
Nick Clemens (kidclamp)
on 2020-10-27 16:51:05 UTC
(
hide
)
Description:
Bug 17515: Order Z3950 server by rank and preserve ordering
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2020-10-27 16:51:05 UTC
Size:
8.40 KB
patch
obsolete
>From b6de2501ea9b73f2b30fb66acccc2b44d4b112a3 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Tue, 27 Oct 2020 15:59:46 +0000 >Subject: [PATCH] Bug 17515: Order Z3950 server by rank and preserve ordering > >Previously we put all the servers into an object with keys of the server id > >This patch converts it to an array of objects to preserve order, and adjusts code to use the array index >where necessary and store the server id within the array > >To test: >1 - Add some new Z3950 servers, they don't need to be valid > FIRST > SECOND > THIRD > FOURTH >2 - Adjust the ranking so FOURTH:1 THIRD:2 SECOND:3 FIRST:4 >3 - Enable and launch the advanced editor >4 - Click 'Advanced' under search on the left >5 - Note the list displays in the order you entered the servers >6 - Apply patch >7 - Reload >8 - Order is correct >9 - With valid servers, confirm that searching still works and servers can be checked or unchecked to include/remove from results > >https://bugs.koha-community.org/show_bug.cgi?id=17515 >--- > Koha/MetaSearcher.pm | 2 +- > cataloguing/editor.pl | 2 +- > .../intranet-tmpl/lib/koha/cateditor/search.js | 4 +-- > .../prog/en/includes/cateditor-ui.inc | 33 ++++++++++++---------- > svc/cataloguing/metasearch | 1 + > 5 files changed, 23 insertions(+), 19 deletions(-) > >diff --git a/Koha/MetaSearcher.pm b/Koha/MetaSearcher.pm >index 280d1b24c0..f11166087e 100644 >--- a/Koha/MetaSearcher.pm >+++ b/Koha/MetaSearcher.pm >@@ -127,7 +127,7 @@ sub search { > extra => $2, > id => $server_id, > host => $server_id, >- name => $server_id, >+ servername => $server_id, > }; > } > } >diff --git a/cataloguing/editor.pl b/cataloguing/editor.pl >index 454f319c6e..b52c8505de 100755 >--- a/cataloguing/editor.pl >+++ b/cataloguing/editor.pl >@@ -81,7 +81,7 @@ my $dbh = C4::Context->dbh; > $template->{VARS}->{z3950_servers} = $dbh->selectall_arrayref( q{ > SELECT * FROM z3950servers > WHERE recordtype != 'authority' AND servertype = 'zed' >- ORDER BY servername >+ ORDER BY rank,servername > }, { Slice => {} } ); > > output_html_with_http_headers $input, $cookie, $template->output; >diff --git a/koha-tmpl/intranet-tmpl/lib/koha/cateditor/search.js b/koha-tmpl/intranet-tmpl/lib/koha/cateditor/search.js >index f73d0292c1..5b2cdefe4e 100644 >--- a/koha-tmpl/intranet-tmpl/lib/koha/cateditor/search.js >+++ b/koha-tmpl/intranet-tmpl/lib/koha/cateditor/search.js >@@ -73,8 +73,8 @@ define( [ 'koha-backend', 'marc-record' ], function( KohaBackend, MARC ) { > > var itemTag = KohaBackend.GetSubfieldForKohaField('items.itemnumber')[0]; > >- $.each( servers, function ( id, info ) { >- if ( info.checked ) Search.includedServers.push( id ); >+ $.each( servers, function ( index, info ) { >+ if ( info.checked ) Search.includedServers.push( info.server_id ); > } ); > > if ( Search.includedServers.length == 0 ) return false; >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/cateditor-ui.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/cateditor-ui.inc >index b8afedb50b..6f44f4b9da 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/cateditor-ui.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/cateditor-ui.inc >@@ -41,20 +41,22 @@ require.config( { > > <script> > require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'preferences', 'resources', 'text-marc', 'widget' ], function( KohaBackend, Search, Macros, MARCEditor, MARC, Preferences, Resources, TextMARC, Widget ) { >- var z3950Servers = { >- 'koha:biblioserver': { >+ var z3950Servers = [ >+ { >+ server_id: 'koha:biblioserver', > name: _("Local catalog"), > recordtype: 'biblio', > checked: false, > }, > [%- FOREACH server = z3950_servers -%] >- [% server.id | html %]: { >+ { >+ server_id: [% server.id | html %], > name: '[% server.servername | html %]', > recordtype: '[% server.recordtype | html %]', > checked: [% server.checked ? 'true' : 'false' | html %], > }, > [%- END -%] >- }; >+ ]; > > // The columns that should show up in a search, in order, and keyed by the corresponding <metadata> tag in the XSL and Pazpar2 config > var z3950Labels = [ >@@ -405,8 +407,8 @@ require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr > // Search functions > function showAdvancedSearch() { > $('#advanced-search-servers').empty(); >- $.each( z3950Servers, function( server_id, server ) { >- $('#advanced-search-servers').append( '<li data-server-id="' + server_id + '"><label><input class="search-toggle-server" type="checkbox"' + ( server.checked ? ' checked="checked">' : '>' ) + server.name + '</label></li>' ); >+ $.each( z3950Servers, function( index, server ) { >+ $('#advanced-search-servers').append( '<li data-server-id="' + index + '"><label><input class="search-toggle-server" type="checkbox"' + ( server.checked ? ' checked="checked">' : '>' ) + server.name + '</label></li>' ); > } ); > $('#advanced-search-ui').modal('show'); > } >@@ -457,18 +459,18 @@ require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr > $('#searchresults tbody').empty(); > $('#search-serversinfo').empty(); > >- $.each( z3950Servers, function( server_id, server ) { >- var num_fetched = data.num_fetched[server_id]; >+ $.each( z3950Servers, function( index, server ) { >+ var num_fetched = data.num_fetched[server.server_id]; > >- if ( data.errors[server_id] ) { >- num_fetched = data.errors[server_id]; >+ if ( data.errors[server.server_id] ) { >+ num_fetched = data.errors[server.server_id]; > } else if ( num_fetched == null ) { > num_fetched = '-'; >- } else if ( num_fetched < data.num_hits[server_id] ) { >+ } else if ( num_fetched < data.num_hits[server.server_id] ) { > num_fetched += '+'; > } > >- $('#search-serversinfo').append( '<li data-server-id="' + server_id + '"><label><input class="search-toggle-server" type="checkbox"' + ( server.checked ? ' checked="checked">' : '>' ) + server.name + ' (' + num_fetched + ')' + '</label></li>' ); >+ $('#search-serversinfo').append( '<li data-server-id="' + index + '"><label><input class="search-toggle-server" type="checkbox"' + ( server.checked ? ' checked="checked">' : '>' ) + server.name + ' (' + num_fetched + ')' + '</label></li>' ); > } ); > > var seenColumns = {}; >@@ -511,7 +513,8 @@ require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr > } > > var result = '<tr>'; >- result += '<td class="sourcecol">' + z3950Servers[ hit.server ].name + '</td>'; >+ var server_name = hit.servername == 'koha:biblioserver' ? _("Local catalog") : hit.servername; >+ result += '<td class="sourcecol">' + server_name + '</td>'; > > $.each( z3950Labels, function( undef, label ) { > if ( !seenColumns[ label[0] ] ) return; >@@ -641,8 +644,8 @@ require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr > // Macros loaded on first show of modal > break; > case 'selected_search_targets': >- $.each( z3950Servers, function( server_id, server ) { >- var saved_val = Preferences.user.selected_search_targets[server_id]; >+ $.each( z3950Servers, function( index, server ) { >+ var saved_val = Preferences.user.selected_search_targets[server.server_id]; > > if ( saved_val != null ) server.checked = saved_val; > } ); >diff --git a/svc/cataloguing/metasearch b/svc/cataloguing/metasearch >index 110732f7cf..b56bb7031a 100755 >--- a/svc/cataloguing/metasearch >+++ b/svc/cataloguing/metasearch >@@ -56,6 +56,7 @@ my @hits; > foreach my $hit ( $searcher->results( $offset, $page_size ) ) { > push @hits, { > server => $hit->{server}->{id}, >+ servername => $hit->{server}->{servername}, > index => $hit->{index}, > record => $hit->{record}->as_xml_record(), > metadata => $hit->{metadata} >-- >2.11.0
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 17515
:
112583
|
112585
|
112592
|
112805