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

Commit

Permalink
Merge pull request #93 from umco/develop
Browse files Browse the repository at this point in the history
Release 0.5.0
  • Loading branch information
leekelleher authored Feb 21, 2018
2 parents 2ddb60e + 91971a3 commit e80d101
Show file tree
Hide file tree
Showing 30 changed files with 524 additions and 485 deletions.
3 changes: 2 additions & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Copyright © 2014 Umbrella Inc, Our Umbraco and other contributors
Copyright © 2017 UMCO, Our Umbraco and other contributors
Copyright © 2014 Umbrella Inc

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
Expand Down
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,16 @@
[![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)
[![NuGet release](https://img.shields.io/nuget/v/Our.Umbraco.DocTypeGridEditor.svg)](https://www.nuget.org/packages/Our.Umbraco.DocTypeGridEditor)
[![Our Umbraco project page](https://img.shields.io/badge/our-umbraco-orange.svg)](https://our.umbraco.org/projects/backoffice-extensions/doc-type-grid-editor)
[![Chat on Gitter](https://img.shields.io/badge/gitter-join_chat-green.svg)](https://gitter.im/leekelleher/umbraco-doc-type-grid-editor)


A grid editor for Umbraco 7 that allows you to use Doc Types as a blue print for cell data.
A grid editor for Umbraco 7 that allows you to use Doc Types as a blue print for grid-cell data.


## Getting Started

### Installation

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

Expand All @@ -35,7 +34,8 @@ We also have a [MyGet package repository](https://www.myget.org/gallery/umbraco-

If you prefer, you can compile Doc Type Grid Editor yourself, you'll need:

* Visual Studio 2012 (or above)
* [Visual Studio 2017 (or above, including Community Editions)](https://www.visualstudio.com/downloads/)
* Microsoft Build Tools 2015 (aka [MSBuild 15](https://www.microsoft.com/en-us/download/details.aspx?id=48159))

To clone it locally click the "Clone in Windows" button above or run the following git commands.

Expand Down Expand Up @@ -93,6 +93,8 @@ Have a question?

## License

Copyright © 2014 Umbrella Inc, Our Umbraco and [other contributors](https://github.com/umco/umbraco-doc-type-grid-editor/graphs/contributors)
Copyright © 2017 UMCO, Our Umbraco and [other contributors](https://github.com/umco/umbraco-doc-type-grid-editor/graphs/contributors)

Copyright © 2014 Umbrella Inc

Licensed under the [MIT License](LICENSE.md)
15 changes: 10 additions & 5 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
image: Visual Studio 2017

# version format
version: 0.4.0.{build}
version: 0.5.0.{build}

# UMBRACO_PACKAGE_PRERELEASE_SUFFIX if a rtm release build this should be blank, otherwise if empty will default to alpha
# example UMBRACO_PACKAGE_PRERELEASE_SUFFIX=beta
Expand All @@ -9,8 +11,11 @@ init:
cache:
- src\packages -> **\packages.config # preserve "packages" directory in the root of build folder but will reset it if packages.config is modified

before_build:
- nuget restore src

build_script:
- build-appveyor.cmd
- build-appveyor.cmd

artifacts:
- path: artifacts\*.nupkg
Expand All @@ -19,8 +24,8 @@ artifacts:
deploy:
# MyGet Deployment for builds & releases
- provider: NuGet
server: https://www.myget.org/F/umbraco-packages/
symbol_server: https://nuget.symbolsource.org/MyGet/umbraco-packages
server: https://www.myget.org/F/umbraco-packages/api/v2/package
symbol_server: https://www.myget.org/F/umbraco-packages/symbols/api/v2/package
api_key:
secure: 36/Ax5O+e6wENlhoTwgvoEBZV3FG4XjF429SNTej2qsGTAL+cdfA1kT/tm1St8vx
artifact: /.*\.nupkg/
Expand All @@ -42,7 +47,7 @@ deploy:
- provider: NuGet
server:
api_key:
secure: eSLiOXbGVrxSG+X7PV6qTTUZ5VzS9EFj5+EufaWPfd+QXkF6gc8rZ4mGoHIVp/fL
secure: 0+oAleUTnr9UuJrhLW5rphRR+QGz00XX1Ui3k5kwyr2kUdEamiQ3F+gW0q8MJbDT
artifact: /.*\.nupkg/
on:
branch: master
Expand Down
5 changes: 3 additions & 2 deletions build-appveyor.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ ECHO APPVEYOR_REPO_TAG: %APPVEYOR_REPO_TAG%
ECHO APPVEYOR_BUILD_NUMBER : %APPVEYOR_BUILD_NUMBER%
ECHO APPVEYOR_BUILD_VERSION : %APPVEYOR_BUILD_VERSION%

CALL src\.nuget\NuGet.exe restore src\Our.Umbraco.DocTypeGridEditor.sln
CALL "%WINDIR%\Microsoft.NET\Framework\v4.0.30319\msbuild.exe" build\package.proj
CALL build\tools\NuGet.exe restore src\Our.Umbraco.DocTypeGridEditor.sln
CALL "%programfiles(x86)%\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\amd64\MsBuild.exe" build\package.proj
REM CALL "%programfiles(x86)%\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\amd64\MsBuild.exe" build\package.proj
6 changes: 3 additions & 3 deletions build/package.proj
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<PropertyGroup>
<ProjectName>Our.Umbraco.DocTypeGridEditor</ProjectName>
<PackageName>Doc Type Grid Editor</PackageName>
<MinUmbracoVersion>7.3.0</MinUmbracoVersion>
<MinUmbracoVersion>7.4.0</MinUmbracoVersion>
<Readme>Doc Type Grid Editor is an advanced grid editor for Umbraco 7</Readme>
<AuthorName>Matt Brailsford, Lee Kelleher</AuthorName>
<AuthorUrl>https://github.com/umco/umbraco-doc-type-grid-editor/graphs/contributors</AuthorUrl>
Expand All @@ -31,7 +31,7 @@
<PropertyGroup>
<PackageId>Our.Umbraco.DocTypeGridEditor</PackageId>
<NuGetPackageName>Doc Type Grid Editor for Umbraco</NuGetPackageName>
<Copyright>Copyright &#169; 2015 Matt Brailsford, Lee Kelleher</Copyright>
<Copyright>Copyright &#169; 2017 UMCO</Copyright>
<Owners>Matt Brailsford, Lee Kelleher</Owners>
<IconUrl>https://our.umbraco.org/media/wiki/145708/635623742802070736_dtgepng.png</IconUrl>
<Tags>umbraco grid document type editor</Tags>
Expand Down Expand Up @@ -195,7 +195,7 @@
OutputDirectory="$(ArtifactsDir)"
Files="@(PackageFiles)" />

<MSBuild.NuGet.Tasks.Pack NuGetExePath="$(RootDir)\src\.nuget\NuGet.exe"
<MSBuild.NuGet.Tasks.Pack NuGetExePath="$(RootDir)\build\tools\NuGet.exe"
ManifestFile="$(BuildNuGetDir)\package.nuspec"
BasePath="$(BuildNuGetDir)"
Version="$(ProductVersion)"
Expand Down
Binary file added build/tools/NuGet.exe
Binary file not shown.
37 changes: 21 additions & 16 deletions docs/developers-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ With the **Doc Type Grid Editor** then, we bridge that gap, allowing you to reus
Before you get started, there are a number of things you will need:

1. .NET 4.5+
2. Umbraco 7.2.0+
2. Umbraco 7.4.0+
3. The **Doc Type Grid Editor** package installed

---
Expand All @@ -44,20 +44,25 @@ The **Doc Type Grid Editor** is configured via the grid.editors.config.js config

```javascript
[
...
{
"name": "Doc Type",
"alias": "docType",
"view": "/App_Plugins/../doctypegrideditor.html",
"render": "/App_Plugins/../doctypegrideditor.cshtml",
"icon": "icon-item-arrangement",
"config": {
"allowedDocTypes": [...],
"enablePreview": true,
"viewPath": "/Views/Partials/"
},
...
]
...
{
"name": "Doc Type",
"alias": "docType",
"view": "/App_Plugins/DocTypeGridEditor/Views/doctypegrideditor.html",
"render": "/App_Plugins/DocTypeGridEditor/Render/DocTypeGridEditor.cshtml",
"icon": "icon-item-arrangement",
"config": {
"allowedDocTypes": [...],
"nameTemplate": "",
"enablePreview": true,
"viewPath": "/Views/Partials/Grid/Editors/DocTypeGridEditor/",
"previewViewPath": "/Views/Partials/Grid/Editors/DocTypeGridEditor/Previews/",
"previewCssFilePath": "",
"previewJsFilePath": ""
}
},
...
]
```

![Doc Type Grid Editor - JSON configuration](img/screenshot-07.png)
Expand Down Expand Up @@ -155,7 +160,7 @@ If you are not the type of developer that likes to put business logic in your vi
Simply create your controller inheriting from the above class, giving it a class name of `{DocTypeAlias}SurfaceController` and an action name of `{DocTypeAlias}` and the **Doc Type Grid Editor** will automatically wire it up for you and use it at render time.

```csharp
public class TestDocTypeSurfaceController
public class TestDocTypeSurfaceController
: DocTypeGridEditorSurfaceController
{
public ActionResult TestDocType()
Expand Down
6 changes: 0 additions & 6 deletions src/.nuget/NuGet.Config

This file was deleted.

Binary file removed src/.nuget/NuGet.exe
Binary file not shown.
35 changes: 18 additions & 17 deletions src/Our.Umbraco.DocTypeGridEditor.sln
Original file line number Diff line number Diff line change
@@ -1,21 +1,10 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27004.2009
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Our.Umbraco.DocTypeGridEditor", "Our.Umbraco.DocTypeGridEditor\Our.Umbraco.DocTypeGridEditor.csproj", "{4BD1DB40-1B39-4966-8740-D6A39D658598}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{CEE9961C-D747-40CD-B0B2-868D6B46833E}"
ProjectSection(SolutionItems) = preProject
.nuget\NuGet.Config = .nuget\NuGet.Config
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Docs", "Docs", "{D588B45D-9E67-4136-8271-2B8724C8165F}"
ProjectSection(SolutionItems) = preProject
..\CONTRIBUTING.md = ..\CONTRIBUTING.md
..\LICENSE.md = ..\LICENSE.md
..\README.md = ..\README.md
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build Package", "Build Package", "{42CE1449-272B-453B-B162-4558FD38BF41}"
ProjectSection(SolutionItems) = preProject
..\appveyor.yml = ..\appveyor.yml
Expand All @@ -29,6 +18,16 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build Package", "Build Pack
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{8412A31B-D80C-42DE-9589-4BD08F43F86B}"
ProjectSection(SolutionItems) = preProject
..\CONTRIBUTING.md = ..\CONTRIBUTING.md
..\LICENSE.md = ..\LICENSE.md
..\README.md = ..\README.md
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Documentation", "Documentation", "{29E2BB68-801F-456D-B691-4E93F884FCD5}"
ProjectSection(SolutionItems) = preProject
..\docs\developers-guide.md = ..\docs\developers-guide.md
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -45,8 +44,10 @@ Global
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{CEE9961C-D747-40CD-B0B2-868D6B46833E} = {8412A31B-D80C-42DE-9589-4BD08F43F86B}
{D588B45D-9E67-4136-8271-2B8724C8165F} = {8412A31B-D80C-42DE-9589-4BD08F43F86B}
{42CE1449-272B-453B-B162-4558FD38BF41} = {8412A31B-D80C-42DE-9589-4BD08F43F86B}
{29E2BB68-801F-456D-B691-4E93F884FCD5} = {8412A31B-D80C-42DE-9589-4BD08F43F86B}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {03435AB1-C9D8-46BD-9C91-2D4FCF44D57E}
EndGlobalSection
EndGlobal
79 changes: 52 additions & 27 deletions src/Our.Umbraco.DocTypeGridEditor/Bootstrap.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
using System.Web.Mvc;
using System;
using System.Web.Mvc;
using Newtonsoft.Json;
using Our.Umbraco.DocTypeGridEditor.Web.Attributes;
using Our.Umbraco.DocTypeGridEditor.Web.Mvc;
using Umbraco.Core;
using Umbraco.Core.Events;
using Umbraco.Core.Models;
using Umbraco.Core.Services;
using Umbraco.Core.Sync;
using Umbraco.Web.Cache;
using Umbraco.Web.Routing;

namespace Our.Umbraco.DocTypeGridEditor
{
Expand All @@ -14,40 +16,63 @@ protected override void ApplicationStarting(UmbracoApplicationBase umbracoApplic
{
GlobalFilters.Filters.Add(new DocTypeGridEditorPreviewAttribute());

if (!DefaultDocTypeGridEditorSurfaceControllerResolver.HasCurrent)
if (DefaultDocTypeGridEditorSurfaceControllerResolver.HasCurrent == false)
{
DefaultDocTypeGridEditorSurfaceControllerResolver.Current = new DefaultDocTypeGridEditorSurfaceControllerResolver();
}
}

protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
DataTypeService.Saved += ExpireDataTypeCache;
ContentTypeService.SavedContentType += ExpireContentTypeCache;
}

private void ExpireDataTypeCache(IDataTypeService sender, SaveEventArgs<IDataTypeDefinition> e)
{
foreach (var dataType in e.SavedEntities)
DataTypeCacheRefresher.CacheUpdated += (sender, e) =>
{
ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheItem(
string.Concat("Our.Umbraco.DocTypeGridEditor.Web.Extensions.ContentTypeServiceExtensions.GetAliasById_", dataType.Key));
if (e.MessageType == MessageType.RefreshByJson)
{
var payload = JsonConvert.DeserializeAnonymousType((string)e.MessageObject, new[] { new { Id = default(int), UniqueId = default(Guid) } });
if (payload != null)
{
foreach (var item in payload)
{
applicationContext.ApplicationCache.RuntimeCache.ClearCacheItem(
string.Concat("Our.Umbraco.DocTypeGridEditor.Web.Extensions.ContentTypeServiceExtensions.GetAliasById_", item.UniqueId));

ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheItem(
string.Concat("Our.Umbraco.DocTypeGridEditor.Helpers.DocTypeGridEditorHelper.GetPreValuesCollectionByDataTypeId_", dataType.Id));
}
}
applicationContext.ApplicationCache.RuntimeCache.ClearCacheItem(
string.Concat("Our.Umbraco.DocTypeGridEditor.Helpers.DocTypeGridEditorHelper.GetPreValuesCollectionByDataTypeId_", item.Id));
}
}
}
};

private void ExpireContentTypeCache(IContentTypeService sender, SaveEventArgs<IContentType> e)
{
foreach (var contentType in e.SavedEntities)
ContentTypeCacheRefresher.CacheUpdated += (sender, e) =>
{
ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheItem(
string.Concat("Our.Umbraco.DocTypeGridEditor.Helpers.DocTypeGridEditorHelper.GetContentTypesByAlias_", contentType.Alias));
if (e.MessageType == MessageType.RefreshByJson)
{
var payload = JsonConvert.DeserializeAnonymousType((string)e.MessageObject, new[] { new { Alias = default(string) } });
if (payload != null)
{
foreach (var item in payload)
{
applicationContext.ApplicationCache.RuntimeCache.ClearCacheItem(
string.Concat("Our.Umbraco.DocTypeGridEditor.Helpers.DocTypeGridEditorHelper.GetContentTypesByAlias_", item.Alias));

ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheItem(
string.Concat("Our.Umbraco.DocTypeGridEditor.Helpers.DocTypeGridEditorHelper.GetContentTypeAliasByGuid_", contentType.Key));
}
// NOTE: Unsure how to get the doctype GUID, without hitting the database?
// So we end up clearing the entire cache for this key. [LK:2018-01-30]
applicationContext.ApplicationCache.RuntimeCache.ClearCacheByKeySearch(
"Our.Umbraco.DocTypeGridEditor.Helpers.DocTypeGridEditorHelper.GetContentTypeAliasByGuid_");
}
}
}
};

PublishedContentRequest.Prepared += (sender, e) =>
{
// Check if it's a dtgePreview request and is set to redirect.
// If so reset the redirect url to an empty string to stop the redirect happening in preview mode.
if (sender is PublishedContentRequest request && request.Uri.Query.InvariantContains("dtgePreview") && request.IsRedirect)
{
request.SetRedirect(string.Empty);
}
};
}
}
}
}
19 changes: 19 additions & 0 deletions src/Our.Umbraco.DocTypeGridEditor/Extensions/JsonExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System;
using Newtonsoft.Json.Linq;

namespace Our.Umbraco.DocTypeGridEditor.Extensions
{
internal static class JsonExtensions
{
public static void Rename(this JToken token, string newName)
{
var parent = token.Parent;

if (parent == null)
throw new InvalidOperationException("The parent is missing.");

var newToken = new JProperty(newName, token);
parent.Replace(newToken);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public static bool ViewExists(
ControllerContext controllerContext,
string viewName, bool isPartial = false)
{
var result = !isPartial
var result = isPartial == false
? viewEngines.FindView(controllerContext, viewName, null)
: viewEngines.FindPartialView(controllerContext, viewName);

Expand Down
Loading

0 comments on commit e80d101

Please sign in to comment.