fix autoFilter behavior

pull/149/head
Dimitri Gigot 2020-03-26 13:39:49 +00:00
parent b54b00dcaa
commit 784dcf9751
1 changed files with 9 additions and 7 deletions

View File

@ -251,15 +251,17 @@ function showTab(tabname) {
// =========================================== Library
var activeFilter = window.location.hash ? window.location.hash.slice(1) : '';
var chips = Array.from(document.querySelectorAll('.chip')).map(chip => chip.attributes.filterid.value)
var hash = window.location.hash ? window.location.hash.slice(1) : '';
var activeFilter = !!~chips.indexOf(hash) ? hash : ''//window.location.hash ? window.location.hash.slice(1) : '';
var currentSearch = '';
function refreshFilter(){
var filtersContainer = document.querySelector("#librarycontainer .filter-nav");
if(activeFilter){
filtersContainer.querySelector('.active').classList.remove('active');
filtersContainer.querySelector('.chip[filterid="'+activeFilter+'"]').classList.add('active')
}
filtersContainer.querySelector('.active').classList.remove('active');
if(activeFilter) filtersContainer.querySelector('.chip[filterid="'+activeFilter+'"]').classList.add('active')
else filtersContainer.querySelector('.chip[filterid]').classList.add('active')
}
function refreshLibrary() {
var panelbody = document.querySelector("#librarycontainer .panel-body");
@ -515,10 +517,10 @@ Comms.watchConnectionChange(handleConnectionChange);
var filtersContainer = document.querySelector("#librarycontainer .filter-nav");
filtersContainer.addEventListener('click', ({ target }) => {
if (!target.hasAttribute('filterid')) return;
//if (!target.hasAttribute('filterid')) return;
if (target.classList.contains('active')) return;
activeFilter = target.getAttribute('filterid');
activeFilter = target.getAttribute('filterid') || '';
refreshFilter();
refreshLibrary();
window.location.hash = activeFilter