mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
add show method for PlaylistEditor Class
This commit is contained in:
parent
675a59adc4
commit
d702ad938a
7 changed files with 37 additions and 11 deletions
|
@ -339,7 +339,8 @@ function executeCommand(item, id, options) {
|
||||||
break;
|
break;
|
||||||
case 'addtoplaylist':
|
case 'addtoplaylist':
|
||||||
import('./playlisteditor/playlisteditor').then(({ default: PlaylistEditor }) => {
|
import('./playlisteditor/playlisteditor').then(({ default: PlaylistEditor }) => {
|
||||||
new PlaylistEditor({
|
const playlistEditor = new PlaylistEditor();
|
||||||
|
playlistEditor.show({
|
||||||
items: [itemId],
|
items: [itemId],
|
||||||
serverId: serverId
|
serverId: serverId
|
||||||
}).then(getResolveFunction(resolve, id, true), getResolveFunction(resolve, id));
|
}).then(getResolveFunction(resolve, id, true), getResolveFunction(resolve, id));
|
||||||
|
|
|
@ -6,7 +6,6 @@ import dom from '../../scripts/dom';
|
||||||
import './multiSelect.scss';
|
import './multiSelect.scss';
|
||||||
import ServerConnections from '../ServerConnections';
|
import ServerConnections from '../ServerConnections';
|
||||||
import alert from '../alert';
|
import alert from '../alert';
|
||||||
import PlaylistEditor from '../playlisteditor/playlisteditor';
|
|
||||||
import confirm from '../confirm/confirm';
|
import confirm from '../confirm/confirm';
|
||||||
import itemHelper from '../itemHelper';
|
import itemHelper from '../itemHelper';
|
||||||
import datetime from '../../scripts/datetime';
|
import datetime from '../../scripts/datetime';
|
||||||
|
@ -269,9 +268,16 @@ function showMenuForSelectedItems(e) {
|
||||||
dispatchNeedsRefresh();
|
dispatchNeedsRefresh();
|
||||||
break;
|
break;
|
||||||
case 'playlist':
|
case 'playlist':
|
||||||
new PlaylistEditor({
|
import('../playlisteditor/playlisteditor').then(({ default: PlaylistEditor }) => {
|
||||||
items: items,
|
const playlistEditor = new PlaylistEditor();
|
||||||
serverId: serverId
|
playlistEditor.show({
|
||||||
|
items: items,
|
||||||
|
serverId: serverId
|
||||||
|
}).catch(() => {
|
||||||
|
// Dialog closed
|
||||||
|
});
|
||||||
|
}).catch(err => {
|
||||||
|
console.error('[AddToPlaylist] failed to load playlist editor', err);
|
||||||
});
|
});
|
||||||
hideSelections();
|
hideSelections();
|
||||||
dispatchNeedsRefresh();
|
dispatchNeedsRefresh();
|
||||||
|
|
|
@ -222,7 +222,7 @@ function centerFocus(elem, horiz, on) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export class PlaylistEditor {
|
export class PlaylistEditor {
|
||||||
constructor(options) {
|
show(options) {
|
||||||
const items = options.items || {};
|
const items = options.items || {};
|
||||||
currentServerId = options.serverId;
|
currentServerId = options.serverId;
|
||||||
|
|
||||||
|
|
|
@ -704,15 +704,20 @@ export default function () {
|
||||||
import('../playlisteditor/playlisteditor').then(({ default: PlaylistEditor }) => {
|
import('../playlisteditor/playlisteditor').then(({ default: PlaylistEditor }) => {
|
||||||
getSaveablePlaylistItems().then(function (items) {
|
getSaveablePlaylistItems().then(function (items) {
|
||||||
const serverId = items.length ? items[0].ServerId : ApiClient.serverId();
|
const serverId = items.length ? items[0].ServerId : ApiClient.serverId();
|
||||||
new PlaylistEditor({
|
const playlistEditor = new PlaylistEditor();
|
||||||
|
playlistEditor.show({
|
||||||
items: items.map(function (i) {
|
items: items.map(function (i) {
|
||||||
return i.Id;
|
return i.Id;
|
||||||
}),
|
}),
|
||||||
serverId: serverId,
|
serverId: serverId,
|
||||||
enableAddToPlayQueue: false,
|
enableAddToPlayQueue: false,
|
||||||
defaultValue: 'new'
|
defaultValue: 'new'
|
||||||
|
}).catch(() => {
|
||||||
|
// Dialog closed
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
}).catch(err => {
|
||||||
|
console.error('[savePlaylist] failed to load playlist editor', err);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -282,11 +282,15 @@ function executeAction(card, target, action) {
|
||||||
|
|
||||||
function addToPlaylist(item) {
|
function addToPlaylist(item) {
|
||||||
import('./playlisteditor/playlisteditor').then(({ default: PlaylistEditor }) => {
|
import('./playlisteditor/playlisteditor').then(({ default: PlaylistEditor }) => {
|
||||||
new PlaylistEditor().show({
|
const playlistEditor = new PlaylistEditor();
|
||||||
|
playlistEditor.show({
|
||||||
items: [item.Id],
|
items: [item.Id],
|
||||||
serverId: item.ServerId
|
serverId: item.ServerId
|
||||||
|
}).catch(() => {
|
||||||
|
// Dialog closed
|
||||||
});
|
});
|
||||||
|
}).catch(err => {
|
||||||
|
console.error('[addToPlaylist] failed to load playlist editor', err);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -401,10 +401,15 @@ function onNewItemClick() {
|
||||||
const instance = this;
|
const instance = this;
|
||||||
|
|
||||||
import('../components/playlisteditor/playlisteditor').then(({ default: PlaylistEditor }) => {
|
import('../components/playlisteditor/playlisteditor').then(({ default: PlaylistEditor }) => {
|
||||||
new PlaylistEditor({
|
const playlistEditor = new PlaylistEditor();
|
||||||
|
playlistEditor.show({
|
||||||
items: [],
|
items: [],
|
||||||
serverId: instance.params.serverId
|
serverId: instance.params.serverId
|
||||||
|
}).catch(() => {
|
||||||
|
// Dialog closed
|
||||||
});
|
});
|
||||||
|
}).catch(err => {
|
||||||
|
console.error('[onNewItemClick] failed to load playlist editor', err);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -187,10 +187,15 @@ export default function (view) {
|
||||||
view.querySelector('.btnNewPlaylist').addEventListener('click', function () {
|
view.querySelector('.btnNewPlaylist').addEventListener('click', function () {
|
||||||
import('../components/playlisteditor/playlisteditor').then(({ default: PlaylistEditor }) => {
|
import('../components/playlisteditor/playlisteditor').then(({ default: PlaylistEditor }) => {
|
||||||
const serverId = ApiClient.serverInfo().Id;
|
const serverId = ApiClient.serverInfo().Id;
|
||||||
new PlaylistEditor({
|
const playlistEditor = new PlaylistEditor();
|
||||||
|
playlistEditor.show({
|
||||||
items: [],
|
items: [],
|
||||||
serverId: serverId
|
serverId: serverId
|
||||||
|
}).catch(() => {
|
||||||
|
// Dialog closed
|
||||||
});
|
});
|
||||||
|
}).catch(err => {
|
||||||
|
console.error('[btnNewPlaylist] failed to load playlist editor', err);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
onViewStyleChange();
|
onViewStyleChange();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue