mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
improve itemContextMenu.js by adding a helper function to itemHelper.js
This commit is contained in:
parent
394a548263
commit
fd50b3af55
2 changed files with 29 additions and 5 deletions
|
@ -214,11 +214,7 @@ export function getCommands(options) {
|
|||
});
|
||||
}
|
||||
|
||||
if ((canEdit || user.Policy.EnableSubtitleManagement) && item.MediaType === 'Video' && item.Type !== 'TvChannel' && item.Type !== 'Program'
|
||||
&& item.LocationType !== 'Virtual'
|
||||
&& !(item.Type === 'Recording' && item.Status !== 'Completed')
|
||||
&& options.editSubtitles !== false
|
||||
) {
|
||||
if (itemHelper.canEditSubtitles(user, item) && options.editSubtitles !== false) {
|
||||
commands.push({
|
||||
name: globalize.translate('EditSubtitles'),
|
||||
id: 'editsubtitles',
|
||||
|
|
|
@ -155,6 +155,33 @@ export function canEditImages (user, item) {
|
|||
return itemType !== 'Timer' && itemType !== 'SeriesTimer' && canEdit(user, item) && !isLocalItem(item);
|
||||
}
|
||||
|
||||
export function canEditSubtitles (user, item) {
|
||||
if (item.MediaType !== 'Video') {
|
||||
return false;
|
||||
}
|
||||
const itemType = item.Type;
|
||||
if (itemType === 'Recording' && item.Status !== 'Completed') {
|
||||
return false;
|
||||
}
|
||||
if (itemType === 'TvChannel'
|
||||
|| itemType === 'Program'
|
||||
|| itemType === 'Timer'
|
||||
|| itemType === 'SeriesTimer'
|
||||
|| itemType === 'UserRootFolder'
|
||||
|| itemType === 'UserView'
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
if (isLocalItem(item)) {
|
||||
return false;
|
||||
}
|
||||
if (item.LocationType === 'Virtual') {
|
||||
return false;
|
||||
}
|
||||
return user.Policy.EnableSubtitleManagement
|
||||
|| user.Policy.IsAdministrator;
|
||||
}
|
||||
|
||||
export function canShare (item, user) {
|
||||
if (item.Type === 'Program') {
|
||||
return false;
|
||||
|
@ -300,6 +327,7 @@ export default {
|
|||
canIdentify: canIdentify,
|
||||
canEdit: canEdit,
|
||||
canEditImages: canEditImages,
|
||||
canEditSubtitles: canEditSubtitles,
|
||||
canShare: canShare,
|
||||
enableDateAddedDisplay: enableDateAddedDisplay,
|
||||
canMarkPlayed: canMarkPlayed,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue