Add move to top and bottom context menu options
After adding an item to a playlist, I often want to move it to the top and it's tedious to drag and drop if the playlist is large. This adds 'Move to Top' and 'Move to Bottom' options to a playlist item context menu.
This commit is contained in:
@@ -291,6 +291,22 @@ export function getCommands(options) {
|
||||
});
|
||||
}
|
||||
|
||||
if (item.PlaylistItemId && options.playlistId && item.PlaylistIndex > 0) {
|
||||
commands.push({
|
||||
name: globalize.translate('MoveToTop'),
|
||||
id: 'movetotop',
|
||||
icon: 'vertical_align_top'
|
||||
});
|
||||
}
|
||||
|
||||
if (item.PlaylistItemId && options.playlistId && item.PlaylistIndex < (item.PlaylistItems - 1)) {
|
||||
commands.push({
|
||||
name: globalize.translate('MoveToBottom'),
|
||||
id: 'movetobottom',
|
||||
icon: 'vertical_align_bottom'
|
||||
});
|
||||
}
|
||||
|
||||
if (options.collectionId) {
|
||||
commands.push({
|
||||
name: globalize.translate('RemoveFromCollection'),
|
||||
@@ -559,6 +575,22 @@ function executeCommand(item, id, options) {
|
||||
getResolveFunction(resolve, id, true)();
|
||||
});
|
||||
break;
|
||||
case 'movetotop':
|
||||
apiClient.ajax({
|
||||
url: apiClient.getUrl('Playlists/' + options.playlistId + '/Items/' + item.PlaylistItemId + '/Move/0'),
|
||||
type: 'POST'
|
||||
}).then(function () {
|
||||
getResolveFunction(resolve, id, true)();
|
||||
});
|
||||
break;
|
||||
case 'movetobottom':
|
||||
apiClient.ajax({
|
||||
url: apiClient.getUrl('Playlists/' + options.playlistId + '/Items/' + item.PlaylistItemId + '/Move/' + (item.PlaylistItems - 1)),
|
||||
type: 'POST'
|
||||
}).then(function () {
|
||||
getResolveFunction(resolve, id, true)();
|
||||
});
|
||||
break;
|
||||
case 'removefromcollection':
|
||||
apiClient.ajax({
|
||||
type: 'DELETE',
|
||||
|
||||
Reference in New Issue
Block a user