2018-07-16 22:32:46 +10:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
2018-07-13 12:45:04 +10:00
|
|
|
|
using AutoMapper;
|
|
|
|
|
|
using Umbraco.Core.Models;
|
2018-07-16 22:32:46 +10:00
|
|
|
|
using Umbraco.Core.PropertyEditors;
|
|
|
|
|
|
using Umbraco.Core.Services;
|
2018-07-13 12:45:04 +10:00
|
|
|
|
using Umbraco.Web.Models.ContentEditing;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Umbraco.Web.Models.Mapping
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
internal class ContentAppResolver : IValueResolver<IContent, ContentItemDisplay, IEnumerable<ContentApp>>
|
|
|
|
|
|
{
|
|
|
|
|
|
private readonly ContentApp _contentApp = new ContentApp
|
|
|
|
|
|
{
|
2018-09-14 09:20:05 +01:00
|
|
|
|
Alias = "umbContent",
|
2018-07-13 12:45:04 +10:00
|
|
|
|
Name = "Content",
|
|
|
|
|
|
Icon = "icon-document",
|
|
|
|
|
|
View = "views/content/apps/content/content.html"
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
private readonly ContentApp _infoApp = new ContentApp
|
|
|
|
|
|
{
|
2018-09-14 09:20:05 +01:00
|
|
|
|
Alias = "umbInfo",
|
2018-07-13 12:45:04 +10:00
|
|
|
|
Name = "Info",
|
|
|
|
|
|
Icon = "icon-info",
|
|
|
|
|
|
View = "views/content/apps/info/info.html"
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2018-07-16 22:32:46 +10:00
|
|
|
|
private readonly IDataTypeService _dataTypeService;
|
|
|
|
|
|
private readonly PropertyEditorCollection _propertyEditorCollection;
|
|
|
|
|
|
|
|
|
|
|
|
public ContentAppResolver(IDataTypeService dataTypeService, PropertyEditorCollection propertyEditorCollection)
|
2018-07-13 12:45:04 +10:00
|
|
|
|
{
|
2018-07-16 22:32:46 +10:00
|
|
|
|
_dataTypeService = dataTypeService ?? throw new ArgumentNullException(nameof(dataTypeService));
|
|
|
|
|
|
_propertyEditorCollection = propertyEditorCollection ?? throw new ArgumentNullException(nameof(propertyEditorCollection));
|
|
|
|
|
|
}
|
2018-07-13 12:45:04 +10:00
|
|
|
|
|
|
|
|
|
|
public IEnumerable<ContentApp> Resolve(IContent source, ContentItemDisplay destination, IEnumerable<ContentApp> destMember, ResolutionContext context)
|
|
|
|
|
|
{
|
2018-08-07 15:59:19 +02:00
|
|
|
|
var apps = new List<ContentApp>();
|
2018-07-13 12:45:04 +10:00
|
|
|
|
|
|
|
|
|
|
if (source.ContentType.IsContainer)
|
|
|
|
|
|
{
|
2018-07-16 22:32:46 +10:00
|
|
|
|
//If it's a container then add the list view app and view model
|
2018-07-17 14:23:07 +10:00
|
|
|
|
apps.AppendListViewApp(_dataTypeService, _propertyEditorCollection, source.ContentType.Alias, "content");
|
2018-07-13 12:45:04 +10:00
|
|
|
|
}
|
|
|
|
|
|
|
2018-08-07 15:59:19 +02:00
|
|
|
|
apps.Add(_contentApp);
|
|
|
|
|
|
apps.Add(_infoApp);
|
2018-08-17 14:14:01 +02:00
|
|
|
|
|
2018-07-13 12:45:04 +10:00
|
|
|
|
return apps;
|
|
|
|
|
|
}
|
2018-08-07 15:59:19 +02:00
|
|
|
|
}
|
2018-07-13 12:45:04 +10:00
|
|
|
|
|
|
|
|
|
|
}
|