mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Nested bogus folders + back button
This commit is contained in:
@@ -69,6 +69,20 @@ export class FilterHelper {
|
||||
return data.filter(entity => fuzzySearchResults.includes(entity.uid));
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the given entity is tagged with the given tag ID.
|
||||
* @param {object} entity Searchable entity
|
||||
* @param {string} tagId Tag ID to check
|
||||
* @returns {boolean} Whether the entity is tagged with the given tag ID
|
||||
*/
|
||||
isElementTagged(entity, tagId) {
|
||||
const isCharacter = entity.type === 'character';
|
||||
const lookupValue = isCharacter ? entity.item.avatar : String(entity.id);
|
||||
const isTagged = Array.isArray(tag_map[lookupValue]) && tag_map[lookupValue].includes(tagId);
|
||||
|
||||
return isTagged;
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies a tag filter to the data.
|
||||
* @param {any[]} data The data to filter.
|
||||
@@ -82,19 +96,12 @@ export class FilterHelper {
|
||||
return data;
|
||||
}
|
||||
|
||||
function isElementTagged(entity, tagId) {
|
||||
const isCharacter = entity.type === 'character';
|
||||
const lookupValue = isCharacter ? entity.item.avatar : String(entity.id);
|
||||
const isTagged = Array.isArray(tag_map[lookupValue]) && tag_map[lookupValue].includes(tagId);
|
||||
return isTagged;
|
||||
}
|
||||
|
||||
function getIsTagged(entity) {
|
||||
const tagFlags = selected.map(tagId => isElementTagged(entity, tagId));
|
||||
const getIsTagged = (entity) => {
|
||||
const tagFlags = selected.map(tagId => this.isElementTagged(entity, tagId));
|
||||
const trueFlags = tagFlags.filter(x => x);
|
||||
const isTagged = TAG_LOGIC_AND ? tagFlags.length === trueFlags.length : trueFlags.length > 0;
|
||||
|
||||
const excludedTagFlags = excluded.map(tagId => isElementTagged(entity, tagId));
|
||||
const excludedTagFlags = excluded.map(tagId => this.isElementTagged(entity, tagId));
|
||||
const isExcluded = excludedTagFlags.includes(true);
|
||||
|
||||
if (isExcluded) {
|
||||
|
@@ -1649,7 +1649,17 @@ function sortEntitiesList(entities) {
|
||||
return;
|
||||
}
|
||||
|
||||
entities.sort((a, b) => sortFunc(a.item, b.item));
|
||||
entities.sort((a, b) => {
|
||||
if (a.type === 'tag' && b.type !== 'tag') {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (a.type !== 'tag' && b.type === 'tag') {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return sortFunc(a.item, b.item);
|
||||
});
|
||||
}
|
||||
|
||||
async function saveTheme() {
|
||||
|
@@ -38,14 +38,13 @@ export const tag_filter_types = {
|
||||
};
|
||||
|
||||
const ACTIONABLE_TAGS = {
|
||||
|
||||
FAV: { id: 1, name: 'Show only favorites', color: 'rgba(255, 255, 0, 0.5)', action: applyFavFilter, icon: 'fa-solid fa-star', class: 'filterByFavorites' },
|
||||
GROUP: { id: 0, name: 'Show only groups', color: 'rgba(100, 100, 100, 0.5)', action: filterByGroups, icon: 'fa-solid fa-users', class: 'filterByGroups' },
|
||||
VIEW: { id: 2, name: 'Manage tags', color: 'rgba(150, 100, 100, 0.5)', action: onViewTagsListClick, icon: 'fa-solid fa-gear', class: 'manageTags' },
|
||||
HINT: { id: 3, name: 'Show Tag List', color: 'rgba(150, 100, 100, 0.5)', action: onTagListHintClick, icon: 'fa-solid fa-tags', class: 'showTagList' },
|
||||
}
|
||||
|
||||
const InListActionable = {
|
||||
VIEW: { id: 2, name: 'Manage tags', color: 'rgba(150, 100, 100, 0.5)', action: onViewTagsListClick, icon: 'fa-solid fa-gear' },
|
||||
}
|
||||
|
||||
const DEFAULT_TAGS = [
|
||||
@@ -321,9 +320,9 @@ function appendTagToList(listElement, tag, { removable, selectable, action, isGe
|
||||
tagElement.on('click', () => action.bind(tagElement)(filter));
|
||||
tagElement.addClass('actionable');
|
||||
}
|
||||
if (action && tag.id === 2) {
|
||||
/*if (action && tag.id === 2) {
|
||||
tagElement.addClass('innerActionable hidden');
|
||||
}
|
||||
}*/
|
||||
|
||||
$(listElement).append(tagElement);
|
||||
}
|
||||
|
Reference in New Issue
Block a user