Skip to content
Snippets Groups Projects
Commit 176a4cd2 authored by Konrad Mohrfeldt's avatar Konrad Mohrfeldt :koala:
Browse files

refactor: simplify PlaylistSelector logic

parent ed43a7ea
No related branches found
No related tags found
No related merge requests found
...@@ -106,15 +106,16 @@ import { mapGetters } from 'vuex' ...@@ -106,15 +106,16 @@ import { mapGetters } from 'vuex'
import prettyDate from '@/mixins/prettyDate' import prettyDate from '@/mixins/prettyDate'
import playlist from '@/mixins/playlist' import playlist from '@/mixins/playlist'
import { useTimeSlotStore } from '@/stores/timeslots'
export default { export default {
mixins: [prettyDate, playlist], mixins: [prettyDate, playlist],
props: {
timeslot: { type: Object, required: true },
},
data() { data() {
return { return {
scheduleId: null, scheduleId: null,
timeslot: null,
audioFile: null, audioFile: null,
audioUpload: false, audioUpload: false,
audioUploadError: '', audioUploadError: '',
...@@ -167,7 +168,6 @@ export default { ...@@ -167,7 +168,6 @@ export default {
getTimeslotById: 'shows/getTimeslotById', getTimeslotById: 'shows/getTimeslotById',
}), }),
}, },
methods: { methods: {
upload(event) { upload(event) {
event.preventDefault() event.preventDefault()
...@@ -211,15 +211,14 @@ export default { ...@@ -211,15 +211,14 @@ export default {
this.audioUpload = !this.audioUpload this.audioUpload = !this.audioUpload
}, },
open(scheduleId, timeslotId) { open(scheduleId) {
this.audioFile = null this.audioFile = null
this.audioUpload = false this.audioUpload = false
this.scheduleId = scheduleId this.scheduleId = scheduleId
this.timeslot = this.getTimeslotById(timeslotId)
this.$refs.modalPlaylistSelector.show() this.$refs.modalPlaylistSelector.show()
}, },
choose(data) { async choose(data) {
const { item } = data || {} const { item } = data || {}
const { id } = item || {} const { id } = item || {}
let confirmed = true let confirmed = true
...@@ -229,16 +228,8 @@ export default { ...@@ -229,16 +228,8 @@ export default {
} }
if (confirmed) { if (confirmed) {
const ts = { ...this.timeslot } const timeslotStore = useTimeSlotStore()
ts.playlistId = id await timeslotStore.partialUpdate(this.timeslot.id, { playlistId: id ?? null })
this.$store.dispatch('shows/updateTimeslot', {
showId: this.selectedShow.id,
scheduleId: this.scheduleId,
timeslot: ts,
callback: () => {
this.timeslot = this.getTimeslotById(ts.id)
},
})
} }
}, },
......
...@@ -65,7 +65,7 @@ ...@@ -65,7 +65,7 @@
</tr> </tr>
<Teleport to="body"> <Teleport to="body">
<PlaylistModal ref="playlistModal" /> <PlaylistModal ref="playlistModal" :timeslot="timeslot" />
<NoteEditorModal <NoteEditorModal
v-model="localNoteId" v-model="localNoteId"
:is-open="showNoteEditor" :is-open="showNoteEditor"
...@@ -132,6 +132,6 @@ function editNote() { ...@@ -132,6 +132,6 @@ function editNote() {
} }
function editPlaylist() { function editPlaylist() {
playlistModal.value.open(props.timeslot.scheduleId, props.timeslot.id) playlistModal.value.open(props.timeslot.scheduleId)
} }
</script> </script>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment