diff --git a/src/playlist/Playlist.vue b/src/playlist/Playlist.vue index ab22382..aa1bdbf 100644 --- a/src/playlist/Playlist.vue +++ b/src/playlist/Playlist.vue @@ -3,11 +3,17 @@

{{ playlist.name }}

+ + Edit playlist + Delete playlist
+

+ {{ playlist.comment }} +

+ + + + diff --git a/src/shared/components/index.ts b/src/shared/components/index.ts index 22e8fb0..c741c28 100644 --- a/src/shared/components/index.ts +++ b/src/shared/components/index.ts @@ -13,6 +13,7 @@ import { BFormCheckbox, BFormGroup, BFormInput, + BFormTextarea, BModal, BOverlay, BProgress, @@ -27,6 +28,7 @@ Vue.component('BSidebar', BSidebar) Vue.component('BFormGroup', BFormGroup) Vue.component('BFormInput', BFormInput) Vue.component('BFormCheckbox', BFormCheckbox) +Vue.component('BFormTextarea', BFormTextarea) Vue.component('BButton', BButton) Vue.component('BProgress', BProgress) Vue.component('BOverlay', BOverlay) diff --git a/src/shared/store.ts b/src/shared/store.ts index fe61b40..4ee3036 100644 --- a/src/shared/store.ts +++ b/src/shared/store.ts @@ -41,6 +41,10 @@ const setupRootModule = (authService: AuthService, api: API): Module state.playlists = playlists .sort((a: any, b: any) => b.changed.localeCompare(a.changed)) }, + setPlaylist(state, playlist: any) { + const idx = state.playlists.findIndex(x => x.id === playlist.id) + state.playlists.splice(idx, 1, playlist) + }, removePlaylist(state, id: string) { state.playlists = state.playlists.filter(p => p.id !== id) }, @@ -62,6 +66,16 @@ const setupRootModule = (authService: AuthService, api: API): Module commit('setPlaylists', result) }) }, + updatePlaylist({ commit, state }, { id, name, comment }) { + api.editPlaylist(id, name, comment).then(() => { + const playlist = { + ...state.playlists.find(x => x.id === id), + name, + comment, + } + commit('setPlaylist', playlist) + }) + }, addTrackToPlaylist({ }, { playlistId, trackId }) { api.addToPlaylist(playlistId, trackId) },