mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-01-31 12:09:17 +08:00
Trigger search on filters flyout close, fix render when filters are clear [SCI-5393]
This commit is contained in:
parent
451e0316ad
commit
e099827b1b
1 changed files with 34 additions and 30 deletions
|
@ -667,6 +667,38 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function initProjectsFilters() {
|
function initProjectsFilters() {
|
||||||
|
function applyFilters() {
|
||||||
|
let teamId = $('.projects-filters').data('team-id');
|
||||||
|
projectsViewSearch = $('#textSearchFilterInput').closest('.select-block').find('input[type=text]').val();
|
||||||
|
try {
|
||||||
|
let storagePath = `project_filters_per_team/${teamId}/recent_search_keywords`;
|
||||||
|
let recentSearchKeywords = JSON.parse(localStorage.getItem(storagePath));
|
||||||
|
if (!Array.isArray(recentSearchKeywords)) recentSearchKeywords = [];
|
||||||
|
if (recentSearchKeywords.indexOf(projectsViewSearch) !== -1) {
|
||||||
|
recentSearchKeywords.splice(recentSearchKeywords.indexOf(projectsViewSearch), 1);
|
||||||
|
}
|
||||||
|
if (recentSearchKeywords.length > 4) {
|
||||||
|
recentSearchKeywords = recentSearchKeywords.slice(0, 4);
|
||||||
|
}
|
||||||
|
recentSearchKeywords.unshift(projectsViewSearch);
|
||||||
|
localStorage.setItem(storagePath, JSON.stringify(recentSearchKeywords));
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
|
|
||||||
|
$('#applyProjectFiltersButton').closest('.dropdown').removeClass('open');
|
||||||
|
|
||||||
|
createdOnFromFilter = $createdOnFromFilter.val();
|
||||||
|
createdOnToFilter = $createdOnToFilter.val();
|
||||||
|
membersFilter = dropdownSelector.getValues($('.members-filter'));
|
||||||
|
lookInsideFolders = $foldersCB.prop('checked') ? 'true' : '';
|
||||||
|
archivedOnFromFilter = $archivedOnFromFilter.val();
|
||||||
|
archivedOnToFilter = $archivedOnToFilter.val();
|
||||||
|
|
||||||
|
appliedFiltersMark();
|
||||||
|
refreshCurrentView();
|
||||||
|
}
|
||||||
|
|
||||||
let $projectsFilter = $('.projects-index .projects-filters');
|
let $projectsFilter = $('.projects-index .projects-filters');
|
||||||
let $membersFilter = $('.members-filter', $projectsFilter);
|
let $membersFilter = $('.members-filter', $projectsFilter);
|
||||||
let $foldersCB = $('#folder_search', $projectsFilter);
|
let $foldersCB = $('#folder_search', $projectsFilter);
|
||||||
|
@ -734,41 +766,13 @@
|
||||||
$('#textSearchFilterHistory').hide();
|
$('#textSearchFilterHistory').hide();
|
||||||
$textFilter.closest('.dropdown').removeClass('open');
|
$textFilter.closest('.dropdown').removeClass('open');
|
||||||
$('#folderSearchInfo').hide();
|
$('#folderSearchInfo').hide();
|
||||||
|
applyFilters();
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#applyProjectFiltersButton').click((e) => {
|
$('#applyProjectFiltersButton').click((e) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
applyFilters();
|
||||||
let teamId = $('.projects-filters').data('team-id');
|
|
||||||
projectsViewSearch = $('#textSearchFilterInput').closest('.select-block').find('input[type=text]').val();
|
|
||||||
try {
|
|
||||||
let storagePath = `project_filters_per_team/${teamId}/recent_search_keywords`;
|
|
||||||
let recentSearchKeywords = JSON.parse(localStorage.getItem(storagePath));
|
|
||||||
if (!Array.isArray(recentSearchKeywords)) recentSearchKeywords = [];
|
|
||||||
if (recentSearchKeywords.indexOf(projectsViewSearch) !== -1) {
|
|
||||||
recentSearchKeywords.splice(recentSearchKeywords.indexOf(projectsViewSearch), 1);
|
|
||||||
}
|
|
||||||
if (recentSearchKeywords.length > 4) {
|
|
||||||
recentSearchKeywords = recentSearchKeywords.slice(0, 4);
|
|
||||||
}
|
|
||||||
recentSearchKeywords.unshift(projectsViewSearch);
|
|
||||||
localStorage.setItem(storagePath, JSON.stringify(recentSearchKeywords));
|
|
||||||
} catch (error) {
|
|
||||||
console.error(error);
|
|
||||||
}
|
|
||||||
|
|
||||||
$(e.target).closest('.dropdown').removeClass('open');
|
|
||||||
|
|
||||||
createdOnFromFilter = $createdOnFromFilter.val();
|
|
||||||
createdOnToFilter = $createdOnToFilter.val();
|
|
||||||
membersFilter = dropdownSelector.getValues($('.members-filter'));
|
|
||||||
lookInsideFolders = $foldersCB.prop('checked');
|
|
||||||
archivedOnFromFilter = $archivedOnFromFilter.val();
|
|
||||||
archivedOnToFilter = $archivedOnToFilter.val();
|
|
||||||
|
|
||||||
appliedFiltersMark();
|
|
||||||
refreshCurrentView();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Clear filters
|
// Clear filters
|
||||||
|
|
Loading…
Reference in a new issue