2019-06-03 13:06:44 +02:00
|
|
|
<template>
|
|
|
|
<div id="Base">
|
2020-11-27 23:02:59 +01:00
|
|
|
<div class="loading" v-if="!searchinfos">
|
2021-06-01 22:46:15 +02:00
|
|
|
<span>{{ $t('default.Loading…') }}</span>
|
2019-06-10 18:30:48 +02:00
|
|
|
</div>
|
|
|
|
<div class="cards-list" v-else>
|
|
|
|
<aside class="search-info">
|
|
|
|
{{ searchinfos }}
|
|
|
|
</aside>
|
2020-11-27 23:02:59 +01:00
|
|
|
<div class="loading" v-if="!items.length & !noresults">
|
2021-06-01 22:46:15 +02:00
|
|
|
<span>{{ $t('default.Loading…') }}</span>
|
2020-11-27 23:02:59 +01:00
|
|
|
</div>
|
|
|
|
<ul v-else>
|
2021-02-22 16:05:54 +01:00
|
|
|
<li v-for="item in items" v-bind:key="item.id">
|
2020-12-24 14:50:13 +01:00
|
|
|
<Card v-if="item.bundle == 'materiau'" :item="item"/>
|
|
|
|
<CardThematique v-if="item.bundle == 'thematique'" :item="item"/>
|
2019-06-03 13:06:44 +02:00
|
|
|
</li>
|
|
|
|
</ul>
|
2019-06-12 12:16:15 +02:00
|
|
|
<infinite-loading
|
|
|
|
v-if="count > limit"
|
|
|
|
@infinite="nextPage"
|
|
|
|
>
|
|
|
|
<div slot="no-more">No more results</div>
|
|
|
|
</infinite-loading>
|
2019-06-03 13:06:44 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
|
|
|
import Card from 'vuejs/components/Content/Card'
|
2020-12-24 14:50:13 +01:00
|
|
|
import CardThematique from 'vuejs/components/Content/CardThematique'
|
2019-06-03 13:06:44 +02:00
|
|
|
|
|
|
|
import { mapState, mapActions } from 'vuex'
|
|
|
|
|
|
|
|
export default {
|
|
|
|
name: "Base",
|
2019-06-06 18:12:07 +02:00
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
pagetitle:"Base",
|
|
|
|
// searchinfos: null
|
|
|
|
}
|
|
|
|
},
|
2019-06-03 13:06:44 +02:00
|
|
|
computed: {
|
|
|
|
...mapState({
|
2019-06-06 18:12:07 +02:00
|
|
|
items: state => state.Search.items,
|
2019-06-12 12:16:15 +02:00
|
|
|
searchinfos: state => state.Search.infos,
|
|
|
|
count: state => state.Search.count,
|
2020-11-27 23:02:59 +01:00
|
|
|
noresults: state => state.Search.noresults,
|
2019-06-12 12:16:15 +02:00
|
|
|
limit: state => state.Search.limit
|
2019-06-03 13:06:44 +02:00
|
|
|
})
|
|
|
|
},
|
2019-06-04 22:38:44 +02:00
|
|
|
methods: {
|
|
|
|
...mapActions({
|
2019-06-12 12:16:15 +02:00
|
|
|
newSearch: 'Search/newSearch',
|
|
|
|
nextPage: 'Search/nextPage'
|
|
|
|
}),
|
|
|
|
// infiniteHandler($state){
|
2021-03-31 18:42:05 +02:00
|
|
|
// console.log('inifiniteHandler', $state)
|
2019-06-12 12:16:15 +02:00
|
|
|
// this.nextPage()
|
|
|
|
// }
|
2019-06-04 22:38:44 +02:00
|
|
|
},
|
|
|
|
created() {
|
2019-06-06 17:37:43 +02:00
|
|
|
// at first page load or first route entering launch a search if params exists in url query
|
2021-03-31 18:42:05 +02:00
|
|
|
console.log('Base created() location',window.location)
|
2019-06-04 22:38:44 +02:00
|
|
|
let params = new URLSearchParams(window.location.search)
|
2021-04-05 12:45:58 +02:00
|
|
|
if (params.has('keys')) {
|
2019-06-04 22:38:44 +02:00
|
|
|
this.$store.commit('Search/setKeys', params.get('keys'))
|
2019-06-06 18:12:07 +02:00
|
|
|
this.pagetitle = params.get('keys')
|
2021-03-31 18:42:05 +02:00
|
|
|
} else {
|
2021-01-19 16:30:14 +01:00
|
|
|
this.$store.commit('Search/setKeys', '')
|
|
|
|
this.pagetitle = 'Base'
|
2019-06-04 22:38:44 +02:00
|
|
|
}
|
2021-04-05 12:45:58 +02:00
|
|
|
|
2022-08-12 17:00:49 +02:00
|
|
|
if (params.has('terms')) {
|
|
|
|
console.log('Base created, has terms', params.get('terms'))
|
|
|
|
// this.$store.commit('Search/setTerms', params.get('terms').split(','))
|
|
|
|
this.$store.commit('Search/setTerms', JSON.parse(params.get('terms')))
|
2021-04-05 12:45:58 +02:00
|
|
|
} else {
|
2022-08-12 17:00:49 +02:00
|
|
|
this.$store.commit('Search/setTerms', [])
|
2021-04-05 12:45:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (params.has('filters')) {
|
|
|
|
this.$store.commit('Search/setFilters', params.get('filters').split(','))
|
|
|
|
} else {
|
|
|
|
this.$store.commit('Search/setFilters', [])
|
|
|
|
}
|
|
|
|
|
|
|
|
this.newSearch()
|
2019-06-04 22:38:44 +02:00
|
|
|
},
|
|
|
|
beforeRouteUpdate (to, from, next) {
|
2019-06-06 17:37:43 +02:00
|
|
|
// when query change launch a new search
|
2021-03-31 18:42:05 +02:00
|
|
|
console.log('Base beforeRouteUpdate', to, from, next)
|
2019-06-04 22:38:44 +02:00
|
|
|
this.$store.commit('Search/setKeys', to.query.keys)
|
2022-08-12 17:00:49 +02:00
|
|
|
this.$store.commit('Search/setTerms', to.query.terms)
|
2021-04-05 12:45:58 +02:00
|
|
|
this.$store.commit('Search/setFilters', to.query.filters)
|
2019-06-06 18:12:07 +02:00
|
|
|
this.pagetitle = to.query.keys
|
2019-06-04 22:38:44 +02:00
|
|
|
this.newSearch()
|
|
|
|
next()
|
|
|
|
},
|
2019-06-03 13:06:44 +02:00
|
|
|
components: {
|
2020-12-24 14:50:13 +01:00
|
|
|
Card,
|
|
|
|
CardThematique
|
2019-06-03 13:06:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
2019-06-12 12:16:15 +02:00
|
|
|
|
2019-06-03 13:06:44 +02:00
|
|
|
</style>
|