diff --git a/dashboard-ui/scripts/edititemmetadata.js b/dashboard-ui/scripts/edititemmetadata.js index 8deb4e0edc..b95cef20b4 100644 --- a/dashboard-ui/scripts/edititemmetadata.js +++ b/dashboard-ui/scripts/edititemmetadata.js @@ -1159,7 +1159,7 @@ performAdvancedRefresh(page); break; case 'delete': - LibraryBrowser.deleteItem(currentItem.Id); + LibraryBrowser.deleteItems([currentItem.Id]); break; case 'editimages': LibraryBrowser.editImages(currentItem.Id); diff --git a/dashboard-ui/scripts/librarybrowser.js b/dashboard-ui/scripts/librarybrowser.js index 2ba0816f48..3a5e5b79ea 100644 --- a/dashboard-ui/scripts/librarybrowser.js +++ b/dashboard-ui/scripts/librarybrowser.js @@ -834,27 +834,37 @@ }); - Dashboard.alert(Globalize.translate('MessageRefreshQueued')); }, - deleteItem: function (itemId) { + deleteItems: function (itemIds) { - // The timeout allows the flyout to close - setTimeout(function () { + return new Promise(function (resolve, reject) { 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) { - 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) { @@ -991,7 +1001,7 @@ PlaylistManager.showPanel([itemId]); break; case 'delete': - LibraryBrowser.deleteItem(itemId); + LibraryBrowser.deleteItems([itemId]); break; case 'download': { @@ -1594,12 +1604,8 @@ itemCommands.push('queuefromhere'); } - // There's no detail page with a dedicated delete function - if (item.Type == 'Playlist' || item.Type == 'BoxSet') { - - if (item.CanDelete) { - itemCommands.push('delete'); - } + if (item.CanDelete) { + itemCommands.push('delete'); } if (SyncManager.isAvailable(item)) { @@ -2892,7 +2898,7 @@ var fireCallbackOnClose = false; var delay = browserInfo.animate ? 0 : 100; - setTimeout(function() { + setTimeout(function () { paperDialogHelper.open(dlg).then(function () { if (options.callback && fireCallbackOnClose) { diff --git a/dashboard-ui/scripts/librarylist.js b/dashboard-ui/scripts/librarylist.js index d55214233d..c22dc976d8 100644 --- a/dashboard-ui/scripts/librarylist.js +++ b/dashboard-ui/scripts/librarylist.js @@ -469,7 +469,7 @@ PlaylistManager.showPanel([itemId]); break; case 'delete': - LibraryBrowser.deleteItem(itemId); + LibraryBrowser.deleteItems([itemId]); break; case 'download': { @@ -1025,7 +1025,7 @@ function showSelections(initialCard) { - require(['paper-checkbox'], function() { + require(['paper-checkbox'], function () { var cards = document.querySelectorAll('.card'); for (var i = 0, length = cards.length; i < length; i++) { showSelection(cards[i]); @@ -1101,6 +1101,14 @@ ironIcon: 'playlist-add' }); + if (user.Policy.EnableContentDeletion) { + items.push({ + name: Globalize.translate('ButtonDelete'), + id: 'delete', + ironIcon: 'delete' + }); + } + if (user.Policy.EnableContentDownloading && AppInfo.supportsDownloading) { //items.push({ // name: Globalize.translate('ButtonDownload'), @@ -1149,6 +1157,12 @@ PlaylistManager.showPanel(items); hideSelections(); break; + case 'delete': + LibraryBrowser.deleteItems(items).then(function () { + Dashboard.navigate('index.html'); + }); + hideSelections(); + break; case 'groupvideos': combineVersions($($.mobile.activePage)[0], items); break; diff --git a/dashboard-ui/scripts/livetvrecordings.js b/dashboard-ui/scripts/livetvrecordings.js index c1556f214f..f33ae36ce7 100644 --- a/dashboard-ui/scripts/livetvrecordings.js +++ b/dashboard-ui/scripts/livetvrecordings.js @@ -85,7 +85,8 @@ ApiClient.getLiveTvRecordings({ userId: Dashboard.getCurrentUserId(), - IsInProgress: true + IsInProgress: true, + Fields: 'CanDelete' }).then(function (result) { @@ -97,7 +98,8 @@ userId: Dashboard.getCurrentUserId(), limit: 12, - IsInProgress: false + IsInProgress: false, + Fields: 'CanDelete' }).then(function (result) { diff --git a/dashboard-ui/strings/javascript/en-US.json b/dashboard-ui/strings/javascript/en-US.json index 098fc299f4..b23b571bc2 100644 --- a/dashboard-ui/strings/javascript/en-US.json +++ b/dashboard-ui/strings/javascript/en-US.json @@ -355,6 +355,8 @@ "ButtonBrowseOnlineImages": "Browse online images", "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?", + "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.", "MessageValueNotCorrect": "The value entered is not correct. Please try again.", "MessageItemSaved": "Item saved.", diff --git a/dashboard-ui/strings/javascript/javascript.json b/dashboard-ui/strings/javascript/javascript.json index 4801adcb2a..185a5c47fd 100644 --- a/dashboard-ui/strings/javascript/javascript.json +++ b/dashboard-ui/strings/javascript/javascript.json @@ -359,6 +359,8 @@ "ButtonBrowseOnlineImages": "Browse online images", "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?", + "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.", "MessageValueNotCorrect": "The value entered is not correct. Please try again.", "MessageItemSaved": "Item saved.",