add "add/remove to library" in playlist view
This commit is contained in:
parent
f9e19fa6b2
commit
2e05c0ef9f
2 changed files with 37 additions and 10 deletions
|
@ -55,6 +55,10 @@
|
||||||
@click="app.mk.shuffleMode = 1;app.playMediaItemById(data.attributes.playParams.id ?? data.id, data.attributes.playParams.kind ?? data.type, data.attributes.playParams.isLibrary ?? false, data.attributes.url)">
|
@click="app.mk.shuffleMode = 1;app.playMediaItemById(data.attributes.playParams.id ?? data.id, data.attributes.playParams.kind ?? data.type, data.attributes.playParams.isLibrary ?? false, data.attributes.url)">
|
||||||
Shuffle
|
Shuffle
|
||||||
</button>
|
</button>
|
||||||
|
<button class="wr-btn" style="min-width: 120px;"
|
||||||
|
@click="(!inLibrary) ? addToLibrary(data.attributes.playParams.id.toString()) : removeFromLibrary(data.attributes.playParams.id.toString())">
|
||||||
|
{{ (!inLibrary) ? "Add to Library" : "Remove from Library" }}
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -89,17 +93,40 @@
|
||||||
return {
|
return {
|
||||||
editorialNotesExpanded: false,
|
editorialNotesExpanded: false,
|
||||||
drag: false,
|
drag: false,
|
||||||
nameEditing: false
|
nameEditing: false,
|
||||||
|
inLibrary: null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted: function () {
|
||||||
|
this.isInLibrary()
|
||||||
|
},
|
||||||
|
watch:{
|
||||||
|
data : function() {
|
||||||
|
this.isInLibrary()
|
||||||
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
async isInLibrary () {
|
||||||
|
if (this.data.type && !this.data.type.includes('library')){
|
||||||
|
// please keep using vars here
|
||||||
|
var params = {"fields[albums]": "inLibrary","relate" : "library"}
|
||||||
|
var res = await app.mkapi(this.data.attributes.playParams.kind ?? this.data.type, false , this.data.attributes.playParams.id ?? this.data.id, params);
|
||||||
|
this.inLibrary = (res && res.attributes && res.attributes.inLibrary) ? res.attributes.inLibrary : false} else {this.inLibrary = true}
|
||||||
|
},
|
||||||
editPlaylist() {
|
editPlaylist() {
|
||||||
app.editPlaylist(this.data.id, this.data.attributes.name);
|
app.editPlaylist(this.data.id, this.data.attributes.name);
|
||||||
this.nameEditing = false
|
this.nameEditing = false
|
||||||
},
|
},
|
||||||
|
addToLibrary(id) {
|
||||||
|
app.mk.addToLibrary(id)
|
||||||
|
this.inLibrary = true
|
||||||
|
},
|
||||||
|
removeFromLibrary(id) {
|
||||||
|
let kind = this.data.attributes.playParams.kind ?? this.data.type ?? '';
|
||||||
|
var truekind = (!kind.endsWith("s")) ? (kind + "s") : kind;
|
||||||
|
app.mk.api.library.remove({[truekind]: this.data.id ?? this.data.attributes.playParams.id })
|
||||||
|
this.inLibrary = false
|
||||||
|
},
|
||||||
editPlaylistName() {
|
editPlaylistName() {
|
||||||
if(this.data.attributes.canEdit && this.data.type == "library-playlists") {
|
if(this.data.attributes.canEdit && this.data.type == "library-playlists") {
|
||||||
this.nameEditing = true
|
this.nameEditing = true
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue