Tag Folders: tag filters indicator and show settings

- Add an indicator if any tag filters are applied, so you can see if there are any filters even if the list is collapsed
- Save collapse state of the tag list
- Fix folders vanishing if tag filters are applied (now really)
This commit is contained in:
Wolfsblvt
2024-02-19 03:15:45 +01:00
parent 25b528ee4f
commit 25a0ea0cb6
4 changed files with 47 additions and 10 deletions

View File

@ -187,10 +187,8 @@
.tag_as_folder.yes_folder:after { .tag_as_folder.yes_folder:after {
position: absolute; position: absolute;
top: -8px; top: calc(var(--mainFontSize) * -0.5);
bottom: 0; right: calc(var(--mainFontSize) * -0.5);
left: 0;
right: -24px;
content: "\2714"; content: "\2714";
font-size: calc(var(--mainFontSize) * 1); font-size: calc(var(--mainFontSize) * 1);
color: green; color: green;
@ -205,10 +203,8 @@
.tag_as_folder.no_folder:after { .tag_as_folder.no_folder:after {
position: absolute; position: absolute;
top: -8px; top: calc(var(--mainFontSize) * -0.5);
bottom: 0; right: calc(var(--mainFontSize) * -0.5);
left: 0;
right: -24px;
content: "\2715"; content: "\2715";
font-size: calc(var(--mainFontSize) * 1); font-size: calc(var(--mainFontSize) * 1);
color: red; color: red;
@ -220,3 +216,19 @@
1px -1px 0px black; 1px -1px 0px black;
opacity: 1; opacity: 1;
} }
.tag.indicator:after {
position: absolute;
top: calc(var(--mainFontSize) * -0.5);
right: -2px;
content: "\25CF";
font-size: calc(var(--mainFontSize) * 1);
color: var(--SmartThemeBodyColor);
line-height: calc(var(--mainFontSize) * 1.3);
text-align: center;
text-shadow: 1px 1px 0px black,
-1px -1px 0px black,
-1px 1px 0px black,
1px -1px 0px black;
opacity: 1;
}

View File

@ -116,6 +116,7 @@ export class FilterHelper {
} }
const getIsTagged = (entity) => { const getIsTagged = (entity) => {
const isTag = entity.type === 'tag';
const tagFlags = selected.map(tagId => this.isElementTagged(entity, tagId)); const tagFlags = selected.map(tagId => this.isElementTagged(entity, tagId));
const trueFlags = tagFlags.filter(x => x); const trueFlags = tagFlags.filter(x => x);
const isTagged = TAG_LOGIC_AND ? tagFlags.length === trueFlags.length : trueFlags.length > 0; const isTagged = TAG_LOGIC_AND ? tagFlags.length === trueFlags.length : trueFlags.length > 0;
@ -123,7 +124,9 @@ export class FilterHelper {
const excludedTagFlags = excluded.map(tagId => this.isElementTagged(entity, tagId)); const excludedTagFlags = excluded.map(tagId => this.isElementTagged(entity, tagId));
const isExcluded = excludedTagFlags.includes(true); const isExcluded = excludedTagFlags.includes(true);
if (isExcluded) { if (isTag) {
return true;
} else if (isExcluded) {
return false; return false;
} else if (selected.length > 0 && !isTagged) { } else if (selected.length > 0 && !isTagged) {
return false; return false;

View File

@ -234,6 +234,7 @@ let power_user = {
encode_tags: false, encode_tags: false,
servers: [], servers: [],
bogus_folders: false, bogus_folders: false,
show_tag_filters: false,
aux_field: 'character_version', aux_field: 'character_version',
restore_user_input: true, restore_user_input: true,
reduced_motion: false, reduced_motion: false,

View File

@ -370,6 +370,7 @@ function onTagFilterClick(listElement) {
} }
runTagFilters(listElement); runTagFilters(listElement);
updateTagFilterIndicator();
} }
function runTagFilters(listElement) { function runTagFilters(listElement) {
@ -407,6 +408,21 @@ function printTagFilters(type = tag_filter_types.character) {
for (const tagId of selectedTagIds) { for (const tagId of selectedTagIds) {
$(`${FILTER_SELECTOR} .tag[id="${tagId}"]`).trigger('click'); $(`${FILTER_SELECTOR} .tag[id="${tagId}"]`).trigger('click');
} }
if (power_user.show_tag_filters) {
$('.rm_tag_controls .showTagList').addClass('selected');
$('.rm_tag_controls').find('.tag:not(.actionable)').show();
}
updateTagFilterIndicator();
}
function updateTagFilterIndicator() {
if ($('.rm_tag_controls').find('.tag:not(.actionable)').is('.selected, .excluded')) {
$('.rm_tag_controls .showTagList').addClass('indicator');
} else {
$('.rm_tag_controls .showTagList').removeClass('indicator');
}
} }
function onTagRemoveClick(event) { function onTagRemoveClick(event) {
@ -829,10 +845,15 @@ function onTagColorize2(evt) {
} }
function onTagListHintClick() { function onTagListHintClick() {
console.log($(this)); console.debug($(this));
$(this).toggleClass('selected'); $(this).toggleClass('selected');
$(this).siblings('.tag:not(.actionable)').toggle(100); $(this).siblings('.tag:not(.actionable)').toggle(100);
$(this).siblings('.innerActionable').toggleClass('hidden'); $(this).siblings('.innerActionable').toggleClass('hidden');
power_user.show_tag_filters = $(this).hasClass('selected');
saveSettingsDebounced();
console.log('show_tag_filters', power_user.show_tag_filters);
} }
jQuery(() => { jQuery(() => {