From 7bbf4f7b5fe54a46d2c54a4dc445a0400dfbef23 Mon Sep 17 00:00:00 2001 From: Nick Clemens 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 Signed-off-by: B Johnson Signed-off-by: Katrin Fischer Signed-off-by: Jonathan Druart --- Koha/MetaSearcher.pm | 2 +- cataloguing/editor.pl | 2 +- .../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 eed243735d..47dffe801e 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( {