diff --git a/app/client/src/components/PlaylistPopup.vue b/app/client/src/components/PlaylistPopup.vue index a760df9..56278e5 100644 --- a/app/client/src/components/PlaylistPopup.vue +++ b/app/client/src/components/PlaylistPopup.vue @@ -2,9 +2,10 @@
- + -

{{$t("Create playlist")}}

+

{{$t("Create playlist")}}

+

{{$t("Edit playlist")}}

@@ -12,12 +13,15 @@ - {{$t("Create")}} + +
{{$t("Create")}}
+
{{$t("Save")}}
+
- +

{{$t("Add to playlist")}}

@@ -54,10 +58,10 @@ export default { //Make mutable addToPlaylist: this.track?true:false, - title: '', - description: '', - type: 'Private', - types: ['Private', 'Public'], + title: this.playlist ? this.playlist.title : '', + description: this.playlist ? this.playlist.description : '', + type: this.$t('Private'), + types: [this.$t('Public'), this.$t('Private'), this.$t('Collaborative')], createLoading: false, loading: false, @@ -68,24 +72,44 @@ export default { track: { type: Object, default: null + }, + //If editing playlist + edit: { + type: Boolean, + default: false + }, + //For editting + playlist: { + type: Object, + default: null } }, methods: { //Create playlist async create() { this.createLoading = true; - - await this.$axios.post('/playlist', { - description: this.description, - title: this.title, - type: this.type.toLowerCase(), - track: this.track ? this.track.id : null - }); + if (this.edit) { + await this.$axios.put('/playlist/' + this.playlist.id, { + description: this.description, + title: this.title, + type: this.types.indexOf(this.type), + }); + } else { + await this.$axios.post('/playlist', { + description: this.description, + title: this.title, + type: this.types.indexOf(this.type), + track: this.track ? this.track.id : null + }); + } this.createLoading = false; this.$emit('created'); this.$emit('close'); - this.$root.globalSnackbar = this.$t('Added to playlist!'); + if (this.edit) + this.$emit("edit"); + else + this.$root.globalSnackbar = this.$t('Added to playlist!'); }, //Add track to playlist async addTrack(playlist) { diff --git a/app/client/src/locales/en.json b/app/client/src/locales/en.json index 0d6b36b..51e1e9b 100644 --- a/app/client/src/locales/en.json +++ b/app/client/src/locales/en.json @@ -140,5 +140,11 @@ "New update available:": "New update available:", "Shuffle": "Shuffle", "Download album cover": "Download album cover", - "Art Resolution": "Art Resolution" + "Art Resolution": "Art Resolution", + "Public": "Public", + "Private": "Private", + "Collaborative": "Collaborative", + "Edit playlist": "Edit playlist", + "Save": "Save", + "Edit": "Edit" } \ No newline at end of file diff --git a/app/client/src/views/PlaylistPage.vue b/app/client/src/views/PlaylistPage.vue index 3e020da..2c980a8 100644 --- a/app/client/src/views/PlaylistPage.vue +++ b/app/client/src/views/PlaylistPage.vue @@ -13,7 +13,12 @@ -

{{playlist.title}}

+

+ {{playlist.title}} + mdi-lock + mdi-earth + mdi-account-edit +

{{playlist.user.name}}

{{playlist.description}}
@@ -45,6 +50,10 @@ mdi-delete {{$t('Delete')}} + + mdi-pencil + {{$t('Edit')}} +
@@ -94,17 +103,24 @@ + + + + + +