mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
add Add to collection buttons
This commit is contained in:
parent
9b452f3b53
commit
218e086d94
19 changed files with 481 additions and 214 deletions
|
@ -24,6 +24,12 @@
|
|||
|
||||
Dashboard.getPluginSecurityInfo().done(function (pluginSecurityInfo) {
|
||||
|
||||
if (pluginSecurityInfo.IsMBSupporter) {
|
||||
$('.supporterPromotion', page).hide();
|
||||
} else {
|
||||
$('.supporterPromotion', page).show();
|
||||
}
|
||||
|
||||
DashboardPage.renderSupporterIcon(page, pluginSecurityInfo);
|
||||
});
|
||||
|
||||
|
|
|
@ -90,7 +90,7 @@
|
|||
fileOptions.includeFiles = options.includeFiles;
|
||||
}
|
||||
|
||||
options.header = options.header || Globalize.translate('HeaderSelectMediaPath');
|
||||
options.header = options.header || Globalize.translate('HeaderSelectPath');
|
||||
options.instruction = options.instruction || "";
|
||||
|
||||
var html = '<div data-role="popup" id="popupDirectoryPicker" class="popup" style="min-width:65%;">';
|
||||
|
|
|
@ -908,13 +908,17 @@
|
|||
}
|
||||
}
|
||||
|
||||
if (BoxSetEditor.supportsAddingToCollection(item)) {
|
||||
itemCommands.push('addtocollection');
|
||||
}
|
||||
|
||||
if (options.playFromHere) {
|
||||
itemCommands.push('playfromhere');
|
||||
itemCommands.push('queuefromhere');
|
||||
}
|
||||
|
||||
// There's no detail page with a dedicated delete function
|
||||
if (item.Type == 'Playlist') {
|
||||
if (item.Type == 'Playlist' || item.Type == 'BoxSet') {
|
||||
itemCommands.push('delete');
|
||||
}
|
||||
|
||||
|
|
|
@ -185,6 +185,17 @@
|
|||
return false;
|
||||
}
|
||||
|
||||
function onAddToCollectionButtonClick() {
|
||||
|
||||
var id = this.getAttribute('data-itemid');
|
||||
|
||||
closeContextMenu();
|
||||
|
||||
BoxSetEditor.showPanel([id]);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function onAddToPlaylistButtonClick() {
|
||||
|
||||
var id = this.getAttribute('data-itemid');
|
||||
|
@ -377,6 +388,10 @@
|
|||
|
||||
var href = card.getAttribute('data-href') || card.href || $('a', card).attr('href');
|
||||
|
||||
if (commands.indexOf('addtocollection') != -1) {
|
||||
html += '<li data-icon="plus"><a href="#" class="btnAddToCollection" data-itemid="' + itemId + '">' + Globalize.translate('ButtonAddToCollection') + '</a></li>';
|
||||
}
|
||||
|
||||
if (commands.indexOf('playlist') != -1) {
|
||||
html += '<li data-icon="plus"><a href="#" class="btnAddToPlaylist" data-itemid="' + itemId + '">' + Globalize.translate('ButtonAddToPlaylist') + '</a></li>';
|
||||
}
|
||||
|
@ -464,6 +479,7 @@
|
|||
$('.btnExternalPlayer', elem).on('click', onExternalPlayerButtonClick);
|
||||
$('.btnDelete', elem).on('click', onDeleteButtonClick);
|
||||
$('.btnSync', elem).on('click', onSyncButtonClick);
|
||||
$('.btnAddToCollection', elem).on('click', onAddToCollectionButtonClick);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -826,7 +842,7 @@
|
|||
return;
|
||||
}
|
||||
|
||||
BoxSetEditor.showPanel(page, selection);
|
||||
BoxSetEditor.showPanel(selection);
|
||||
}
|
||||
|
||||
function addToPlaylist(page) {
|
||||
|
|
|
@ -15,12 +15,14 @@
|
|||
html += '</button>';
|
||||
|
||||
html += '<div class="libraryMenuButtonText headerButton"><span>MEDIA</span><span class="mediaBrowserAccent">BROWSER</span></div>';
|
||||
|
||||
html += '<div class="viewMenuSearch">';
|
||||
html += '<input type="text" data-role="none" class="headerSearchInput" autocomplete="off" spellcheck="off" />';
|
||||
html += '<div class="searchInputIcon fa fa-search"></div>';
|
||||
html += '<button data-role="none" type="button" data-iconpos="notext" class="imageButton btnCloseSearch" style="display:none;"><i class="fa fa-close"></i></button>';
|
||||
html += '</div>';
|
||||
|
||||
|
||||
|
||||
html += '<div class="viewMenuSecondary">';
|
||||
|
||||
if (user.localUser) {
|
||||
|
@ -84,11 +86,11 @@
|
|||
html += '<div class="libraryMenuDivider"></div>';
|
||||
html += '<div class="adminMenuOptions">';
|
||||
|
||||
html += '<a class="viewMenuLink viewMenuTextLink lnkMediaFolder iconViewMenu" data-itemid="dashboard" href="dashboard.html"><span class="fa fa-dashboard"></span>' + Globalize.translate('ButtonDashboard') + '</a>';
|
||||
html += '<a class="viewMenuLink viewMenuTextLink lnkMediaFolder editorViewMenu iconViewMenu" data-itemid="editor" href="edititemmetadata.html"><span class="fa fa-edit"></span>' + Globalize.translate('ButtonMetadataManager') + '</a>';
|
||||
html += '<a class="viewMenuLink viewMenuTextLink lnkMediaFolder iconViewMenu" data-itemid="reports" href="reports.html"><span class="fa fa-bar-chart"></span>' + Globalize.translate('ButtonReports') + '</a>';
|
||||
html += '<a class="sidebarLink lnkMediaFolder" data-itemid="dashboard" href="dashboard.html"><span class="fa fa-dashboard sidebarLinkIcon"></span>' + Globalize.translate('ButtonDashboard') + '</a>';
|
||||
html += '<a class="sidebarLink lnkMediaFolder editorViewMenu" data-itemid="editor" href="edititemmetadata.html"><span class="fa fa-edit sidebarLinkIcon"></span>' + Globalize.translate('ButtonMetadataManager') + '</a>';
|
||||
html += '<a class="sidebarLink lnkMediaFolder" data-itemid="reports" href="reports.html"><span class="fa fa-bar-chart sidebarLinkIcon"></span>' + Globalize.translate('ButtonReports') + '</a>';
|
||||
html += '</div>';
|
||||
html += '<a class="viewMenuLink viewMenuTextLink lnkMediaFolder iconViewMenu syncViewMenu" data-itemid="mysync" href="mysync.html"><span class="fa fa-cloud"></span>' + Globalize.translate('ButtonSync') + '</a>';
|
||||
html += '<a class="sidebarLink lnkMediaFolder syncViewMenu" data-itemid="mysync" href="mysync.html"><span class="fa fa-cloud sidebarLinkIcon"></span>' + Globalize.translate('ButtonSync') + '</a>';
|
||||
|
||||
return html;
|
||||
}
|
||||
|
@ -181,13 +183,13 @@
|
|||
iconCssClass += ' fa-folder-open-o';
|
||||
}
|
||||
|
||||
return '<a data-itemid="' + itemId + '" class="lnkMediaFolder viewMenuLink viewMenuTextLink iconViewMenu" href="' + getItemHref(i, i.CollectionType) + '"><span class="' + iconCssClass + '"></span><span class="sectionName">' + i.Name + '</span></a>';
|
||||
return '<a data-itemid="' + itemId + '" class="lnkMediaFolder sidebarLink" href="' + getItemHref(i, i.CollectionType) + '"><span class="' + iconCssClass + ' sidebarLinkIcon"></span><span class="sectionName">' + i.Name + '</span></a>';
|
||||
|
||||
}).join('');
|
||||
|
||||
var elem = $('.libraryMenuOptions').html(html);
|
||||
|
||||
$('.viewMenuTextLink', elem).on('click', function () {
|
||||
$('.sidebarLink', elem).on('click', function () {
|
||||
|
||||
var section = $('.sectionName', this)[0];
|
||||
var text = section ? section.innerHTML : this.innerHTML;
|
||||
|
@ -225,11 +227,11 @@
|
|||
|
||||
html += '<div data-role="panel" id="libraryPanel" class="libraryPanel" data-position="left" data-display="overlay" data-position-fixed="true" data-theme="b">';
|
||||
|
||||
html += '<div style="margin: 0 -1em;">';
|
||||
html += '<div class="sidebarLinks librarySidebarLinks" style="margin-top: 0;margin-left: -1em;margin-right: -1em;">';
|
||||
|
||||
var homeHref = ConnectionManager.currentApiClient() ? 'index.html' : 'selectserver.html';
|
||||
|
||||
html += '<a class="lnkMediaFolder viewMenuLink viewMenuTextLink homeViewMenu" href="' + homeHref + '">' + Globalize.translate('ButtonHome') + '</a>';
|
||||
html += '<a class="lnkMediaFolder sidebarLink homeViewMenu" href="' + homeHref + '">' + Globalize.translate('ButtonHome') + '</a>';
|
||||
|
||||
html += '<div class="libraryMenuDivider"></div>';
|
||||
|
||||
|
|
|
@ -270,25 +270,92 @@
|
|||
|
||||
(function ($, document) {
|
||||
|
||||
function showNewCollectionPanel(page, items) {
|
||||
function getNewCollectionPanel(createIfNeeded) {
|
||||
|
||||
$('.fldSelectedItemIds', page).val(items.join(','));
|
||||
var panel = $('.newCollectionPanel');
|
||||
|
||||
var panel = $('.newCollectionPanel', page).panel('toggle');
|
||||
if (createIfNeeded && !panel.length) {
|
||||
|
||||
populateCollections(panel);
|
||||
var html = '';
|
||||
|
||||
html += '<div>';
|
||||
html += '<div data-role="panel" class="newCollectionPanel" data-position="right" data-display="overlay" data-position-fixed="true" data-theme="a">';
|
||||
html += '<form class="newCollectionForm">';
|
||||
|
||||
html += '<h3>' + Globalize.translate('HeaderAddToCollection') + '</h3>';
|
||||
|
||||
html += '<div class="fldSelectCollection">';
|
||||
html += '<br />';
|
||||
html += '<label for="selectCollectionToAddTo">' + Globalize.translate('LabelSelectCollection') + '</label>';
|
||||
html += '<select id="selectCollectionToAddTo" data-mini="true"></select>';
|
||||
html += '</div>';
|
||||
|
||||
html += '<div class="newCollectionInfo">';
|
||||
html += '<br />';
|
||||
|
||||
html += '<div>';
|
||||
html += '<label for="txtNewCollectionName">' + Globalize.translate('LabelName') + '</label>';
|
||||
html += '<input type="text" id="txtNewCollectionName" required="required" />';
|
||||
html += '<div class="fieldDescription">' + Globalize.translate('NewCollectionNameExample') + '</div>';
|
||||
html += '</div>';
|
||||
|
||||
html += '<br />';
|
||||
|
||||
html += '<div>';
|
||||
html += '<label for="chkEnableInternetMetadata">' + Globalize.translate('OptionSearchForInternetMetadata') + '</label>';
|
||||
html += '<input type="checkbox" id="chkEnableInternetMetadata" data-mini="true" />';
|
||||
html += '</div>';
|
||||
|
||||
// newCollectionInfo
|
||||
html += '</div>';
|
||||
|
||||
html += '<br />';
|
||||
html += '<p>';
|
||||
html += '<input class="fldSelectedItemIds" type="hidden" />';
|
||||
html += '<button type="submit" data-icon="plus" data-mini="true" data-theme="b">' + Globalize.translate('ButtonSubmit') + '</button>';
|
||||
html += '</p>';
|
||||
|
||||
html += '</form>';
|
||||
html += '</div>';
|
||||
html += '</div>';
|
||||
|
||||
panel = $(html).appendTo(document.body).trigger('create').find('.newCollectionPanel');
|
||||
|
||||
$('#selectCollectionToAddTo', panel).on('change', function () {
|
||||
|
||||
if (this.value) {
|
||||
$('.newCollectionInfo', panel).hide();
|
||||
$('#txtNewCollectionName', panel).removeAttr('required');
|
||||
} else {
|
||||
$('.newCollectionInfo', panel).show();
|
||||
$('#txtNewCollectionName', panel).attr('required', 'required');
|
||||
}
|
||||
});
|
||||
|
||||
$('.newCollectionForm', panel).off('submit', BoxSetEditor.onNewCollectionSubmit).on('submit', BoxSetEditor.onNewCollectionSubmit);
|
||||
}
|
||||
return panel;
|
||||
}
|
||||
|
||||
function showCollectionPanel(items) {
|
||||
|
||||
var panel = getNewCollectionPanel(true).panel('toggle');
|
||||
|
||||
$('.fldSelectedItemIds', panel).val(items.join(','));
|
||||
|
||||
if (items.length) {
|
||||
$('.fldSelectCollection', panel).show();
|
||||
populateCollections(panel);
|
||||
} else {
|
||||
$('.fldSelectCollection', panel).hide();
|
||||
$('#selectCollectionToAddTo', panel).html('').val('').selectmenu('refresh').trigger('change');
|
||||
}
|
||||
}
|
||||
|
||||
function populateCollections(panel) {
|
||||
|
||||
var select = $('#selectCollectionToAddTo', panel);
|
||||
|
||||
if (!select.length) {
|
||||
|
||||
$('#txtNewCollectionName', panel).val('').focus();
|
||||
return;
|
||||
}
|
||||
|
||||
$('.newCollectionInfo', panel).hide();
|
||||
|
||||
var options = {
|
||||
|
@ -320,18 +387,7 @@
|
|||
// The button is created dynamically
|
||||
$(page).on('click', '.btnNewCollection', function () {
|
||||
|
||||
showNewCollectionPanel(page, []);
|
||||
});
|
||||
|
||||
$('#selectCollectionToAddTo', page).on('change', function () {
|
||||
|
||||
if (this.value) {
|
||||
$('.newCollectionInfo', page).hide();
|
||||
$('#txtNewCollectionName', page).removeAttr('required');
|
||||
} else {
|
||||
$('.newCollectionInfo', page).show();
|
||||
$('#txtNewCollectionName', page).attr('required', 'required');
|
||||
}
|
||||
showCollectionPanel(page, []);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -346,13 +402,13 @@
|
|||
});
|
||||
}
|
||||
|
||||
function createCollection(page) {
|
||||
function createCollection(panel) {
|
||||
|
||||
var url = ApiClient.getUrl("Collections", {
|
||||
|
||||
Name: $('#txtNewCollectionName', page).val(),
|
||||
IsLocked: !$('#chkEnableInternetMetadata', page).checked(),
|
||||
Ids: $('.fldSelectedItemIds', page).val() || ''
|
||||
Name: $('#txtNewCollectionName', panel).val(),
|
||||
IsLocked: !$('#chkEnableInternetMetadata', panel).checked(),
|
||||
Ids: $('.fldSelectedItemIds', panel).val() || ''
|
||||
|
||||
//ParentId: getParameterByName('parentId') || LibraryMenu.getTopParentId()
|
||||
|
||||
|
@ -369,17 +425,17 @@
|
|||
|
||||
var id = result.Id;
|
||||
|
||||
$('.newCollectionPanel', page).panel('toggle');
|
||||
panel.panel('toggle');
|
||||
redirectToCollection(id);
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
function addToCollection(page, id) {
|
||||
function addToCollection(panel, id) {
|
||||
|
||||
var url = ApiClient.getUrl("Collections/" + id + "/Items", {
|
||||
|
||||
Ids: $('.fldSelectedItemIds', page).val() || ''
|
||||
Ids: $('.fldSelectedItemIds', panel).val() || ''
|
||||
});
|
||||
|
||||
ApiClient.ajax({
|
||||
|
@ -390,33 +446,39 @@
|
|||
|
||||
Dashboard.hideLoadingMsg();
|
||||
|
||||
$('.newCollectionPanel', page).panel('toggle');
|
||||
redirectToCollection(id);
|
||||
panel.panel('toggle');
|
||||
|
||||
Dashboard.alert(Globalize.translate('MessageItemsAdded'));
|
||||
});
|
||||
}
|
||||
|
||||
window.BoxSetEditor = {
|
||||
|
||||
showPanel: function (page, items) {
|
||||
showNewCollectionPanel(page, items);
|
||||
showPanel: function (items) {
|
||||
showCollectionPanel(items);
|
||||
},
|
||||
|
||||
onNewCollectionSubmit: function () {
|
||||
|
||||
Dashboard.showLoadingMsg();
|
||||
|
||||
var page = $(this).parents('.page');
|
||||
var panel = getNewCollectionPanel(false);
|
||||
|
||||
var collectionId = $('#selectCollectionToAddTo', page).val();
|
||||
var collectionId = $('#selectCollectionToAddTo', panel).val();
|
||||
|
||||
if (collectionId) {
|
||||
addToCollection(page, collectionId);
|
||||
addToCollection(panel, collectionId);
|
||||
} else {
|
||||
createCollection(page);
|
||||
createCollection(panel);
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
|
||||
supportsAddingToCollection: function (item) {
|
||||
|
||||
|
||||
return item.LocationType == 'FileSystem';
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -356,19 +356,13 @@
|
|||
|
||||
if (createIfNeeded && !elem.length) {
|
||||
|
||||
var html = '<div class="searchResultsOverlay ui-page-theme-b"><div style="text-align:right;padding: 1em 2em 0 0;"><button class="btnCloseSearch" data-icon="delete" data-mini="true" data-inline="true" style="margin:0;">Close</button></div>';
|
||||
var html = '<div class="searchResultsOverlay ui-page-theme-b">';
|
||||
|
||||
html += '<div class="searchResultsContainer"><div class="itemsContainer"></div></div></div>';
|
||||
|
||||
elem = $(html).appendTo(document.body).hide().trigger('create');
|
||||
|
||||
elem.createCardMenus();
|
||||
|
||||
$('.btnCloseSearch', elem).on('click', function () {
|
||||
$('.headerSearchInput').val('');
|
||||
onHeaderSearchChange('');
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
return elem;
|
||||
|
@ -377,11 +371,12 @@
|
|||
function onHeaderSearchChange(val) {
|
||||
|
||||
if (val) {
|
||||
|
||||
$('.btnCloseSearch').show();
|
||||
updateSearchOverlay(getSearchOverlay(true).fadeIn('fast'), val);
|
||||
|
||||
} else {
|
||||
|
||||
$('.btnCloseSearch').hide();
|
||||
updateSearchOverlay(getSearchOverlay(false).fadeOut('fast'), val);
|
||||
}
|
||||
}
|
||||
|
@ -414,6 +409,11 @@
|
|||
}
|
||||
|
||||
});
|
||||
|
||||
$('.btnCloseSearch').on('click', function () {
|
||||
$('.headerSearchInput').val('');
|
||||
onHeaderSearchChange('');
|
||||
});
|
||||
}
|
||||
|
||||
$(document).on('pagehide', ".libraryPage", function () {
|
||||
|
|
|
@ -1 +1,63 @@
|
|||
|
||||
(function ($, document, window) {
|
||||
|
||||
function loadPage(page, config) {
|
||||
|
||||
$('#txtSyncTempPath', page).val(config.TemporaryPath || '');
|
||||
|
||||
Dashboard.hideLoadingMsg();
|
||||
}
|
||||
|
||||
$(document).on('pageinit', "#syncSettingsPage", function () {
|
||||
|
||||
var page = this;
|
||||
|
||||
$('#btnSelectSyncTempPath', page).on("click.selectDirectory", function () {
|
||||
|
||||
var picker = new DirectoryBrowser(page);
|
||||
|
||||
picker.show({
|
||||
|
||||
callback: function (path) {
|
||||
|
||||
if (path) {
|
||||
$('#txtSyncTempPath', page).val(path);
|
||||
}
|
||||
picker.close();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
}).on('pageshow', "#syncSettingsPage", function () {
|
||||
|
||||
Dashboard.showLoadingMsg();
|
||||
|
||||
var page = this;
|
||||
|
||||
ApiClient.getNamedConfiguration("sync").done(function (config) {
|
||||
|
||||
loadPage(page, config);
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
window.SyncSettingsPage = {
|
||||
|
||||
onSubmit: function () {
|
||||
|
||||
Dashboard.showLoadingMsg();
|
||||
|
||||
var form = this;
|
||||
|
||||
ApiClient.getNamedConfiguration("sync").done(function (config) {
|
||||
|
||||
config.TemporaryPath = $('#txtSyncTempPath', form).val();
|
||||
|
||||
ApiClient.updateNamedConfiguration("sync", config).done(Dashboard.processServerConfigurationUpdateResult);
|
||||
});
|
||||
|
||||
// Disable default form submission
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
})(jQuery, document, window);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue