1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

#712 - group multiple versions

This commit is contained in:
Luke Pulverenti 2014-03-18 21:35:40 -04:00
parent 494e982690
commit 9a16060663
4 changed files with 78 additions and 21 deletions

View file

@ -40,7 +40,7 @@
<div class="selectionCommands" style="display: none;"> <div class="selectionCommands" style="display: none;">
<div data-role="controlgroup" data-type="horizontal" class="selectionCommandsControlGroup"> <div data-role="controlgroup" data-type="horizontal" class="selectionCommandsControlGroup">
<button class="btnMergeVersions" data-mini="true" data-icon="recycle" data-inline="true" title="Combine Versions">Combine</button> <button class="btnMergeVersions" data-mini="true" data-icon="recycle" data-inline="true" title="Combine Versions">Group Versions</button>
</div> </div>
</div> </div>
</div> </div>

View file

@ -665,7 +665,7 @@
cssClass += ' ' + options.shape + 'PosterItem'; cssClass += ' ' + options.shape + 'PosterItem';
html += '<a data-itemid="' + item.Id + '" class="' + cssClass + '" data-primaryversionid="' + (item.PrimaryVersionId || '') + '" data-locationtype="' + item.LocationType + '" data-mediatype="' + (item.MediaType || '') + '" href="' + LibraryBrowser.getHref(item, options.context) + '">'; html += '<a data-itemid="' + item.Id + '" class="' + cssClass + '" data-alternateversioncount="' + (item.AlternateVersionCount || '0') + '" href="' + LibraryBrowser.getHref(item, options.context) + '">';
// Ribbon // Ribbon
if (item.MediaType == "Video" && options.formatIndicators) { if (item.MediaType == "Video" && options.formatIndicators) {

View file

@ -166,6 +166,27 @@
function onMenuCommand(command, elem) { function onMenuCommand(command, elem) {
var id = elem.getAttribute('data-itemid'); var id = elem.getAttribute('data-itemid');
var page = $(elem).parents('.page');
if (command == 'SplitVersions') {
splitVersions(id, page);
}
}
function splitVersions(id, page) {
Dashboard.showLoadingMsg();
$.ajax({
type: "DELETE",
url: ApiClient.getUrl("Videos/" + id + "/AlternateVersions")
}).done(function () {
Dashboard.hideLoadingMsg();
$('.itemsContainer', page).trigger('needsrefresh');
});
} }
function getContextMenuOptions(elem) { function getContextMenuOptions(elem) {
@ -173,7 +194,6 @@
var items = []; var items = [];
var id = elem.getAttribute('data-itemid'); var id = elem.getAttribute('data-itemid');
var mediatype = elem.getAttribute('data-mediatype');
items.push({ type: 'header', text: 'Edit' }); items.push({ type: 'header', text: 'Edit' });
@ -181,12 +201,12 @@
items.push({ type: 'link', text: 'Images', url: 'edititemimages.html?id=' + id }); items.push({ type: 'link', text: 'Images', url: 'edititemimages.html?id=' + id });
//if (mediatype == 'Video' && elem.getAttribute('data-locationtype') == 'FileSystem' && !elem.getAttribute('data-primaryversionid')) { if (elem.getAttribute('data-alternateversioncount') != '0') {
// items.push({ type: 'divider' }); items.push({ type: 'divider' });
// items.push({ type: 'header', text: 'Manage' }); items.push({ type: 'header', text: 'Manage' });
// items.push({ type: 'command', text: 'Alternate Versions', name: 'AlternateVersions' }); items.push({ type: 'command', text: 'Split Versions', name: 'SplitVersions' });
//} }
return items; return items;
} }
@ -260,11 +280,11 @@
if (user.Configuration.IsAdministrator) { if (user.Configuration.IsAdministrator) {
//sequence.createContextMenu({ sequence.createContextMenu({
// getOptions: getContextMenuOptions, getOptions: getContextMenuOptions,
// command: onMenuCommand, command: onMenuCommand,
// selector: '.posterItem' selector: '.posterItem'
//}); });
} }
}); });
@ -290,6 +310,8 @@
selectionCommands.show(); selectionCommands.show();
$('.itemSelectionPanel', page).show(); $('.itemSelectionPanel', page).show();
$('.chkItemSelect:checked', page).checked(false).checkboxradio('refresh');
} }
Dashboard.hideLoadingMsg(); Dashboard.hideLoadingMsg();
@ -307,7 +329,7 @@
var selection = $('.chkItemSelect:checked', page); var selection = $('.chkItemSelect:checked', page);
return selection.parents('.posterItem') return selection.parents('.posterItem')
.map(function() { .map(function () {
return this.getAttribute('data-itemid'); return this.getAttribute('data-itemid');
@ -328,7 +350,36 @@
return; return;
} }
hideSelections(); var names = $('.chkItemSelect:checked', page).parents('.posterItem').get().reverse().map(function (e) {
return $('.posterItemText', e).html();
}).join('<br/>');
var msg = "The following titles will be grouped into one item:<br/><br/>" + names;
msg += "<br/><br/>Media Browser clients will choose the optimal version to play based on device and network conditions. Are you sure you wish to continue?";
Dashboard.confirm(msg, "Group Versions", function (confirmResult) {
if (confirmResult) {
Dashboard.showLoadingMsg();
$.ajax({
type: "POST",
url: ApiClient.getUrl("Videos/MergeVersions", { Ids: selection.join(',') })
}).done(function () {
Dashboard.hideLoadingMsg();
hideSelections();
$('.itemsContainer', page).trigger('needsrefresh');
});
}
});
} }
$(document).on('pageinit', ".libraryPage", function () { $(document).on('pageinit', ".libraryPage", function () {

View file

@ -345,6 +345,12 @@
reloadItems(page); reloadItems(page);
}); });
$('.itemsContainer', page).on('needsrefresh', function() {
reloadItems(page);
});
}).on('pagebeforeshow', "#moviesPage", function () { }).on('pagebeforeshow', "#moviesPage", function () {
var page = this; var page = this;