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

52 lines
1.1 KiB
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.
*/
2017-05-07 17:41:12 +00:00
import { assignIn } from 'lodash'
2016-11-26 03:25:35 +00:00
import isMobile from 'ismobilejs'
2016-01-14 08:02:59 +00:00
2016-11-26 03:25:35 +00:00
import { playback } from '../services'
import songList from '../components/shared/song-list.vue'
import songListControls from '../components/shared/song-list-controls.vue'
import controlsToggler from '../components/shared/song-list-controls-toggler.vue'
2016-01-14 08:02:59 +00:00
export default {
2016-11-17 08:37:12 +00:00
components: { songList, songListControls, controlsToggler },
2016-06-25 16:05:24 +00:00
2016-11-26 03:25:35 +00:00
data () {
2016-06-25 16:05:24 +00:00
return {
2016-11-17 07:07:12 +00:00
state: null,
2016-06-25 16:05:24 +00:00
meta: {
songCount: 0,
2016-11-26 03:25:35 +00:00
totalLength: '00:00'
2016-06-25 16:05:24 +00:00
},
2016-11-17 07:07:12 +00:00
selectedSongs: [],
2016-11-17 08:37:12 +00:00
showingControls: false,
2016-11-17 07:07:12 +00:00
songListControlConfig: {},
2016-11-26 03:25:35 +00:00
isPhone: isMobile.phone
}
2016-06-25 16:05:24 +00:00
},
methods: {
2016-11-26 03:25:35 +00:00
setSelectedSongs (songs) {
this.selectedSongs = songs
2016-01-14 08:02:59 +00:00
},
2016-06-25 16:05:24 +00:00
2016-11-26 03:25:35 +00:00
updateMeta (meta) {
2017-05-07 17:41:12 +00:00
assignIn(this.meta, meta)
2016-06-25 16:05:24 +00:00
},
2016-11-26 03:25:35 +00:00
shuffleAll () {
playback.queueAndPlay(this.state.songs, true)
2016-11-17 07:07:12 +00:00
},
2016-11-26 03:25:35 +00:00
shuffleSelected () {
playback.queueAndPlay(this.selectedSongs, true)
2016-06-25 16:05:24 +00:00
},
2016-11-17 08:37:12 +00:00
2016-11-26 03:25:35 +00:00
toggleControls () {
this.showingControls = !this.showingControls
2016-11-17 08:37:12 +00:00
}
2016-11-26 03:25:35 +00:00
}
}