add delete to multi-select

This commit is contained in:
Luke Pulverenti 2016-01-19 14:03:46 -05:00
parent d541bebde0
commit c37b8b12ed
6 changed files with 48 additions and 22 deletions

View File

@ -1159,7 +1159,7 @@
performAdvancedRefresh(page); performAdvancedRefresh(page);
break; break;
case 'delete': case 'delete':
LibraryBrowser.deleteItem(currentItem.Id); LibraryBrowser.deleteItems([currentItem.Id]);
break; break;
case 'editimages': case 'editimages':
LibraryBrowser.editImages(currentItem.Id); LibraryBrowser.editImages(currentItem.Id);

View File

@ -834,27 +834,37 @@
}); });
Dashboard.alert(Globalize.translate('MessageRefreshQueued')); Dashboard.alert(Globalize.translate('MessageRefreshQueued'));
}, },
deleteItem: function (itemId) { deleteItems: function (itemIds) {
// The timeout allows the flyout to close return new Promise(function (resolve, reject) {
setTimeout(function () {
var msg = Globalize.translate('ConfirmDeleteItem'); var msg = Globalize.translate('ConfirmDeleteItem');
var title = Globalize.translate('HeaderDeleteItem');
Dashboard.confirm(msg, Globalize.translate('HeaderDeleteItem'), function (result) { if (itemIds.length > 1) {
msg = Globalize.translate('ConfirmDeleteItems');
title = Globalize.translate('HeaderDeleteItems');
}
Dashboard.confirm(msg, title, function (result) {
if (result) { if (result) {
ApiClient.deleteItem(itemId);
Events.trigger(LibraryBrowser, 'itemdeleting', [itemId]); var promises = itemIds.map(function (itemId) {
ApiClient.deleteItem(itemId);
Events.trigger(LibraryBrowser, 'itemdeleting', [itemId]);
});
resolve();
} else {
reject();
} }
}); });
});
}, 250);
}, },
editImages: function (itemId) { editImages: function (itemId) {
@ -991,7 +1001,7 @@
PlaylistManager.showPanel([itemId]); PlaylistManager.showPanel([itemId]);
break; break;
case 'delete': case 'delete':
LibraryBrowser.deleteItem(itemId); LibraryBrowser.deleteItems([itemId]);
break; break;
case 'download': case 'download':
{ {
@ -1594,12 +1604,8 @@
itemCommands.push('queuefromhere'); itemCommands.push('queuefromhere');
} }
// There's no detail page with a dedicated delete function if (item.CanDelete) {
if (item.Type == 'Playlist' || item.Type == 'BoxSet') { itemCommands.push('delete');
if (item.CanDelete) {
itemCommands.push('delete');
}
} }
if (SyncManager.isAvailable(item)) { if (SyncManager.isAvailable(item)) {
@ -2892,7 +2898,7 @@
var fireCallbackOnClose = false; var fireCallbackOnClose = false;
var delay = browserInfo.animate ? 0 : 100; var delay = browserInfo.animate ? 0 : 100;
setTimeout(function() { setTimeout(function () {
paperDialogHelper.open(dlg).then(function () { paperDialogHelper.open(dlg).then(function () {
if (options.callback && fireCallbackOnClose) { if (options.callback && fireCallbackOnClose) {

View File

@ -469,7 +469,7 @@
PlaylistManager.showPanel([itemId]); PlaylistManager.showPanel([itemId]);
break; break;
case 'delete': case 'delete':
LibraryBrowser.deleteItem(itemId); LibraryBrowser.deleteItems([itemId]);
break; break;
case 'download': case 'download':
{ {
@ -1025,7 +1025,7 @@
function showSelections(initialCard) { function showSelections(initialCard) {
require(['paper-checkbox'], function() { require(['paper-checkbox'], function () {
var cards = document.querySelectorAll('.card'); var cards = document.querySelectorAll('.card');
for (var i = 0, length = cards.length; i < length; i++) { for (var i = 0, length = cards.length; i < length; i++) {
showSelection(cards[i]); showSelection(cards[i]);
@ -1101,6 +1101,14 @@
ironIcon: 'playlist-add' ironIcon: 'playlist-add'
}); });
if (user.Policy.EnableContentDeletion) {
items.push({
name: Globalize.translate('ButtonDelete'),
id: 'delete',
ironIcon: 'delete'
});
}
if (user.Policy.EnableContentDownloading && AppInfo.supportsDownloading) { if (user.Policy.EnableContentDownloading && AppInfo.supportsDownloading) {
//items.push({ //items.push({
// name: Globalize.translate('ButtonDownload'), // name: Globalize.translate('ButtonDownload'),
@ -1149,6 +1157,12 @@
PlaylistManager.showPanel(items); PlaylistManager.showPanel(items);
hideSelections(); hideSelections();
break; break;
case 'delete':
LibraryBrowser.deleteItems(items).then(function () {
Dashboard.navigate('index.html');
});
hideSelections();
break;
case 'groupvideos': case 'groupvideos':
combineVersions($($.mobile.activePage)[0], items); combineVersions($($.mobile.activePage)[0], items);
break; break;

View File

@ -85,7 +85,8 @@
ApiClient.getLiveTvRecordings({ ApiClient.getLiveTvRecordings({
userId: Dashboard.getCurrentUserId(), userId: Dashboard.getCurrentUserId(),
IsInProgress: true IsInProgress: true,
Fields: 'CanDelete'
}).then(function (result) { }).then(function (result) {
@ -97,7 +98,8 @@
userId: Dashboard.getCurrentUserId(), userId: Dashboard.getCurrentUserId(),
limit: 12, limit: 12,
IsInProgress: false IsInProgress: false,
Fields: 'CanDelete'
}).then(function (result) { }).then(function (result) {

View File

@ -355,6 +355,8 @@
"ButtonBrowseOnlineImages": "Browse online images", "ButtonBrowseOnlineImages": "Browse online images",
"HeaderDeleteItem": "Delete Item", "HeaderDeleteItem": "Delete Item",
"ConfirmDeleteItem": "Deleting this item will delete it from both the file system and your media library. Are you sure you wish to continue?", "ConfirmDeleteItem": "Deleting this item will delete it from both the file system and your media library. Are you sure you wish to continue?",
"HeaderDeleteItems": "Delete Items",
"ConfirmDeleteItems": "Deleting these items will delete them from both the file system and your media library. Are you sure you wish to continue?",
"MessagePleaseEnterNameOrId": "Please enter a name or an external Id.", "MessagePleaseEnterNameOrId": "Please enter a name or an external Id.",
"MessageValueNotCorrect": "The value entered is not correct. Please try again.", "MessageValueNotCorrect": "The value entered is not correct. Please try again.",
"MessageItemSaved": "Item saved.", "MessageItemSaved": "Item saved.",

View File

@ -359,6 +359,8 @@
"ButtonBrowseOnlineImages": "Browse online images", "ButtonBrowseOnlineImages": "Browse online images",
"HeaderDeleteItem": "Delete Item", "HeaderDeleteItem": "Delete Item",
"ConfirmDeleteItem": "Deleting this item will delete it from both the file system and your media library. Are you sure you wish to continue?", "ConfirmDeleteItem": "Deleting this item will delete it from both the file system and your media library. Are you sure you wish to continue?",
"HeaderDeleteItems": "Delete Items",
"ConfirmDeleteItems": "Deleting these items will delete them from both the file system and your media library. Are you sure you wish to continue?",
"MessagePleaseEnterNameOrId": "Please enter a name or an external Id.", "MessagePleaseEnterNameOrId": "Please enter a name or an external Id.",
"MessageValueNotCorrect": "The value entered is not correct. Please try again.", "MessageValueNotCorrect": "The value entered is not correct. Please try again.",
"MessageItemSaved": "Item saved.", "MessageItemSaved": "Item saved.",