2016-01-14 08:02:59 +00:00
|
|
|
/**
|
|
|
|
* Add necessary functionalities into a view that contains a song-list component.
|
|
|
|
*/
|
|
|
|
|
2016-03-31 07:44:36 +00:00
|
|
|
import { assign } from 'lodash';
|
2016-01-14 08:02:59 +00:00
|
|
|
|
2016-06-25 05:24:55 +00:00
|
|
|
import { event } from '../utils';
|
2016-06-25 10:15:57 +00:00
|
|
|
import { playback } from '../services';
|
2016-01-14 08:02:59 +00:00
|
|
|
import addToMenu from '../components/shared/add-to-menu.vue';
|
|
|
|
import songList from '../components/shared/song-list.vue';
|
|
|
|
|
|
|
|
export default {
|
2016-06-25 16:05:24 +00:00
|
|
|
components: { addToMenu, songList },
|
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
/**
|
|
|
|
* Whether or not to show the "Add To" button in the header.
|
|
|
|
*
|
|
|
|
* @type {Boolean}
|
|
|
|
*/
|
|
|
|
showingAddToMenu: false,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* An array of selected songs in the list.
|
|
|
|
*
|
|
|
|
* @type {Array.<Object>}
|
|
|
|
*/
|
|
|
|
selectedSongs: [],
|
|
|
|
|
|
|
|
meta: {
|
|
|
|
songCount: 0,
|
|
|
|
totalLength: '00:00',
|
|
|
|
},
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
/**
|
|
|
|
* Shuffles the currently selected songs.
|
|
|
|
*/
|
|
|
|
shuffleSelected() {
|
|
|
|
if (this.selectedSongs.length < 2) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
playback.queueAndPlay(this.selectedSongs, true);
|
2016-01-14 08:02:59 +00:00
|
|
|
},
|
|
|
|
|
2016-06-25 16:05:24 +00:00
|
|
|
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);
|
|
|
|
},
|
|
|
|
|
|
|
|
closeAddToMenu() {
|
|
|
|
this.showingAddToMenu = false;
|
|
|
|
},
|
|
|
|
},
|
2016-01-14 08:02:59 +00:00
|
|
|
};
|