|
@@ -66,7 +66,7 @@
|
|
|
</v-btn>
|
|
</v-btn>
|
|
|
</v-col>
|
|
</v-col>
|
|
|
<v-col cols="2" class="py-2 px-1 d-flex justify-end">
|
|
<v-col cols="2" class="py-2 px-1 d-flex justify-end">
|
|
|
- <v-btn class="h100" @click="test()">
|
|
|
|
|
|
|
+ <v-btn class="h100" @click="search()">
|
|
|
{{ $t('search') }}
|
|
{{ $t('search') }}
|
|
|
</v-btn>
|
|
</v-btn>
|
|
|
</v-col>
|
|
</v-col>
|
|
@@ -88,7 +88,7 @@
|
|
|
<!-- Results -->
|
|
<!-- Results -->
|
|
|
<v-data-iterator
|
|
<v-data-iterator
|
|
|
v-else
|
|
v-else
|
|
|
- :items="filteredEvents"
|
|
|
|
|
|
|
+ :items="events"
|
|
|
:page.sync="page"
|
|
:page.sync="page"
|
|
|
:items-per-page="itemsPerPage"
|
|
:items-per-page="itemsPerPage"
|
|
|
sort-by="name"
|
|
sort-by="name"
|
|
@@ -155,9 +155,10 @@
|
|
|
<template #footer>
|
|
<template #footer>
|
|
|
<v-pagination
|
|
<v-pagination
|
|
|
v-model="page"
|
|
v-model="page"
|
|
|
- :length="pageCount"
|
|
|
|
|
|
|
+ :length="pagesCount"
|
|
|
total-visible="9"
|
|
total-visible="9"
|
|
|
color="primary"
|
|
color="primary"
|
|
|
|
|
+ @input="pageUpdated"
|
|
|
/>
|
|
/>
|
|
|
</template>
|
|
</template>
|
|
|
</v-data-iterator>
|
|
</v-data-iterator>
|
|
@@ -167,7 +168,6 @@
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
<script lang="ts">
|
|
|
import Vue from 'vue'
|
|
import Vue from 'vue'
|
|
|
-import sphericDistance from '@/services/utils/geo'
|
|
|
|
|
import EventsProvider from "~/services/data/EventsProvider"
|
|
import EventsProvider from "~/services/data/EventsProvider"
|
|
|
import { today, todayIso, formatIso } from '@/services/utils/date'
|
|
import { today, todayIso, formatIso } from '@/services/utils/date'
|
|
|
import { addDays, nextSunday, addMonths } from "date-fns";
|
|
import { addDays, nextSunday, addMonths } from "date-fns";
|
|
@@ -180,29 +180,36 @@ export default Vue.extend({
|
|
|
theme: this.$route.query.theme ?? 'orange',
|
|
theme: this.$route.query.theme ?? 'orange',
|
|
|
hideTitle: this.$route.query.hideTitle === 'true',
|
|
hideTitle: this.$route.query.hideTitle === 'true',
|
|
|
events: [] as Array<PublicEvent>,
|
|
events: [] as Array<PublicEvent>,
|
|
|
- filteredEvents: [] as Array<PublicEvent>,
|
|
|
|
|
loading: true,
|
|
loading: true,
|
|
|
page: 1,
|
|
page: 1,
|
|
|
- itemsPerPage: 8,
|
|
|
|
|
|
|
+ itemsPerPage: 16,
|
|
|
textFilter: null as string | null,
|
|
textFilter: null as string | null,
|
|
|
locationFilter: null as Coordinates | null,
|
|
locationFilter: null as Coordinates | null,
|
|
|
- dateRangeFilter: defaultDateRange
|
|
|
|
|
|
|
+ dateRangeFilter: defaultDateRange,
|
|
|
|
|
+ totalRecords: 0 as number,
|
|
|
|
|
+ pagesCount: 1 as number | null,
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
async fetch () {
|
|
async fetch () {
|
|
|
- await new EventsProvider(this.$axios).getBy().then(
|
|
|
|
|
- (res) => {
|
|
|
|
|
- this.events = res
|
|
|
|
|
- this.filteredEvents = res
|
|
|
|
|
|
|
+ this.loading = true
|
|
|
|
|
+ await new EventsProvider(this.$axios).getBy(
|
|
|
|
|
+ this.textFilter,
|
|
|
|
|
+ null,
|
|
|
|
|
+ this.dateRangeFilter.start,
|
|
|
|
|
+ this.dateRangeFilter.end,
|
|
|
|
|
+ null,
|
|
|
|
|
+ this.page,
|
|
|
|
|
+ this.itemsPerPage
|
|
|
|
|
+ ).then(
|
|
|
|
|
+ (collection: HydraCollection<PublicEvent>) => {
|
|
|
|
|
+ this.events = collection.items
|
|
|
|
|
+ this.loading = false
|
|
|
|
|
+ this.totalRecords = collection.totalItems
|
|
|
|
|
+ this.page = collection.page ?? 1
|
|
|
|
|
+ this.pagesCount = collection.lastPage ?? 1
|
|
|
})
|
|
})
|
|
|
},
|
|
},
|
|
|
computed: {
|
|
computed: {
|
|
|
- totalRecords (): number {
|
|
|
|
|
- return this.filteredEvents.length
|
|
|
|
|
- },
|
|
|
|
|
- pageCount (): number {
|
|
|
|
|
- return Math.floor(this.totalRecords / this.itemsPerPage) + 1
|
|
|
|
|
- },
|
|
|
|
|
dateRangeMin(): string {
|
|
dateRangeMin(): string {
|
|
|
return todayIso()
|
|
return todayIso()
|
|
|
},
|
|
},
|
|
@@ -236,9 +243,6 @@ export default Vue.extend({
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
methods: {
|
|
methods: {
|
|
|
- test () {
|
|
|
|
|
- console.log(this.dateRangeFilter)
|
|
|
|
|
- },
|
|
|
|
|
textFilterChanged (newVal: string) {
|
|
textFilterChanged (newVal: string) {
|
|
|
this.textFilter = newVal
|
|
this.textFilter = newVal
|
|
|
},
|
|
},
|
|
@@ -256,50 +260,17 @@ export default Vue.extend({
|
|
|
this.dateRangeFilter = defaultDateRange
|
|
this.dateRangeFilter = defaultDateRange
|
|
|
const addressSearch = this.$refs.addressSearch as any
|
|
const addressSearch = this.$refs.addressSearch as any
|
|
|
addressSearch.clear()
|
|
addressSearch.clear()
|
|
|
- this.filteredEvents = this.events
|
|
|
|
|
- },
|
|
|
|
|
- /**
|
|
|
|
|
- * Does the event match the current textFilter
|
|
|
|
|
- * @param event
|
|
|
|
|
- * @returns {boolean}
|
|
|
|
|
- */
|
|
|
|
|
- matchTextFilter (event: PublicEvent): boolean {
|
|
|
|
|
- if (!this.textFilter) { return true }
|
|
|
|
|
-
|
|
|
|
|
- return normalize(event.name).includes(normalize(this.textFilter))
|
|
|
|
|
- },
|
|
|
|
|
- /**
|
|
|
|
|
- * Does the event match the current locationFilter
|
|
|
|
|
- * @param event
|
|
|
|
|
- * @returns {boolean}
|
|
|
|
|
- */
|
|
|
|
|
- matchLocationFilter (event: PublicEvent): boolean {
|
|
|
|
|
- if (!this.locationFilter) { return true }
|
|
|
|
|
- if (event.address === null || !event.address.latitude || !event.address.longitude) { return false }
|
|
|
|
|
-
|
|
|
|
|
- const radius = 30
|
|
|
|
|
-
|
|
|
|
|
- return sphericDistance(
|
|
|
|
|
- this.locationFilter.latitude,
|
|
|
|
|
- this.locationFilter.longitude,
|
|
|
|
|
- event.address.latitude,
|
|
|
|
|
- event.address.longitude
|
|
|
|
|
- ) <= radius
|
|
|
|
|
|
|
+ this.search()
|
|
|
},
|
|
},
|
|
|
- /**
|
|
|
|
|
- * Does the event match each of the page filters
|
|
|
|
|
- * @param event
|
|
|
|
|
- * @returns {boolean}
|
|
|
|
|
- */
|
|
|
|
|
- matchFilters (event: PublicEvent): boolean {
|
|
|
|
|
- return this.matchTextFilter(event) &&
|
|
|
|
|
- this.matchLocationFilter(event)
|
|
|
|
|
|
|
+ pageUpdated (page: number): void {
|
|
|
|
|
+ this.page = page
|
|
|
|
|
+ this.search()
|
|
|
},
|
|
},
|
|
|
/**
|
|
/**
|
|
|
* Update the filteredEvents array
|
|
* Update the filteredEvents array
|
|
|
*/
|
|
*/
|
|
|
search (): void {
|
|
search (): void {
|
|
|
- this.filteredEvents = this.events.filter((e) => { return this.matchFilters(e) })
|
|
|
|
|
|
|
+ this.$fetch()
|
|
|
},
|
|
},
|
|
|
/**
|
|
/**
|
|
|
* Enhanced filter for v-autocomplete components
|
|
* Enhanced filter for v-autocomplete components
|