mirror of
https://framagit.org/les/gancio.git
synced 2025-02-01 00:52:01 +01:00
feat(fedi/collections): add instances as potential filter in collections
This commit is contained in:
parent
07fcbbd4ce
commit
7a6101be7b
1 changed files with 30 additions and 7 deletions
|
@ -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-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
|
||||||
v-card-title {{ $t('admin.edit_collection') }}
|
v-card-title {{ $t('admin.edit_collection') }}
|
||||||
v-card-text
|
v-card-text
|
||||||
|
@ -27,7 +27,25 @@ v-container
|
||||||
h3(v-else class='text-h5' v-text='collection.name')
|
h3(v-else class='text-h5' v-text='collection.name')
|
||||||
|
|
||||||
v-row
|
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'
|
v-autocomplete(v-model='filterTags'
|
||||||
cache-items
|
cache-items
|
||||||
:prepend-inner-icon="mdiTagMultiple"
|
:prepend-inner-icon="mdiTagMultiple"
|
||||||
|
@ -43,7 +61,7 @@ v-container
|
||||||
v-chip(v-bind="attrs" close :close-icon='mdiCloseCircle' @click:close='parent.selectItem(item)'
|
v-chip(v-bind="attrs" close :close-icon='mdiCloseCircle' @click:close='parent.selectItem(item)'
|
||||||
:input-value="selected" label small) {{ item }}
|
:input-value="selected" label small) {{ item }}
|
||||||
|
|
||||||
v-col(cols=5)
|
v-col(cols=4)
|
||||||
v-autocomplete(v-model='filterPlaces'
|
v-autocomplete(v-model='filterPlaces'
|
||||||
cache-items
|
cache-items
|
||||||
:prepend-inner-icon="mdiMapMarker"
|
:prepend-inner-icon="mdiMapMarker"
|
||||||
|
@ -68,8 +86,7 @@ v-container
|
||||||
//- v-list-item-title(v-text='item.name')
|
//- v-list-item-title(v-text='item.name')
|
||||||
//- v-list-item-subtitle(v-text='item.address')
|
//- 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(
|
v-data-table(
|
||||||
:headers='filterHeaders'
|
:headers='filterHeaders'
|
||||||
|
@ -129,6 +146,8 @@ export default {
|
||||||
collection: { name: '', id: null },
|
collection: { name: '', id: null },
|
||||||
filterTags: [],
|
filterTags: [],
|
||||||
filterPlaces: [],
|
filterPlaces: [],
|
||||||
|
filterActors: [],
|
||||||
|
actors: [],
|
||||||
tags: [],
|
tags: [],
|
||||||
places: [],
|
places: [],
|
||||||
collections: [],
|
collections: [],
|
||||||
|
@ -142,6 +161,7 @@ export default {
|
||||||
{ value: 'actions', text: this.$t('common.actions'), align: 'right', width: 150 }
|
{ value: 'actions', text: this.$t('common.actions'), align: 'right', width: 150 }
|
||||||
],
|
],
|
||||||
filterHeaders: [
|
filterHeaders: [
|
||||||
|
{ value: 'actors', text: this.$t('common.actors') },
|
||||||
{ value: 'tags', text: this.$t('common.tags') },
|
{ value: 'tags', text: this.$t('common.tags') },
|
||||||
{ value: 'places', text: this.$t('common.places') },
|
{ value: 'places', text: this.$t('common.places') },
|
||||||
{ value: 'actions', text: this.$t('common.actions'), align: 'right' }
|
{ value: 'actions', text: this.$t('common.actions'), align: 'right' }
|
||||||
|
@ -159,6 +179,9 @@ export default {
|
||||||
searchPlaces: debounce(async function (ev) {
|
searchPlaces: debounce(async function (ev) {
|
||||||
this.places = await this.$axios.$get(`/place?search=${ev.target.value}`)
|
this.places = await this.$axios.$get(`/place?search=${ev.target.value}`)
|
||||||
}, 100),
|
}, 100),
|
||||||
|
searchActors: debounce(async function (ev) {
|
||||||
|
this.actors = await this.$axios.$get(`/instances/friendly?search=${ev.target.value}`)
|
||||||
|
}, 100),
|
||||||
collectionFilters(collection) {
|
collectionFilters(collection) {
|
||||||
return collection.filters.map(f => {
|
return collection.filters.map(f => {
|
||||||
const tags = f.tags?.join(', ')
|
const tags = f.tags?.join(', ')
|
||||||
|
@ -174,8 +197,8 @@ export default {
|
||||||
const filter = { collectionId: this.collection.id, tags, places }
|
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
|
// 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))
|
isEqual(sortBy(f.places, 'id'), sortBy(filter.places, 'id')) && isEqual(sortBy(f.tags), sortBy(filter.tags))
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue