synchie
This commit is contained in:
parent
073082b520
commit
c31e93eefd
4 changed files with 14 additions and 11 deletions
|
@ -36,5 +36,4 @@ onUpdated(() => updateSearch(searchValue, searchType))
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
{{ searchValue + searchType }}
|
|
||||||
</template>
|
</template>
|
|
@ -6,13 +6,19 @@ import { computed, onMounted, onUpdated } from 'vue';
|
||||||
const filteredData = computed(() => {
|
const filteredData = computed(() => {
|
||||||
const searchValue: string = state.search.value;
|
const searchValue: string = state.search.value;
|
||||||
let filteredTopics = state.topics
|
let filteredTopics = state.topics
|
||||||
if (state.search.value !== '') {
|
let testi = null
|
||||||
|
|
||||||
|
if (searchValue !== '') {
|
||||||
filteredTopics = state.topics?.filter((topic: Topic) => {
|
filteredTopics = state.topics?.filter((topic: Topic) => {
|
||||||
return topic.papers?.filter((paper) => {
|
return topic.papers?.filter((paper) => {
|
||||||
paper.name.toLowerCase().includes(searchValue.toLowerCase()) /* || paper.content.toLowerCase().includes(searchValue.toLowerCase()) || paper.reference.toLowerCase().includes(searchValue.toLowerCase()) */
|
paper.name.toLowerCase().includes(searchValue.toLowerCase())
|
||||||
|
// || paper.content.toLowerCase().includes(searchValue.toLowerCase())
|
||||||
|
// || paper.reference.toLowerCase().includes(searchValue.toLowerCase())
|
||||||
|
testi = paper.name.toLowerCase().includes(searchValue.toLowerCase())
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
console.log(testi)
|
||||||
/* 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)
|
||||||
|
@ -43,7 +49,7 @@ onUpdated(() => {
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
{{ state.search.value }}
|
{{ filteredData }}
|
||||||
<ul
|
<ul
|
||||||
v-if="filteredDataLength > 0"
|
v-if="filteredDataLength > 0"
|
||||||
class="w-full grid grid-flow-row gap-2 my-2"
|
class="w-full grid grid-flow-row gap-2 my-2"
|
||||||
|
|
|
@ -13,7 +13,7 @@ interface State {
|
||||||
export const state: State = reactive({
|
export const state: State = reactive({
|
||||||
papers: [],
|
papers: [],
|
||||||
topics: [],
|
topics: [],
|
||||||
search: { value: ref(), type: ref() },
|
search: { value: '', type: '' },
|
||||||
filter: [],
|
filter: [],
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -33,8 +33,8 @@ export function getTopics() {
|
||||||
|
|
||||||
export function updateSearch(searchValue: Ref, searchType: Ref) {
|
export function updateSearch(searchValue: Ref, searchType: Ref) {
|
||||||
state.search = {
|
state.search = {
|
||||||
value: searchValue,
|
value: searchValue.value,
|
||||||
type: searchType,
|
type: searchType.value,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
import type { Ref } from "vue";
|
|
||||||
|
|
||||||
export interface Topic {
|
export interface Topic {
|
||||||
reference: string,
|
reference: string,
|
||||||
papers: Array<Paper>,
|
papers: Array<Paper>,
|
||||||
|
@ -18,8 +16,8 @@ export interface Paper {
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Search {
|
export interface Search {
|
||||||
value: Ref,
|
value: string,
|
||||||
type: Ref,
|
type: string,
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Filter {
|
export interface Filter {
|
||||||
|
|
Loading…
Reference in a new issue