Filterbar on Concert page
This commit is contained in:
@@ -16,7 +16,13 @@ concert.get("/", (req: Request, res: Response) => {
|
||||
let count = req.query.count
|
||||
|
||||
Concert.findAll({
|
||||
include: [ Band, Location ],
|
||||
include: [
|
||||
{
|
||||
model: Location,
|
||||
include: [ City ]
|
||||
},
|
||||
Band
|
||||
],
|
||||
order: [
|
||||
[ 'date', 'ASC' ]
|
||||
]
|
||||
|
||||
@@ -132,7 +132,7 @@
|
||||
"noConcertsFound": "Keine Konzerte gefunden",
|
||||
"from": "ab",
|
||||
"soldOut": "Ausverkauft",
|
||||
"city": "Stadt",
|
||||
"city": "Stadt | Städte",
|
||||
"seatPlan": "Saalplan",
|
||||
"stage": "Bühne",
|
||||
"filtering": "Filtern",
|
||||
|
||||
@@ -132,7 +132,7 @@
|
||||
"noConcertsFound": "No Concerts found",
|
||||
"from": "from",
|
||||
"soldOut": "Sold Out",
|
||||
"city": "City",
|
||||
"city": "City | Cities",
|
||||
"seatPlan": "Seat Plan",
|
||||
"stage": "Stage",
|
||||
"filtering": "Filtering",
|
||||
|
||||
@@ -14,7 +14,10 @@ function itemProps(item: GenreModel) {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<card-view :title="$t('filtering')">
|
||||
<card-view
|
||||
:title="$t('filtering')"
|
||||
icon="mdi-filter"
|
||||
>
|
||||
<v-row>
|
||||
<v-col>
|
||||
<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 cardViewHorizontal from '@/components/basics/cardViewHorizontal.vue';
|
||||
import sectionDivider from '@/components/basics/sectionDivider.vue';
|
||||
import concertFilterbar from './concertFilterbar.vue';
|
||||
|
||||
const concertStore = useConcertStore()
|
||||
|
||||
@@ -17,8 +18,7 @@ concertStore.getConcerts()
|
||||
<v-col cols="10">
|
||||
<v-row>
|
||||
<v-col>
|
||||
Filterbar
|
||||
<!-- todo: Filterbar? -->
|
||||
<concert-filterbar />
|
||||
</v-col>
|
||||
</v-row>
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ import { ref } from "vue";
|
||||
import { ConcertApiModel } from "../data/models/acts/concertApiModel";
|
||||
import { fetchConcertById, fetchAllConcerts, fetchUpcomingConcerts } from "../data/api/concertApi";
|
||||
import { ConcertDetailsApiModel } from "../data/models/acts/concertDetailsApiModel";
|
||||
import { CityModel } from "@/data/models/locations/cityModel";
|
||||
|
||||
export const useConcertStore = defineStore("concertStore", {
|
||||
state: () => ({
|
||||
@@ -15,6 +16,9 @@ export const useConcertStore = defineStore("concertStore", {
|
||||
/** Enhanced data about a specific concert */
|
||||
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 */
|
||||
fetchInProgress: ref(false)
|
||||
}),
|
||||
@@ -28,7 +32,20 @@ export const useConcertStore = defineStore("concertStore", {
|
||||
|
||||
fetchAllConcerts()
|
||||
.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
|
||||
})
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user