mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Add playlist editing
This commit is contained in:
parent
9a192c7e5c
commit
363171b56d
6 changed files with 143 additions and 27 deletions
|
@ -5,7 +5,7 @@ import globalize from '../lib/globalize';
|
|||
import actionsheet from './actionSheet/actionSheet';
|
||||
import { appHost } from './apphost';
|
||||
import { appRouter } from './router/appRouter';
|
||||
import itemHelper from './itemHelper';
|
||||
import itemHelper, { canEditPlaylist } from './itemHelper';
|
||||
import { playbackManager } from './playback/playbackmanager';
|
||||
import ServerConnections from './ServerConnections';
|
||||
import toast from './toast/toast';
|
||||
|
@ -29,7 +29,7 @@ function getDeleteLabel(type) {
|
|||
}
|
||||
}
|
||||
|
||||
export function getCommands(options) {
|
||||
export async function getCommands(options) {
|
||||
const item = options.item;
|
||||
const user = options.user;
|
||||
|
||||
|
@ -209,6 +209,17 @@ export function getCommands(options) {
|
|||
});
|
||||
}
|
||||
|
||||
if (item.Type === BaseItemKind.Playlist) {
|
||||
const _canEditPlaylist = await canEditPlaylist(user, item);
|
||||
if (_canEditPlaylist) {
|
||||
commands.push({
|
||||
name: globalize.translate('Edit'),
|
||||
id: 'editplaylist',
|
||||
icon: 'edit'
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const canEdit = itemHelper.canEdit(user, item);
|
||||
if (canEdit && options.edit !== false && item.Type !== 'SeriesTimer') {
|
||||
const text = (item.Type === 'Timer' || item.Type === 'SeriesTimer') ? globalize.translate('Edit') : globalize.translate('EditMetadata');
|
||||
|
@ -466,6 +477,15 @@ function executeCommand(item, id, options) {
|
|||
case 'edit':
|
||||
editItem(apiClient, item).then(getResolveFunction(resolve, id, true), getResolveFunction(resolve, id));
|
||||
break;
|
||||
case 'editplaylist':
|
||||
import('./playlisteditor/playlisteditor').then(({ default: PlaylistEditor }) => {
|
||||
const playlistEditor = new PlaylistEditor();
|
||||
playlistEditor.show({
|
||||
id: itemId,
|
||||
serverId
|
||||
}).then(getResolveFunction(resolve, id, true), getResolveFunction(resolve, id));
|
||||
});
|
||||
break;
|
||||
case 'editimages':
|
||||
import('./imageeditor/imageeditor').then((imageEditor) => {
|
||||
imageEditor.show({
|
||||
|
@ -712,19 +732,19 @@ function refresh(apiClient, item) {
|
|||
});
|
||||
}
|
||||
|
||||
export function show(options) {
|
||||
const commands = getCommands(options);
|
||||
export async function show(options) {
|
||||
const commands = await getCommands(options);
|
||||
if (!commands.length) {
|
||||
return Promise.reject();
|
||||
throw new Error('No item commands present');
|
||||
}
|
||||
|
||||
return actionsheet.show({
|
||||
const id = await actionsheet.show({
|
||||
items: commands,
|
||||
positionTo: options.positionTo,
|
||||
resolveOnClick: ['share']
|
||||
}).then(function (id) {
|
||||
return executeCommand(options.item, id, options);
|
||||
});
|
||||
|
||||
return executeCommand(options.item, id, options);
|
||||
}
|
||||
|
||||
export default {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue