|
|
@@ -79,7 +79,7 @@ $(() => {
|
|
|
|
|
|
const EMPTY_STRING = "(Empty)";
|
|
|
|
|
|
- window.ReloadFilters = function(mediaManager) {
|
|
|
+ window.ReloadFilters = function(mediaManager, onNewData) {
|
|
|
let buildFilterBar = (labelText, canBeEmpty, possibleValues) => {
|
|
|
let result = document.createElement("div");
|
|
|
result.className = INPUT_CONTAINER_CLASSES;
|
|
|
@@ -91,10 +91,21 @@ $(() => {
|
|
|
select.multiple = 'multiple';
|
|
|
label.appendChild(select);
|
|
|
let allPossibleValues = [].concat(canBeEmpty ? [undefined] : [], possibleValues);
|
|
|
+ let currentSelection = window.FilterManager.getFilterValues(labelText);
|
|
|
+ let existingValue = currentSelection.include.filter(x => allPossibleValues.indexOf(x) >= 0);
|
|
|
+ if (existingValue.length != currentSelection.include.length)
|
|
|
+ window.FilterManager.setFilterValue(labelText, existingValue);
|
|
|
+ existingValue = currentSelection.exclude.filter(x => allPossibleValues.indexOf(x) >= 0);
|
|
|
+ if (existingValue.length != currentSelection.exclude.length)
|
|
|
+ window.FilterManager.setExclusionFilter(labelText, existingValue);
|
|
|
for (let i of allPossibleValues) {
|
|
|
let opt = document.createElement("option");
|
|
|
opt.textContent = i ? i : EMPTY_STRING;
|
|
|
opt.value = i ?? "";
|
|
|
+ if (currentSelection.include.indexOf(opt.value) >= 0)
|
|
|
+ opt.selected = true;
|
|
|
+ else if (currentSelection.exclude.indexOf(opt.value) >= 0)
|
|
|
+ opt.selected = opt.indeterminate = true;
|
|
|
select.appendChild(opt);
|
|
|
}
|
|
|
let multiselect = makeMultiselect(select);
|
|
|
@@ -111,6 +122,8 @@ $(() => {
|
|
|
};
|
|
|
|
|
|
let container = document.getElementById('pch-filterbar');
|
|
|
+ if (container.children.length && !onNewData)
|
|
|
+ return;
|
|
|
container.textContent = '';
|
|
|
if (MediaStorage.Instance.isLoading())
|
|
|
return;
|