Skip to content

Commit 971b66d

Browse files
committed
More or less release ready
1 parent f50cfe8 commit 971b66d

File tree

17 files changed

+633
-87
lines changed

17 files changed

+633
-87
lines changed

Umbraco Relation Editor.sln

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Umbraco.RelationEditor.Web"
77
EndProject
88
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Umbraco.RelationEditor", "Umbraco.RelationEditor\Umbraco.RelationEditor.csproj", "{CD233AE0-2E7F-4A97-A45E-B6A759B41F67}"
99
EndProject
10+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Umbraco.RelationEditor.Tests", "Umbraco.RelationEditor.Tests\Umbraco.RelationEditor.Tests.csproj", "{1F10C3B0-4F95-412E-B2C1-4B47E3E138A3}"
11+
EndProject
1012
Global
1113
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1214
Debug|Any CPU = Debug|Any CPU
@@ -21,6 +23,10 @@ Global
2123
{CD233AE0-2E7F-4A97-A45E-B6A759B41F67}.Debug|Any CPU.Build.0 = Debug|Any CPU
2224
{CD233AE0-2E7F-4A97-A45E-B6A759B41F67}.Release|Any CPU.ActiveCfg = Release|Any CPU
2325
{CD233AE0-2E7F-4A97-A45E-B6A759B41F67}.Release|Any CPU.Build.0 = Release|Any CPU
26+
{1F10C3B0-4F95-412E-B2C1-4B47E3E138A3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
27+
{1F10C3B0-4F95-412E-B2C1-4B47E3E138A3}.Debug|Any CPU.Build.0 = Debug|Any CPU
28+
{1F10C3B0-4F95-412E-B2C1-4B47E3E138A3}.Release|Any CPU.ActiveCfg = Release|Any CPU
29+
{1F10C3B0-4F95-412E-B2C1-4B47E3E138A3}.Release|Any CPU.Build.0 = Release|Any CPU
2430
EndGlobalSection
2531
GlobalSection(SolutionProperties) = preSolution
2632
HideSolutionNode = FALSE
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.IO;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
using System.Xml;
8+
using System.Xml.Serialization;
9+
using NUnit.Framework;
10+
using Umbraco.Core.Models;
11+
12+
namespace Umbraco.RelationEditor.Tests
13+
{
14+
[TestFixture]
15+
public class ConfigSerializationTests
16+
{
17+
private const string Input = @"
18+
<RelationEditor>
19+
<ObjectType Name=""Document"" Alias=""page"">
20+
<EnabledRelation Alias=""pagePostRelation"">
21+
<EnabledChildType Alias=""post""/>
22+
</EnabledRelation>
23+
<EnabledRelation Alias=""pageNewsPostRelation"" />
24+
</ObjectType>
25+
<ObjectType Name=""Document"" ObjectTypeAlias=""Content"" AllowInheritance=""true"">
26+
<EnabledRelation Alias=""pagePostRelation"" />
27+
</ObjectType>
28+
</RelationEditor>
29+
";
30+
31+
[Test]
32+
public void SerializeConfiguration()
33+
{
34+
var config = new RelationEditorConfiguration
35+
{
36+
ObjectTypes = new List<ObjectTypeConfiguration>
37+
{
38+
new ObjectTypeConfiguration
39+
{
40+
Name = UmbracoObjectTypes.Document,
41+
Alias = "Page",
42+
EnabledRelations = new List<EnabledRelationConfiguration>
43+
{
44+
new EnabledRelationConfiguration{Alias="PagePostRelation"},
45+
new EnabledRelationConfiguration{Alias="PageNewsPostRelation"},
46+
}
47+
}
48+
}
49+
};
50+
51+
var stringBuilder = new StringBuilder();
52+
var writer = new StringWriter(stringBuilder);
53+
var xmlWriter = XmlWriter.Create(writer, new XmlWriterSettings {OmitXmlDeclaration = true, Indent = true});
54+
var namespaces = new XmlSerializerNamespaces(new[] { new XmlQualifiedName("") });
55+
56+
var serializer = new XmlSerializer(typeof(RelationEditorConfiguration));
57+
serializer.Serialize(xmlWriter, config, namespaces);
58+
writer.Flush();
59+
Console.WriteLine(stringBuilder.ToString());
60+
}
61+
62+
[Test]
63+
public void DeserializeConfiguration()
64+
{
65+
var config = DeserializeFromInput();
66+
Assert.IsNotNull(config);
67+
Assert.AreEqual(2, config.ObjectTypes.Count);
68+
Assert.IsFalse(config.ObjectTypes[0].AllowInheritance);
69+
Assert.IsTrue(config.ObjectTypes[1].AllowInheritance);
70+
Assert.AreEqual("pagePostRelation", config.ObjectTypes[1].EnabledRelations[0].Alias);
71+
Assert.AreEqual(UmbracoObjectTypes.Document, config.ObjectTypes[1].Name);
72+
Assert.AreEqual("post", config.ObjectTypes[0].EnabledRelations[0].EnabledChildTypes[0].Alias);
73+
}
74+
75+
[Test]
76+
public void GetMethods()
77+
{
78+
var config = DeserializeFromInput();
79+
Assert.IsFalse(config.Get(UmbracoObjectTypes.Member, "").Enabled);
80+
Assert.IsTrue(config.Get(UmbracoObjectTypes.Document, "page").Enabled);
81+
Assert.IsFalse(config.Get(UmbracoObjectTypes.Document, "page").Get("invalidRelation").Enabled);
82+
Assert.IsTrue(config.Get(UmbracoObjectTypes.Document, "page").Get("pagePostRelation").Enabled);
83+
Assert.IsFalse(config.Get(UmbracoObjectTypes.Document, "page").Get("pagePostRelation").Get("invalidChild").Enabled);
84+
Assert.IsTrue(config.Get(UmbracoObjectTypes.Document, "page").Get("pagePostRelation").Get("post").Enabled);
85+
}
86+
87+
private static RelationEditorConfiguration DeserializeFromInput()
88+
{
89+
var serializer = new XmlSerializer(typeof (RelationEditorConfiguration));
90+
var reader = new StringReader(Input);
91+
var config = (RelationEditorConfiguration) serializer.Deserialize(reader);
92+
return config;
93+
}
94+
}
95+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle("Umbraco.RelationEditor.Tests")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("Umbraco.RelationEditor.Tests")]
13+
[assembly: AssemblyCopyright("Copyright © 2014")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible(false)]
21+
22+
// The following GUID is for the ID of the typelib if this project is exposed to COM
23+
[assembly: Guid("29597df1-8889-42b3-ba51-c4148c38641e")]
24+
25+
// Version information for an assembly consists of the following four values:
26+
//
27+
// Major Version
28+
// Minor Version
29+
// Build Number
30+
// Revision
31+
//
32+
// You can specify all the values or you can default the Build and Revision Numbers
33+
// by using the '*' as shown below:
34+
// [assembly: AssemblyVersion("1.0.*")]
35+
[assembly: AssemblyVersion("1.0.0.0")]
36+
[assembly: AssemblyFileVersion("1.0.0.0")]
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{1F10C3B0-4F95-412E-B2C1-4B47E3E138A3}</ProjectGuid>
8+
<OutputType>Library</OutputType>
9+
<AppDesignerFolder>Properties</AppDesignerFolder>
10+
<RootNamespace>Umbraco.RelationEditor.Tests</RootNamespace>
11+
<AssemblyName>Umbraco.RelationEditor.Tests</AssemblyName>
12+
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
13+
<FileAlignment>512</FileAlignment>
14+
</PropertyGroup>
15+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
16+
<DebugSymbols>true</DebugSymbols>
17+
<DebugType>full</DebugType>
18+
<Optimize>false</Optimize>
19+
<OutputPath>bin\Debug\</OutputPath>
20+
<DefineConstants>DEBUG;TRACE</DefineConstants>
21+
<ErrorReport>prompt</ErrorReport>
22+
<WarningLevel>4</WarningLevel>
23+
</PropertyGroup>
24+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
25+
<DebugType>pdbonly</DebugType>
26+
<Optimize>true</Optimize>
27+
<OutputPath>bin\Release\</OutputPath>
28+
<DefineConstants>TRACE</DefineConstants>
29+
<ErrorReport>prompt</ErrorReport>
30+
<WarningLevel>4</WarningLevel>
31+
</PropertyGroup>
32+
<ItemGroup>
33+
<Reference Include="nunit.framework">
34+
<HintPath>..\packages\NUnit.2.6.3\lib\nunit.framework.dll</HintPath>
35+
</Reference>
36+
<Reference Include="System" />
37+
<Reference Include="System.Core" />
38+
<Reference Include="System.Xml.Linq" />
39+
<Reference Include="System.Data.DataSetExtensions" />
40+
<Reference Include="Microsoft.CSharp" />
41+
<Reference Include="System.Data" />
42+
<Reference Include="System.Xml" />
43+
<Reference Include="Umbraco.Core">
44+
<HintPath>..\packages\UmbracoCms.Core.7.0.2\lib\Umbraco.Core.dll</HintPath>
45+
</Reference>
46+
</ItemGroup>
47+
<ItemGroup>
48+
<Compile Include="ConfigSerializationTests.cs" />
49+
<Compile Include="Properties\AssemblyInfo.cs" />
50+
</ItemGroup>
51+
<ItemGroup>
52+
<None Include="packages.config" />
53+
</ItemGroup>
54+
<ItemGroup>
55+
<ProjectReference Include="..\Umbraco.RelationEditor\Umbraco.RelationEditor.csproj">
56+
<Project>{CD233AE0-2E7F-4A97-A45E-B6A759B41F67}</Project>
57+
<Name>Umbraco.RelationEditor</Name>
58+
</ProjectReference>
59+
</ItemGroup>
60+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
61+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
62+
Other similar extension points exist, see Microsoft.Common.targets.
63+
<Target Name="BeforeBuild">
64+
</Target>
65+
<Target Name="AfterBuild">
66+
</Target>
67+
-->
68+
</Project>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<packages>
3+
<package id="NUnit" version="2.6.3" targetFramework="net45" />
4+
</packages>

Umbraco.RelationEditor.Web/App_Plugins/RelationEditor/editrelations.html

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,31 @@
22
<div class="umb-dialog-body">
33
<div class="umb-pane">
44
<p class="abstract" ng-hide="success">
5-
Assign related content to {{currentNode.name}} below.
5+
Assign related items to {{currentNode.name}}.
66
</p>
77

88
<div class="sortableFrame" ng-repeat="resourceSet in resourceSets">
99
<h4>{{resourceSet.Name}}</h4>
10-
<table class="sortableNodes">
10+
<table class="sortableNodes" ng-class="resourceSet.Direction">
1111
<thead>
1212
<tr>
13+
<th style="width:5%">&nbsp;</th>
1314
<th style="width:15%;">ID</th>
14-
<th style="width:75%;">Name</th>
15+
<th style="width:70%;">Name</th>
1516
<th style="width:10%">&nbsp;</th>
1617
</tr>
1718
</thead>
1819
<tbody reledit-sortable="{containment:'parent'}" ng-model="resourceSet.Relations">
1920
<tr ng-repeat="relation in resourceSet.Relations" ng-show="isActive(relation)">
21+
<td style="width:5%;" class="direction"></td>
2022
<td style="width:15%;">{{relation.ChildId}}</td>
21-
<td style="width:75%;">{{relation.ChildName}}</td>
23+
<td style="width:70%;">{{relation.ChildName}}</td>
2224
<td style="width:10%;"><button class="btn btn-danger" ng-click="remove(relation)">Remove</button></td>
2325
</tr>
2426
</tbody>
2527
<tfoot>
2628
<tr>
27-
<td colspan="2">
29+
<td colspan="4">
2830
<button class="btn btn-primary" ng-click="pickRelation($index)">Add</button>
2931
</td>
3032
</tr>

Umbraco.RelationEditor.Web/App_Plugins/RelationEditor/relationeditor.css

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,46 +9,47 @@
99
{
1010
width: 100%;
1111
padding: 4px;
12-
display: block;
1312
border-spacing:0;
1413
border-collapse:collapse;
1514
}
1615

17-
.sortableNodes thead,
18-
.sortableNodes tbody,
19-
.sortableNodes tfoot {
20-
width: 100%;
21-
display: table;
22-
}
23-
2416
.sortableNodes thead tr th
2517
{
2618
border-bottom: 1px solid #ccc;
27-
padding: 4px;
28-
padding-right: 25px;
29-
background-image: url(../../umbraco_client/tableSorting/img/bg.gif);
3019
font-weight: bold;
31-
background-repeat: no-repeat;
32-
background-position: center right;
20+
}
21+
22+
.sortableNodes th,
23+
.sortableNodes td {
24+
padding: 4px;
3325
}
3426

3527
.sortableNodes tbody tr td
3628
{
3729
border-bottom: 1px solid #efefef;
3830
}
3931

40-
.sortableNodes td
32+
.sortableNodes tbody td
4133
{
42-
padding: 4px;
4334
cursor: move;
4435
}
4536

46-
tr.tDnD_whileDrag, tr.tDnD_whileDrag td
47-
{
48-
background: #dcecf3;
49-
border-color: #a8d8eb !Important;
50-
margin-top: 20px;
51-
}
37+
.sortableNodes tfoot td {
38+
text-align: right;
39+
}
40+
41+
.sortableNodes .direction {
42+
background-repeat: no-repeat;
43+
background-position: 50% 50%;
44+
}
45+
46+
.sortableNodes.bidirectional .direction {
47+
background-image: url('../../umbraco/developer/relationtypes/images/bidirectional.png')
48+
}
49+
50+
.sortableNodes.parentchild .direction {
51+
background-image: url('../../umbraco/developer/relationtypes/images/parenttochild.png')
52+
}
5253

5354
.sortableNodes .nowrap
5455
{

0 commit comments

Comments
 (0)