added add to playlist to playlists and albums
This commit is contained in:
parent
747be8849b
commit
93c24a2a38
3 changed files with 39 additions and 29 deletions
|
@ -1,5 +1,4 @@
|
||||||
<script type="text/x-template" id="add-to-playlist">
|
<script type="text/x-template" id="add-to-playlist">
|
||||||
<template>
|
|
||||||
<div class="modal-fullscreen addtoplaylist-panel" @click.self="app.resetState()" @contextmenu.self="app.resetState()">
|
<div class="modal-fullscreen addtoplaylist-panel" @click.self="app.resetState()" @contextmenu.self="app.resetState()">
|
||||||
<div class="modal-window">
|
<div class="modal-window">
|
||||||
<div class="modal-header">
|
<div class="modal-header">
|
||||||
|
@ -30,7 +29,6 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
@ -65,7 +63,7 @@
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
playlistSelect(playlist) {
|
playlistSelect(playlist) {
|
||||||
if(playlist.type != "library-playlist-folders") {
|
if (playlist.type != "library-playlist-folders") {
|
||||||
this.addToPlaylist(playlist.id)
|
this.addToPlaylist(playlist.id)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -40,7 +40,7 @@
|
||||||
relateMediaItems: {
|
relateMediaItems: {
|
||||||
type: Array,
|
type: Array,
|
||||||
required: false,
|
required: false,
|
||||||
default () {
|
default() {
|
||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -62,30 +62,33 @@
|
||||||
this.icon = await this.$root.getSvgIcon("./assets/feather/folder.svg")
|
this.icon = await this.$root.getSvgIcon("./assets/feather/folder.svg")
|
||||||
}
|
}
|
||||||
let playlistMap = this.$root.playlists.trackMapping
|
let playlistMap = this.$root.playlists.trackMapping
|
||||||
if(this.relateMediaItems.length != 0) {
|
if (this.relateMediaItems.length != 0) {
|
||||||
if(playlistMap[this.relateMediaItems[0]].includes(this.item.id)) {
|
if (playlistMap[this.relateMediaItems[0]]) {
|
||||||
this.hasRelatedMediaItems = true
|
if (playlistMap[this.relateMediaItems[0]].includes(this.item.id)) {
|
||||||
|
this.hasRelatedMediaItems = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
clickEvent() {
|
clickEvent() {
|
||||||
if(this.item.type != "library-playlist-folders") {
|
if (this.item.type != "library-playlist-folders") {
|
||||||
if(this.playlistSelect) {
|
if (this.playlistSelect) {
|
||||||
this.playlistSelect(this.item)
|
this.playlistSelect(this.item)
|
||||||
}else{
|
} else {
|
||||||
this.openPlaylist(this.item)
|
this.openPlaylist(this.item)
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
this.getPlaylistChildren(this.item)
|
this.getPlaylistChildren(this.item)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
rename() {
|
rename() {
|
||||||
this.renaming = false
|
this.renaming = false
|
||||||
|
|
||||||
if(this.item.type === "library-playlist-folders") {
|
if (this.item.type === "library-playlist-folders") {
|
||||||
this.$root.editPlaylistFolder(this.item.id, this.item.attributes.name)
|
this.$root.editPlaylistFolder(this.item.id, this.item.attributes.name)
|
||||||
}else{
|
} else {
|
||||||
this.$root.editPlaylist(this.item.id, this.item.attributes.name)
|
this.$root.editPlaylist(this.item.id, this.item.attributes.name)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -93,7 +96,7 @@
|
||||||
let self = this
|
let self = this
|
||||||
this.children = []
|
this.children = []
|
||||||
this.children = this.$root.playlists.listing.filter(child => {
|
this.children = this.$root.playlists.listing.filter(child => {
|
||||||
if(child.parent == self.item.id) {
|
if (child.parent == self.item.id) {
|
||||||
return child
|
return child
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -117,13 +120,13 @@
|
||||||
|
|
||||||
// find the item in this.$root.playlists.listing and store it in a variable
|
// find the item in this.$root.playlists.listing and store it in a variable
|
||||||
this.$root.playlists.listing.filter(playlist => {
|
this.$root.playlists.listing.filter(playlist => {
|
||||||
if(playlist.id == item.id) {
|
if (playlist.id == item.id) {
|
||||||
console.log(playlist)
|
console.log(playlist)
|
||||||
playlist.parent = sendTo.id
|
playlist.parent = sendTo.id
|
||||||
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
if(typeof this.$parent.getChildren == "function") {
|
if (typeof this.$parent.getChildren == "function") {
|
||||||
this.$parent.getChildren()
|
this.$parent.getChildren()
|
||||||
console.log(this.$parent.children)
|
console.log(this.$parent.children)
|
||||||
}
|
}
|
||||||
|
@ -142,14 +145,14 @@
|
||||||
id: this.playlistRoot,
|
id: this.playlistRoot,
|
||||||
type: "library-playlist-folders"
|
type: "library-playlist-folders"
|
||||||
})
|
})
|
||||||
setTimeout(()=>{self.getChildren()}, 2000)
|
setTimeout(() => { self.getChildren() }, 2000)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"rename": {
|
"rename": {
|
||||||
name: this.$root.getLz('action.rename'),
|
name: this.$root.getLz('action.rename'),
|
||||||
action: () => {
|
action: () => {
|
||||||
this.renaming = true
|
this.renaming = true
|
||||||
setTimeout(()=>{
|
setTimeout(() => {
|
||||||
document.querySelector(".pl-rename-field").focus()
|
document.querySelector(".pl-rename-field").focus()
|
||||||
document.querySelector(".pl-rename-field").select()
|
document.querySelector(".pl-rename-field").select()
|
||||||
}, 100)
|
}, 100)
|
||||||
|
@ -171,7 +174,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(this.item.type === "library-playlist-folders") {
|
if (this.item.type === "library-playlist-folders") {
|
||||||
menu.items.addToFavorites.disabled = true
|
menu.items.addToFavorites.disabled = true
|
||||||
}
|
}
|
||||||
app.showMenuPanel(menu, event)
|
app.showMenuPanel(menu, event)
|
||||||
|
@ -180,23 +183,23 @@
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
evt.dataTransfer.dropEffect = "move";
|
evt.dataTransfer.dropEffect = "move";
|
||||||
},
|
},
|
||||||
onDrop (evt) {
|
onDrop(evt) {
|
||||||
let data = JSON.parse(evt.dataTransfer.getData("text/plain"))
|
let data = JSON.parse(evt.dataTransfer.getData("text/plain"))
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
if(data.id == this.item.id) {
|
if (data.id == this.item.id) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
console.log(data)
|
console.log(data)
|
||||||
if(data) {
|
if (data) {
|
||||||
if(this.item.type == "library-playlists" || this.item.type == "library-playlist-folders") {
|
if (this.item.type == "library-playlists" || this.item.type == "library-playlist-folders") {
|
||||||
if(data.type == "library-playlists" && this.item.type == "library-playlists") {
|
if (data.type == "library-playlists" && this.item.type == "library-playlists") {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.move(data, this.item)
|
this.move(data, this.item)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
startDrag (evt) {
|
startDrag(evt) {
|
||||||
evt.dataTransfer.dropEffect = 'move'
|
evt.dataTransfer.dropEffect = 'move'
|
||||||
evt.dataTransfer.effectAllowed = 'move'
|
evt.dataTransfer.effectAllowed = 'move'
|
||||||
evt.dataTransfer.setData('text/plain', JSON.stringify(this.item))
|
evt.dataTransfer.setData('text/plain', JSON.stringify(this.item))
|
||||||
|
@ -211,11 +214,11 @@
|
||||||
this.children = []
|
this.children = []
|
||||||
this.getChildren()
|
this.getChildren()
|
||||||
this.toggleFolder()
|
this.toggleFolder()
|
||||||
|
|
||||||
this.$root.mk.api.v3.music(`v1/me/library/playlist-folders/${item.id}/children`).then(data => {
|
this.$root.mk.api.v3.music(`v1/me/library/playlist-folders/${item.id}/children`).then(data => {
|
||||||
let children = data.data.data;
|
let children = data.data.data;
|
||||||
children.forEach(child => {
|
children.forEach(child => {
|
||||||
if(!self.$root.playlists.listing.find(listing => listing.id == child.id)) {
|
if (!self.$root.playlists.listing.find(listing => listing.id == child.id)) {
|
||||||
child.parent = self.item.id
|
child.parent = self.item.id
|
||||||
self.$root.playlists.listing.push(child)
|
self.$root.playlists.listing.push(child)
|
||||||
}
|
}
|
||||||
|
@ -234,9 +237,9 @@
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
isPlaylistSelected(item) {
|
isPlaylistSelected(item) {
|
||||||
if(this.$root.showingPlaylist.id == item.id) {
|
if (this.$root.showingPlaylist.id == item.id) {
|
||||||
return ["active"]
|
return ["active"]
|
||||||
} else {
|
} else {
|
||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -483,6 +483,15 @@
|
||||||
|
|
||||||
let menuItems = {
|
let menuItems = {
|
||||||
items: {
|
items: {
|
||||||
|
"addToPlaylist": {
|
||||||
|
name: app.getLz('action.addToPlaylist'),
|
||||||
|
"icon": "./assets/feather/list.svg",
|
||||||
|
action: () => {
|
||||||
|
app.selectedMediaItems = []
|
||||||
|
app.select_selectMediaItem(this.data.attributes.playParams.id ?? this.data.id, this.data.attributes.playParams.kind ?? this.data.type, 0, 0, this.data.attributes.playParams.isLibrary ?? false)
|
||||||
|
app.promptAddToPlaylist()
|
||||||
|
}
|
||||||
|
},
|
||||||
"share": {
|
"share": {
|
||||||
name: app.getLz('term.share'),
|
name: app.getLz('term.share'),
|
||||||
icon: "./assets/feather/share.svg",
|
icon: "./assets/feather/share.svg",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue