Merge branch '3436-relations-editor' of https://github.com/jamescoxhead/Umbraco-CMS into jamescoxhead-3436-relations-editor
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; }
|
||||
}
|
||||
}
|
||||
@@ -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,35 @@ namespace Umbraco.Web.Models.Mapping
|
||||
{
|
||||
public RelationMapperProfile()
|
||||
{
|
||||
//FROM IRelationType TO RelationType
|
||||
CreateMap<IRelationType, RelationType>();
|
||||
// FROM IRelationType to RelationTypeDisplay
|
||||
CreateMap<IRelationType, RelationTypeDisplay>()
|
||||
.ForMember(x => x.Icon, expression => expression.Ignore())
|
||||
.ForMember(x => x.Trashed, expression => expression.Ignore())
|
||||
.ForMember(x => x.Alias, expression => expression.Ignore())
|
||||
.ForMember(x => x.Path, expression => expression.Ignore())
|
||||
.ForMember(x => x.AdditionalData, expression => expression.Ignore())
|
||||
.ForMember(x => x.ChildObjectTypeName, expression => expression.Ignore())
|
||||
.ForMember(x => x.ParentObjectTypeName, expression => expression.Ignore())
|
||||
.ForMember(x => x.Relations, expression => expression.Ignore())
|
||||
.ForMember(
|
||||
x => x.Udi,
|
||||
expression => expression.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>();
|
||||
|
||||
// FROM RelationTypeSave to IRelationType
|
||||
CreateMap<RelationTypeSave, IRelationType>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user