Skip to content

Commit

Permalink
Implement dropdown to choose playlist in mediaupload dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
ssrahn committed Aug 31, 2023
1 parent e09f38c commit 87cd322
Showing 1 changed file with 49 additions and 16 deletions.
65 changes: 49 additions & 16 deletions vueapp/components/Videos/VideoUpload.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,20 @@
name="title" id="titleField" v-model="upload.title" required>
</label>

<label>
<span v-translate>
Zu Wiedergabeliste hinzufügen
</span>

<select v-model="upload.playlist" required>
<option v-for="playlist in upload_playlists"
v-bind:key="playlist.id"
:value="playlist.id">
{{ playlist.title }}
</option>
</select>
</label>

<label>
<span class="required" v-translate>
Aufnahmezeitpunkt
Expand Down Expand Up @@ -229,6 +243,7 @@ export default {
creator: this.currentUser.username,
contributor: this.currentUser.fullname,
workflow: null,
playlist: null,
recordDate: format(new Date(), "yyyy-MM-dd'T'HH:ii", { locale: de}),
subject: this.$gettext('Medienupload, Stud.IP')
},
Expand All @@ -245,9 +260,21 @@ export default {
'config' : 'simple_config_list',
'course_config': 'course_config',
'cid' : 'cid',
'playlist' : 'playlist'
'playlist' : 'playlist',
'playlists' : 'playlists'
}),
upload_playlists() {
let upload_playlists = this.playlists
if (!this.playlist) {
upload_playlists.unshift({
id: null,
title: 'Keine Wiedergabeliste auswählen'
})
}
return upload_playlists;
},
upload_workflows() {
let upload_wfs = [];
Expand Down Expand Up @@ -379,28 +406,30 @@ export default {
}
});
// If a playlist is selected, add the Video to the playlist
if (view.playlist) {
view.$store.dispatch('createVideo', {
'episode': episode_id,
'config_id': view.selectedServer.id,
'title': uploadData.title,
'description': uploadData.description
})
.then(({ data }) => {
this.$store.dispatch('addMessage', data.message);
if(data.event?.token) {
// Add event to database
view.$store.dispatch('createVideo', {
'episode': episode_id,
'config_id': view.selectedServer.id,
'title': uploadData.title,
'description': uploadData.description
})
.then(({ data }) => {
this.$store.dispatch('addMessage', data.message);
// If a playlist is selected, connect event with playlist
if (data.event?.token && uploadData.playlist) {
let playlist = view.playlists.find(p => p.id === uploadData.playlist);
if (playlist) {
this.$store.dispatch('addVideoToPlaylists', {
token: data.event.token,
playlists: [view.playlist],
playlists: [playlist],
})
.then(({data}) => {
this.$store.dispatch('addMessage', data.message);
})
}
});
}
}
});
}
});
},
Expand All @@ -425,6 +454,10 @@ export default {
if (this.cid) {
this.$store.dispatch('loadCourseConfig', this.cid);
}
if (this.playlist) {
this.upload.playlist = this.playlist.id;
}
}
}
</script>

0 comments on commit 87cd322

Please sign in to comment.