introduce tag exclusion

This commit is contained in:
lightling 2025-04-19 17:22:43 -04:00
parent 9d919bfb0a
commit 246d352761
Signed by: lightling
GPG key ID: F1F29650D537C773
6 changed files with 31 additions and 3 deletions

View file

@ -32,6 +32,15 @@ export type ListWithEntries<T> = {
* Entries that are embedded directly in the list config * Entries that are embedded directly in the list config
*/ */
embeddedEntries?: ListEntries<T> embeddedEntries?: ListEntries<T>
/**
* Array of `tag.tagId`s that will be excluded from global tags for a given media list
*/
excludeTags: string[]
/**
* Array of `tag.category` that will be excluded from global tags for a given media list;
* to exclude tags without categories given, add `'NoCategory'` to this array.
*/
excludeTagCategories: string[]
} }
/** /**

View file

@ -24,6 +24,12 @@
}, },
"description": { "description": {
"type": "richtext" "type": "richtext"
},
"excludeTags": {
"type": "string"
},
"excludeTagCategories": {
"type": "string"
} }
} }
} }

View file

@ -468,6 +468,8 @@ export interface ApiMediaListMediaList extends Struct.CollectionTypeSchema {
'manyToMany', 'manyToMany',
'api::media-entry.media-entry' 'api::media-entry.media-entry'
>; >;
excludeTagCategories: Schema.Attribute.String;
excludeTags: Schema.Attribute.String;
locale: Schema.Attribute.String & Schema.Attribute.Private; locale: Schema.Attribute.String & Schema.Attribute.Private;
localizations: Schema.Attribute.Relation< localizations: Schema.Attribute.Relation<
'oneToMany', 'oneToMany',

View file

@ -5,6 +5,8 @@ import { fetchAndParseConfig } from 'src/utilities/fetch'
const props = defineProps<{ const props = defineProps<{
tags: string | MediaEntryTag[] tags: string | MediaEntryTag[]
excludeTags?: string[]
excludeTagCategories?: string[]
}>() }>()
const emits = defineEmits<{ const emits = defineEmits<{
@ -56,9 +58,11 @@ const resetTags = () => {
} }
onMounted(async () => { onMounted(async () => {
tagsLoaded.value = Array.isArray(props.tags) const tags = Array.isArray(props.tags)
? tagsLoaded.value = props.tags ? props.tags
: await fetchAndParseConfig<MediaEntryTag[]>(props.tags) : await fetchAndParseConfig<MediaEntryTag[]>(props.tags)
tagsLoaded.value = tags.filter(tag => !props.excludeTags?.includes(tag.tagId) && !props.excludeTagCategories?.includes(tag.category || 'NoCategory'))
}) })
</script> </script>

View file

@ -4,7 +4,6 @@ import type {
ConfigfulRouteDefinition, ConfigfulRouteDefinition,
ListWithWarnings, ListWithWarnings,
MediaEntry, MediaEntry,
ResolvedListEntries,
} from '@goldenwere/mackenzii-types' } from '@goldenwere/mackenzii-types'
import { fetchAndParseConfig, fetchConfigsFromList, storage } from 'src/utilities/fetch' import { fetchAndParseConfig, fetchConfigsFromList, storage } from 'src/utilities/fetch'
import { getCurrentRoute } from 'src/utilities/vuetils' import { getCurrentRoute } from 'src/utilities/vuetils'
@ -121,6 +120,8 @@ onMounted(async () => {
FilterPanel( FilterPanel(
v-if='ready && globalConfig.tags' v-if='ready && globalConfig.tags'
:tags='globalConfig.tags' :tags='globalConfig.tags'
:excludeTags='config.excludeTags'
:excludeTagCategories='config.excludeTagCategories'
@toggledTagsChanged='onToggledTagsChanged($event)' @toggledTagsChanged='onToggledTagsChanged($event)'
) )
Transition Transition

View file

@ -122,6 +122,12 @@ const mapStrapiResponseToMackenzii = async (inVal) => {
// handle list basic fields // handle list basic fields
outVal.title = data.title; outVal.title = data.title;
if (!!data.excludeTags) {
outVal.excludeTags = data.excludeTags.split(/,| |;/).filter(val => val !== '');
}
if (!!data.excludeTagCategories) {
outVal.excludeTagCategories = data.excludeTagCategories.split(/,| |;/).filter(val => val !== '');
}
// handle list entries // handle list entries
outVal.entries = {}; outVal.entries = {};