2016-10-10 10:57:39 +02:00
|
|
|
<template>
|
|
|
|
<main>
|
|
|
|
<div class="wrap-content" v-if=" ! loading">
|
2016-10-18 09:57:47 +02:00
|
|
|
<Item :item="item" v-for="(item, index) in items"
|
|
|
|
:key="index"
|
|
|
|
:genre="displayGenre"
|
|
|
|
:date="displayDate"
|
|
|
|
></Item>
|
2016-10-10 10:57:39 +02:00
|
|
|
|
|
|
|
<span class="nothing-found" v-if=" ! items.length">No Movies Found</span>
|
|
|
|
|
|
|
|
<div class="load-more-wrap">
|
2016-10-18 09:57:47 +02:00
|
|
|
<span class="load-more" v-if=" ! clickedMoreLoading && paginator" @click="loadMore()">Load More</span>
|
2016-10-10 10:57:39 +02:00
|
|
|
<span class="loader" v-if="clickedMoreLoading"><i></i></span>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<span class="loader fullsize-loader" v-if="loading"><i></i></span>
|
|
|
|
</main>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import Item from './Item.vue';
|
|
|
|
import { mapActions, mapState } from 'vuex'
|
|
|
|
|
|
|
|
export default {
|
|
|
|
created() {
|
|
|
|
this.fetchData();
|
2016-10-18 09:57:47 +02:00
|
|
|
this.fetchSettings();
|
|
|
|
},
|
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
displayGenre: null,
|
|
|
|
displayDate: null
|
|
|
|
}
|
2016-10-10 10:57:39 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
computed: {
|
|
|
|
...mapState({
|
|
|
|
loading: state => state.loading,
|
|
|
|
items: state => state.items,
|
|
|
|
userFilter: state => state.userFilter,
|
|
|
|
clickedMoreLoading: state => state.clickedMoreLoading,
|
|
|
|
paginator: state => state.paginator
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
...mapActions([ 'loadItems', 'loadMoreItems', 'setSearchTitle' ]),
|
|
|
|
|
|
|
|
fetchData() {
|
|
|
|
this.loadItems(this.userFilter);
|
|
|
|
this.setSearchTitle('');
|
|
|
|
},
|
|
|
|
|
2016-10-18 09:57:47 +02:00
|
|
|
fetchSettings() {
|
|
|
|
this.$http.get(`${config.api}/settings`).then(value => {
|
|
|
|
const data = value.body;
|
|
|
|
|
|
|
|
this.displayGenre = data.genre;
|
|
|
|
this.displayDate = data.date;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2016-10-10 10:57:39 +02:00
|
|
|
loadMore() {
|
|
|
|
this.loadMoreItems(this.paginator);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
components: {
|
|
|
|
Item
|
|
|
|
},
|
|
|
|
|
|
|
|
watch: {
|
2016-10-18 09:57:47 +02:00
|
|
|
$route() {
|
|
|
|
this.fetchData();
|
|
|
|
}
|
2016-10-10 10:57:39 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|