introduce tag exclusion
This commit is contained in:
parent
9d919bfb0a
commit
246d352761
6 changed files with 31 additions and 3 deletions
9
libs/types/src/content/templates/shared.d.ts
vendored
9
libs/types/src/content/templates/shared.d.ts
vendored
|
@ -32,6 +32,15 @@ export type ListWithEntries<T> = {
|
|||
* Entries that are embedded directly in the list config
|
||||
*/
|
||||
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[]
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -24,6 +24,12 @@
|
|||
},
|
||||
"description": {
|
||||
"type": "richtext"
|
||||
},
|
||||
"excludeTags": {
|
||||
"type": "string"
|
||||
},
|
||||
"excludeTagCategories": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -468,6 +468,8 @@ export interface ApiMediaListMediaList extends Struct.CollectionTypeSchema {
|
|||
'manyToMany',
|
||||
'api::media-entry.media-entry'
|
||||
>;
|
||||
excludeTagCategories: Schema.Attribute.String;
|
||||
excludeTags: Schema.Attribute.String;
|
||||
locale: Schema.Attribute.String & Schema.Attribute.Private;
|
||||
localizations: Schema.Attribute.Relation<
|
||||
'oneToMany',
|
||||
|
|
|
@ -5,6 +5,8 @@ import { fetchAndParseConfig } from 'src/utilities/fetch'
|
|||
|
||||
const props = defineProps<{
|
||||
tags: string | MediaEntryTag[]
|
||||
excludeTags?: string[]
|
||||
excludeTagCategories?: string[]
|
||||
}>()
|
||||
|
||||
const emits = defineEmits<{
|
||||
|
@ -56,9 +58,11 @@ const resetTags = () => {
|
|||
}
|
||||
|
||||
onMounted(async () => {
|
||||
tagsLoaded.value = Array.isArray(props.tags)
|
||||
? tagsLoaded.value = props.tags
|
||||
const tags = Array.isArray(props.tags)
|
||||
? props.tags
|
||||
: await fetchAndParseConfig<MediaEntryTag[]>(props.tags)
|
||||
|
||||
tagsLoaded.value = tags.filter(tag => !props.excludeTags?.includes(tag.tagId) && !props.excludeTagCategories?.includes(tag.category || 'NoCategory'))
|
||||
})
|
||||
</script>
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@ import type {
|
|||
ConfigfulRouteDefinition,
|
||||
ListWithWarnings,
|
||||
MediaEntry,
|
||||
ResolvedListEntries,
|
||||
} from '@goldenwere/mackenzii-types'
|
||||
import { fetchAndParseConfig, fetchConfigsFromList, storage } from 'src/utilities/fetch'
|
||||
import { getCurrentRoute } from 'src/utilities/vuetils'
|
||||
|
@ -121,6 +120,8 @@ onMounted(async () => {
|
|||
FilterPanel(
|
||||
v-if='ready && globalConfig.tags'
|
||||
:tags='globalConfig.tags'
|
||||
:excludeTags='config.excludeTags'
|
||||
:excludeTagCategories='config.excludeTagCategories'
|
||||
@toggledTagsChanged='onToggledTagsChanged($event)'
|
||||
)
|
||||
Transition
|
||||
|
|
|
@ -122,6 +122,12 @@ const mapStrapiResponseToMackenzii = async (inVal) => {
|
|||
|
||||
// handle list basic fields
|
||||
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
|
||||
outVal.entries = {};
|
||||
|
|
Loading…
Add table
Reference in a new issue