mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
use shared playlist editor
This commit is contained in:
parent
dcb6b103ec
commit
6a539b8f3a
13 changed files with 362 additions and 303 deletions
|
@ -16,12 +16,12 @@
|
||||||
},
|
},
|
||||||
"devDependencies": {},
|
"devDependencies": {},
|
||||||
"ignore": [],
|
"ignore": [],
|
||||||
"version": "1.3.65",
|
"version": "1.3.70",
|
||||||
"_release": "1.3.65",
|
"_release": "1.3.70",
|
||||||
"_resolution": {
|
"_resolution": {
|
||||||
"type": "version",
|
"type": "version",
|
||||||
"tag": "1.3.65",
|
"tag": "1.3.70",
|
||||||
"commit": "8a512f0acee81e973007eb43566b7d3aebb7a613"
|
"commit": "5430fc4c71fcc8e5929ee2e12120e2dc7e8c9011"
|
||||||
},
|
},
|
||||||
"_source": "https://github.com/MediaBrowser/emby-webcomponents.git",
|
"_source": "https://github.com/MediaBrowser/emby-webcomponents.git",
|
||||||
"_target": "^1.2.0",
|
"_target": "^1.2.0",
|
||||||
|
|
|
@ -89,7 +89,7 @@
|
||||||
dialogHelper.close(dlg);
|
dialogHelper.close(dlg);
|
||||||
|
|
||||||
require(['toast'], function (toast) {
|
require(['toast'], function (toast) {
|
||||||
toast(globalize.translate('MessageItemsAdded'));
|
toast(globalize.translate('sharedcomponents#MessageItemsAdded'));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -118,7 +118,7 @@
|
||||||
|
|
||||||
var html = '';
|
var html = '';
|
||||||
|
|
||||||
html += '<option value="">' + globalize.translate('sharedcomponents#NewCollection') + '</option>';
|
html += '<option value="">' + globalize.translate('sharedcomponents#OptionNew') + '</option>';
|
||||||
|
|
||||||
html += result.Items.map(function (i) {
|
html += result.Items.map(function (i) {
|
||||||
|
|
||||||
|
@ -201,7 +201,7 @@
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
content.querySelector('.btnSubmit').addEventListener('submit', function () {
|
content.querySelector('.btnSubmit').addEventListener('click', function () {
|
||||||
// Do a fake form submit this the button isn't a real submit button
|
// Do a fake form submit this the button isn't a real submit button
|
||||||
var fakeSubmit = document.createElement('input');
|
var fakeSubmit = document.createElement('input');
|
||||||
fakeSubmit.setAttribute('type', 'submit');
|
fakeSubmit.setAttribute('type', 'submit');
|
||||||
|
@ -216,7 +216,7 @@
|
||||||
}, 500);
|
}, 500);
|
||||||
});
|
});
|
||||||
|
|
||||||
content.querySelector('.newCollectionForm').addEventListener('submit', onSubmit);
|
content.querySelector('form').addEventListener('submit', onSubmit);
|
||||||
|
|
||||||
content.querySelector('.fldSelectedItemIds', content).value = items.join(',');
|
content.querySelector('.fldSelectedItemIds', content).value = items.join(',');
|
||||||
|
|
||||||
|
|
|
@ -3,17 +3,14 @@
|
||||||
var globalOnOpenCallback;
|
var globalOnOpenCallback;
|
||||||
|
|
||||||
function enableAnimation() {
|
function enableAnimation() {
|
||||||
|
|
||||||
if (browser.animate) {
|
if (browser.animate) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (browser.mobile || browser.tv) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
function dialogHashHandler(dlg, hash, resolve) {
|
function dialogHashHandler(dlg, hash, resolve) {
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
font-family: inherit;
|
font-family: inherit;
|
||||||
font-weight: inherit;
|
font-weight: inherit;
|
||||||
color: inherit;
|
color: inherit;
|
||||||
padding: .6em .8em .3em 0;
|
padding: .35em .8em .3em 0;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
outline: none !important;
|
outline: none !important;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
define(['apphost', 'globalize', 'connectionManager'], function (appHost, globalize, connectionManager) {
|
define(['apphost', 'globalize', 'connectionManager', 'itemHelper'], function (appHost, globalize, connectionManager, itemHelper) {
|
||||||
|
|
||||||
function getCommands(options) {
|
function getCommands(options) {
|
||||||
|
|
||||||
|
@ -11,10 +11,19 @@ define(['apphost', 'globalize', 'connectionManager'], function (appHost, globali
|
||||||
|
|
||||||
var commands = [];
|
var commands = [];
|
||||||
|
|
||||||
|
if (itemHelper.supportsAddingToCollection(item)) {
|
||||||
commands.push({
|
commands.push({
|
||||||
name: globalize.translate('sharedcomponents#AddToCollection'),
|
name: globalize.translate('sharedcomponents#AddToCollection'),
|
||||||
id: 'addtocollection'
|
id: 'addtocollection'
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (itemHelper.supportsAddingToPlaylist(item)) {
|
||||||
|
commands.push({
|
||||||
|
name: globalize.translate('sharedcomponents#AddToPlaylist'),
|
||||||
|
id: 'addtoplaylist'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (item.CanDelete) {
|
if (item.CanDelete) {
|
||||||
commands.push({
|
commands.push({
|
||||||
|
@ -71,6 +80,18 @@ define(['apphost', 'globalize', 'connectionManager'], function (appHost, globali
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case 'addtoplaylist':
|
||||||
|
{
|
||||||
|
require(['playlistEditor'], function (playlistEditor) {
|
||||||
|
|
||||||
|
new playlistEditor().show({
|
||||||
|
items: [itemId],
|
||||||
|
serverId: serverId
|
||||||
|
|
||||||
|
}).then(reject, reject);
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
case 'download':
|
case 'download':
|
||||||
{
|
{
|
||||||
require(['fileDownloader'], function (fileDownloader) {
|
require(['fileDownloader'], function (fileDownloader) {
|
||||||
|
|
|
@ -48,7 +48,25 @@ define([], function () {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function supportsAddingToCollection(item) {
|
||||||
|
var invalidTypes = ['Person', 'Genre', 'MusicGenre', 'Studio', 'GameGenre', 'BoxSet', 'Playlist', 'UserView', 'CollectionFolder', 'Audio', 'Episode', 'TvChannel', 'Program', 'MusicAlbum', 'Timer'];
|
||||||
|
|
||||||
|
return !item.CollectionType && invalidTypes.indexOf(item.Type) == -1 && item.MediaType != 'Photo';
|
||||||
|
}
|
||||||
|
|
||||||
|
function supportsAddingToPlaylist(item) {
|
||||||
|
if (item.Type == 'Program') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (item.Type == 'Timer') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return item.RunTimeTicks || item.IsFolder || item.Type == "Genre" || item.Type == "MusicGenre" || item.Type == "MusicArtist";
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
getDisplayName: getDisplayName
|
getDisplayName: getDisplayName,
|
||||||
|
supportsAddingToCollection: supportsAddingToCollection,
|
||||||
|
supportsAddingToPlaylist: supportsAddingToPlaylist
|
||||||
};
|
};
|
||||||
});
|
});
|
279
dashboard-ui/bower_components/emby-webcomponents/playlisteditor/playlisteditor.js
vendored
Normal file
279
dashboard-ui/bower_components/emby-webcomponents/playlisteditor/playlisteditor.js
vendored
Normal file
|
@ -0,0 +1,279 @@
|
||||||
|
define(['shell', 'dialogHelper', 'loading', 'layoutManager', 'connectionManager', 'scrollHelper', 'embyRouter', 'globalize', 'paper-checkbox', 'paper-input', 'paper-icon-button-light', 'emby-select', 'html!./../icons/nav.html', 'css!./../formdialog'], function (shell, dialogHelper, loading, layoutManager, connectionManager, scrollHelper, embyRouter, globalize) {
|
||||||
|
|
||||||
|
var lastPlaylistId = '';
|
||||||
|
var currentServerId;
|
||||||
|
|
||||||
|
function parentWithClass(elem, className) {
|
||||||
|
|
||||||
|
while (!elem.classList || !elem.classList.contains(className)) {
|
||||||
|
elem = elem.parentNode;
|
||||||
|
|
||||||
|
if (!elem) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return elem;
|
||||||
|
}
|
||||||
|
|
||||||
|
function onSubmit(e) {
|
||||||
|
|
||||||
|
loading.show();
|
||||||
|
|
||||||
|
var panel = parentWithClass(this, 'dialog');
|
||||||
|
|
||||||
|
var playlistId = panel.querySelector('#selectPlaylistToAddTo').value;
|
||||||
|
var apiClient = connectionManager.getApiClient(currentServerId);
|
||||||
|
|
||||||
|
if (playlistId) {
|
||||||
|
lastPlaylistId = playlistId;
|
||||||
|
addToPlaylist(apiClient, panel, playlistId);
|
||||||
|
} else {
|
||||||
|
createPlaylist(apiClient, panel);
|
||||||
|
}
|
||||||
|
|
||||||
|
e.preventDefault();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function createPlaylist(apiClient, dlg) {
|
||||||
|
|
||||||
|
var url = apiClient.getUrl("Playlists", {
|
||||||
|
|
||||||
|
Name: dlg.querySelector('#txtNewPlaylistName').value,
|
||||||
|
Ids: dlg.querySelector('.fldSelectedItemIds').value || '',
|
||||||
|
userId: apiClient.getCurrentUserId()
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
apiClient.ajax({
|
||||||
|
type: "POST",
|
||||||
|
url: url,
|
||||||
|
dataType: "json"
|
||||||
|
|
||||||
|
}).then(function (result) {
|
||||||
|
|
||||||
|
loading.hide();
|
||||||
|
|
||||||
|
var id = result.Id;
|
||||||
|
|
||||||
|
dialogHelper.close(dlg);
|
||||||
|
redirectToPlaylist(apiClient, id);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function redirectToPlaylist(apiClient, id) {
|
||||||
|
|
||||||
|
apiClient.getItem(apiClient.getCurrentUserId(), id).then(function (item) {
|
||||||
|
|
||||||
|
embyRouter.showItem(item);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function addToPlaylist(apiClient, dlg, id) {
|
||||||
|
|
||||||
|
var url = apiClient.getUrl("Playlists/" + id + "/Items", {
|
||||||
|
|
||||||
|
Ids: dlg.querySelector('.fldSelectedItemIds').value || '',
|
||||||
|
userId: apiClient.getCurrentUserId()
|
||||||
|
});
|
||||||
|
|
||||||
|
apiClient.ajax({
|
||||||
|
type: "POST",
|
||||||
|
url: url
|
||||||
|
|
||||||
|
}).then(function () {
|
||||||
|
|
||||||
|
loading.hide();
|
||||||
|
|
||||||
|
dialogHelper.close(dlg);
|
||||||
|
|
||||||
|
require(['toast'], function (toast) {
|
||||||
|
toast(globalize.translate('sharedcomponents#MessageItemsAdded'));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function triggerChange(select) {
|
||||||
|
select.dispatchEvent(new CustomEvent('change', {}));
|
||||||
|
}
|
||||||
|
|
||||||
|
function populatePlaylists(panel) {
|
||||||
|
|
||||||
|
var select = panel.querySelector('#selectPlaylistToAddTo');
|
||||||
|
|
||||||
|
loading.hide();
|
||||||
|
|
||||||
|
panel.querySelector('.newPlaylistInfo').classList.add('hide');
|
||||||
|
|
||||||
|
var options = {
|
||||||
|
|
||||||
|
Recursive: true,
|
||||||
|
IncludeItemTypes: "Playlist",
|
||||||
|
SortBy: 'SortName'
|
||||||
|
};
|
||||||
|
|
||||||
|
var apiClient = connectionManager.getApiClient(currentServerId);
|
||||||
|
apiClient.getItems(apiClient.getCurrentUserId(), options).then(function (result) {
|
||||||
|
|
||||||
|
var html = '';
|
||||||
|
|
||||||
|
html += '<option value="">' + globalize.translate('sharedcomponents#OptionNew') + '</option>';
|
||||||
|
|
||||||
|
html += result.Items.map(function (i) {
|
||||||
|
|
||||||
|
return '<option value="' + i.Id + '">' + i.Name + '</option>';
|
||||||
|
});
|
||||||
|
|
||||||
|
select.innerHTML = html;
|
||||||
|
select.value = lastPlaylistId || '';
|
||||||
|
triggerChange(select);
|
||||||
|
|
||||||
|
loading.hide();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function getEditorHtml() {
|
||||||
|
|
||||||
|
var html = '';
|
||||||
|
|
||||||
|
html += '<div class="dialogContent smoothScrollY">';
|
||||||
|
html += '<div class="dialogContentInner centeredContent">';
|
||||||
|
html += '<form style="margin:auto;">';
|
||||||
|
|
||||||
|
html += '<div class="fldSelectPlaylist">';
|
||||||
|
html += '<select is="emby-select" id="selectPlaylistToAddTo" label="' + globalize.translate('sharedcomponents#LabelPlaylist') + '"></select>';
|
||||||
|
html += '</div>';
|
||||||
|
|
||||||
|
html += '<div class="newPlaylistInfo">';
|
||||||
|
|
||||||
|
html += '<div>';
|
||||||
|
html += '<paper-input type="text" id="txtNewPlaylistName" required="required" label="' + globalize.translate('sharedcomponents#LabelName') + '"></paper-input>';
|
||||||
|
html += '</div>';
|
||||||
|
|
||||||
|
html += '<br />';
|
||||||
|
|
||||||
|
// newPlaylistInfo
|
||||||
|
html += '</div>';
|
||||||
|
|
||||||
|
html += '<br />';
|
||||||
|
html += '<div>';
|
||||||
|
html += '<paper-button raised class="btnSubmit block">' + globalize.translate('sharedcomponents#ButtonOk') + '</paper-button>';
|
||||||
|
html += '</div>';
|
||||||
|
|
||||||
|
html += '<input type="hidden" class="fldSelectedItemIds" />';
|
||||||
|
|
||||||
|
html += '</form>';
|
||||||
|
html += '</div>';
|
||||||
|
html += '</div>';
|
||||||
|
|
||||||
|
return html;
|
||||||
|
}
|
||||||
|
|
||||||
|
function initEditor(content, items) {
|
||||||
|
|
||||||
|
content.querySelector('#selectPlaylistToAddTo').addEventListener('change', function () {
|
||||||
|
if (this.value) {
|
||||||
|
content.querySelector('.newPlaylistInfo').classList.add('hide');
|
||||||
|
content.querySelector('#txtNewPlaylistName').removeAttribute('required');
|
||||||
|
} else {
|
||||||
|
content.querySelector('.newPlaylistInfo').classList.remove('hide');
|
||||||
|
content.querySelector('#txtNewPlaylistName').setAttribute('required', 'required');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
populatePlaylists(content);
|
||||||
|
|
||||||
|
content.querySelector('.btnSubmit').addEventListener('click', function () {
|
||||||
|
// Do a fake form submit this the button isn't a real submit button
|
||||||
|
var fakeSubmit = document.createElement('input');
|
||||||
|
fakeSubmit.setAttribute('type', 'submit');
|
||||||
|
fakeSubmit.style.display = 'none';
|
||||||
|
var form = content.querySelector('form');
|
||||||
|
form.appendChild(fakeSubmit);
|
||||||
|
fakeSubmit.click();
|
||||||
|
|
||||||
|
// Seeing issues in smart tv browsers where the form does not get submitted if the button is removed prior to the submission actually happening
|
||||||
|
setTimeout(function () {
|
||||||
|
form.removeChild(fakeSubmit);
|
||||||
|
}, 500);
|
||||||
|
});
|
||||||
|
|
||||||
|
content.querySelector('form').addEventListener('submit', onSubmit);
|
||||||
|
|
||||||
|
content.querySelector('.fldSelectedItemIds', content).value = items.join(',');
|
||||||
|
|
||||||
|
if (items.length) {
|
||||||
|
content.querySelector('.fldSelectPlaylist').classList.remove('hide');
|
||||||
|
populatePlaylists(content);
|
||||||
|
} else {
|
||||||
|
content.querySelector('.fldSelectPlaylist').classList.add('hide');
|
||||||
|
|
||||||
|
var selectPlaylistToAddTo = content.querySelector('#selectPlaylistToAddTo');
|
||||||
|
selectPlaylistToAddTo.innerHTML = '';
|
||||||
|
selectPlaylistToAddTo.value = '';
|
||||||
|
triggerChange(selectPlaylistToAddTo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function playlisteditor() {
|
||||||
|
|
||||||
|
var self = this;
|
||||||
|
|
||||||
|
self.show = function (options) {
|
||||||
|
|
||||||
|
var items = options.items || {};
|
||||||
|
currentServerId = options.serverId;
|
||||||
|
|
||||||
|
var dialogOptions = {
|
||||||
|
removeOnClose: true,
|
||||||
|
scrollY: false
|
||||||
|
};
|
||||||
|
|
||||||
|
if (layoutManager.tv) {
|
||||||
|
dialogOptions.size = 'fullscreen';
|
||||||
|
} else {
|
||||||
|
dialogOptions.size = 'small';
|
||||||
|
}
|
||||||
|
|
||||||
|
var dlg = dialogHelper.createDialog(dialogOptions);
|
||||||
|
|
||||||
|
dlg.classList.add('formDialog');
|
||||||
|
|
||||||
|
var html = '';
|
||||||
|
var title = globalize.translate('sharedcomponents#AddToPlaylist');
|
||||||
|
|
||||||
|
html += '<div class="dialogHeader" style="margin:0 0 2em;">';
|
||||||
|
html += '<button is="paper-icon-button-light" class="btnCancel" tabindex="-1"><iron-icon icon="nav:arrow-back"></iron-icon></button>';
|
||||||
|
html += '<div class="dialogHeaderTitle">';
|
||||||
|
html += title;
|
||||||
|
html += '</div>';
|
||||||
|
|
||||||
|
html += '</div>';
|
||||||
|
|
||||||
|
html += getEditorHtml();
|
||||||
|
|
||||||
|
dlg.innerHTML = html;
|
||||||
|
document.body.appendChild(dlg);
|
||||||
|
|
||||||
|
initEditor(dlg, items);
|
||||||
|
|
||||||
|
dlg.querySelector('.btnCancel').addEventListener('click', function () {
|
||||||
|
|
||||||
|
dialogHelper.close(dlg);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (layoutManager.tv) {
|
||||||
|
scrollHelper.centerFocus.on(dlg.querySelector('.dialogContent'), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Promise(function (resolve, reject) {
|
||||||
|
|
||||||
|
dlg.addEventListener('close', resolve);
|
||||||
|
dialogHelper.open(dlg);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return playlisteditor;
|
||||||
|
});
|
|
@ -62,5 +62,9 @@
|
||||||
"NewCollectionHelp": "Collections allow you to create personalized groupings of movies and other library content.",
|
"NewCollectionHelp": "Collections allow you to create personalized groupings of movies and other library content.",
|
||||||
"SearchForCollectionInternetMetadata": "Search the internet for artwork and metadata",
|
"SearchForCollectionInternetMetadata": "Search the internet for artwork and metadata",
|
||||||
"LabelName": "Name:",
|
"LabelName": "Name:",
|
||||||
"NewCollectionNameExample": "Example: Star Wars Collection"
|
"NewCollectionNameExample": "Example: Star Wars Collection",
|
||||||
|
"MessageItemsAdded": "Items added.",
|
||||||
|
"OptionNew": "New...",
|
||||||
|
"LabelPlaylist": "Playlist:",
|
||||||
|
"AddToPlaylist": "Add to Playlist"
|
||||||
}
|
}
|
|
@ -1,236 +0,0 @@
|
||||||
define(['dialogHelper', 'jQuery', 'paper-input', 'paper-icon-button-light'], function (dialogHelper, $) {
|
|
||||||
|
|
||||||
var lastPlaylistId = '';
|
|
||||||
|
|
||||||
function redirectToPlaylist(id) {
|
|
||||||
|
|
||||||
var context = getParameterByName('context');
|
|
||||||
|
|
||||||
ApiClient.getItem(Dashboard.getCurrentUserId(), id).then(function (item) {
|
|
||||||
|
|
||||||
Dashboard.navigate(LibraryBrowser.getHref(item, context));
|
|
||||||
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function onAddToPlaylistFormSubmit() {
|
|
||||||
|
|
||||||
Dashboard.showLoadingMsg();
|
|
||||||
|
|
||||||
var panel = $(this).parents('.dialog')[0];
|
|
||||||
|
|
||||||
var playlistId = $('#selectPlaylistToAddTo', panel).val();
|
|
||||||
|
|
||||||
if (playlistId) {
|
|
||||||
lastPlaylistId = playlistId;
|
|
||||||
addToPlaylist(panel, playlistId);
|
|
||||||
} else {
|
|
||||||
createPlaylist(panel);
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
function createPlaylist(dlg) {
|
|
||||||
|
|
||||||
var url = ApiClient.getUrl("Playlists", {
|
|
||||||
|
|
||||||
Name: $('#txtNewPlaylistName', dlg).val(),
|
|
||||||
Ids: $('.fldSelectedItemIds', dlg).val() || '',
|
|
||||||
userId: Dashboard.getCurrentUserId()
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
ApiClient.ajax({
|
|
||||||
type: "POST",
|
|
||||||
url: url,
|
|
||||||
dataType: "json"
|
|
||||||
|
|
||||||
}).then(function (result) {
|
|
||||||
|
|
||||||
Dashboard.hideLoadingMsg();
|
|
||||||
|
|
||||||
var id = result.Id;
|
|
||||||
|
|
||||||
dialogHelper.close(dlg);
|
|
||||||
redirectToPlaylist(id);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function addToPlaylist(dlg, id) {
|
|
||||||
|
|
||||||
var url = ApiClient.getUrl("Playlists/" + id + "/Items", {
|
|
||||||
|
|
||||||
Ids: $('.fldSelectedItemIds', dlg).val() || '',
|
|
||||||
userId: Dashboard.getCurrentUserId()
|
|
||||||
});
|
|
||||||
|
|
||||||
ApiClient.ajax({
|
|
||||||
type: "POST",
|
|
||||||
url: url
|
|
||||||
|
|
||||||
}).then(function () {
|
|
||||||
|
|
||||||
Dashboard.hideLoadingMsg();
|
|
||||||
|
|
||||||
dialogHelper.close(dlg);
|
|
||||||
require(['toast'], function (toast) {
|
|
||||||
toast(Globalize.translate('MessageAddedToPlaylistSuccess'));
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function onDialogClosed() {
|
|
||||||
|
|
||||||
$(this).remove();
|
|
||||||
Dashboard.hideLoadingMsg();
|
|
||||||
}
|
|
||||||
|
|
||||||
function populatePlaylists(panel) {
|
|
||||||
|
|
||||||
var select = $('#selectPlaylistToAddTo', panel);
|
|
||||||
|
|
||||||
if (!select.length) {
|
|
||||||
|
|
||||||
$('#txtNewPlaylistName', panel).val('').focus();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Dashboard.showLoadingMsg();
|
|
||||||
|
|
||||||
$('.newPlaylistInfo', panel).hide();
|
|
||||||
|
|
||||||
var options = {
|
|
||||||
|
|
||||||
Recursive: true,
|
|
||||||
IncludeItemTypes: "Playlist",
|
|
||||||
SortBy: 'SortName'
|
|
||||||
};
|
|
||||||
|
|
||||||
ApiClient.getItems(Dashboard.getCurrentUserId(), options).then(function (result) {
|
|
||||||
|
|
||||||
var html = '';
|
|
||||||
|
|
||||||
html += '<option value="">' + Globalize.translate('OptionNewPlaylist') + '</option>';
|
|
||||||
|
|
||||||
html += result.Items.map(function (i) {
|
|
||||||
|
|
||||||
return '<option value="' + i.Id + '">' + i.Name + '</option>';
|
|
||||||
});
|
|
||||||
|
|
||||||
select.html(html).val(lastPlaylistId || '').trigger('change');
|
|
||||||
|
|
||||||
Dashboard.hideLoadingMsg();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function getEditorHtml() {
|
|
||||||
|
|
||||||
var html = '';
|
|
||||||
|
|
||||||
html += '<form style="margin:auto;">';
|
|
||||||
|
|
||||||
html += '<div class="fldSelectPlaylist">';
|
|
||||||
html += '<label for="selectPlaylistToAddTo" class="selectLabel">' + Globalize.translate('LabelSelectPlaylist') + '</label>';
|
|
||||||
html += '<select id="selectPlaylistToAddTo" data-mini="true"></select>';
|
|
||||||
html += '</div>';
|
|
||||||
|
|
||||||
html += '<div class="newPlaylistInfo">';
|
|
||||||
|
|
||||||
html += '<div>';
|
|
||||||
html += '<paper-input type="text" id="txtNewPlaylistName" required="required" label="' + Globalize.translate('LabelName') + '"></paper-input>';
|
|
||||||
html += '</div>';
|
|
||||||
|
|
||||||
html += '<br />';
|
|
||||||
|
|
||||||
// newPlaylistInfo
|
|
||||||
html += '</div>';
|
|
||||||
|
|
||||||
html += '<br />';
|
|
||||||
html += '<div>';
|
|
||||||
html += '<button type="submit" class="clearButton" data-role="none"><paper-button raised class="submit block">' + Globalize.translate('ButtonOk') + '</paper-button></button>';
|
|
||||||
html += '</div>';
|
|
||||||
|
|
||||||
html += '<input type="hidden" class="fldSelectedItemIds" />';
|
|
||||||
|
|
||||||
html += '</form>';
|
|
||||||
|
|
||||||
return html;
|
|
||||||
}
|
|
||||||
|
|
||||||
function initEditor(content, items) {
|
|
||||||
|
|
||||||
$('#selectPlaylistToAddTo', content).on('change', function () {
|
|
||||||
|
|
||||||
if (this.value) {
|
|
||||||
$('.newPlaylistInfo', content).hide();
|
|
||||||
$('input', content).removeAttr('required');
|
|
||||||
} else {
|
|
||||||
$('.newPlaylistInfo', content).show();
|
|
||||||
$('input', content).attr('required', 'required');
|
|
||||||
}
|
|
||||||
|
|
||||||
}).trigger('change');
|
|
||||||
|
|
||||||
populatePlaylists(content);
|
|
||||||
|
|
||||||
$('form', content).on('submit', onAddToPlaylistFormSubmit);
|
|
||||||
|
|
||||||
$('.fldSelectedItemIds', content).val(items.join(','));
|
|
||||||
|
|
||||||
if (items.length) {
|
|
||||||
$('.fldSelectPlaylist', content).show();
|
|
||||||
populatePlaylists(content);
|
|
||||||
} else {
|
|
||||||
$('.fldSelectPlaylist', content).hide();
|
|
||||||
$('#selectPlaylistToAddTo', content).html('').val('').trigger('change');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function playlisteditor() {
|
|
||||||
|
|
||||||
var self = this;
|
|
||||||
|
|
||||||
self.show = function (items) {
|
|
||||||
|
|
||||||
items = items || [];
|
|
||||||
|
|
||||||
var dlg = dialogHelper.createDialog({
|
|
||||||
size: 'small'
|
|
||||||
});
|
|
||||||
|
|
||||||
dlg.classList.add('ui-body-b');
|
|
||||||
dlg.classList.add('background-theme-b');
|
|
||||||
|
|
||||||
var html = '';
|
|
||||||
|
|
||||||
var title = Globalize.translate('HeaderAddToPlaylist');
|
|
||||||
|
|
||||||
html += '<div class="dialogHeader" style="margin:0 0 2em;">';
|
|
||||||
html += '<button is="paper-icon-button-light" class="btnCancel" tabindex="-1"><iron-icon icon="arrow-back"></iron-icon></button>';
|
|
||||||
html += '<div class="dialogHeaderTitle">';
|
|
||||||
html += title;
|
|
||||||
html += '</div>';
|
|
||||||
html += '</div>';
|
|
||||||
|
|
||||||
html += getEditorHtml();
|
|
||||||
|
|
||||||
dlg.innerHTML = html;
|
|
||||||
document.body.appendChild(dlg);
|
|
||||||
|
|
||||||
initEditor(dlg, items);
|
|
||||||
|
|
||||||
$(dlg).on('close', onDialogClosed);
|
|
||||||
|
|
||||||
dialogHelper.open(dlg);
|
|
||||||
|
|
||||||
$('.btnCancel', dlg).on('click', function () {
|
|
||||||
|
|
||||||
dialogHelper.close(dlg);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
return playlisteditor;
|
|
||||||
});
|
|
|
@ -1,4 +1,4 @@
|
||||||
define(['playlistManager', 'scrollHelper', 'appSettings', 'appStorage', 'apphost', 'datetime', 'jQuery', 'itemHelper', 'mediaInfo', 'scrollStyles'], function (playlistManager, scrollHelper, appSettings, appStorage, appHost, datetime, $, itemHelper, mediaInfo) {
|
define(['scrollHelper', 'appSettings', 'appStorage', 'apphost', 'datetime', 'jQuery', 'itemHelper', 'mediaInfo', 'scrollStyles'], function (scrollHelper, appSettings, appStorage, appHost, datetime, $, itemHelper, mediaInfo) {
|
||||||
|
|
||||||
function parentWithClass(elem, className) {
|
function parentWithClass(elem, className) {
|
||||||
|
|
||||||
|
@ -670,11 +670,11 @@
|
||||||
|
|
||||||
var commands = [];
|
var commands = [];
|
||||||
|
|
||||||
if (LibraryBrowser.supportsAddingToCollection(item)) {
|
if (itemHelper.supportsAddingToCollection(item)) {
|
||||||
commands.push('addtocollection');
|
commands.push('addtocollection');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (playlistManager.supportsPlaylists(item)) {
|
if (itemHelper.supportsAddingToPlaylist(item)) {
|
||||||
commands.push('playlist');
|
commands.push('playlist');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -938,9 +938,11 @@
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case 'playlist':
|
case 'playlist':
|
||||||
require(['playlistManager'], function (playlistManager) {
|
require(['playlistEditor'], function (playlistEditor) {
|
||||||
|
new playlistEditor().show({
|
||||||
playlistManager.showPanel([itemId]);
|
items: items,
|
||||||
|
serverId: serverId
|
||||||
|
});
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case 'delete':
|
case 'delete':
|
||||||
|
@ -1561,13 +1563,6 @@
|
||||||
return html;
|
return html;
|
||||||
},
|
},
|
||||||
|
|
||||||
supportsAddingToCollection: function (item) {
|
|
||||||
|
|
||||||
var invalidTypes = ['Person', 'Genre', 'MusicGenre', 'Studio', 'GameGenre', 'BoxSet', 'Playlist', 'UserView', 'CollectionFolder', 'Audio', 'Episode', 'TvChannel', 'Program', 'MusicAlbum', 'Timer'];
|
|
||||||
|
|
||||||
return !item.CollectionType && invalidTypes.indexOf(item.Type) == -1 && item.MediaType != 'Photo';
|
|
||||||
},
|
|
||||||
|
|
||||||
enableSync: function (item, user) {
|
enableSync: function (item, user) {
|
||||||
if (AppInfo.isNativeApp && !Dashboard.capabilities().SupportsSync) {
|
if (AppInfo.isNativeApp && !Dashboard.capabilities().SupportsSync) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -1604,7 +1599,7 @@
|
||||||
itemCommands.push('shuffle');
|
itemCommands.push('shuffle');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (playlistManager.supportsPlaylists(item)) {
|
if (itemHelper.supportsAddingToPlaylist(item)) {
|
||||||
|
|
||||||
if (options.showRemoveFromPlaylist) {
|
if (options.showRemoveFromPlaylist) {
|
||||||
itemCommands.push('removefromplaylist');
|
itemCommands.push('removefromplaylist');
|
||||||
|
@ -1614,7 +1609,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.showAddToCollection !== false) {
|
if (options.showAddToCollection !== false) {
|
||||||
if (LibraryBrowser.supportsAddingToCollection(item)) {
|
if (itemHelper.supportsAddingToCollection(item)) {
|
||||||
itemCommands.push('addtocollection');
|
itemCommands.push('addtocollection');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -503,9 +503,11 @@
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case 'playlist':
|
case 'playlist':
|
||||||
require(['playlistManager'], function (playlistManager) {
|
require(['playlistEditor'], function (playlistEditor) {
|
||||||
|
new playlistEditor().show({
|
||||||
playlistManager.showPanel([itemId]);
|
items: [itemId],
|
||||||
|
serverId: serverId
|
||||||
|
});
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case 'delete':
|
case 'delete':
|
||||||
|
@ -1244,11 +1246,13 @@
|
||||||
hideSelections();
|
hideSelections();
|
||||||
break;
|
break;
|
||||||
case 'playlist':
|
case 'playlist':
|
||||||
require(['playlistManager'], function (playlistManager) {
|
require(['playlistEditor'], function (playlistEditor) {
|
||||||
|
new playlistEditor().show({
|
||||||
playlistManager.showPanel(items);
|
items: items,
|
||||||
hideSelections();
|
serverId: serverId
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
hideSelections();
|
||||||
break;
|
break;
|
||||||
case 'delete':
|
case 'delete':
|
||||||
LibraryBrowser.deleteItems(items).then(function () {
|
LibraryBrowser.deleteItems(items).then(function () {
|
||||||
|
|
|
@ -1,23 +0,0 @@
|
||||||
define([], function () {
|
|
||||||
|
|
||||||
return {
|
|
||||||
|
|
||||||
showPanel: function (items) {
|
|
||||||
|
|
||||||
require(['playlisteditor'], function (playlisteditor) {
|
|
||||||
new playlisteditor().show(items);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
supportsPlaylists: function (item) {
|
|
||||||
|
|
||||||
if (item.Type == 'Program') {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (item.Type == 'Timer') {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return item.RunTimeTicks || item.IsFolder || item.Type == "Genre" || item.Type == "MusicGenre" || item.Type == "MusicArtist";
|
|
||||||
}
|
|
||||||
};
|
|
||||||
});
|
|
|
@ -1769,6 +1769,7 @@ var AppInfo = {};
|
||||||
|
|
||||||
define("emby-select", [embyWebComponentsBowerPath + "/emby-select/emby-select"], returnFirstDependency);
|
define("emby-select", [embyWebComponentsBowerPath + "/emby-select/emby-select"], returnFirstDependency);
|
||||||
define("collectionEditor", [embyWebComponentsBowerPath + "/collectioneditor/collectioneditor"], returnFirstDependency);
|
define("collectionEditor", [embyWebComponentsBowerPath + "/collectioneditor/collectioneditor"], returnFirstDependency);
|
||||||
|
define("playlistEditor", [embyWebComponentsBowerPath + "/playlisteditor/playlisteditor"], returnFirstDependency);
|
||||||
define("recordingCreator", [embyWebComponentsBowerPath + "/recordingcreator/recordingcreator"], returnFirstDependency);
|
define("recordingCreator", [embyWebComponentsBowerPath + "/recordingcreator/recordingcreator"], returnFirstDependency);
|
||||||
define("recordingEditor", [embyWebComponentsBowerPath + "/recordingcreator/recordingeditor"], returnFirstDependency);
|
define("recordingEditor", [embyWebComponentsBowerPath + "/recordingcreator/recordingeditor"], returnFirstDependency);
|
||||||
define("mediaInfo", [embyWebComponentsBowerPath + "/mediainfo/mediainfo"], returnFirstDependency);
|
define("mediaInfo", [embyWebComponentsBowerPath + "/mediainfo/mediainfo"], returnFirstDependency);
|
||||||
|
@ -1804,7 +1805,6 @@ var AppInfo = {};
|
||||||
paths.appStorage = apiClientBowerPath + "/appstorage";
|
paths.appStorage = apiClientBowerPath + "/appstorage";
|
||||||
}
|
}
|
||||||
|
|
||||||
paths.playlistManager = "scripts/playlistmanager";
|
|
||||||
paths.syncDialog = "scripts/sync";
|
paths.syncDialog = "scripts/sync";
|
||||||
|
|
||||||
var sha1Path = bowerPath + "/cryptojslib/components/sha1-min";
|
var sha1Path = bowerPath + "/cryptojslib/components/sha1-min";
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue