Skip to content
This repository was archived by the owner on Feb 10, 2024. It is now read-only.

Commit a3ad8b5

Browse files
authored
Merge pull request #184 from skttl/develop
Preparing 1.2.0
2 parents 5770d9a + 449ab5b commit a3ad8b5

17 files changed

+372
-54
lines changed

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ A grid editor for Umbraco 8 that allows you to use Doc Types as a blue print for
1212

1313
### Installation
1414

15-
> *Note:* Doc Type Grid Editor has been developed against **Umbraco v8.1.0** and will support that version and above.
15+
> *Note:* Doc Type Grid Editor has been developed against **Umbraco v8.6.0** and will support that version and above.
1616
1717
Doc Type Grid Editor can be installed from either Our Umbraco package repository, or build manually from the source-code.
1818

@@ -60,8 +60,6 @@ Please be aware that not all property-editors will work within Doc Type Grid Edi
6060
* Tags
6161
* Upload
6262

63-
Another known issue is that validation of property-editors within the overlay do not always work. For editors that use client-side (HTML5) validation, this may appear to work, (e.g. text input require attribute is added), but server-side validation does not work.
64-
6563
---
6664

6765
## Contributing to this project

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
image: Visual Studio 2017
22

33
# version format
4-
version: 1.1.0.{build}
4+
version: 1.2.0.{build}
55

66
# UMBRACO_PACKAGE_PRERELEASE_SUFFIX if a rtm release build this should be blank, otherwise if empty will default to alpha
77
# example UMBRACO_PACKAGE_PRERELEASE_SUFFIX=beta

build/package.proj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<PropertyGroup>
1919
<ProjectName>Our.Umbraco.DocTypeGridEditor</ProjectName>
2020
<PackageName>Doc Type Grid Editor</PackageName>
21-
<MinUmbracoVersion>8.1.0</MinUmbracoVersion>
21+
<MinUmbracoVersion>8.6.0</MinUmbracoVersion>
2222
<Readme>Doc Type Grid Editor is an advanced grid editor for Umbraco 8</Readme>
2323
<AuthorName>Matt Brailsford, Lee Kelleher, Søren Kottal</AuthorName>
2424
<AuthorUrl>https://github.com/umco/umbraco-doc-type-grid-editor/graphs/contributors</AuthorUrl>

docs/developers-guide.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,47 @@ By inheriting from the `DocTypeGridEditorSurfaceController` base class, you'll a
207207

208208
---
209209

210+
### Value Processors
211+
Since Doc Type Grid Editor stores the data for each property as a JSON-blob, we're not processing the values in the same way as Umbraco-core before storing it. This also means that the values that comes back and are passed into a Property Value Converter might be in of a type/format that that Property Value Convert can't handle.
212+
213+
We've added something that we call "ValueProcessors" and these can be used to modify the raw property value before we send it to the property value converter. One example of where this is needed is the Tags-editor.
214+
215+
If you need to perform some processing of a value before it's sent to the property value converter you can add your own ValueProcessor.
216+
217+
```csharp
218+
public class UmbracoColorPickerValueProcessor : IDocTypeGridEditorValueProcessor
219+
{
220+
public bool IsProcessorFor(string propertyEditorAlias)
221+
=> propertyEditorAlias.Equals(Constants.PropertyEditors.Aliases.ColorPicker);
222+
223+
public object ProcessValue(object value)
224+
{
225+
// Do something with the value
226+
return value;
227+
}
228+
}
229+
```
230+
231+
Then register this during composition withing IUserComposer,
232+
```csharp
233+
public class MyCustomDocTypeGridEditorComposer : IUserComposer
234+
{
235+
public void Compose(Composition composition)
236+
{
237+
composition.DocTypeGridEditorValueProcessors()
238+
.Append<UmbracoColorPickerValueProcessor>();
239+
}
240+
}
241+
```
242+
243+
Dot Type Grid editor ships with a ValueProcessor for the Umbraco-Tags property.
244+
245+
**Note:** When using a Tag-editor inside a DTGE this would not create any relationship between the current node and that tag, if you need to tag a node you should use the Tags-editor as a property directly on the document type.
246+
247+
248+
249+
250+
210251
### Useful Links
211252

212253
* [Source Code](https://github.com/skttl/umbraco-doc-type-grid-editor)
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using Our.Umbraco.DocTypeGridEditor.Extensions;
2+
using Our.Umbraco.DocTypeGridEditor.ValueProcessing;
3+
using Umbraco.Core;
4+
using Umbraco.Core.Composing;
5+
6+
namespace Our.Umbraco.DocTypeGridEditor.Composing
7+
{
8+
/// <summary>
9+
/// Composes defaults for Doc Type Grid Editor
10+
/// </summary>
11+
public class DocTypeGridEditorComposer : IUserComposer
12+
{
13+
public void Compose(Composition composition)
14+
{
15+
composition.DocTypeGridEditorValueProcessors().Append<UmbracoTagsValueProcessor>();
16+
composition.DataValueReferenceFactories().Append<DocTypeGridEditorDataValueReference>();
17+
}
18+
}
19+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using Our.Umbraco.DocTypeGridEditor.ValueProcessing.Collections;
2+
using Umbraco.Core.Composing;
3+
4+
namespace Our.Umbraco.DocTypeGridEditor.Extensions
5+
{
6+
public static class CompositionExtensions
7+
{
8+
/// <summary>
9+
/// Used to modify the collection of Value Processors for Doc Type Grid Editor
10+
/// </summary>
11+
/// <param name="composition"></param>
12+
/// <returns></returns>
13+
public static DocTypeGridEditorValueProcessorsCollectionBuilder DocTypeGridEditorValueProcessors(this Composition composition)
14+
=> composition.WithCollectionBuilder<DocTypeGridEditorValueProcessorsCollectionBuilder>();
15+
}
16+
}

src/Our.Umbraco.DocTypeGridEditor/Helpers/DocTypeGridEditorHelper.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Linq;
4+
using System.Web.Mvc;
45
using Newtonsoft.Json;
56
using Newtonsoft.Json.Linq;
67
using Our.Umbraco.DocTypeGridEditor.Extensions;
78
using Our.Umbraco.DocTypeGridEditor.Models;
9+
using Our.Umbraco.DocTypeGridEditor.ValueProcessing;
10+
using Our.Umbraco.DocTypeGridEditor.ValueProcessing.Collections;
811
using Umbraco.Core;
912
using Umbraco.Core.Cache;
1013
using Umbraco.Web.Composing;
@@ -64,6 +67,14 @@ private static IPublishedElement ConvertValue(string id, string contentTypeAlias
6467

6568
var newValue = propEditor.GetValueEditor().FromEditor(contentPropData, jProp.Value);
6669

70+
// Performing "ValueProcessing" if any ValueProcessor is configured for this Property Editor-alias.
71+
var processorsCollection = Current.Factory.GetInstance<DocTypeGridEditorValueProcessorsCollection>();
72+
var processor = processorsCollection.FirstOrDefault(x => x.IsProcessorFor(propEditor.Alias));
73+
if (processor != null)
74+
{
75+
newValue = processor.ProcessValue(newValue);
76+
}
77+
6778
/* Now that we have the DB stored value, we actually need to then convert it into its
6879
* XML serialized state as expected by the published property by calling ConvertDbToString
6980
*/
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using Newtonsoft.Json;
2+
using Newtonsoft.Json.Linq;
3+
using System;
4+
using System.Collections.Generic;
5+
using System.Linq;
6+
using System.Text;
7+
using System.Threading.Tasks;
8+
9+
namespace Our.Umbraco.DocTypeGridEditor.Models
10+
{
11+
public class DocTypeGridEditorValue
12+
{
13+
[JsonProperty("value")]
14+
public JObject Value { get; set; }
15+
[JsonProperty("dtgeContentTypeAlias")]
16+
public string ContentTypeAlias { get; set; }
17+
[JsonProperty("id")]
18+
public Guid Id { get; set; }
19+
}
20+
}

src/Our.Umbraco.DocTypeGridEditor/Our.Umbraco.DocTypeGridEditor.csproj

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,17 @@
3535
<WarningLevel>4</WarningLevel>
3636
</PropertyGroup>
3737
<ItemGroup>
38+
<Reference Include="ClientDependency.Core, Version=1.9.9.0, Culture=neutral, processorArchitecture=MSIL">
39+
<HintPath>..\packages\ClientDependency.1.9.9\lib\net45\ClientDependency.Core.dll</HintPath>
40+
</Reference>
41+
<Reference Include="ClientDependency.Core.Mvc, Version=1.9.3.0, Culture=neutral, processorArchitecture=MSIL">
42+
<HintPath>..\packages\ClientDependency-Mvc5.1.9.3\lib\net45\ClientDependency.Core.Mvc.dll</HintPath>
43+
</Reference>
3844
<Reference Include="CSharpTest.Net.Collections, Version=14.906.1403.1082, Culture=neutral, PublicKeyToken=06aee00cce822474, processorArchitecture=MSIL">
3945
<HintPath>..\packages\CSharpTest.Net.Collections.14.906.1403.1082\lib\net40\CSharpTest.Net.Collections.dll</HintPath>
4046
</Reference>
41-
<Reference Include="Examine, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
42-
<HintPath>..\packages\Examine.1.0.0\lib\net452\Examine.dll</HintPath>
47+
<Reference Include="Examine, Version=1.0.2.0, Culture=neutral, processorArchitecture=MSIL">
48+
<HintPath>..\packages\Examine.1.0.2\lib\net452\Examine.dll</HintPath>
4349
</Reference>
4450
<Reference Include="HtmlAgilityPack, Version=1.8.14.0, Culture=neutral, PublicKeyToken=bd319b19eaf3b43a, processorArchitecture=MSIL">
4551
<HintPath>..\packages\HtmlAgilityPack.1.8.14\lib\Net45\HtmlAgilityPack.dll</HintPath>
@@ -206,21 +212,26 @@
206212
<Reference Include="System.Xml" />
207213
<Reference Include="System.Xml.Linq" />
208214
<Reference Include="Umbraco.Core, Version=8.0.0.0, Culture=neutral, processorArchitecture=MSIL">
209-
<HintPath>..\packages\UmbracoCms.Core.8.1.0\lib\net472\Umbraco.Core.dll</HintPath>
215+
<HintPath>..\packages\UmbracoCms.Core.8.6.0\lib\net472\Umbraco.Core.dll</HintPath>
210216
</Reference>
211217
<Reference Include="Umbraco.Examine, Version=8.0.0.0, Culture=neutral, processorArchitecture=MSIL">
212-
<HintPath>..\packages\UmbracoCms.Web.8.1.0\lib\net472\Umbraco.Examine.dll</HintPath>
218+
<HintPath>..\packages\UmbracoCms.Web.8.6.0\lib\net472\Umbraco.Examine.dll</HintPath>
219+
</Reference>
220+
<Reference Include="Umbraco.ModelsBuilder.Embedded, Version=8.0.0.0, Culture=neutral, processorArchitecture=MSIL">
221+
<HintPath>..\packages\UmbracoCms.Web.8.6.0\lib\net472\Umbraco.ModelsBuilder.Embedded.dll</HintPath>
213222
</Reference>
214223
<Reference Include="Umbraco.Web, Version=8.0.0.0, Culture=neutral, processorArchitecture=MSIL">
215-
<HintPath>..\packages\UmbracoCms.Web.8.1.0\lib\net472\Umbraco.Web.dll</HintPath>
224+
<HintPath>..\packages\UmbracoCms.Web.8.6.0\lib\net472\Umbraco.Web.dll</HintPath>
216225
</Reference>
217226
<Reference Include="Umbraco.Web.UI, Version=8.0.0.0, Culture=neutral, processorArchitecture=MSIL">
218-
<HintPath>..\packages\UmbracoCms.Web.8.1.0\lib\net472\Umbraco.Web.UI.dll</HintPath>
227+
<HintPath>..\packages\UmbracoCms.Web.8.6.0\lib\net472\Umbraco.Web.UI.dll</HintPath>
219228
</Reference>
220229
</ItemGroup>
221230
<ItemGroup>
222231
<Compile Include="Bootstrap.cs" />
223232
<Compile Include="Composing\Current.cs" />
233+
<Compile Include="Models\DocTypeGridEditorValue.cs" />
234+
<Compile Include="ValueProcessing\DocTypeGridEditorDataValueReference.cs" />
224235
<Compile Include="Extensions\JsonExtensions.cs" />
225236
<Compile Include="Helpers\DocTypeGridEditorHelper.cs" />
226237
<Compile Include="Helpers\XmlHelper.cs" />
@@ -231,6 +242,12 @@
231242
<Compile Include="Models\UnpublishedProperty.cs" />
232243
<Compile Include="Properties\AssemblyInfo.cs" />
233244
<Compile Include="Properties\VersionInfo.cs" />
245+
<Compile Include="Composing\DocTypeGridEditorComposer.cs" />
246+
<Compile Include="Extensions\CompositionExtensions.cs" />
247+
<Compile Include="ValueProcessing\Collections\DocTypeGridEditorValueProcessorsCollection.cs" />
248+
<Compile Include="ValueProcessing\Collections\DocTypeGridEditorValueProcessorsCollectionBuilder.cs" />
249+
<Compile Include="ValueProcessing\IDocTypeGridEditorValueProcessor.cs" />
250+
<Compile Include="ValueProcessing\UmbracoTagsValueProcessor.cs" />
234251
<Compile Include="Web\Controllers\DocTypeGridEditorApiController.cs" />
235252
<Compile Include="Extensions\ContentTypeServiceExtensions.cs" />
236253
<Compile Include="Web\Controllers\DocTypeGridEditorSurfaceController.cs" />
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using System.Collections.Generic;
2+
using Umbraco.Core.Composing;
3+
4+
namespace Our.Umbraco.DocTypeGridEditor.ValueProcessing.Collections
5+
{
6+
/// <summary>
7+
/// Collection to hold references to Value Processors to be used with Doc Type Grid Editor. <see cref="IDocTypeGridEditorValueProcessor"/>
8+
/// </summary>
9+
public class DocTypeGridEditorValueProcessorsCollection : BuilderCollectionBase<IDocTypeGridEditorValueProcessor>
10+
{
11+
public DocTypeGridEditorValueProcessorsCollection(IEnumerable<IDocTypeGridEditorValueProcessor> items) : base(items)
12+
{ }
13+
}
14+
}

0 commit comments

Comments
 (0)