From aa9acb388fa723274d777f82ccb551accb058b9d Mon Sep 17 00:00:00 2001 From: plegall Date: Thu, 13 May 2021 13:26:08 +0200 Subject: [PATCH] (cp 0996526) Fixes #1399 Search result limit set to 100. + translation lines. Variable to limit the number of results is set to 100. Added some translation lines to notice the user that he has ti refine the search. One translation line corrected because it was in french in the uk_UK file --- admin/themes/default/template/cat_search.tpl | 14 +++++++++++--- language/en_UK/admin.lang.php | 1 + language/fr_FR/admin.lang.php | 1 + 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/admin/themes/default/template/cat_search.tpl b/admin/themes/default/template/cat_search.tpl index 7e37ab553..7f24b1df1 100644 --- a/admin/themes/default/template/cat_search.tpl +++ b/admin/themes/default/template/cat_search.tpl @@ -12,8 +12,12 @@ var data = {json_encode($data_cat)}; // Numeric array of all categories var categories = Object.values(data); +const RESULT_LIMIT = 100; + var str_albums_found = '{"%d albums found"|translate}'; var str_album_found = '{"1 album found"|translate}'; +var str_result_limit = '{"%d+ albums found, try to refine the search"|translate}'; + {literal} var editLink = "admin.php?page=album-"; var colors = ["icon-red", "icon-blue", "icon-yellow", "icon-purple", "icon-green"]; @@ -39,14 +43,18 @@ function updateSearch () { nbResult = 0; categories.forEach((c) => { - if (c[0].toString().toLowerCase().search(string.toLowerCase()) != -1) { + if (c[0].toString().toLowerCase().search(string.toLowerCase()) != -1 && nbResult < RESULT_LIMIT) { addAlbumResult(c); nbResult++; } }) if (nbResult != 1) { - $('.search-album-num-result').html(str_albums_found.replace('%d', nbResult)); + if (nbResult >= RESULT_LIMIT) { + $('.search-album-num-result').html(str_result_limit.replace('%d', nbResult)); + } else { + $('.search-album-num-result').html(str_albums_found.replace('%d', nbResult)); + } } else { $('.search-album-num-result').html(str_album_found); } @@ -104,7 +112,7 @@ function getHtmlPath (cat) { return html } -// Make the results appear one after one +// Make the results appear one after one [and limit results to 100] function resultAppear(result) { result.fadeIn(); if (result.next().length != 0) { diff --git a/language/en_UK/admin.lang.php b/language/en_UK/admin.lang.php index 7f776e9d0..2fc9259bc 100644 --- a/language/en_UK/admin.lang.php +++ b/language/en_UK/admin.lang.php @@ -1131,3 +1131,4 @@ $lang['Apply an automatic order'] = 'Apply an automatic order'; $lang['Root'] = 'Root'; $lang['Apply to direct sub-albums'] = 'Apply to direct sub-albums'; $lang['Apply to the whole hierarchy'] = 'Apply to the whole hierarchy'; +$lang['%d+ albums found, try to refine the search'] = '%d+ albums found, try to refine the search'; diff --git a/language/fr_FR/admin.lang.php b/language/fr_FR/admin.lang.php index 9372ca7e1..751ba6118 100644 --- a/language/fr_FR/admin.lang.php +++ b/language/fr_FR/admin.lang.php @@ -1133,3 +1133,4 @@ $lang['Apply an automatic order'] = 'Appliquer un ordre automatique'; $lang['Root'] = 'Racine'; $lang['Apply to direct sub-albums'] = 'Appliquer aux sous-albums'; $lang['Apply to the whole hierarchy'] = 'Appliquer à toute l\'arborescence'; +$lang['%d+ albums found, try to refine the search'] = '%d+ albums trouvé, essayez d affiner la recherche';