koel/resources/assets/js/components/main-wrapper/main-content/albums.vue

79 lines
1.7 KiB
Vue
Raw Normal View History

2015-12-13 04:42:28 +00:00
<template>
2016-06-25 16:05:24 +00:00
<section id="albumsWrapper">
<h1 class="heading">
<span>Albums</span>
2016-10-31 04:28:12 +00:00
<view-mode-switch :mode="viewMode" for="albums"/>
2016-06-25 16:05:24 +00:00
</h1>
2015-12-13 04:42:28 +00:00
<div class="albums main-scroll-wrap" :class="'as-'+viewMode" @scroll="scrolling">
2016-10-31 04:28:12 +00:00
<album-item v-for="item in displayedItems" :album="item"/>
<span class="item filler" v-for="n in 6"/>
<to-top-button :showing="showBackToTop"/>
2016-06-25 16:05:24 +00:00
</div>
</section>
2015-12-13 04:42:28 +00:00
</template>
<script>
2016-06-25 16:05:24 +00:00
import { filterBy, limitBy, event } from '../../../utils';
import { albumStore } from '../../../stores';
import albumItem from '../../shared/album-item.vue';
import viewModeSwitch from '../../shared/view-mode-switch.vue';
import infiniteScroll from '../../../mixins/infinite-scroll';
2016-06-25 16:05:24 +00:00
export default {
mixins: [infiniteScroll],
components: { albumItem, viewModeSwitch },
2015-12-13 04:42:28 +00:00
2016-06-25 16:05:24 +00:00
data() {
return {
perPage: 9,
numOfItems: 9,
q: '',
viewMode: null,
};
},
2015-12-13 04:42:28 +00:00
2016-06-25 16:05:24 +00:00
computed: {
displayedItems() {
return limitBy(
filterBy(albumStore.all, this.q, 'name', 'artist.name'),
this.numOfItems
);
},
},
2015-12-13 04:42:28 +00:00
2016-06-25 16:05:24 +00:00
methods: {
changeViewMode(mode) {
this.viewMode = mode;
},
},
2015-12-30 04:14:47 +00:00
2016-06-25 16:05:24 +00:00
created() {
event.on({
/**
* When the application is ready, load the first batch of items.
*/
'koel:ready': () => this.displayMore(),
2016-01-07 06:15:25 +00:00
2016-06-25 16:05:24 +00:00
'koel:teardown': () => {
this.q = '';
this.numOfItems = 9;
},
2016-06-25 05:24:55 +00:00
2016-06-25 16:05:24 +00:00
'filter:changed': q => this.q = q,
});
},
};
2015-12-13 04:42:28 +00:00
</script>
<style lang="sass">
2016-06-25 16:05:24 +00:00
@import "../../../../sass/partials/_vars.scss";
@import "../../../../sass/partials/_mixins.scss";
2015-12-13 04:42:28 +00:00
2016-06-25 16:05:24 +00:00
#albumsWrapper {
.albums {
@include artist-album-wrapper();
}
}
2015-12-13 04:42:28 +00:00
</style>