mirror of
https://github.com/koel/koel
synced 2024-11-28 15:00:42 +00:00
Refactor
This commit is contained in:
parent
d449076e2b
commit
03017604ae
5 changed files with 41 additions and 47 deletions
|
@ -167,10 +167,11 @@
|
|||
/**
|
||||
* Load (display) a main panel (view).
|
||||
*
|
||||
* @param string view The view, which can be found under components/main-wrapper/main-content.
|
||||
* @param string view The view, which can be found under components/main-wrapper/main-content.
|
||||
* @param [...args] Extra data to attach to the view.
|
||||
*/
|
||||
loadMainView(view) {
|
||||
this.$broadcast('main-content-view:load', view);
|
||||
loadMainView(view, ...args) {
|
||||
this.$broadcast('main-content-view:load', view, ...args);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -179,15 +180,13 @@
|
|||
* @param {Object} playlist The playlist object
|
||||
*/
|
||||
loadPlaylist(playlist) {
|
||||
this.$broadcast('playlist:load', playlist);
|
||||
this.loadMainView('playlist');
|
||||
this.loadMainView('playlist', playlist);
|
||||
},
|
||||
|
||||
/**
|
||||
* Load the Favorites view.
|
||||
*/
|
||||
loadFavorites() {
|
||||
this.$broadcast('favorites:load');
|
||||
this.loadMainView('favorites');
|
||||
},
|
||||
|
||||
|
@ -197,8 +196,7 @@
|
|||
* @param {Object} album The album object
|
||||
*/
|
||||
loadAlbum(album) {
|
||||
this.$broadcast('album:load', album);
|
||||
this.loadMainView('album');
|
||||
this.loadMainView('album', album);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -207,8 +205,7 @@
|
|||
* @param {Object} artist The artist object
|
||||
*/
|
||||
loadArtist(artist) {
|
||||
this.$broadcast('artist:load', artist);
|
||||
this.loadMainView('artist');
|
||||
this.loadMainView('artist', artist);
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
@ -69,13 +69,16 @@
|
|||
|
||||
events: {
|
||||
/**
|
||||
* Listen to 'album:load' event (triggered from $root currently)
|
||||
* to load the requested album into view.
|
||||
*
|
||||
* @param {Object} album
|
||||
* Listen to 'main-content-view:load' event (triggered from $root currently)
|
||||
* to load the requested album into view if applicable.
|
||||
*
|
||||
* @param {string} view The view name
|
||||
* @param {Object} album The album object
|
||||
*/
|
||||
'album:load': function (album) {
|
||||
this.album = album;
|
||||
'main-content-view:load': function (view, album) {
|
||||
if (view === 'album') {
|
||||
this.album = album;
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
|
|
|
@ -69,14 +69,17 @@
|
|||
|
||||
events: {
|
||||
/**
|
||||
* Listen to 'artist:load' event (triggered from $root currently)
|
||||
* to load the requested artist into view.
|
||||
*
|
||||
* @param {Object} artist
|
||||
* Listen to 'main-content-view:load' event (triggered from $root currently)
|
||||
* to load the requested artist into view if applicable.
|
||||
*
|
||||
* @param {string} view The view's name
|
||||
* @param {Object} artist
|
||||
*/
|
||||
'artist:load': function (artist) {
|
||||
artistStore.getSongsByArtist(artist);
|
||||
this.artist = artist;
|
||||
'main-content-view:load': function (view, artist) {
|
||||
if (view === 'artist') {
|
||||
artistStore.getSongsByArtist(artist);
|
||||
this.artist = artist;
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
|
|
|
@ -76,13 +76,16 @@
|
|||
|
||||
events: {
|
||||
/**
|
||||
* Listen to 'playlist:load' event (triggered from $root currently)
|
||||
* to load the requested playlist into view.
|
||||
*
|
||||
* @param {Object} playlist
|
||||
* Listen to 'main-content-view:load' event (triggered from $root currently)
|
||||
* to load the requested playlist into view if applicable.
|
||||
*
|
||||
* @param {string} view The view's name.
|
||||
* @param {Object} playlist
|
||||
*/
|
||||
'playlist:load': function (playlist) {
|
||||
this.playlist = playlist;
|
||||
'main-content-view:load': function (view, playlist) {
|
||||
if (view === 'playlist') {
|
||||
this.playlist = playlist;
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
|
|
|
@ -151,24 +151,12 @@
|
|||
},
|
||||
|
||||
events: {
|
||||
/**
|
||||
* Listen to 'playlist:load' event to determine if the current item should be highlighted.
|
||||
*
|
||||
* @param {Object} playlist The playlist being loaded.
|
||||
*/
|
||||
'playlist:load': function (playlist) {
|
||||
this.active = this.playlist === playlist;
|
||||
},
|
||||
|
||||
/**
|
||||
* Listen to 'favorites:load' event to highlight the Favorites item if need be.
|
||||
*/
|
||||
'favorites:load': function () {
|
||||
this.active = this.isFavorites;
|
||||
},
|
||||
|
||||
'main-content-view:load': function (view) {
|
||||
if (view !== 'playlist' && view !== 'favorites') {
|
||||
'main-content-view:load': function (view, playlist) {
|
||||
if (view === 'favorites') {
|
||||
this.active = this.isFavorites;
|
||||
} else if (view === 'playlist') {
|
||||
this.active = this.playlist === playlist;
|
||||
} else {
|
||||
this.active = false;
|
||||
}
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue