Commit 531b6ccb authored by jackie / Andrea Ida Malkah Klaura's avatar jackie / Andrea Ida Malkah Klaura
Browse files

FIX: update playlists table after edit

parent 38fb3e27
Pipeline #384 failed with stages
in 1 minute and 14 seconds
...@@ -788,11 +788,14 @@ export default { ...@@ -788,11 +788,14 @@ export default {
return null return null
}, },
// Returns a playlist object from the playlists array, given a playlist ID // Returns a playlist object from the playlists array, given a playlist ID.
getPlaylistById: function (id) { // If the mode parameter is used and set to 'index', then the playlists
// index in the playlist array is returned instead of the object
getPlaylistById: function (id, mode) {
for (var i in this.playlists) { for (var i in this.playlists) {
if (this.playlists[i].id === id) { if (this.playlists[i].id === id) {
return this.playlists[i] if (mode === 'index') { return i }
else { return this.playlists[i] }
} }
} }
return null return null
...@@ -944,15 +947,14 @@ export default { ...@@ -944,15 +947,14 @@ export default {
// when updating an existing playlist we use a PUT request and add the id // when updating an existing playlist we use a PUT request and add the id
// of the playlist to the uri // of the playlist to the uri
} else if (this.playlistEditor.mode === 'edit') { } else if (this.playlistEditor.mode === 'edit') {
uri += '/' + this.playlistEditor.id var id = this.playlistEditor.id
uri += '/' + id
axios.put(uri, data, { axios.put(uri, data, {
withCredentials: true, withCredentials: true,
headers: { 'Authorization': 'Bearer ' + this.$parent.user.access_token } headers: { 'Authorization': 'Bearer ' + this.$parent.user.access_token }
}).then(response => { }).then(response => {
// TODO: seems to be not implemented in the tank yet this.playlists[this.getPlaylistById(id, 'index')] = response.data
// update this as soon as tank has it implemented this.$refs.playlistsTable.refresh()
//this.playlists.push(response.data)
console.log(response.data)
}).catch(error => { }).catch(error => {
console.log('Error: ' + error.response.status + ' ' + error.response.statusText) console.log('Error: ' + error.response.status + ' ' + error.response.statusText)
console.log(error.response) console.log(error.response)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment