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

Commit 2ddb60e

Browse files
authored
Merge pull request #69 from umco/develop
Release 0.4.0
2 parents fb22f57 + 86f6bd7 commit 2ddb60e

19 files changed

+335
-156
lines changed

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Doc Type Grid Editor
22

3-
[![Build status](https://img.shields.io/appveyor/ci/leekelleher/umbraco-doc-type-grid-editor.svg)](https://ci.appveyor.com/project/leekelleher/umbraco-doc-type-grid-editor)
3+
[![Build status](https://img.shields.io/appveyor/ci/UMCO/umbraco-doc-type-grid-editor.svg)](https://ci.appveyor.com/project/UMCO/umbraco-doc-type-grid-editor)
44
[![NuGet release](https://img.shields.io/nuget/v/Our.Umbraco.DocTypeGridEditor.svg)](https://www.nuget.org/packages/Our.Umbraco.DocTypeGridEditor)
55
[![Our Umbraco project page](https://img.shields.io/badge/our-umbraco-orange.svg)](https://our.umbraco.org/projects/backoffice-extensions/doc-type-grid-editor)
66
[![Chat on Gitter](https://img.shields.io/badge/gitter-join_chat-green.svg)](https://gitter.im/leekelleher/umbraco-doc-type-grid-editor)
@@ -13,7 +13,7 @@ A grid editor for Umbraco 7 that allows you to use Doc Types as a blue print for
1313

1414
### Installation
1515

16-
> *Note:* Doc Type Grid Editor has been developed against **Umbraco v7.2.0** and will support that version and above.
16+
> *Note:* Doc Type Grid Editor has been developed against **Umbraco v7.3.0** and will support that version and above.
1717
1818
Doc Type Grid Editor can be installed from either Our Umbraco package repository, or build manually from the source-code.
1919

@@ -55,12 +55,12 @@ A PDF download is also available: [Doc Type Grid Editor - Developers Guide v1.0.
5555

5656
## Known Issues
5757

58-
Please be aware that not all property-editors will work within Doc Type Grid Editor. The following property-editors are known to have compatibility issues:
58+
Please be aware that not all property-editors will work within Doc Type Grid Editor. The following Umbraco core property-editors are known to have compatibility issues:
5959

60-
* Upload (default Umbraco core)
61-
* Image Cropper (default Umbraco core)
62-
* Macro Container (default Umbraco core)
63-
* Tags (default Umbraco core)
60+
* Image Cropper
61+
* Macro Container
62+
* Tags
63+
* Upload
6464

6565
---
6666

appveyor.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# version format
2-
version: 0.3.0.{build}
2+
version: 0.4.0.{build}
33

44
# UMBRACO_PACKAGE_PRERELEASE_SUFFIX if a rtm release build this should be blank, otherwise if empty will default to alpha
55
# example UMBRACO_PACKAGE_PRERELEASE_SUFFIX=beta
@@ -22,15 +22,15 @@ deploy:
2222
server: https://www.myget.org/F/umbraco-packages/
2323
symbol_server: https://nuget.symbolsource.org/MyGet/umbraco-packages
2424
api_key:
25-
secure: Q1/4K8VSwr7BjwmKDTef8y5lOc7S+jK9ELuWy67y6OVRpjxmnF9M3Gfs1kT+ir8x
25+
secure: 36/Ax5O+e6wENlhoTwgvoEBZV3FG4XjF429SNTej2qsGTAL+cdfA1kT/tm1St8vx
2626
artifact: /.*\.nupkg/
2727
on:
2828
branch: develop
2929

3030
# GitHub Deployment for releases
3131
- provider: GitHub
3232
auth_token:
33-
secure: pEozEGTqJutQwOidJU6BTB+Ix0NV4vrUnomhfeqheVz4RNwfxjEYLoqR4XabhlPz
33+
secure: yDxrRTveSScJA35MQTOaLYVjoPKFKl2bHBkG+JMZjiN0r7AfuUCxVU3CgW8Imu4h
3434
artifact: /.*\.zip/ # upload all Zip packages to release assets
3535
draft: false
3636
prerelease: false
@@ -42,7 +42,7 @@ deploy:
4242
- provider: NuGet
4343
server:
4444
api_key:
45-
secure: CGzDKxw4QI/z2VSe9ceiYlIabqGXHolgBgVNWWZjVAJ2V5WLF11IFdlp9r5Qp+Sw
45+
secure: eSLiOXbGVrxSG+X7PV6qTTUZ5VzS9EFj5+EufaWPfd+QXkF6gc8rZ4mGoHIVp/fL
4646
artifact: /.*\.nupkg/
4747
on:
4848
branch: master

build/package.proj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@
1818
<PropertyGroup>
1919
<ProjectName>Our.Umbraco.DocTypeGridEditor</ProjectName>
2020
<PackageName>Doc Type Grid Editor</PackageName>
21-
<MinUmbracoVersion>7.2.0</MinUmbracoVersion>
22-
<Readme>Doc Type Grid Editor is an advanced grid editor for the new Umbraco v7.2 Grid</Readme>
21+
<MinUmbracoVersion>7.3.0</MinUmbracoVersion>
22+
<Readme>Doc Type Grid Editor is an advanced grid editor for Umbraco 7</Readme>
2323
<AuthorName>Matt Brailsford, Lee Kelleher</AuthorName>
24-
<AuthorUrl>https://github.com/leekelleher/umbraco-doc-type-grid-editor/graphs/contributors</AuthorUrl>
24+
<AuthorUrl>https://github.com/umco/umbraco-doc-type-grid-editor/graphs/contributors</AuthorUrl>
2525
<PackageLicenseName>MIT license</PackageLicenseName>
2626
<PackageLicenseUrl>http://opensource.org/licenses/MIT</PackageLicenseUrl>
27-
<ProjectUrl>https://github.com/leekelleher/umbraco-doc-type-grid-editor</ProjectUrl>
27+
<ProjectUrl>https://github.com/umco/umbraco-doc-type-grid-editor</ProjectUrl>
2828
</PropertyGroup>
2929

3030
<!-- NUGET ONLY PROPERTIES -->

src/Our.Umbraco.DocTypeGridEditor.sln

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
2-
Microsoft Visual Studio Solution File, Format Version 12.00
1+
Microsoft Visual Studio Solution File, Format Version 12.00
32
# Visual Studio 14
43
VisualStudioVersion = 14.0.25420.1
54
MinimumVisualStudioVersion = 10.0.40219.1

src/Our.Umbraco.DocTypeGridEditor/Bootstrap.cs

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,40 @@ protected override void ApplicationStarting(UmbracoApplicationBase umbracoApplic
1414
{
1515
GlobalFilters.Filters.Add(new DocTypeGridEditorPreviewAttribute());
1616

17-
DefaultDocTypeGridEditorSurfaceControllerResolver.Current = new DefaultDocTypeGridEditorSurfaceControllerResolver();
17+
if (!DefaultDocTypeGridEditorSurfaceControllerResolver.HasCurrent)
18+
{
19+
DefaultDocTypeGridEditorSurfaceControllerResolver.Current = new DefaultDocTypeGridEditorSurfaceControllerResolver();
20+
}
1821
}
1922

2023
protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
2124
{
22-
DataTypeService.Saved += ExpireCache;
25+
DataTypeService.Saved += ExpireDataTypeCache;
26+
ContentTypeService.SavedContentType += ExpireContentTypeCache;
2327
}
2428

25-
private void ExpireCache(IDataTypeService sender, SaveEventArgs<IDataTypeDefinition> e)
29+
private void ExpireDataTypeCache(IDataTypeService sender, SaveEventArgs<IDataTypeDefinition> e)
2630
{
2731
foreach (var dataType in e.SavedEntities)
2832
{
2933
ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheItem(
3034
string.Concat("Our.Umbraco.DocTypeGridEditor.Web.Extensions.ContentTypeServiceExtensions.GetAliasById_", dataType.Key));
35+
36+
ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheItem(
37+
string.Concat("Our.Umbraco.DocTypeGridEditor.Helpers.DocTypeGridEditorHelper.GetPreValuesCollectionByDataTypeId_", dataType.Id));
38+
}
39+
}
40+
41+
private void ExpireContentTypeCache(IContentTypeService sender, SaveEventArgs<IContentType> e)
42+
{
43+
foreach (var contentType in e.SavedEntities)
44+
{
45+
ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheItem(
46+
string.Concat("Our.Umbraco.DocTypeGridEditor.Helpers.DocTypeGridEditorHelper.GetContentTypesByAlias_", contentType.Alias));
47+
48+
ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheItem(
49+
string.Concat("Our.Umbraco.DocTypeGridEditor.Helpers.DocTypeGridEditorHelper.GetContentTypeAliasByGuid_", contentType.Key));
3150
}
3251
}
3352
}
34-
}
53+
}

src/Our.Umbraco.DocTypeGridEditor/Extensions/ViewEnginesCollectionExtensions.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System.Web.Mvc;
2-
using Umbraco.Core.Logging;
32

43
namespace Our.Umbraco.DocTypeGridEditor.Extensions
54
{
@@ -17,8 +16,6 @@ public static bool ViewExists(
1716
if (result.View != null)
1817
return true;
1918

20-
LogHelper.Info<ViewEngineCollection>("[DocTypeGridEditor] No view file found with the name '{0}'", () => viewName);
21-
2219
return false;
2320
}
2421
}

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

Lines changed: 47 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,14 @@ public static IPublishedContent ConvertValueToContent(string id, string contentT
2828
if (string.IsNullOrWhiteSpace(contentTypeAlias))
2929
return null;
3030

31+
if (dataJson == null)
32+
return null;
33+
3134
if (UmbracoContext.Current == null)
3235
return ConvertValue(id, contentTypeAlias, dataJson);
3336

3437
return (IPublishedContent)ApplicationContext.Current.ApplicationCache.RequestCache.GetCacheItem(
35-
string.Concat("DocTypeGridEditorHelper.ConvertValueToContent_", id, "_", contentTypeAlias),
38+
string.Concat("Our.Umbraco.DocTypeGridEditor.Helpers.DocTypeGridEditorHelper.ConvertValueToContent_", id, "_", contentTypeAlias),
3639
() =>
3740
{
3841
return ConvertValue(id, contentTypeAlias, dataJson);
@@ -41,22 +44,17 @@ public static IPublishedContent ConvertValueToContent(string id, string contentT
4144

4245
private static IPublishedContent ConvertValue(string id, string contentTypeAlias, string dataJson)
4346
{
44-
using (var timer = DisposableTimer.DebugDuration<DocTypeGridEditorHelper>(string.Format("ConvertValueToContent ({0}, {1})", id, contentTypeAlias)))
47+
using (var timer = ApplicationContext.Current.ProfilingLogger.DebugDuration<DocTypeGridEditorHelper>(string.Format("ConvertValue ({0}, {1})", id, contentTypeAlias)))
4548
{
46-
Guid contentTypeGuid;
47-
if (Guid.TryParse(contentTypeAlias, out contentTypeGuid))
48-
contentTypeAlias = Services.ContentTypeService.GetAliasByGuid(contentTypeGuid);
49-
50-
var publishedContentType = PublishedContentType.Get(PublishedItemType.Content, contentTypeAlias);
51-
var contentType = ApplicationContext.Current.Services.ContentTypeService.GetContentType(contentTypeAlias);
49+
var contentTypes = GetContentTypesByAlias(contentTypeAlias);
5250
var properties = new List<IPublishedProperty>();
5351

5452
// Convert all the properties
5553
var data = JsonConvert.DeserializeObject(dataJson);
5654
var propValues = ((JObject)data).ToObject<Dictionary<string, object>>();
5755
foreach (var jProp in propValues)
5856
{
59-
var propType = publishedContentType.GetPropertyType(jProp.Key);
57+
var propType = contentTypes.PublishedContentType.GetPropertyType(jProp.Key);
6058
if (propType != null)
6159
{
6260
/* Because we never store the value in the database, we never run the property editors
@@ -65,8 +63,7 @@ private static IPublishedContent ConvertValue(string id, string contentTypeAlias
6563
* we go on to convert the value for the view.
6664
*/
6765
var propEditor = PropertyEditorResolver.Current.GetByAlias(propType.PropertyEditorAlias);
68-
var propPreValues = Services.DataTypeService.GetPreValuesCollectionByDataTypeId(
69-
propType.DataTypeId);
66+
var propPreValues = GetPreValuesCollectionByDataTypeId(propType.DataTypeId);
7067

7168
var contentPropData = new ContentPropertyData(
7269
jProp.Value,
@@ -78,7 +75,7 @@ private static IPublishedContent ConvertValue(string id, string contentTypeAlias
7875
/* Now that we have the DB stored value, we actually need to then convert it into it's
7976
* XML serialized state as expected by the published property by calling ConvertDbToString
8077
*/
81-
var propType2 = contentType.CompositionPropertyTypes.Single(x => x.Alias.InvariantEquals(propType.PropertyTypeAlias));
78+
var propType2 = contentTypes.ContentType.CompositionPropertyTypes.Single(x => x.Alias.InvariantEquals(propType.PropertyTypeAlias));
8279

8380
Property prop2 = null;
8481
try
@@ -91,15 +88,14 @@ private static IPublishedContent ConvertValue(string id, string contentTypeAlias
9188
*/
9289
prop2 = new Property(propType2, newValue);
9390
}
94-
catch(Exception ex)
91+
catch (Exception ex)
9592
{
9693
LogHelper.Error<DocTypeGridEditorHelper>("[DocTypeGridEditor] Error creating Property object.", ex);
9794
}
9895

9996
if (prop2 != null)
10097
{
101-
var newValue2 = propEditor.ValueEditor.ConvertDbToString(prop2, propType2,
102-
ApplicationContext.Current.Services.DataTypeService);
98+
var newValue2 = propEditor.ValueEditor.ConvertDbToString(prop2, propType2, Services.DataTypeService);
10399

104100
properties.Add(new DetachedPublishedProperty(propType, newValue2));
105101
}
@@ -118,11 +114,46 @@ private static IPublishedContent ConvertValue(string id, string contentTypeAlias
118114
var containerNode = pcr != null && pcr.HasPublishedContent ? pcr.PublishedContent : null;
119115

120116
return new DetachedPublishedContent(nameObj != null ? nameObj.ToString() : null,
121-
publishedContentType,
117+
contentTypes.PublishedContentType,
122118
properties.ToArray(),
123119
containerNode);
124120
}
125121

126122
}
123+
124+
private static PreValueCollection GetPreValuesCollectionByDataTypeId(int dataTypeId)
125+
{
126+
return (PreValueCollection)ApplicationContext.Current.ApplicationCache.RuntimeCache.GetCacheItem(
127+
string.Concat("Our.Umbraco.DocTypeGridEditor.Helpers.DocTypeGridEditorHelper.GetPreValuesCollectionByDataTypeId_", dataTypeId),
128+
() => Services.DataTypeService.GetPreValuesCollectionByDataTypeId(dataTypeId));
129+
}
130+
131+
private static ContentTypeContainer GetContentTypesByAlias(string contentTypeAlias)
132+
{
133+
Guid contentTypeGuid;
134+
if (Guid.TryParse(contentTypeAlias, out contentTypeGuid))
135+
contentTypeAlias = GetContentTypeAliasByGuid(contentTypeGuid);
136+
137+
return (ContentTypeContainer)ApplicationContext.Current.ApplicationCache.RuntimeCache.GetCacheItem(
138+
string.Concat("Our.Umbraco.DocTypeGridEditor.Helpers.DocTypeGridEditorHelper.GetContentTypesByAlias_", contentTypeAlias),
139+
() => new ContentTypeContainer
140+
{
141+
PublishedContentType = PublishedContentType.Get(PublishedItemType.Content, contentTypeAlias),
142+
ContentType = Services.ContentTypeService.GetContentType(contentTypeAlias)
143+
});
144+
}
145+
146+
private static string GetContentTypeAliasByGuid(Guid contentTypeGuid)
147+
{
148+
return (string)ApplicationContext.Current.ApplicationCache.RuntimeCache.GetCacheItem(
149+
string.Concat("Our.Umbraco.DocTypeGridEditor.Helpers.DocTypeGridEditorHelper.GetContentTypeAliasByGuid_", contentTypeGuid),
150+
() => Services.ContentTypeService.GetAliasByGuid(contentTypeGuid));
151+
}
152+
}
153+
154+
public class ContentTypeContainer
155+
{
156+
public PublishedContentType PublishedContentType { get; set; }
157+
public IContentType ContentType { get; set; }
127158
}
128159
}

0 commit comments

Comments
 (0)