2019-06-03 13:06:44 +02:00
|
|
|
<template>
|
|
|
|
<div id="Base">
|
2019-06-10 18:30:48 +02:00
|
|
|
<div class="loading" v-if="!items.length">
|
|
|
|
<span>Loading ...</span>
|
|
|
|
</div>
|
|
|
|
<div class="cards-list" v-else>
|
|
|
|
<aside class="search-info">
|
|
|
|
{{ searchinfos }}
|
|
|
|
</aside>
|
2019-06-03 13:06:44 +02:00
|
|
|
<ul>
|
2019-06-11 18:04:46 +02:00
|
|
|
<li v-for="item in items" v-bind:key="item.uuid">
|
2019-06-03 13:06:44 +02:00
|
|
|
<Card :item="item"/>
|
|
|
|
</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'
|
|
|
|
|
|
|
|
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,
|
|
|
|
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){
|
|
|
|
// console.log('inifiniteHandler', $state);
|
|
|
|
// 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
|
2019-06-04 22:38:44 +02:00
|
|
|
console.log('Base created() location',window.location);
|
|
|
|
let params = new URLSearchParams(window.location.search)
|
2019-06-06 17:37:43 +02:00
|
|
|
if(params.has('keys') || params.has('term')){
|
2019-06-04 22:38:44 +02:00
|
|
|
this.$store.commit('Search/setKeys', params.get('keys'))
|
2019-06-06 17:37:43 +02:00
|
|
|
this.$store.commit('Search/setTerm', params.get('term'))
|
2019-06-06 18:12:07 +02:00
|
|
|
this.pagetitle = params.get('keys')
|
2019-06-04 22:38:44 +02:00
|
|
|
this.newSearch()
|
|
|
|
}
|
|
|
|
},
|
|
|
|
beforeRouteUpdate (to, from, next) {
|
2019-06-06 17:37:43 +02:00
|
|
|
// when query change launch a new search
|
2019-06-04 22:38:44 +02:00
|
|
|
console.log('Base beforeRouteUpdate', to, from, next);
|
|
|
|
this.$store.commit('Search/setKeys', to.query.keys)
|
|
|
|
this.$store.commit('Search/setTerm', to.query.term)
|
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: {
|
|
|
|
Card
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
2019-06-12 12:16:15 +02:00
|
|
|
|
2019-06-03 13:06:44 +02:00
|
|
|
</style>
|