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'
|
|
|
|
|
2016-11-23 11:59:22 +01:00
|
|
|
import http from 'axios';
|
|
|
|
|
2016-10-10 10:57:39 +02:00
|
|
|
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() {
|
2016-11-23 11:59:22 +01:00
|
|
|
http(`${config.api}/settings`).then(value => {
|
|
|
|
const data = value.data;
|
2016-10-18 09:57:47 +02:00
|
|
|
|
|
|
|
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>
|