From 0996526e4b5a114c04c54b71b8ca5e323e617109 Mon Sep 17 00:00:00 2001 From: Matthieu Leproux Date: Thu, 6 May 2021 12:33:50 +0200 Subject: [PATCH] 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 | 3 ++- language/fr_FR/admin.lang.php | 3 ++- 3 files changed, 15 insertions(+), 5 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 c26b082dd..061c6e248 100644 --- a/language/en_UK/admin.lang.php +++ b/language/en_UK/admin.lang.php @@ -1166,4 +1166,5 @@ $lang['Hide sub-albums'] = 'Hide sub-albums'; $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'] = 'Appliquer à toute l\'arborescence'; \ No newline at end of file +$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'; \ No newline at end of file diff --git a/language/fr_FR/admin.lang.php b/language/fr_FR/admin.lang.php index d58795c41..4ec9e8c53 100644 --- a/language/fr_FR/admin.lang.php +++ b/language/fr_FR/admin.lang.php @@ -1168,4 +1168,5 @@ $lang['Hide sub-albums'] = 'Cacher les sous-albums'; $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'; \ No newline at end of file +$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'; \ No newline at end of file