koel/resources/assets/js/mixins/has-song-list.js

47 lines
982 B
JavaScript
Raw Normal View History

2016-01-14 08:02:59 +00:00
/**
* Add necessary functionalities into a view that contains a song-list component.
*/
import { assign } from 'lodash';
2016-11-17 07:07:12 +00:00
import isMobile from 'ismobilejs';
2016-01-14 08:02:59 +00:00
2016-06-25 10:15:57 +00:00
import { playback } from '../services';
2016-01-14 08:02:59 +00:00
import songList from '../components/shared/song-list.vue';
2016-11-17 07:07:12 +00:00
import songListControls from '../components/shared/song-list-controls.vue';
2016-01-14 08:02:59 +00:00
export default {
2016-11-17 07:07:12 +00:00
components: { songList, songListControls },
2016-06-25 16:05:24 +00:00
data() {
return {
2016-11-17 07:07:12 +00:00
state: null,
2016-06-25 16:05:24 +00:00
meta: {
songCount: 0,
totalLength: '00:00',
},
2016-11-17 07:07:12 +00:00
selectedSongs: [],
isPhone: isMobile.phone,
showingControls: true,
songListControlConfig: {},
2016-06-25 16:05:24 +00:00
};
},
methods: {
setSelectedSongs(songs) {
this.selectedSongs = songs;
2016-01-14 08:02:59 +00:00
},
2016-06-25 16:05:24 +00:00
updateMeta(meta) {
this.meta = assign(this.meta, meta);
},
2016-11-17 07:07:12 +00:00
shuffleAll() {
playback.queueAndPlay(this.state.songs, true);
},
shuffleSelected() {
playback.queueAndPlay(this.selectedSongs, true);
2016-06-25 16:05:24 +00:00
},
},
2016-01-14 08:02:59 +00:00
};