feat(fedi/collections): add instances as potential filter in collections

This commit is contained in:
lesion 2023-11-09 16:53:44 +01:00
parent 07fcbbd4ce
commit 7a6101be7b
No known key found for this signature in database
GPG key ID: 352918250B012177

View file

@ -10,7 +10,7 @@ v-container
v-btn(color='primary' text @click='newCollection') <v-icon v-text='mdiPlus'></v-icon> {{ $t('admin.new_collection') }}
v-dialog(v-model='dialog' width='800' destroy-on-close :fullscreen='$vuetify.breakpoint.xsOnly')
v-dialog(v-model='dialog' width='900' destroy-on-close :fullscreen='$vuetify.breakpoint.xsOnly')
v-card
v-card-title {{ $t('admin.edit_collection') }}
v-card-text
@ -27,7 +27,25 @@ v-container
h3(v-else class='text-h5' v-text='collection.name')
v-row
v-col(cols=5)
v-col(cols=4)
v-autocomplete(v-model='filterActors'
cache-items
:prepend-icon="mdiTagMultiple"
chips small-chips multiple deletable-chips hide-no-data hide-selected persistent-hint
:disabled="!collection.id"
placeholder='Local'
@input.native='searchActors'
@focus='searchActors'
item-text='ap_id'
item-value='ap_id'
:delimiters="[',', ';']"
:items="actors"
:label="$t('common.actors')")
template(v-slot:selection="{ item, on, attrs, selected, parent }")
v-chip(v-bind="attrs" close :close-icon='mdiCloseCircle' @click:close='parent.selectItem(item)'
:input-value="selected" label small) {{ item }}
v-col(cols=4)
v-autocomplete(v-model='filterTags'
cache-items
:prepend-inner-icon="mdiTagMultiple"
@ -43,7 +61,7 @@ v-container
v-chip(v-bind="attrs" close :close-icon='mdiCloseCircle' @click:close='parent.selectItem(item)'
:input-value="selected" label small) {{ item }}
v-col(cols=5)
v-col(cols=4)
v-autocomplete(v-model='filterPlaces'
cache-items
:prepend-inner-icon="mdiMapMarker"
@ -68,8 +86,7 @@ v-container
//- v-list-item-title(v-text='item.name')
//- v-list-item-subtitle(v-text='item.address')
v-col(cols=2)
v-btn(color='primary' :loading='loading' text @click='addFilter' :disabled='loading || !collection.id || !filterPlaces.length && !filterTags.length') add <v-icon v-text='mdiPlus'></v-icon>
v-btn(color='primary' :loading='loading' text @click='addFilter' :disabled='loading || !collection.id || !filterPlaces.length && !filterTags.length') add <v-icon v-text='mdiPlus'></v-icon>
v-data-table(
:headers='filterHeaders'
@ -129,6 +146,8 @@ export default {
collection: { name: '', id: null },
filterTags: [],
filterPlaces: [],
filterActors: [],
actors: [],
tags: [],
places: [],
collections: [],
@ -142,6 +161,7 @@ export default {
{ value: 'actions', text: this.$t('common.actions'), align: 'right', width: 150 }
],
filterHeaders: [
{ value: 'actors', text: this.$t('common.actors') },
{ value: 'tags', text: this.$t('common.tags') },
{ value: 'places', text: this.$t('common.places') },
{ value: 'actions', text: this.$t('common.actions'), align: 'right' }
@ -159,6 +179,9 @@ export default {
searchPlaces: debounce(async function (ev) {
this.places = await this.$axios.$get(`/place?search=${ev.target.value}`)
}, 100),
searchActors: debounce(async function (ev) {
this.actors = await this.$axios.$get(`/instances/friendly?search=${ev.target.value}`)
}, 100),
collectionFilters(collection) {
return collection.filters.map(f => {
const tags = f.tags?.join(', ')
@ -174,8 +197,8 @@ export default {
const filter = { collectionId: this.collection.id, tags, places }
// tags and places are JSON field and there's no way to use them inside a unique constrain
//
const alreadyExists = this.filters.find(f =>
//
const alreadyExists = this.filters.find(f =>
isEqual(sortBy(f.places, 'id'), sortBy(filter.places, 'id')) && isEqual(sortBy(f.tags), sortBy(filter.tags))
)