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

47 lines
1.3 KiB
JavaScript
Raw Normal View History

2020-08-14 08:46:34 +02:00
import confirm from '../components/confirm/confirm';
2023-05-01 10:04:13 -04:00
import { appRouter } from '../components/router/appRouter';
2020-08-14 08:46:34 +02:00
import globalize from './globalize';
import ServerConnections from '../components/ServerConnections';
import alert from '../components/alert';
2018-10-23 01:05:09 +03:00
2020-05-03 17:53:23 +05:30
function alertText(options) {
return alert(options);
2020-05-03 17:53:23 +05:30
}
2018-10-23 01:05:09 +03:00
2020-05-03 17:53:23 +05:30
export function deleteItem(options) {
2020-05-10 14:46:28 +05:30
const item = options.item;
const parentId = item.SeasonId || item.SeriesId || item.ParentId;
const apiClient = ServerConnections.getApiClient(item.ServerId);
2020-05-03 17:53:23 +05:30
return confirm({
2020-05-03 23:59:23 +05:30
title: globalize.translate('HeaderDeleteItem'),
text: globalize.translate('ConfirmDeleteItem'),
2020-05-03 17:53:23 +05:30
confirmText: globalize.translate('Delete'),
primary: 'delete'
2020-05-03 17:53:23 +05:30
}).then(function () {
2020-05-03 23:59:23 +05:30
return apiClient.deleteItem(item.Id).then(function () {
2020-05-03 17:53:23 +05:30
if (options.navigate) {
if (parentId) {
2020-05-03 23:59:23 +05:30
appRouter.showItem(parentId, item.ServerId);
2020-05-03 17:53:23 +05:30
} else {
appRouter.goHome();
}
2020-05-03 17:53:23 +05:30
}
}, function (err) {
const result = function () {
2020-05-03 17:53:23 +05:30
return Promise.reject(err);
};
2020-05-03 17:53:23 +05:30
return alertText(globalize.translate('ErrorDeletingItem')).then(result, result);
});
2020-05-03 17:53:23 +05:30
});
}
2020-05-03 17:53:23 +05:30
export default {
deleteItem: deleteItem
};