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

86 lines
1.9 KiB
Vue
Raw Normal View History

2016-10-10 10:57:39 +02:00
<template>
<main>
<div class="wrap-content" v-if=" ! loading">
<Item :item="item" v-for="(item, index) in items"
:key="index"
:genre="displayGenre"
:date="displayDate"
></Item>
2016-10-10 10:57:39 +02:00
2016-11-23 21:16:41 +01:00
<span class="nothing-found" v-if=" ! items.length">{{ lang('nothing found') }}</span>
2016-10-10 10:57:39 +02:00
<div class="load-more-wrap">
2016-11-23 21:16:41 +01:00
<span class="load-more" v-if=" ! clickedMoreLoading && paginator" @click="loadMore()">{{ lang('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 21:16:41 +01:00
import Helper from '../../helper';
2016-10-10 10:57:39 +02:00
2016-11-23 11:59:22 +01:00
import http from 'axios';
2016-10-10 10:57:39 +02:00
export default {
2016-11-23 21:16:41 +01:00
mixins: [Helper],
2016-10-10 10:57:39 +02:00
created() {
this.fetchData();
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('');
},
fetchSettings() {
2016-11-23 11:59:22 +01:00
http(`${config.api}/settings`).then(value => {
const data = value.data;
this.displayGenre = data.genre;
this.displayDate = data.date;
});
},
2016-10-10 10:57:39 +02:00
loadMore() {
this.loadMoreItems(this.paginator);
}
},
components: {
Item
},
watch: {
$route() {
this.fetchData();
}
2016-10-10 10:57:39 +02:00
}
}
</script>