1
0
mirror of https://github.com/devfake/flox.git synced 2024-11-15 14:42:31 +01:00
flox/client/app/components/Content/Suggestions.vue

61 lines
1.1 KiB
Vue
Raw Normal View History

2016-10-13 11:11:10 +02:00
<template>
<main>
<div class="wrap-content" v-if=" ! loading">
<Item v-for="(item, index) in suggestItems" :item="item" :key="index"></Item>
</div>
<span class="loader fullsize-loader" v-if="loading"><i></i></span>
</main>
</template>
<script>
import Item from './Item.vue';
import Helper from '../../helper';
import { mapState, mapMutations } from 'vuex'
export default {
mixins: [Helper],
created() {
this.initSuggestions();
},
data() {
return {
suggestItems: []
}
},
computed: {
...mapState({
loading: state => state.loading
})
},
methods: {
...mapMutations([ 'SET_LOADING' ]),
initSuggestions() {
this.SET_LOADING(true);
const tmdbID = this.$route.query.for;
this.$http.get(`${config.api}/suggestions/${tmdbID}`).then(value => {
this.suggestItems = value.body;
this.SET_LOADING(false);
})
}
},
components: {
Item
},
watch: {
$route() {
this.scrollToTop();
this.initSuggestions();
}
}
}
</script>