Implement content apps code config and manifest

This commit is contained in:
Stephan
2018-09-20 17:22:39 +02:00
parent 7f45727936
commit d6775aa79a
25 changed files with 552 additions and 200 deletions

View File

@@ -1,57 +1,26 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using AutoMapper;
using Umbraco.Core.Models;
using Umbraco.Core.PropertyEditors;
using Umbraco.Core.Services;
using Umbraco.Core.Models.ContentEditing;
using Umbraco.Web.ContentApps;
using Umbraco.Web.Models.ContentEditing;
namespace Umbraco.Web.Models.Mapping
{
// injected into ContentMapperProfile,
// maps ContentApps when mapping IMedia to MediaItemDisplay
internal class MediaAppResolver : IValueResolver<IMedia, MediaItemDisplay, IEnumerable<ContentApp>>
{
private static readonly ContentApp _contentApp = new ContentApp
{
Alias = "umbContent",
Name = "Content",
Icon = "icon-document",
View = "views/media/apps/content/content.html"
};
private readonly ContentAppDefinitionCollection _contentAppDefinitions;
private static readonly ContentApp _infoApp = new ContentApp
public MediaAppResolver(ContentAppDefinitionCollection contentAppDefinitions)
{
Alias = "umbInfo",
Name = "Info",
Icon = "icon-info",
View = "views/media/apps/info/info.html"
};
private readonly IDataTypeService _dataTypeService;
private readonly PropertyEditorCollection _propertyEditorCollection;
public MediaAppResolver(IDataTypeService dataTypeService, PropertyEditorCollection propertyEditorCollection)
{
_dataTypeService = dataTypeService ?? throw new ArgumentNullException(nameof(dataTypeService));
_propertyEditorCollection = propertyEditorCollection ?? throw new ArgumentNullException(nameof(propertyEditorCollection));
_contentAppDefinitions = contentAppDefinitions;
}
public IEnumerable<ContentApp> Resolve(IMedia source, MediaItemDisplay destination, IEnumerable<ContentApp> destMember, ResolutionContext context)
{
var apps = new List<ContentApp>();
if (source.ContentType.IsContainer || source.ContentType.Alias == Core.Constants.Conventions.MediaTypes.Folder)
{
apps.AppendListViewApp(_dataTypeService, _propertyEditorCollection, source.ContentType.Alias, "media");
}
else
{
apps.Add(_contentApp);
}
apps.Add(_infoApp);
return apps;
return _contentAppDefinitions.GetContentAppsFor(source);
}
}
}