Merge branch 'temp8' into temp8-3668-query-builder-snippits

This commit is contained in:
Stephan
2019-01-21 10:50:40 +01:00
423 changed files with 4909 additions and 6869 deletions

View File

@@ -1,39 +0,0 @@
using System.Collections.Generic;
using System.Runtime.Serialization;
namespace Umbraco.Web.Models.ContentEditing
{
[DataContract]
public class InstalledPackageModel
{
[DataMember(Name = "id")]
public int Id { get; set; }
[DataMember(Name = "name")]
public string Name { get; set; }
[DataMember(Name = "author")]
public string Author { get; set; }
[DataMember(Name = "files")]
public IEnumerable<string> Files { get; set; }
[DataMember(Name = "version")]
public string Version { get; set; }
[DataMember(Name = "url")]
public string Url { get; set; }
[DataMember(Name = "license")]
public string License { get; set; }
[DataMember(Name = "licenseUrl")]
public string LicenseUrl { get; set; }
[DataMember(Name = "iconUrl")]
public string IconUrl { get; set; }
[DataMember(Name = "readme")]
public string Readme { get; set; }
}
}

View File

@@ -0,0 +1,67 @@
using System.Collections.Generic;
using System.Runtime.Serialization;
namespace Umbraco.Web.Models.ContentEditing
{
/// <summary>
/// The macro display model
/// </summary>
[DataContract(Name = "dictionary", Namespace = "")]
public class MacroDisplay : EntityBasic, INotificationModel
{
/// <summary>
/// Initializes a new instance of the <see cref="MacroDisplay"/> class.
/// </summary>
public MacroDisplay()
{
this.Notifications = new List<Notification>();
this.Parameters = new List<MacroParameterDisplay>();
}
/// <inheritdoc />
[DataMember(Name = "notifications")]
public List<Notification> Notifications { get; }
/// <summary>
/// Gets or sets a value indicating whether the macro can be used in a rich text editor.
/// </summary>
[DataMember(Name = "useInEditor")]
public bool UseInEditor { get; set; }
/// <summary>
/// Gets or sets a value indicating whether the macro should be rendered a rich text editor.
/// </summary>
[DataMember(Name = "renderInEditor")]
public bool RenderInEditor { get; set; }
/// <summary>
/// Gets or sets the cache period.
/// </summary>
[DataMember(Name = "cachePeriod")]
public int CachePeriod { get; set; }
/// <summary>
/// Gets or sets a value indicating whether the macro should be cached by page
/// </summary>
[DataMember(Name = "cacheByPage")]
public bool CacheByPage { get; set; }
/// <summary>
/// Gets or sets a value indicating whether the macro should be cached by user
/// </summary>
[DataMember(Name = "cacheByUser")]
public bool CacheByUser { get; set; }
/// <summary>
/// Gets or sets the view.
/// </summary>
[DataMember(Name = "view")]
public string View { get; set; }
/// <summary>
/// Gets or sets the parameters.
/// </summary>
[DataMember(Name = "parameters")]
public IEnumerable<MacroParameterDisplay> Parameters { get; set; }
}
}

View File

@@ -0,0 +1,35 @@
namespace Umbraco.Web.Models.ContentEditing
{
using System.Runtime.Serialization;
/// <summary>
/// The macro parameter display.
/// </summary>
[DataContract(Name = "parameter", Namespace = "")]
public class MacroParameterDisplay
{
/// <summary>
/// Gets or sets the key.
/// </summary>
[DataMember(Name = "key")]
public string Key { get; set; }
/// <summary>
/// Gets or sets the label.
/// </summary>
[DataMember(Name = "label")]
public string Label { get; set; }
/// <summary>
/// Gets or sets the editor.
/// </summary>
[DataMember(Name = "editor")]
public string Editor { get; set; }
/// <summary>
/// Gets or sets the id.
/// </summary>
[DataMember(Name = "id")]
public int Id { get; set; }
}
}

View File

@@ -86,8 +86,11 @@ namespace Umbraco.Web.Models.ContentEditing
/// <summary>
/// Property Group
/// </summary>
PropertyGroup
PropertyGroup,
//TODO: Dictionary?
/// <summary>
/// Dictionary Item
/// </summary>
DictionaryItem
}
}

View File

@@ -9,6 +9,18 @@ namespace Umbraco.Web.Models.Mapping
{
public CodeFileMapperProfile()
{
CreateMap<Stylesheet, EntityBasic>()
.ForMember(dest => dest.Id, opt => opt.MapFrom(sheet => sheet.Id))
.ForMember(dest => dest.Alias, opt => opt.MapFrom(sheet => sheet.Alias))
.ForMember(dest => dest.Key, opt => opt.MapFrom(sheet => sheet.Key))
.ForMember(dest => dest.Name, opt => opt.MapFrom(sheet => sheet.Name))
.ForMember(dest => dest.ParentId, opt => opt.UseValue(-1))
.ForMember(dest => dest.Path, opt => opt.MapFrom(sheet => sheet.Path))
.ForMember(dest => dest.Trashed, opt => opt.Ignore())
.ForMember(dest => dest.AdditionalData, opt => opt.Ignore())
.ForMember(dest => dest.Udi, opt => opt.Ignore())
.ForMember(dest => dest.Icon, opt => opt.Ignore());
CreateMap<IPartialView, CodeFileDisplay>()
.ForMember(dest => dest.FileType, opt => opt.Ignore())
.ForMember(dest => dest.Notifications, opt => opt.Ignore())

View File

@@ -17,6 +17,18 @@ namespace Umbraco.Web.Models.Mapping
{
public DictionaryMapperProfile(ILocalizationService localizationService)
{
CreateMap<IDictionaryItem, EntityBasic>()
.ForMember(dest => dest.Id, opt => opt.MapFrom(sheet => sheet.Id))
.ForMember(dest => dest.Alias, opt => opt.MapFrom(sheet => sheet.ItemKey))
.ForMember(dest => dest.Key, opt => opt.MapFrom(sheet => sheet.Key))
.ForMember(dest => dest.Name, opt => opt.MapFrom(sheet => sheet.ItemKey))
.ForMember(dest => dest.ParentId, opt => opt.Ignore())
.ForMember(dest => dest.Path, opt => opt.Ignore())
.ForMember(dest => dest.Trashed, opt => opt.Ignore())
.ForMember(dest => dest.AdditionalData, opt => opt.Ignore())
.ForMember(dest => dest.Udi, opt => opt.Ignore())
.ForMember(dest => dest.Icon, opt => opt.Ignore());
CreateMap<IDictionaryItem, DictionaryDisplay>()
.ForMember(x => x.Translations, expression => expression.Ignore())
.ForMember(x => x.Notifications, expression => expression.Ignore())

View File

@@ -16,7 +16,7 @@ namespace Umbraco.Web.Models.Mapping
{
internal class EntityMapperProfile : Profile
{
private static string GetContentTypeIcon(EntitySlim entity)
private static string GetContentTypeIcon(IEntitySlim entity)
=> entity is ContentEntitySlim contentEntity ? contentEntity.ContentTypeIcon : null;
public EntityMapperProfile()
@@ -24,7 +24,7 @@ namespace Umbraco.Web.Models.Mapping
// create, capture, cache
var contentTypeUdiResolver = new ContentTypeUdiResolver();
CreateMap<EntitySlim, EntityBasic>()
CreateMap<IEntitySlim, EntityBasic>()
.ForMember(dest => dest.Name, opt => opt.ResolveUsing<NameResolver>())
.ForMember(dest => dest.Udi, opt => opt.MapFrom(src => Udi.Create(ObjectTypes.GetUdiType(src.NodeObjectType), src.Key)))
.ForMember(dest => dest.Icon, opt => opt.MapFrom(src => GetContentTypeIcon(src)))
@@ -36,6 +36,8 @@ namespace Umbraco.Web.Models.Mapping
{
dest.Icon = "icon-user";
}
dest.AdditionalData.Add("IsContainer", src.IsContainer);
});
CreateMap<PropertyType, EntityBasic>()
@@ -186,9 +188,9 @@ namespace Umbraco.Web.Models.Mapping
/// <summary>
/// Resolves the name for a content item/content variant
/// </summary>
private class NameResolver : IValueResolver<EntitySlim, EntityBasic, string>
private class NameResolver : IValueResolver<IEntitySlim, EntityBasic, string>
{
public string Resolve(EntitySlim source, EntityBasic destination, string destMember, ResolutionContext context)
public string Resolve(IEntitySlim source, EntityBasic destination, string destMember, ResolutionContext context)
{
if (!(source is DocumentEntitySlim doc))
return source.Name;

View File

@@ -12,6 +12,18 @@ namespace Umbraco.Web.Models.Mapping
{
public LanguageMapperProfile()
{
CreateMap<ILanguage, EntityBasic>()
.ForMember(dest => dest.Id, opt => opt.MapFrom(x => x.Id))
.ForMember(dest => dest.Name, opt => opt.MapFrom(x => x.CultureName))
.ForMember(dest => dest.Key, opt => opt.MapFrom(x => x.Key))
.ForMember(dest => dest.Alias, opt => opt.MapFrom(x => x.IsoCode))
.ForMember(dest => dest.ParentId, opt => opt.UseValue(-1))
.ForMember(dest => dest.Path, opt => opt.Ignore())
.ForMember(dest => dest.Trashed, opt => opt.Ignore())
.ForMember(dest => dest.AdditionalData, opt => opt.Ignore())
.ForMember(dest => dest.Udi, opt => opt.Ignore())
.ForMember(dest => dest.Icon, opt => opt.Ignore());
CreateMap<ILanguage, Language>()
.ForMember(l => l.Name, expression => expression.MapFrom(x => x.CultureInfo.DisplayName));

View File

@@ -1,5 +1,6 @@
using System.Collections.Generic;
using AutoMapper;
using Umbraco.Core.Models.Trees;
using Umbraco.Core.Services;
using Umbraco.Web.Models.ContentEditing;
@@ -9,7 +10,7 @@ namespace Umbraco.Web.Models.Mapping
{
public SectionMapperProfile(ILocalizedTextService textService)
{
CreateMap<Core.Models.Section, Section>()
CreateMap<IBackOfficeSection, Section>()
.ForMember(dest => dest.RoutePath, opt => opt.Ignore())
.ForMember(dest => dest.Icon, opt => opt.Ignore())
.ForMember(dest => dest.Name, opt => opt.MapFrom(src => textService.Localize("sections/" + src.Alias, (IDictionary<string, string>)null)))

View File

@@ -12,6 +12,7 @@ using Umbraco.Core.Models.Entities;
using Umbraco.Core.Security;
using Umbraco.Core.Services;
using Umbraco.Web.Actions;
using Umbraco.Web.Services;
namespace Umbraco.Web.Models.Mapping
@@ -22,7 +23,7 @@ namespace Umbraco.Web.Models.Mapping
=> entity is ContentEntitySlim contentEntity ? contentEntity.ContentTypeIcon : null;
public UserMapperProfile(ILocalizedTextService textService, IUserService userService, IEntityService entityService, ISectionService sectionService,
IRuntimeCacheProvider runtimeCache, ActionCollection actions, IGlobalSettings globalSettings)
AppCaches appCaches, ActionCollection actions, IGlobalSettings globalSettings)
{
var userGroupDefaultPermissionsResolver = new UserGroupDefaultPermissionsResolver(textService, actions);
@@ -243,7 +244,7 @@ namespace Umbraco.Web.Models.Mapping
//Important! Currently we are never mapping to multiple UserDisplay objects but if we start doing that
// this will cause an N+1 and we'll need to change how this works.
CreateMap<IUser, UserDisplay>()
.ForMember(dest => dest.Avatars, opt => opt.MapFrom(user => user.GetUserAvatarUrls(runtimeCache)))
.ForMember(dest => dest.Avatars, opt => opt.MapFrom(user => user.GetUserAvatarUrls(appCaches.RuntimeCache)))
.ForMember(dest => dest.Username, opt => opt.MapFrom(user => user.Username))
.ForMember(dest => dest.LastLoginDate, opt => opt.MapFrom(user => user.LastLoginDate == default(DateTime) ? null : (DateTime?)user.LastLoginDate))
.ForMember(dest => dest.UserGroups, opt => opt.MapFrom(user => user.Groups))
@@ -293,7 +294,7 @@ namespace Umbraco.Web.Models.Mapping
//like the load time is waiting.
.ForMember(detail =>
detail.Avatars,
opt => opt.MapFrom(user => user.GetUserAvatarUrls(runtimeCache)))
opt => opt.MapFrom(user => user.GetUserAvatarUrls(appCaches.RuntimeCache)))
.ForMember(dest => dest.Username, opt => opt.MapFrom(user => user.Username))
.ForMember(dest => dest.UserGroups, opt => opt.MapFrom(user => user.Groups))
.ForMember(dest => dest.LastLoginDate, opt => opt.MapFrom(user => user.LastLoginDate == default(DateTime) ? null : (DateTime?)user.LastLoginDate))
@@ -313,7 +314,7 @@ namespace Umbraco.Web.Models.Mapping
.ForMember(dest => dest.AdditionalData, opt => opt.Ignore());
CreateMap<IUser, UserDetail>()
.ForMember(dest => dest.Avatars, opt => opt.MapFrom(user => user.GetUserAvatarUrls(runtimeCache)))
.ForMember(dest => dest.Avatars, opt => opt.MapFrom(user => user.GetUserAvatarUrls(appCaches.RuntimeCache)))
.ForMember(dest => dest.UserId, opt => opt.MapFrom(user => GetIntId(user.Id)))
.ForMember(dest => dest.StartContentIds, opt => opt.MapFrom(user => user.CalculateContentStartNodeIds(entityService)))
.ForMember(dest => dest.StartMediaIds, opt => opt.MapFrom(user => user.CalculateMediaStartNodeIds(entityService)))

View File

@@ -1,30 +0,0 @@
using System;
namespace Umbraco.Web.Models.Trees
{
/// <summary>
/// Identifies an application tree
/// </summary>
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false)]
public class ApplicationAttribute : Attribute
{
/// <summary>
/// Initializes a new instance of the <see cref="ApplicationAttribute"/> class.
/// </summary>
/// <param name="alias">The alias.</param>
/// <param name="name">The name.</param>
/// <param name="sortOrder">The sort order.</param>
public ApplicationAttribute(string alias,
string name,
int sortOrder = 0)
{
Alias = alias;
Name = name;
SortOrder = sortOrder;
}
public string Alias { get; private set; }
public string Name { get; private set; }
public int SortOrder { get; private set; }
}
}

View File

@@ -1,37 +0,0 @@
using Umbraco.Core;
using Umbraco.Core.Models;
namespace Umbraco.Web.Models.Trees
{
// The application definitions are intended as a means to auto populate
// the application.config. On app startup, Umbraco will look for any
// unregistered classes with an ApplicationAttribute and add them to the cache
[Application(Constants.Applications.Content, "Content")]
public class ContentApplicationDefinition : IApplication
{ }
[Application(Constants.Applications.Media, "Media", sortOrder: 1)]
public class MediaApplicationDefinition : IApplication
{ }
[Application(Constants.Applications.Settings, "Settings", sortOrder: 2)]
public class SettingsApplicationDefinition : IApplication
{ }
[Application(Constants.Applications.Packages, "Packages", sortOrder: 3)]
public class PackagesApplicationDefinition : IApplication
{ }
[Application(Constants.Applications.Users, "Users", sortOrder: 4)]
public class UsersApplicationDefinition : IApplication
{ }
[Application(Constants.Applications.Members, "Members", sortOrder: 5)]
public class MembersApplicationDefinition : IApplication
{ }
[Application(Constants.Applications.Translation, "Translation", sortOrder: 6)]
public class TranslationApplicationDefinition : IApplication
{ }
}

View File

@@ -1,10 +0,0 @@
using Umbraco.Core.Composing;
namespace Umbraco.Web.Models.Trees
{
/// <summary>
/// Marker interface for created applications in the umbraco backoffice
/// </summary>
public interface IApplication : IDiscoverable
{ }
}