Commit 1e025c79 authored by jackie / Andrea Ida Malkah Klaura's avatar jackie / Andrea Ida Malkah Klaura
Browse files

refactoring ShowManager playlist modal

parent c9fa9f05
...@@ -833,10 +833,12 @@ export default { ...@@ -833,10 +833,12 @@ export default {
let playlistTitle = '' let playlistTitle = ''
if (this.current.timeslots[i].playlist_id !== null) { if (this.current.timeslots[i].playlist_id !== null) {
let playlist = this.current.playlists.find(list => list.id === this.current.timeslots[i].playlist_id) let playlist = this.current.playlists.find(list => list.id === this.current.timeslots[i].playlist_id)
if (playlist && playlist.description.length > 0) { if (playlist) {
playlistTitle = playlist.description if (playlist.description.length > 0) {
} else { playlistTitle = playlist.description
playlistTitle = playlist.id } else {
playlistTitle = playlist.id
}
} }
} }
...@@ -1075,7 +1077,7 @@ export default { ...@@ -1075,7 +1077,7 @@ export default {
}, },
editTimeslotPlaylist: function (show, schedule, timeslot) { editTimeslotPlaylist: function (show, schedule, timeslot) {
this.$refs.appModalPlaylist.open(show, schedule, timeslot) this.$refs.appModalPlaylist.open(show, schedule, timeslot, this.current.playlists)
}, },
// For a given timeslot ID return the corresponding note, if there is one // For a given timeslot ID return the corresponding note, if there is one
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
</p> </p>
<p>Available playlists:</p> <p>Available playlists:</p>
<div v-if="loaded.playlists"> <div v-if="loaded">
<b-table <b-table
ref="playlistsTable" ref="playlistsTable"
striped striped
...@@ -81,9 +81,7 @@ export default { ...@@ -81,9 +81,7 @@ export default {
timeslot: null, timeslot: null,
timeslotObject: null, timeslotObject: null,
playlists: null, playlists: null,
loaded: { loaded: false,
playlists: false,
},
playlistsTableFields: [ playlistsTableFields: [
{ key: 'id', label: 'Index' }, { key: 'id', label: 'Index' },
...@@ -108,12 +106,13 @@ export default { ...@@ -108,12 +106,13 @@ export default {
}, },
methods: { methods: {
open (show, schedule, timeslot) { open (show, schedule, timeslot, playlists) {
this.show = show this.show = show
this.schedule = schedule this.schedule = schedule
this.timeslot = timeslot this.timeslot = timeslot
this.playlists = playlists
this.timeslotObject = this.getTimeslotObject(timeslot) this.timeslotObject = this.getTimeslotObject(timeslot)
this.loadPlaylists() this.loaded = true
this.$refs.modalShowManagerPlaylist.show() this.$refs.modalShowManagerPlaylist.show()
}, },
...@@ -154,24 +153,6 @@ export default { ...@@ -154,24 +153,6 @@ export default {
return text return text
}, },
loadPlaylists () {
this.loaded.playlists = false
let uri = process.env.VUE_APP_API_TANK + 'shows/' + this.show.slug + '/playlists'
axios.get(uri, {
withCredentials: true,
headers: { 'Authorization': 'Bearer ' + this.$parent.$parent.user.access_token }
}).then(response => {
// we don't have to check separately, if there are playlists, because tank
// always provides an empty array if there are no playlists (or even if there is no corresponding show)
this.playlists = response.data.results
this.loaded.playlists = true
}).catch(error => {
this.$log.error(error.response.status + ' ' + error.response.statusText)
this.$log.error(error.response)
alert('Error: could not fetch playlists from tank. See console for details.')
})
},
notYetImplemented: function () { notYetImplemented: function () {
alert('By the mighty witchcraftry of the mother of time!\n\nThis feature is not implemented yet.') alert('By the mighty witchcraftry of the mother of time!\n\nThis feature is not implemented yet.')
}, },
......
Markdown is supported
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