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

Commit 3b3a892

Browse files
authored
Merge pull request #137 from skttl/v8upgrade
Port to V8
2 parents e7574f8 + b8e78da commit 3b3a892

29 files changed

+1014
-708
lines changed

build/package.proj

Lines changed: 2 additions & 2 deletions
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>7.6.0</MinUmbracoVersion>
21+
<MinUmbracoVersion>8.0.0</MinUmbracoVersion>
2222
<Readme>Doc Type Grid Editor is an advanced grid editor for Umbraco 7</Readme>
2323
<AuthorName>Matt Brailsford, Lee Kelleher</AuthorName>
2424
<AuthorUrl>https://github.com/umco/umbraco-doc-type-grid-editor/graphs/contributors</AuthorUrl>
@@ -31,7 +31,7 @@
3131
<PropertyGroup>
3232
<PackageId>Our.Umbraco.DocTypeGridEditor</PackageId>
3333
<NuGetPackageName>Doc Type Grid Editor for Umbraco</NuGetPackageName>
34-
<Copyright>Copyright &#169; 2017 UMCO</Copyright>
34+
<Copyright>Copyright &#169; 2019 UMCO</Copyright>
3535
<Owners>Matt Brailsford, Lee Kelleher</Owners>
3636
<IconUrl>https://our.umbraco.org/media/wiki/145708/635623742802070736_dtgepng.png</IconUrl>
3737
<Tags>umbraco grid document type editor</Tags>

docs/developers-guide.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ With the **Doc Type Grid Editor** then, we bridge that gap, allowing you to reus
3030

3131
Before you get started, there are a number of things you will need:
3232

33-
1. .NET 4.5+
34-
2. Umbraco 7.6.0+
33+
1. .NET 4.7.2+
34+
2. Umbraco 8.0.2+
3535
3. The **Doc Type Grid Editor** package installed
3636

3737
---
@@ -40,6 +40,8 @@ Before you get started, there are a number of things you will need:
4040

4141
The **Doc Type Grid Editor** is configured via the grid.editors.config.js config file located in the `~/Config` folder. A default configuration should be installed along with the package, but for details on the configuration options, please see below.
4242

43+
You can also add your editors using a package.manifest file in a folder in the `~/App_Plugins` folder.
44+
4345
#### Example
4446

4547
```javascript
@@ -55,6 +57,7 @@ The **Doc Type Grid Editor** is configured via the grid.editors.config.js config
5557
"allowedDocTypes": [...],
5658
"nameTemplate": "",
5759
"enablePreview": true,
60+
"largeDialog": true,
5861
"viewPath": "/Views/Partials/Grid/Editors/DocTypeGridEditor/",
5962
"previewViewPath": "/Views/Partials/Grid/Editors/DocTypeGridEditor/Previews/",
6063
"previewCssFilePath": "",
@@ -84,7 +87,9 @@ The **Doc Type Grid Editor** supports 3 config options, all of which are optiona
8487
|-----------------|----------|-------------|
8588
| AllowedDocTypes | String[] | An array of doc type aliases of which should be allowed to be selected in the grid editor. Strings can be REGEX patterns to allow matching groups of doc types in a single entry. e.g. "Widget$" will match all doc types with an alias ending in "Widget". However if a single doc type is matched, (aka **Single Doc Type Mode**), then dropdown selection stage (in the DTGE panel) will be skipped. |
8689
| EnablePreview | Boolean | Enables rendering a preview of the grid cell in the grid editor. |
90+
| LargeDialog | Boolean | Makes the editing dialog larger. Especially useful for grid editors with complex property editors. |
8791
| ViewPath | String | Set's an alternative view path for where the **Doc Type Grid Editor** should look for views when rendering. Defaults to `~/Views/Partials/` |
92+
| ShowDocTypeSelectAsGrid | Boolean | Makes the content type selection dialog render a grid, in stead of the default list with descriptions |
8893

8994
---
9095

@@ -175,7 +180,7 @@ By inheriting from the `DocTypeGridEditorSurfaceController` base class, you'll a
175180

176181
| Member | Type | Description |
177182
|---------------------------------------------------|-------------------|-------------|
178-
| Model | IPublishedContent | The IPublishedContent instance for you cells data. |
183+
| Model | IPublishedElement | The IPublishedElement instance of your cell's data. |
179184
| ViewPath | String | A reference to the currently configured ViewPath |
180185
| CurrentPartialView(object model = null) | Method | Helper method to return you to the default partial view for this cell. If no model is passed in, the standard Model will be passed down. |
181186
| PartialView(string viewName, object model = null) | Method | Helper method to return you to an alternative partial view for this cell. If no model is passed in, the standard Model will be passed down. |

src/Our.Umbraco.DocTypeGridEditor/Bootstrap.cs

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,35 @@
11
using System;
22
using Newtonsoft.Json;
3-
using Our.Umbraco.DocTypeGridEditor.Web.Mvc;
4-
using Umbraco.Core;
3+
using Umbraco.Core.Composing;
54
using Umbraco.Core.Sync;
65
using Umbraco.Web.Cache;
76

87
namespace Our.Umbraco.DocTypeGridEditor
98
{
10-
internal class Bootstrap : ApplicationEventHandler
11-
{
12-
protected override void ApplicationStarting(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
13-
{
14-
if (DefaultDocTypeGridEditorSurfaceControllerResolver.HasCurrent == false)
15-
{
16-
DefaultDocTypeGridEditorSurfaceControllerResolver.Current = new DefaultDocTypeGridEditorSurfaceControllerResolver();
17-
}
18-
}
199

20-
protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
10+
public class Bootstrap : IUserComposer
11+
{
12+
public void Compose(Composition composition)
2113
{
2214
DataTypeCacheRefresher.CacheUpdated += (sender, e) =>
2315
{
2416
if (e.MessageType == MessageType.RefreshByJson)
2517
{
26-
var payload = JsonConvert.DeserializeAnonymousType((string)e.MessageObject, new[] { new { Id = default(int), UniqueId = default(Guid) } });
18+
var payload = JsonConvert.DeserializeAnonymousType((string) e.MessageObject,
19+
new[] {new {Id = default(int), UniqueId = default(Guid)}});
2720
if (payload != null)
2821
{
2922
foreach (var item in payload)
3023
{
31-
applicationContext.ApplicationCache.RuntimeCache.ClearCacheItem(
32-
string.Concat("Our.Umbraco.DocTypeGridEditor.Web.Extensions.ContentTypeServiceExtensions.GetAliasById_", item.UniqueId));
24+
Current.AppCaches.RuntimeCache.ClearByKey(
25+
string.Concat(
26+
"Our.Umbraco.DocTypeGridEditor.Web.Extensions.ContentTypeServiceExtensions.GetAliasById_",
27+
item.UniqueId));
3328

34-
applicationContext.ApplicationCache.RuntimeCache.ClearCacheItem(
35-
string.Concat("Our.Umbraco.DocTypeGridEditor.Helpers.DocTypeGridEditorHelper.GetPreValuesCollectionByDataTypeId_", item.Id));
29+
Current.AppCaches.RuntimeCache.ClearByKey(
30+
string.Concat(
31+
"Our.Umbraco.DocTypeGridEditor.Helpers.DocTypeGridEditorHelper.GetPreValuesCollectionByDataTypeId_",
32+
item.Id));
3633
}
3734
}
3835
}
@@ -42,17 +39,20 @@ protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplica
4239
{
4340
if (e.MessageType == MessageType.RefreshByJson)
4441
{
45-
var payload = JsonConvert.DeserializeAnonymousType((string)e.MessageObject, new[] { new { Alias = default(string) } });
42+
var payload = JsonConvert.DeserializeAnonymousType((string) e.MessageObject,
43+
new[] {new {Alias = default(string)}});
4644
if (payload != null)
4745
{
4846
foreach (var item in payload)
4947
{
50-
applicationContext.ApplicationCache.RuntimeCache.ClearCacheItem(
51-
string.Concat("Our.Umbraco.DocTypeGridEditor.Helpers.DocTypeGridEditorHelper.GetContentTypesByAlias_", item.Alias));
48+
Current.AppCaches.RuntimeCache.ClearByKey(
49+
string.Concat(
50+
"Our.Umbraco.DocTypeGridEditor.Helpers.DocTypeGridEditorHelper.GetContentTypesByAlias_",
51+
item.Alias));
5252

5353
// NOTE: Unsure how to get the doctype GUID, without hitting the database?
5454
// So we end up clearing the entire cache for this key. [LK:2018-01-30]
55-
applicationContext.ApplicationCache.RuntimeCache.ClearCacheByKeySearch(
55+
Current.AppCaches.RuntimeCache.ClearByKey(
5656
"Our.Umbraco.DocTypeGridEditor.Helpers.DocTypeGridEditorHelper.GetContentTypeAliasByGuid_");
5757
}
5858
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using Our.Umbraco.DocTypeGridEditor.Web.Controllers;
2+
using System;
3+
using Umbraco.Core;
4+
5+
namespace Our.Umbraco.DocTypeGridEditor.Composing
6+
{
7+
public class Current
8+
{
9+
10+
private static Type _defaultDocTypeGridEditorSurfaceControllerType;
11+
12+
// internal - can only be accessed through Composition at compose time
13+
internal static Type DefaultDocTypeGridEditorSurfaceControllerType
14+
{
15+
get => _defaultDocTypeGridEditorSurfaceControllerType;
16+
set
17+
{
18+
if (value.IsOfGenericType(typeof(DocTypeGridEditorSurfaceController<>)) == false)
19+
throw new InvalidOperationException($"The Type specified ({value}) is not of type {typeof(DocTypeGridEditorSurfaceController<>)}");
20+
_defaultDocTypeGridEditorSurfaceControllerType = value;
21+
}
22+
}
23+
}
24+
}
Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using System;
2-
using Umbraco.Core;
32
using Umbraco.Core.Cache;
3+
using Umbraco.Web.Composing;
44
using Umbraco.Core.Services;
55

66
namespace Our.Umbraco.DocTypeGridEditor.Extensions
@@ -9,12 +9,16 @@ internal static class ContentTypeServiceExtensions
99
{
1010
public static string GetAliasByGuid(this IContentTypeService contentTypeService, Guid id)
1111
{
12-
return ApplicationContext.Current.ApplicationCache.RuntimeCache.GetCacheItem<string>(
12+
var cache = Current.AppCaches.RequestCache;
13+
14+
return cache.GetCacheItem<string>(
1315
string.Concat("Our.Umbraco.DocTypeGridEditor.Web.Extensions.ContentTypeServiceExtensions.GetAliasById_", id),
14-
() => ApplicationContext.Current
15-
.DatabaseContext
16-
.Database
17-
.ExecuteScalar<string>("SELECT [cmsContentType].[alias] FROM [cmsContentType] INNER JOIN [umbracoNode] ON [cmsContentType].[nodeId] = [umbracoNode].[id] WHERE [umbracoNode].[uniqueID] = @0", id));
16+
() =>
17+
{
18+
using (var scope = Current.ScopeProvider.CreateScope(autoComplete:true))
19+
return scope.Database.ExecuteScalar<string>("SELECT [cmsContentType].[alias] FROM [cmsContentType] INNER JOIN [umbracoNode] ON [cmsContentType].[nodeId] = [umbracoNode].[id] WHERE [umbracoNode].[uniqueID] = @0", id);
20+
21+
});
1822
}
1923
}
20-
}
24+
}

0 commit comments

Comments
 (0)