From 25f163305fe179d923559dacea37a89f428f6b1f Mon Sep 17 00:00:00 2001 From: Jesse Weaver Date: Thu, 6 Aug 2015 15:56:36 -0600 Subject: [PATCH] Bug 11559: (followup) Fix error when all servers are deselected Signed-off-by: Nick Clemens Signed-off-by: Katrin Fischer --- .../intranet-tmpl/lib/koha/cateditor/search.js | 4 +++- .../prog/en/includes/cateditor-ui.inc | 17 ++++++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/lib/koha/cateditor/search.js b/koha-tmpl/intranet-tmpl/lib/koha/cateditor/search.js index 341da39b7f..bbddc23ccb 100644 --- a/koha-tmpl/intranet-tmpl/lib/koha/cateditor/search.js +++ b/koha-tmpl/intranet-tmpl/lib/koha/cateditor/search.js @@ -75,6 +75,8 @@ define( [ 'marc-record' ], function( MARC ) { if ( info.checked ) Search.includedServers.push( id ); } ); + if ( Search.includedServers.length == 0 ) return false; + $.get( '/cgi-bin/koha/svc/cataloguing/metasearch', { @@ -106,7 +108,7 @@ define( [ 'marc-record' ], function( MARC ) { Fetch: function( options ) { if ( !_last ) return; $.extend( _last.options, options ); - Search.Run( _last.servers, _last.q, _last.options ); + return Search.Run( _last.servers, _last.q, _last.options ); } }; 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 3b71d6a397..0616536703 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/cateditor-ui.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/cateditor-ui.inc @@ -962,13 +962,14 @@ require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr } ); $( document ).on( 'click', 'a.search-nav', function() { - $("#search-overlay").show(); - Search.Fetch( { offset: $( this ).data( 'offset' ) } ); + if ( Search.Fetch( { offset: $( this ).data( 'offset' ) } ) ) { + $("#search-overlay").show(); + } + return false; }); $( document ).on( 'click', 'th[data-sort-label]', function() { - $("#search-overlay").show(); var direction; if ( $( this ).hasClass( 'sorting_asc' ) ) { @@ -977,9 +978,12 @@ require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr direction = 'asc'; } - showSearchSorting( $( this ).data( 'sort-label' ), direction ); + if ( Search.Fetch( { sort_key: $( this ).data( 'sort-label' ), sort_direction: direction } ) ) { + showSearchSorting( $( this ).data( 'sort-label' ), direction ); + + $("#search-overlay").show(); + } - Search.Fetch( { sort_key: $( this ).data( 'sort-label' ), sort_direction: direction } ); return false; }); @@ -987,9 +991,8 @@ require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr var server = z3950Servers[ $( this ).closest('li').data('server-id') ]; server.checked = this.checked; - if ( $('#search-results-ui').is( ':visible' ) ) { + if ( $('#search-results-ui').is( ':visible' ) && Search.Fetch() ) { $("#search-overlay").show(); - Search.Fetch(); } } ); -- 2.39.5