2017-01-27 16:07:14 -07:00
|
|
|
define(["apphost","globalize","connectionManager","itemHelper","embyRouter","playbackManager","loading","appSettings"],function(appHost,globalize,connectionManager,itemHelper,embyRouter,playbackManager,loading,appSettings){"use strict";function getCommands(options){var item=options.item,serverId=item.ServerId,apiClient=connectionManager.getApiClient(serverId),canPlay=playbackManager.canPlay(item);return apiClient.getCurrentUser().then(function(user){var commands=[];if(itemHelper.isLocalItem(item))return commands;if(itemHelper.supportsAddingToCollection(item)&&commands.push({name:globalize.translate("sharedcomponents#AddToCollection"),id:"addtocollection"}),itemHelper.supportsAddingToPlaylist(item)&&commands.push({name:globalize.translate("sharedcomponents#AddToPlaylist"),id:"addtoplaylist"}),playbackManager.canQueue(item)&&options.queue!==!1&&commands.push({name:globalize.translate("sharedcomponents#AddToPlayQueue"),id:"queue"}),"Timer"===item.Type&&user.Policy.EnableLiveTvManagement&&options.cancelTimer!==!1&&commands.push({name:globalize.translate("sharedcomponents#CancelRecording"),id:"canceltimer"}),"Recording"===item.Type&&"InProgress"===item.Status&&user.Policy.EnableLiveTvManagement&&options.cancelTimer!==!1&&commands.push({name:globalize.translate("sharedcomponents#CancelRecording"),id:"canceltimer"}),"SeriesTimer"===item.Type&&user.Policy.EnableLiveTvManagement&&options.cancelTimer!==!1&&commands.push({name:globalize.translate("sharedcomponents#CancelSeries"),id:"cancelseriestimer"}),item.CanDelete&&options.deleteItem!==!1&&("Playlist"===item.Type||"BoxSet"===item.Type?commands.push({name:globalize.translate("sharedcomponents#Delete"),id:"delete"}):commands.push({name:globalize.translate("sharedcomponents#DeleteMedia"),id:"delete"})),item.CanDownload&&appHost.supports("filedownload")&&commands.push({name:globalize.translate("sharedcomponents#Download"),id:"download"}),itemHelper.canEdit(user,item)&&options.edit!==!1&&"SeriesTimer"!==item.Type){var text="Timer"===item.Type||"SeriesTimer"===item.Type?globalize.translate("sharedcomponents#Edit"):globalize.translate("sharedcomponents#EditInfo");commands.push({name:text,id:"edit"})}return itemHelper.canEditImages(user,item)&&options.editImages!==!1&&commands.push({name:globalize.translate("sharedcomponents#EditImages"),id:"editimages"}),itemHelper.canEdit(user,item)&&("Video"!==item.MediaType||"TvChannel"===item.Type||"Program"===item.Type||"Virtual"===item.LocationType||"Recording"===item.Type&&"Completed"!==item.Status||options.editSubtitles!==!1&&commands.push({name:globalize.translate("sharedcomponents#EditSubtitles"),id:"editsubtitles"})),options.identify!==!1&&itemHelper.canIdentify(user,item.Type)&&commands.push({name:globalize.translate("sharedcomponents#Identify"),id:"identify"}),"Audio"!==item.MediaType&&"MusicAlbum"!==item.Type&&"MusicArtist"!==item.Type&&"MusicGenre"!==item.Type&&"music"!==item.CollectionType||options.instantMix!==!1&&commands.push({name:globalize.translate("sharedcomponents#InstantMix"),id:"instantmix"}),appHost.supports("sync")&&options.syncLocal!==!1&&itemHelper.canSync(user,item)&&commands.push({name:globalize.translate("sharedcomponents#MakeAvailableOffline"),id:"synclocal"}),canPlay&&(options.play!==!1&&commands.push({name:globalize.translate("sharedcomponents#Play"),id:"resume"}),options.playAllFromHere&&"Program"!==item.Type&&"TvChannel"!==item.Type&&commands.push({name:globalize.translate("sharedcomponents#PlayAllFromHere"),id:"playallfromhere"})),"Program"===item.Type&&options.record!==!1&&commands.push({name:Globalize.translate("sharedcomponents#Record"),id:"record"}),user.Policy.IsAdministrator&&("Timer"===item.Type||"SeriesTimer"===item.Type||"Program"===item.Type||"TvChannel"===item.Type||"Recording"===item.Type&&"Completed"!==item.Status||commands.push({name:globalize.translate("sharedcomponents#Refresh"),id:"refresh"})),item.PlaylistItemId&&options.playlistId&&commands.push({name:globalize.translate("sharedcomponents#RemoveFromPlaylist"),id:"removefromplaylist"}),options.collectionId&&commands.push({name:globalize.transla
|