Merge branch origin/temp8 into temp8-di2690
This commit is contained in:
15
src/Umbraco.Web/Models/ContentEditing/ObjectType.cs
Normal file
15
src/Umbraco.Web/Models/ContentEditing/ObjectType.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace Umbraco.Web.Models.ContentEditing
|
||||
{
|
||||
[DataContract(Name = "objectType", Namespace = "")]
|
||||
public class ObjectType
|
||||
{
|
||||
[DataMember(Name = "name")]
|
||||
public string Name { get; set; }
|
||||
|
||||
[DataMember(Name = "id")]
|
||||
public Guid Id { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Umbraco.Web.Models.ContentEditing
|
||||
{
|
||||
[DataContract(Name = "relation", Namespace = "")]
|
||||
public class Relation
|
||||
{
|
||||
|
||||
public Relation()
|
||||
{
|
||||
RelationType = new RelationType();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Parent Id of the Relation (Source)
|
||||
/// </summary>
|
||||
[DataMember(Name = "parentId")]
|
||||
public int ParentId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Child Id of the Relation (Destination)
|
||||
/// </summary>
|
||||
[DataMember(Name = "childId")]
|
||||
public int ChildId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the <see cref="RelationType"/> for the Relation
|
||||
/// </summary>
|
||||
[DataMember(Name = "relationType", IsRequired = true)]
|
||||
public RelationType RelationType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a comment for the Relation
|
||||
/// </summary>
|
||||
[DataMember(Name = "comment")]
|
||||
public string Comment { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
52
src/Umbraco.Web/Models/ContentEditing/RelationDisplay.cs
Normal file
52
src/Umbraco.Web/Models/ContentEditing/RelationDisplay.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace Umbraco.Web.Models.ContentEditing
|
||||
{
|
||||
[DataContract(Name = "relation", Namespace = "")]
|
||||
public class RelationDisplay
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the Parent Id of the Relation (Source).
|
||||
/// </summary>
|
||||
[DataMember(Name = "parentId")]
|
||||
[ReadOnly(true)]
|
||||
public int ParentId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Parent Name of the relation (Source).
|
||||
/// </summary>
|
||||
[DataMember(Name = "parentName")]
|
||||
[ReadOnly(true)]
|
||||
public string ParentName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Child Id of the Relation (Destination).
|
||||
/// </summary>
|
||||
[DataMember(Name = "childId")]
|
||||
[ReadOnly(true)]
|
||||
public int ChildId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Child Name of the relation (Destination).
|
||||
/// </summary>
|
||||
[DataMember(Name = "childName")]
|
||||
[ReadOnly(true)]
|
||||
public string ChildName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the date when the Relation was created.
|
||||
/// </summary>
|
||||
[DataMember(Name = "createDate")]
|
||||
[ReadOnly(true)]
|
||||
public DateTime CreateDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a comment for the Relation.
|
||||
/// </summary>
|
||||
[DataMember(Name = "comment")]
|
||||
[ReadOnly(true)]
|
||||
public string Comment { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
using System;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace Umbraco.Web.Models.ContentEditing
|
||||
{
|
||||
[DataContract(Name = "relationType", Namespace = "")]
|
||||
public class RelationType
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Name of the RelationType
|
||||
/// </summary>
|
||||
[DataMember(Name = "name", IsRequired = true)]
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Alias of the RelationType
|
||||
/// </summary>
|
||||
[DataMember(Name = "alias", IsRequired = true)]
|
||||
public string Alias { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a boolean indicating whether the RelationType is Bidirectional (true) or Parent to Child (false)
|
||||
/// </summary>
|
||||
[DataMember(Name = "isBidirectional", IsRequired = true)]
|
||||
public bool IsBidirectional { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Parents object type id
|
||||
/// </summary>
|
||||
/// <remarks>Corresponds to the NodeObjectType in the umbracoNode table</remarks>
|
||||
[DataMember(Name = "parentObjectType", IsRequired = true)]
|
||||
public Guid ParentObjectType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Childs object type id
|
||||
/// </summary>
|
||||
/// <remarks>Corresponds to the NodeObjectType in the umbracoNode table</remarks>
|
||||
[DataMember(Name = "childObjectType", IsRequired = true)]
|
||||
public Guid ChildObjectType { get; set; }
|
||||
}
|
||||
}
|
||||
63
src/Umbraco.Web/Models/ContentEditing/RelationTypeDisplay.cs
Normal file
63
src/Umbraco.Web/Models/ContentEditing/RelationTypeDisplay.cs
Normal file
@@ -0,0 +1,63 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace Umbraco.Web.Models.ContentEditing
|
||||
{
|
||||
[DataContract(Name = "relationType", Namespace = "")]
|
||||
public class RelationTypeDisplay : EntityBasic, INotificationModel
|
||||
{
|
||||
public RelationTypeDisplay()
|
||||
{
|
||||
Notifications = new List<Notification>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a boolean indicating whether the RelationType is Bidirectional (true) or Parent to Child (false)
|
||||
/// </summary>
|
||||
[DataMember(Name = "isBidirectional", IsRequired = true)]
|
||||
public bool IsBidirectional { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Parents object type id
|
||||
/// </summary>
|
||||
/// <remarks>Corresponds to the NodeObjectType in the umbracoNode table</remarks>
|
||||
[DataMember(Name = "parentObjectType", IsRequired = true)]
|
||||
public Guid ParentObjectType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Parent's object type name.
|
||||
/// </summary>
|
||||
[DataMember(Name = "parentObjectTypeName")]
|
||||
[ReadOnly(true)]
|
||||
public string ParentObjectTypeName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Childs object type id
|
||||
/// </summary>
|
||||
/// <remarks>Corresponds to the NodeObjectType in the umbracoNode table</remarks>
|
||||
[DataMember(Name = "childObjectType", IsRequired = true)]
|
||||
public Guid ChildObjectType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Child's object type name.
|
||||
/// </summary>
|
||||
[DataMember(Name = "childObjectTypeName")]
|
||||
[ReadOnly(true)]
|
||||
public string ChildObjectTypeName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the relations associated with this relation type.
|
||||
/// </summary>
|
||||
[DataMember(Name = "relations")]
|
||||
[ReadOnly(true)]
|
||||
public IEnumerable<RelationDisplay> Relations { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// This is used to add custom localized messages/strings to the response for the app to use for localized UI purposes.
|
||||
/// </summary>
|
||||
[DataMember(Name = "notifications")]
|
||||
public List<Notification> Notifications { get; private set; }
|
||||
}
|
||||
}
|
||||
27
src/Umbraco.Web/Models/ContentEditing/RelationTypeSave.cs
Normal file
27
src/Umbraco.Web/Models/ContentEditing/RelationTypeSave.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace Umbraco.Web.Models.ContentEditing
|
||||
{
|
||||
[DataContract(Name = "relationType", Namespace = "")]
|
||||
public class RelationTypeSave : EntityBasic
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets a boolean indicating whether the RelationType is Bidirectional (true) or Parent to Child (false)
|
||||
/// </summary>
|
||||
[DataMember(Name = "isBidirectional", IsRequired = true)]
|
||||
public bool IsBidirectional { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the parent object type ID.
|
||||
/// </summary>
|
||||
[DataMember(Name = "parentObjectType", IsRequired = false)]
|
||||
public Guid ParentObjectType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the child object type ID.
|
||||
/// </summary>
|
||||
[DataMember(Name = "childObjectType", IsRequired = false)]
|
||||
public Guid ChildObjectType { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -123,15 +123,15 @@ namespace Umbraco.Web.Models.Mapping
|
||||
.AfterMap((src, dest) =>
|
||||
{
|
||||
//get the icon if there is one
|
||||
dest.Icon = src.Values.ContainsKey(UmbracoExamineIndexer.IconFieldName)
|
||||
? src.Values[UmbracoExamineIndexer.IconFieldName]
|
||||
dest.Icon = src.Values.ContainsKey(UmbracoExamineIndex.IconFieldName)
|
||||
? src.Values[UmbracoExamineIndex.IconFieldName]
|
||||
: "icon-document";
|
||||
|
||||
dest.Name = src.Values.ContainsKey("nodeName") ? src.Values["nodeName"] : "[no name]";
|
||||
if (src.Values.ContainsKey(UmbracoExamineIndexer.NodeKeyFieldName))
|
||||
if (src.Values.ContainsKey(UmbracoExamineIndex.NodeKeyFieldName))
|
||||
{
|
||||
Guid key;
|
||||
if (Guid.TryParse(src.Values[UmbracoExamineIndexer.NodeKeyFieldName], out key))
|
||||
if (Guid.TryParse(src.Values[UmbracoExamineIndex.NodeKeyFieldName], out key))
|
||||
{
|
||||
dest.Key = key;
|
||||
|
||||
@@ -166,7 +166,7 @@ namespace Umbraco.Web.Models.Mapping
|
||||
dest.ParentId = -1;
|
||||
}
|
||||
}
|
||||
dest.Path = src.Values.ContainsKey(UmbracoExamineIndexer.IndexPathFieldName) ? src.Values[UmbracoExamineIndexer.IndexPathFieldName] : "";
|
||||
dest.Path = src.Values.ContainsKey(UmbracoExamineIndex.IndexPathFieldName) ? src.Values[UmbracoExamineIndex.IndexPathFieldName] : "";
|
||||
|
||||
if (src.Values.ContainsKey(LuceneIndex.ItemTypeFieldName))
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using AutoMapper;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Models;
|
||||
using Relation = Umbraco.Web.Models.ContentEditing.Relation;
|
||||
using RelationType = Umbraco.Web.Models.ContentEditing.RelationType;
|
||||
using Umbraco.Web.Models.ContentEditing;
|
||||
|
||||
namespace Umbraco.Web.Models.Mapping
|
||||
{
|
||||
@@ -9,11 +9,39 @@ namespace Umbraco.Web.Models.Mapping
|
||||
{
|
||||
public RelationMapperProfile()
|
||||
{
|
||||
//FROM IRelationType TO RelationType
|
||||
CreateMap<IRelationType, RelationType>();
|
||||
// FROM IRelationType to RelationTypeDisplay
|
||||
CreateMap<IRelationType, RelationTypeDisplay>()
|
||||
.ForMember(dest => dest.Icon, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.Trashed, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.Alias, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.Path, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.AdditionalData, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.ChildObjectTypeName, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.ParentObjectTypeName, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.Relations, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.ParentId, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.Notifications, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.Udi, opt => opt.MapFrom(content => Udi.Create(Constants.UdiEntityType.RelationType, content.Key)))
|
||||
.AfterMap((src, dest) =>
|
||||
{
|
||||
// Build up the path
|
||||
dest.Path = "-1," + src.Id;
|
||||
|
||||
//FROM IRelation TO Relation
|
||||
CreateMap<IRelation, Relation>();
|
||||
// Set the "friendly" names for the parent and child object types
|
||||
dest.ParentObjectTypeName = ObjectTypes.GetUmbracoObjectType(src.ParentObjectType).GetFriendlyName();
|
||||
dest.ChildObjectTypeName = ObjectTypes.GetUmbracoObjectType(src.ChildObjectType).GetFriendlyName();
|
||||
});
|
||||
|
||||
// FROM IRelation to RelationDisplay
|
||||
CreateMap<IRelation, RelationDisplay>()
|
||||
.ForMember(dest => dest.ParentName, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.ChildName, opt => opt.Ignore());
|
||||
|
||||
// FROM RelationTypeSave to IRelationType
|
||||
CreateMap<RelationTypeSave, IRelationType>()
|
||||
.ForMember(dest => dest.CreateDate, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.UpdateDate, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.DeleteDate, opt => opt.Ignore());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,10 +44,11 @@ namespace Umbraco.Web.Models.Trees
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="hasSeparator"></param>
|
||||
/// <param name="name">The text to display for the menu item, will default to the IAction alias if not specified</param>
|
||||
public MenuItem Add<T>(string name, bool hasSeparator = false)
|
||||
/// <param name="opensDialog">Whether or not this action opens a dialog</param>
|
||||
public MenuItem Add<T>(string name, bool hasSeparator = false, bool opensDialog = false)
|
||||
where T : IAction
|
||||
{
|
||||
var item = CreateMenuItem<T>(name, hasSeparator);
|
||||
var item = CreateMenuItem<T>(name, hasSeparator, opensDialog);
|
||||
if (item != null)
|
||||
{
|
||||
Add(item);
|
||||
@@ -62,11 +63,11 @@ namespace Umbraco.Web.Models.Trees
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="hasSeparator"></param>
|
||||
/// <param name="textService">The <see cref="ILocalizedTextService"/> used to localize the action name based on it's alias</param>
|
||||
/// <param name="opensDialog"></param>
|
||||
/// <param name="opensDialog">Whether or not this action opens a dialog</param>
|
||||
public MenuItem Add<T>(ILocalizedTextService textService, bool hasSeparator = false, bool opensDialog = false)
|
||||
where T : IAction
|
||||
{
|
||||
var item = CreateMenuItem<T>(textService, hasSeparator);
|
||||
var item = CreateMenuItem<T>(textService, hasSeparator, opensDialog);
|
||||
if (item != null)
|
||||
{
|
||||
Add(item);
|
||||
@@ -75,14 +76,15 @@ namespace Umbraco.Web.Models.Trees
|
||||
return null;
|
||||
}
|
||||
|
||||
internal MenuItem CreateMenuItem<T>(string name, bool hasSeparator = false)
|
||||
internal MenuItem CreateMenuItem<T>(string name, bool hasSeparator = false, bool opensDialog = false)
|
||||
where T : IAction
|
||||
{
|
||||
var item = Current.Actions.GetAction<T>();
|
||||
if (item == null) return null;
|
||||
var menuItem = new MenuItem(item, name)
|
||||
{
|
||||
SeperatorBefore = hasSeparator
|
||||
SeperatorBefore = hasSeparator,
|
||||
OpensDialog = opensDialog
|
||||
};
|
||||
|
||||
return menuItem;
|
||||
|
||||
Reference in New Issue
Block a user