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 {
let playlistTitle = ''
if (this.current.timeslots[i].playlist_id !== null) {
let playlist = this.current.playlists.find(list => list.id === this.current.timeslots[i].playlist_id)
if (playlist && playlist.description.length > 0) {
playlistTitle = playlist.description
} else {
playlistTitle = playlist.id
if (playlist) {
if (playlist.description.length > 0) {
playlistTitle = playlist.description
} else {
playlistTitle = playlist.id
}
}
}
......@@ -1075,7 +1077,7 @@ export default {
},
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
......
......@@ -19,7 +19,7 @@
</p>
<p>Available playlists:</p>
<div v-if="loaded.playlists">
<div v-if="loaded">
<b-table
ref="playlistsTable"
striped
......@@ -81,9 +81,7 @@ export default {
timeslot: null,
timeslotObject: null,
playlists: null,
loaded: {
playlists: false,
},
loaded: false,
playlistsTableFields: [
{ key: 'id', label: 'Index' },
......@@ -108,12 +106,13 @@ export default {
},
methods: {
open (show, schedule, timeslot) {
open (show, schedule, timeslot, playlists) {
this.show = show
this.schedule = schedule
this.timeslot = timeslot
this.playlists = playlists
this.timeslotObject = this.getTimeslotObject(timeslot)
this.loadPlaylists()
this.loaded = true
this.$refs.modalShowManagerPlaylist.show()
},
......@@ -154,24 +153,6 @@ export default {
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 () {
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