Filterbar on Concert page
This commit is contained in:
@@ -16,7 +16,13 @@ concert.get("/", (req: Request, res: Response) => {
|
|||||||
let count = req.query.count
|
let count = req.query.count
|
||||||
|
|
||||||
Concert.findAll({
|
Concert.findAll({
|
||||||
include: [ Band, Location ],
|
include: [
|
||||||
|
{
|
||||||
|
model: Location,
|
||||||
|
include: [ City ]
|
||||||
|
},
|
||||||
|
Band
|
||||||
|
],
|
||||||
order: [
|
order: [
|
||||||
[ 'date', 'ASC' ]
|
[ 'date', 'ASC' ]
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -132,7 +132,7 @@
|
|||||||
"noConcertsFound": "Keine Konzerte gefunden",
|
"noConcertsFound": "Keine Konzerte gefunden",
|
||||||
"from": "ab",
|
"from": "ab",
|
||||||
"soldOut": "Ausverkauft",
|
"soldOut": "Ausverkauft",
|
||||||
"city": "Stadt",
|
"city": "Stadt | Städte",
|
||||||
"seatPlan": "Saalplan",
|
"seatPlan": "Saalplan",
|
||||||
"stage": "Bühne",
|
"stage": "Bühne",
|
||||||
"filtering": "Filtern",
|
"filtering": "Filtern",
|
||||||
|
|||||||
@@ -132,7 +132,7 @@
|
|||||||
"noConcertsFound": "No Concerts found",
|
"noConcertsFound": "No Concerts found",
|
||||||
"from": "from",
|
"from": "from",
|
||||||
"soldOut": "Sold Out",
|
"soldOut": "Sold Out",
|
||||||
"city": "City",
|
"city": "City | Cities",
|
||||||
"seatPlan": "Seat Plan",
|
"seatPlan": "Seat Plan",
|
||||||
"stage": "Stage",
|
"stage": "Stage",
|
||||||
"filtering": "Filtering",
|
"filtering": "Filtering",
|
||||||
|
|||||||
@@ -14,7 +14,10 @@ function itemProps(item: GenreModel) {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<card-view :title="$t('filtering')">
|
<card-view
|
||||||
|
:title="$t('filtering')"
|
||||||
|
icon="mdi-filter"
|
||||||
|
>
|
||||||
<v-row>
|
<v-row>
|
||||||
<v-col>
|
<v-col>
|
||||||
<v-select
|
<v-select
|
||||||
|
|||||||
@@ -0,0 +1,51 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import cardView from '@/components/basics/cardView.vue';
|
||||||
|
import outlinedButton from '@/components/basics/outlinedButton.vue';
|
||||||
|
import { CityModel } from '@/data/models/locations/cityModel';
|
||||||
|
import { LocationModel } from '@/data/models/locations/locationModel';
|
||||||
|
import { useConcertStore } from '@/stores/concert.store';
|
||||||
|
import { useLocationStore } from '@/stores/location.store';
|
||||||
|
|
||||||
|
const concertStore = useConcertStore()
|
||||||
|
const locationStore = useLocationStore()
|
||||||
|
|
||||||
|
locationStore.getLocations()
|
||||||
|
|
||||||
|
function itemProps(item: CityModel) {
|
||||||
|
return {
|
||||||
|
title: item.name
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<card-view
|
||||||
|
:title="$t('filtering')"
|
||||||
|
icon="mdi-filter"
|
||||||
|
>
|
||||||
|
<v-row>
|
||||||
|
<v-col>
|
||||||
|
<v-select
|
||||||
|
v-model="concertStore.filteredCities"
|
||||||
|
:items="locationStore.cities"
|
||||||
|
variant="outlined"
|
||||||
|
:label="$t('city', 2)"
|
||||||
|
:item-props="itemProps"
|
||||||
|
chips
|
||||||
|
clearable
|
||||||
|
hide-details
|
||||||
|
multiple
|
||||||
|
/>
|
||||||
|
</v-col>
|
||||||
|
|
||||||
|
<v-col cols="auto">
|
||||||
|
<outlined-button
|
||||||
|
@click="concertStore.getConcerts"
|
||||||
|
height="100%"
|
||||||
|
>
|
||||||
|
{{ $t('filtering') }}
|
||||||
|
</outlined-button>
|
||||||
|
</v-col>
|
||||||
|
</v-row>
|
||||||
|
</card-view>
|
||||||
|
</template>
|
||||||
@@ -3,6 +3,7 @@ import { useConcertStore } from '@/stores/concert.store';
|
|||||||
import concertListItem from '@/components/pageParts/concertListItem.vue';
|
import concertListItem from '@/components/pageParts/concertListItem.vue';
|
||||||
import cardViewHorizontal from '@/components/basics/cardViewHorizontal.vue';
|
import cardViewHorizontal from '@/components/basics/cardViewHorizontal.vue';
|
||||||
import sectionDivider from '@/components/basics/sectionDivider.vue';
|
import sectionDivider from '@/components/basics/sectionDivider.vue';
|
||||||
|
import concertFilterbar from './concertFilterbar.vue';
|
||||||
|
|
||||||
const concertStore = useConcertStore()
|
const concertStore = useConcertStore()
|
||||||
|
|
||||||
@@ -17,8 +18,7 @@ concertStore.getConcerts()
|
|||||||
<v-col cols="10">
|
<v-col cols="10">
|
||||||
<v-row>
|
<v-row>
|
||||||
<v-col>
|
<v-col>
|
||||||
Filterbar
|
<concert-filterbar />
|
||||||
<!-- todo: Filterbar? -->
|
|
||||||
</v-col>
|
</v-col>
|
||||||
</v-row>
|
</v-row>
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { ref } from "vue";
|
|||||||
import { ConcertApiModel } from "../data/models/acts/concertApiModel";
|
import { ConcertApiModel } from "../data/models/acts/concertApiModel";
|
||||||
import { fetchConcertById, fetchAllConcerts, fetchUpcomingConcerts } from "../data/api/concertApi";
|
import { fetchConcertById, fetchAllConcerts, fetchUpcomingConcerts } from "../data/api/concertApi";
|
||||||
import { ConcertDetailsApiModel } from "../data/models/acts/concertDetailsApiModel";
|
import { ConcertDetailsApiModel } from "../data/models/acts/concertDetailsApiModel";
|
||||||
|
import { CityModel } from "@/data/models/locations/cityModel";
|
||||||
|
|
||||||
export const useConcertStore = defineStore("concertStore", {
|
export const useConcertStore = defineStore("concertStore", {
|
||||||
state: () => ({
|
state: () => ({
|
||||||
@@ -15,6 +16,9 @@ export const useConcertStore = defineStore("concertStore", {
|
|||||||
/** Enhanced data about a specific concert */
|
/** Enhanced data about a specific concert */
|
||||||
concert: ref<ConcertDetailsApiModel>(new ConcertDetailsApiModel()),
|
concert: ref<ConcertDetailsApiModel>(new ConcertDetailsApiModel()),
|
||||||
|
|
||||||
|
/** Array of cities for which the concerts should be filtered */
|
||||||
|
filteredCities: ref<Array<CityModel>>([]),
|
||||||
|
|
||||||
/** Request to server sent, waiting for data response */
|
/** Request to server sent, waiting for data response */
|
||||||
fetchInProgress: ref(false)
|
fetchInProgress: ref(false)
|
||||||
}),
|
}),
|
||||||
@@ -28,7 +32,20 @@ export const useConcertStore = defineStore("concertStore", {
|
|||||||
|
|
||||||
fetchAllConcerts()
|
fetchAllConcerts()
|
||||||
.then(result => {
|
.then(result => {
|
||||||
this.concerts = result.data
|
this.concerts = result.data.filter((concert: ConcertApiModel) => {
|
||||||
|
if (this.filteredCities.length == 0) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
for (let city of this.filteredCities) {
|
||||||
|
if (city.name == concert.location.city.name) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
})
|
||||||
|
|
||||||
this.fetchInProgress = false
|
this.fetchInProgress = false
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user