@@ -69,7 +69,7 @@ v-container
|
|||||||
//- v-list-item-subtitle(v-text='item.address')
|
//- v-list-item-subtitle(v-text='item.address')
|
||||||
|
|
||||||
v-col(cols=2)
|
v-col(cols=2)
|
||||||
v-btn(color='primary' text @click='addFilter' :disabled='!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'
|
||||||
@@ -110,6 +110,9 @@ v-container
|
|||||||
<script>
|
<script>
|
||||||
import get from 'lodash/get'
|
import get from 'lodash/get'
|
||||||
import debounce from 'lodash/debounce'
|
import debounce from 'lodash/debounce'
|
||||||
|
import isEqual from 'lodash/isEqual'
|
||||||
|
import sortBy from 'lodash/sortBy'
|
||||||
|
|
||||||
import { mdiPencil, mdiChevronLeft, mdiChevronRight, mdiMagnify, mdiPlus, mdiTagMultiple, mdiMapMarker, mdiDeleteForever, mdiCloseCircle, mdiChevronDown } from '@mdi/js'
|
import { mdiPencil, mdiChevronLeft, mdiChevronRight, mdiMagnify, mdiPlus, mdiTagMultiple, mdiMapMarker, mdiDeleteForever, mdiCloseCircle, mdiChevronDown } from '@mdi/js'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@@ -147,7 +150,7 @@ export default {
|
|||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
searchTags: debounce(async function (ev) {
|
searchTags: debounce(async function (ev) {
|
||||||
this.tags = await this.$axios.$get(`/tag?search=${ev.target.value}`)
|
this.tags = await this.$axios.$get(`/tag?search=${encodeURIComponent(ev.target.value)}`)
|
||||||
}, 100),
|
}, 100),
|
||||||
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}`)
|
||||||
@@ -163,9 +166,20 @@ export default {
|
|||||||
this.loading = true
|
this.loading = true
|
||||||
const tags = this.filterTags
|
const tags = this.filterTags
|
||||||
const places = this.filterPlaces.map(p => ({ id: p.id, name: p.name }))
|
const places = this.filterPlaces.map(p => ({ id: p.id, name: p.name }))
|
||||||
const filter = await this.$axios.$post('/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
|
||||||
|
//
|
||||||
|
const alreadyExists = this.filters.find(f =>
|
||||||
|
isEqual(sortBy(f.places, 'id'), sortBy(filter.places, 'id')) && isEqual(sortBy(f.tags), sortBy(filter.tags))
|
||||||
|
)
|
||||||
|
|
||||||
|
if (alreadyExists) return
|
||||||
|
|
||||||
|
const ret = await this.$axios.$post('/filter', filter )
|
||||||
this.$fetch()
|
this.$fetch()
|
||||||
this.filters.push(filter)
|
this.filters.push(ret)
|
||||||
this.filterTags = []
|
this.filterTags = []
|
||||||
this.filterPlaces = []
|
this.filterPlaces = []
|
||||||
this.loading = false
|
this.loading = false
|
||||||
|
|||||||
@@ -54,11 +54,10 @@ v-container
|
|||||||
<script>
|
<script>
|
||||||
import { mdiPencil, mdiChevronLeft, mdiChevronRight, mdiMagnify, mdiEye, mdiMapSearch, mdiChevronDown, mdiDeleteForever, mdiTag } from '@mdi/js'
|
import { mdiPencil, mdiChevronLeft, mdiChevronRight, mdiMagnify, mdiEye, mdiMapSearch, mdiChevronDown, mdiDeleteForever, mdiTag } from '@mdi/js'
|
||||||
import { mapState } from 'vuex'
|
import { mapState } from 'vuex'
|
||||||
import debounce from 'lodash/debounce'
|
|
||||||
import get from 'lodash/get'
|
import get from 'lodash/get'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data( {$store} ) {
|
data() {
|
||||||
return {
|
return {
|
||||||
mdiPencil, mdiChevronRight, mdiChevronLeft, mdiMagnify, mdiEye, mdiMapSearch, mdiChevronDown, mdiDeleteForever, mdiTag,
|
mdiPencil, mdiChevronRight, mdiChevronLeft, mdiMagnify, mdiEye, mdiMapSearch, mdiChevronDown, mdiDeleteForever, mdiTag,
|
||||||
loading: false,
|
loading: false,
|
||||||
|
|||||||
Reference in New Issue
Block a user