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,56 +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 IContent to ContentItemDisplay
internal class ContentAppResolver : IValueResolver<IContent, ContentItemDisplay, IEnumerable<ContentApp>>
{
private readonly ContentApp _contentApp = new ContentApp
{
Alias = "umbContent",
Name = "Content",
Icon = "icon-document",
View = "views/content/apps/content/content.html"
};
private readonly ContentAppDefinitionCollection _contentAppDefinitions;
private readonly ContentApp _infoApp = new ContentApp
public ContentAppResolver(ContentAppDefinitionCollection contentAppDefinitions)
{
Alias = "umbInfo",
Name = "Info",
Icon = "icon-info",
View = "views/content/apps/info/info.html"
};
private readonly IDataTypeService _dataTypeService;
private readonly PropertyEditorCollection _propertyEditorCollection;
public ContentAppResolver(IDataTypeService dataTypeService, PropertyEditorCollection propertyEditorCollection)
{
_dataTypeService = dataTypeService ?? throw new ArgumentNullException(nameof(dataTypeService));
_propertyEditorCollection = propertyEditorCollection ?? throw new ArgumentNullException(nameof(propertyEditorCollection));
_contentAppDefinitions = contentAppDefinitions;
}
public IEnumerable<ContentApp> Resolve(IContent source, ContentItemDisplay destination, IEnumerable<ContentApp> destMember, ResolutionContext context)
{
var apps = new List<ContentApp>();
if (source.ContentType.IsContainer)
{
//If it's a container then add the list view app and view model
apps.AppendListViewApp(_dataTypeService, _propertyEditorCollection, source.ContentType.Alias, "content");
}
apps.Add(_contentApp);
apps.Add(_infoApp);
return apps;
return _contentAppDefinitions.GetContentAppsFor(source);
}
}
}
}