Skip to content

Add removal of items in multi-selection for collections #6800

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@
- [Jxiced](https://github.com/Jxiced)
- [Derek Huber](https://github.com/Derek4aty1)
- [StableCrimson](https://github.com/StableCrimson)
- [Faris Mektem](https://github.com/mektem)

## Emby Contributors

Expand Down
30 changes: 30 additions & 0 deletions src/components/multiSelect/multiSelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import alert from '../alert';
import confirm from '../confirm/confirm';
import itemHelper from '../itemHelper';
import datetime from '../../scripts/datetime';
import { getParameterByName } from 'utils/url';

let selectedItems = [];
let selectedElements = [];
Expand Down Expand Up @@ -167,6 +168,16 @@ function showMenuForSelectedItems(e) {
const apiClient = ServerConnections.currentApiClient();

apiClient.getCurrentUser().then(user => {
// get collection id
const collectionId = getParameterByName('id');
let collectionItem = null;

if (collectionId) {
apiClient.getItem(user.Id, collectionId).then(collection => {
collectionItem = collection;
});
}

// get first selected item to perform metadata refresh permission check
apiClient.getItem(apiClient.getCurrentUserId(), selectedItems[0]).then(firstItem => {
const menuItems = [];
Expand All @@ -183,6 +194,14 @@ function showMenuForSelectedItems(e) {
icon: 'add'
});

if (collectionItem && collectionItem.Type === 'BoxSet') {
menuItems.push({
name: globalize.translate('RemoveFromCollection'),
id: 'removefromcollection',
icon: 'playlist_remove'
});
}

menuItems.push({
name: globalize.translate('AddToPlaylist'),
id: 'playlist',
Expand Down Expand Up @@ -265,6 +284,17 @@ function showMenuForSelectedItems(e) {
hideSelections();
dispatchNeedsRefresh();
break;
case 'removefromcollection':
apiClient.ajax({
type: 'DELETE',
url: apiClient.getUrl('Collections/' + collectionId + '/Items', {
Ids: items.join(',')
})
}).then(() => {
dispatchNeedsRefresh();
hideSelections();
});
break;
case 'playlist':
import('../playlisteditor/playlisteditor').then(({ default: PlaylistEditor }) => {
const playlistEditor = new PlaylistEditor();
Expand Down
Loading