related to #1931 Added empty all filters button

This commit is contained in:
MatthieuLP
2023-07-24 15:22:10 +02:00
parent 01e3bb61ea
commit 6907bf26f5
4 changed files with 32 additions and 0 deletions
+1
View File
@@ -428,4 +428,5 @@ $lang['Choose filters'] = 'Choose filters';
$lang['Clear'] = 'Clear';
$lang['Fill in the filters to start a search'] = 'Fill in the filters to start a search';
$lang['Pre-established filters are proposed, but you can add or remove them using the "Choose filters" button.'] = 'Pre-established filters are proposed, but you can add or remove them using the "Choose filters" button.';
$lang['Empty filters'] = 'Empty filters';
?>
+1
View File
@@ -433,3 +433,4 @@ $lang['Choose filters'] = 'Choisir les filtres';
$lang['Clear'] = 'Vider';
$lang['Fill in the filters to start a search'] = 'Complétez les filtres pour lancer une recherche';
$lang['Pre-established filters are proposed, but you can add or remove them using the "Choose filters" button.'] = 'Des filtres préétablis vous sont proposés, mais vous pouvez aussi en ajouter ou en retirer grâce au bouton "Choisir les filtres".';
$lang['Empty filters'] = 'Vider les filtres';
+26
View File
@@ -39,6 +39,7 @@ $(document).ready(function () {
// Declare params sent to pwg.images.filteredSearch.update
PS_params = {};
PS_params.search_id = search_id;
empty_filters_list = [];
// Setup word filter
if (global_params.fields.allwords) {
@@ -80,6 +81,8 @@ $(document).ready(function () {
PS_params.allwords = word_search_str.slice(0, -1);
PS_params.allwords_fields = word_search_fields;
PS_params.allwords_mode = word_search_mode;
empty_filters_list.push(PS_params.allwords);
}
//Hide filter spinner
$(".filter-spinner").hide();
@@ -115,6 +118,8 @@ $(document).ready(function () {
PS_params.tags = global_params.fields.tags.words.length > 0 ? global_params.fields.tags.words : '';
PS_params.tags_mode = global_params.fields.tags.mode;
empty_filters_list.push(PS_params.tags);
}
// Setup album filter
@@ -148,6 +153,8 @@ $(document).ready(function () {
PS_params.categories = global_params.fields.cat.words.length > 0 ? global_params.fields.cat.words : '';
PS_params.categories_withsubs = global_params.fields.cat.sub_inc;
empty_filters_list.push(PS_params.categories);
}
// Setup author filter
@@ -178,6 +185,8 @@ $(document).ready(function () {
});
PS_params.authors = global_params.fields.author.words.length > 0 ? global_params.fields.author.words : '';
empty_filters_list.push(PS_params.authors);
}
});
@@ -208,6 +217,8 @@ $(document).ready(function () {
});
PS_params.added_by = global_params.fields.added_by.length > 0 ? global_params.fields.added_by : '';
empty_filters_list.push(PS_params.added_by);
}
});
@@ -239,6 +250,8 @@ $(document).ready(function () {
});
PS_params.filetypes = global_params.fields.filetypes.length > 0 ? global_params.fields.filetypes : '';
empty_filters_list.push(PS_params.filetypes);
}
// Adapt no result message
@@ -247,6 +260,19 @@ $(document).ready(function () {
$(".mcs-no-result .text .bot").html(str_empty_search_bot_alt);
}
if (!empty_filters_list.every(param => param === "" || param === null)) {
$(".clear-all").addClass("clickable");
$(".clear-all.clickable").on('click', function () {
exclude_params = ['search_id', 'allwords_mode', 'allwords_fields', 'tags_mode', 'categories_withsubs'];
for (const key in PS_params) {
if (!exclude_params.includes(key)) {
PS_params[key] = '';
}
}
performSearch(PS_params, true);
});
}
/**
* Filter Manager
*/
+4
View File
@@ -482,6 +482,10 @@ str_empty_search_bot_alt = "{'Pre-established filters are proposed, but you can
</div>
{/if}
<div>
<span class="mcs-icon pwg-icon-broom clear-all">{'Empty filters'|@translate}</span>
</div>
{* <div class="filter filter-note">
Note div
<div class="filter-form filter-note-form">