This commit is contained in:
Vri 🌈 2023-06-22 21:04:01 +02:00
parent 3402d6f33c
commit 92ab1d5d46
Signed by: vrifox
GPG key ID: D40098E5B60B2197
4 changed files with 26 additions and 21 deletions

View file

@ -67,13 +67,12 @@ export default {
</header> </header>
<main class="flex flex-row max-w-5xl m-auto"> <main class="flex flex-row max-w-5xl m-auto">
</main>
<RouterView <RouterView
:papers="papers" :papers="papers"
:search="search" :search="search"
:filter="filter" :filter="filter"
></RouterView> ></RouterView>
</main>
<footer> <footer>
<!-- <FooterMenu /> --> <!-- <FooterMenu /> -->
</footer> </footer>

View file

@ -5,18 +5,18 @@ export default {
props: { props: {
search: Object, search: Object,
filter: Object, filter: Object,
topics: Object, topics: Array<Object>,
}, },
computed: { computed: {
filteredData() { filteredData(): Array<Object> {
const paperQuery: String = this.search?.value const paperQuery: String = this.search?.value
let filteredTopics: any = this.topics?.paper let filteredTopics: Array<Object> = this.topics as Array<Object>
if (paperQuery !== '') { /* if (paperQuery !== '') {
filteredTopics = this.topics?.paper.filter((paper: any) => { filteredTopics = this.topics?.filter((topic: Object) => {
return paper.name.toLowerCase().includes(paperQuery.toLowerCase()) || paper.content.toLowerCase().includes(paperQuery.toLowerCase()) || paper.reference.toLowerCase().includes(paperQuery.toLowerCase()) return topic.papers?.filter().name.toLowerCase().includes(paperQuery.toLowerCase()) || paper.content.toLowerCase().includes(paperQuery.toLowerCase()) || paper.reference.toLowerCase().includes(paperQuery.toLowerCase())
}) }) as Array<Object>
} } */
if (this.filter?.type !== '') { /* if (this.filter?.type !== '') {
filteredTopics = filteredTopics.filter((topic: any) => { filteredTopics = filteredTopics.filter((topic: any) => {
return topic.reference.includes(this.filter?.type.key) && topic.paper_type.includes(this.filter?.type.value) return topic.reference.includes(this.filter?.type.key) && topic.paper_type.includes(this.filter?.type.value)
}) })
@ -25,7 +25,7 @@ export default {
filteredTopics = filteredTopics.filter((topic: any) => { filteredTopics = filteredTopics.filter((topic: any) => {
return topic.originator.includes(this.filter?.originator) return topic.originator.includes(this.filter?.originator)
}) })
} } */
return filteredTopics return filteredTopics
}, },
}, },
@ -37,26 +37,31 @@ export default {
const date = new Date(paperDate) const date = new Date(paperDate)
return new Intl.DateTimeFormat('de-DE', { dateStyle: 'full' }).format(date) return new Intl.DateTimeFormat('de-DE', { dateStyle: 'full' }).format(date)
}, },
filteredDataLength(): Number {
return Object.keys(this.filteredData).length
},
}, },
} }
</script> </script>
<template> <template>
{{ topics }}
<ul <ul
v-if="filteredData" v-if="filteredDataLength"
class="w-full grid grid-flow-row gap-2 my-2" class="w-full grid grid-flow-row gap-2 my-2"
> >
<p>Wir konnten {{ filteredData.length }} Einträge finden</p> <p>Wir konnten {{ filteredDataLength }} Einträge finden</p>
{{ filteredData }}
<li <li
v-for="(paper, i) in filteredData" v-for="(topic, i) in filteredData"
:key="i" :key="i"
> >
<article <article
class="p-4 rounded-lg bg-background-100 dark:bg-background-900" class="p-4 rounded-lg bg-background-100 dark:bg-background-900"
@click.prevent="openPaper()" @click.prevent="openPaper()"
> >
<h4 class="text-xl">{{ paper.name }}</h4> <h4 class="text-xl">{{ topic }}</h4>
<p>{{ date(paper.published_at) }}: <a :href="paper.url" class="text-secondary-button-500">{{ paper.paper_type}} von {{ paper.originator }}</a></p> <p>{{ date(topic.papers[0].published_at) }}: <a :href="topic.papers[0].url" class="text-secondary-button-500">{{ paper.paper_type}} von {{ paper.originator }}</a></p>
</article> </article>
</li> </li>
</ul> </ul>

View file

@ -7,6 +7,7 @@ const routes: Array<any> = [
path: '/themen/', path: '/themen/',
name: 'topics', name: 'topics',
component: ()=>import("@/views/TheTopics.vue"), component: ()=>import("@/views/TheTopics.vue"),
props: { topics: true },
}, },
{ path: '/themen/:reference', name: 'topics.show', component: ()=>import("@/views/TopicsShow.vue") }, { path: '/themen/:reference', name: 'topics.show', component: ()=>import("@/views/TopicsShow.vue") },
{ path: '/karte', name: 'map', component: ()=>import("@/views/TheMap.vue") }, { path: '/karte', name: 'map', component: ()=>import("@/views/TheMap.vue") },

View file

@ -8,12 +8,12 @@ export default {
TopicList, TopicList,
}, },
computed: { computed: {
topics() { topics(): Array<Object> {
const topicReferences = [...new Set(this.papers?.map((paper: any) => paper.reference))] const topicReferences = [...new Set(this.papers?.map((paper: any) => paper.reference))]
return topicReferences.map( (entry: any) => { return topicReferences.map( (ref: String) => {
return { return {
'ref': entry, 'ref': ref,
'paper': this.papers?.find( (paper: any) => paper.reference == entry) 'papers': this.papers?.filter( (paper: any) => paper.reference === ref) as Object,
} }
}) })
}, },