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

Commit 4d5675b

Browse files
authored
Merge pull request #104 from skttl/content-templates
Adds support for content templates
2 parents 3b319a2 + 9286f49 commit 4d5675b

File tree

6 files changed

+126
-84
lines changed

6 files changed

+126
-84
lines changed

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

Lines changed: 13 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -32,44 +32,23 @@
3232
<WarningLevel>4</WarningLevel>
3333
</PropertyGroup>
3434
<ItemGroup>
35-
<Reference Include="businesslogic, Version=1.0.5885.31228, Culture=neutral, processorArchitecture=MSIL">
36-
<HintPath>..\packages\UmbracoCms.Core.7.4.0\lib\businesslogic.dll</HintPath>
35+
<Reference Include="businesslogic, Version=1.0.6470.38240, Culture=neutral, processorArchitecture=MSIL">
36+
<HintPath>..\packages\UmbracoCms.Core.7.7.0\lib\net45\businesslogic.dll</HintPath>
3737
<Private>False</Private>
3838
</Reference>
39-
<Reference Include="ClientDependency.Core, Version=1.8.4.0, Culture=neutral, processorArchitecture=MSIL">
40-
<HintPath>..\packages\ClientDependency.1.8.4\lib\net45\ClientDependency.Core.dll</HintPath>
39+
<Reference Include="cms, Version=1.0.6470.38240, Culture=neutral, processorArchitecture=MSIL">
40+
<HintPath>..\packages\UmbracoCms.Core.7.7.0\lib\net45\cms.dll</HintPath>
4141
<Private>False</Private>
4242
</Reference>
43-
<Reference Include="ClientDependency.Core.Mvc, Version=1.8.0.0, Culture=neutral, processorArchitecture=MSIL">
44-
<HintPath>..\packages\ClientDependency-Mvc5.1.8.0.0\lib\net45\ClientDependency.Core.Mvc.dll</HintPath>
43+
<Reference Include="interfaces, Version=1.0.6470.38233, Culture=neutral, processorArchitecture=MSIL">
44+
<HintPath>..\packages\UmbracoCms.Core.7.7.0\lib\net45\interfaces.dll</HintPath>
4545
<Private>False</Private>
4646
</Reference>
47-
<Reference Include="cms, Version=1.0.5885.31228, Culture=neutral, processorArchitecture=MSIL">
48-
<HintPath>..\packages\UmbracoCms.Core.7.4.0\lib\cms.dll</HintPath>
49-
<Private>False</Private>
50-
</Reference>
51-
<Reference Include="interfaces, Version=1.0.5885.31225, Culture=neutral, processorArchitecture=MSIL">
52-
<HintPath>..\packages\UmbracoCms.Core.7.4.0\lib\interfaces.dll</HintPath>
53-
<Private>False</Private>
54-
</Reference>
55-
<Reference Include="log4net, Version=1.2.11.0, Culture=neutral, processorArchitecture=MSIL">
56-
<HintPath>..\packages\UmbracoCms.Core.7.4.0\lib\log4net.dll</HintPath>
57-
<Private>False</Private>
58-
</Reference>
59-
<Reference Include="Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
60-
<Private>False</Private>
61-
<HintPath>..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll</HintPath>
62-
</Reference>
63-
<Reference Include="MiniProfiler">
64-
<HintPath>..\packages\MiniProfiler.2.1.0\lib\net40\MiniProfiler.dll</HintPath>
65-
<Private>False</Private>
66-
</Reference>
67-
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
68-
<HintPath>..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll</HintPath>
47+
<Reference Include="Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
48+
<HintPath>..\packages\Newtonsoft.Json.10.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
6949
<Private>False</Private>
7050
</Reference>
7151
<Reference Include="System" />
72-
<Reference Include="System.Core" />
7352
<Reference Include="System.Web" />
7453
<Reference Include="System.Web.Http, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
7554
<HintPath>..\packages\Microsoft.AspNet.WebApi.Core.5.2.3\lib\net45\System.Web.Http.dll</HintPath>
@@ -79,15 +58,13 @@
7958
<HintPath>..\packages\Microsoft.AspNet.Mvc.5.2.3\lib\net45\System.Web.Mvc.dll</HintPath>
8059
<Private>False</Private>
8160
</Reference>
82-
<Reference Include="System.Xml.Linq" />
83-
<Reference Include="Microsoft.CSharp" />
8461
<Reference Include="System.Xml" />
85-
<Reference Include="umbraco, Version=1.0.5885.31230, Culture=neutral, processorArchitecture=MSIL">
86-
<HintPath>..\packages\UmbracoCms.Core.7.4.0\lib\umbraco.dll</HintPath>
62+
<Reference Include="umbraco, Version=1.0.6470.38242, Culture=neutral, processorArchitecture=MSIL">
63+
<HintPath>..\packages\UmbracoCms.Core.7.7.0\lib\net45\umbraco.dll</HintPath>
8764
<Private>False</Private>
8865
</Reference>
89-
<Reference Include="Umbraco.Core, Version=1.0.5885.31226, Culture=neutral, processorArchitecture=MSIL">
90-
<HintPath>..\packages\UmbracoCms.Core.7.4.0\lib\Umbraco.Core.dll</HintPath>
66+
<Reference Include="Umbraco.Core, Version=1.0.6470.38234, Culture=neutral, processorArchitecture=MSIL">
67+
<HintPath>..\packages\UmbracoCms.Core.7.7.0\lib\net45\Umbraco.Core.dll</HintPath>
9168
<Private>False</Private>
9269
</Reference>
9370
</ItemGroup>
@@ -138,6 +115,7 @@
138115
<Error Condition="!Exists('..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" Text="This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=317567." HelpKeyword="BCLBUILD2001" />
139116
<Error Condition="Exists('..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" Text="The build restored NuGet packages. Build the project again to include these packages in the build. For more information, see http://go.microsoft.com/fwlink/?LinkID=317568." HelpKeyword="BCLBUILD2002" />
140117
</Target>
118+
<Import Project="..\packages\AutoMapper.3.3.1\tools\AutoMapper.targets" Condition="Exists('..\packages\AutoMapper.3.3.1\tools\AutoMapper.targets')" />
141119
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
142120
Other similar extension points exist, see Microsoft.Common.targets.
143121
<Target Name="BeforeBuild">

src/Our.Umbraco.DocTypeGridEditor/Web/Controllers/DocTypeGridEditorApiController.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,22 @@ public object GetContentTypeAliasByGuid([ModelBinder] Guid guid)
2727
[HttpGet]
2828
public IEnumerable<object> GetContentTypes([ModelBinder] string[] allowedContentTypes)
2929
{
30-
return Services.ContentTypeService.GetAllContentTypes()
30+
var contentTypes = Services.ContentTypeService.GetAllContentTypes()
3131
.Where(x => allowedContentTypes == null || allowedContentTypes.Length == 0 || allowedContentTypes.Any(y => Regex.IsMatch(x.Alias, y)))
3232
.OrderBy(x => x.Name)
33+
.ToList();
34+
var blueprints = Services.ContentService.GetBlueprintsForContentTypes(contentTypes.Select(x => x.Id).ToArray()).ToArray();
35+
36+
return contentTypes
3337
.Select(x => new
3438
{
3539
id = x.Id,
3640
guid = x.Key,
3741
name = x.Name,
3842
alias = x.Alias,
3943
description = x.Description,
40-
icon = x.Icon
44+
icon = x.Icon,
45+
blueprints = blueprints.Where(bp => bp.ContentTypeId == x.Id).ToDictionary(bp => bp.Id, bp => bp.Name)
4146
});
4247
}
4348

src/Our.Umbraco.DocTypeGridEditor/Web/UI/App_Plugins/DocTypeGridEditor/Js/doctypegrideditor.controllers.js

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,9 @@ angular.module("umbraco").controller("Our.Umbraco.DocTypeGridEditor.Dialogs.DocT
195195
"contentResource",
196196
"Our.Umbraco.DocTypeGridEditor.Resources.DocTypeGridEditorResources",
197197
"Our.Umbraco.DocTypeGridEditor.Services.DocTypeGridEditorUtilityService",
198+
"blueprintConfig",
198199

199-
function ($scope, $interpolate, formHelper, contentResource, dtgeResources, dtgeUtilityService) {
200+
function ($scope, $interpolate, formHelper, contentResource, dtgeResources, dtgeUtilityService, blueprintConfig) {
200201

201202
$scope.docTypes = [];
202203
$scope.dialogMode = "selectDocType";
@@ -208,13 +209,41 @@ angular.module("umbraco").controller("Our.Umbraco.DocTypeGridEditor.Dialogs.DocT
208209
: undefined;
209210

210211
$scope.model.nameExp = nameExp;
211-
212-
$scope.selectDocType = function (alias) {
212+
213+
function createBlank() {
213214
$scope.dialogMode = "edit";
214-
$scope.model.dialogData.docTypeAlias = alias;
215215
loadNode();
216216
};
217217

218+
function createOrSelectBlueprintIfAny(docType) {
219+
220+
$scope.model.dialogData.docTypeAlias = docType.alias;
221+
var blueprintIds = _.keys(docType.blueprints || {});
222+
$scope.selectedDocType = docType;
223+
224+
if (blueprintIds.length) {
225+
if (blueprintConfig.skipSelect) {
226+
createFromBlueprint(blueprintIds[0]);
227+
} else {
228+
$scope.dialogMode = "selectBlueprint";
229+
}
230+
} else {
231+
createBlank();
232+
}
233+
};
234+
235+
function createFromBlueprint(blueprintId) {
236+
contentResource.getBlueprintScaffold(-20, blueprintId).then(function (data) {
237+
// Assign the model to scope
238+
$scope.nodeContext = $scope.model.node = data;
239+
$scope.dialogMode = "edit";
240+
});
241+
};
242+
243+
$scope.createBlank = createBlank;
244+
$scope.createOrSelectBlueprintIfAny = createOrSelectBlueprintIfAny;
245+
$scope.createFromBlueprint = createFromBlueprint;
246+
218247
function loadNode() {
219248
contentResource.getScaffold(-20, $scope.model.dialogData.docTypeAlias).then(function (data) {
220249

@@ -250,9 +279,7 @@ angular.module("umbraco").controller("Our.Umbraco.DocTypeGridEditor.Dialogs.DocT
250279
dtgeResources.getContentTypes($scope.model.allowedDocTypes).then(function (docTypes) {
251280
$scope.docTypes = docTypes;
252281
if ($scope.docTypes.length == 1) {
253-
$scope.model.dialogData.docTypeAlias = $scope.docTypes[0].alias;
254-
$scope.dialogMode = "edit";
255-
loadNode();
282+
createOrSelectBlueprintIfAny($scope.docTypes[0]);
256283
}
257284
});
258285
}

src/Our.Umbraco.DocTypeGridEditor/Web/UI/App_Plugins/DocTypeGridEditor/Views/doctypegrideditor.dialog.html

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<umb-control-group label="{{selectContentTypeLabel}}" ng-switch-when="selectDocType">
55
<ul class="umb-actions umb-actions-child">
66
<li data-element="action-create-{{docType.alias}}" ng-repeat="docType in docTypes | orderBy:'name':false">
7-
<a ng-click="selectDocType(docType.alias)">
7+
<a ng-click="createOrSelectBlueprintIfAny(docType)">
88
<i class="large {{docType.icon}}"></i>
99
<span class="menu-label">
1010
{{docType.name}}
@@ -17,6 +17,29 @@
1717
</ul>
1818
</umb-control-group>
1919

20+
<div ng-switch-when="selectBlueprint">
21+
<h5><localize key="blueprints_selectBlueprint">Select a blueprint</localize></h5>
22+
23+
<ul class="umb-actions umb-actions-child">
24+
<li ng-repeat="(key, value) in selectedDocType.blueprints | orderBy:'name':false">
25+
<a ng-click="createFromBlueprint(key)">
26+
<i class="large {{selectedDocType.icon}}"></i>
27+
<span class="menu-label">
28+
{{value}}
29+
</span>
30+
</a>
31+
</li>
32+
<li class="sep" ng-show="allowBlank">
33+
<a ng-click="createBlank()">
34+
<i class="large {{selectedDocType.icon}}"></i>
35+
<span class="menu-label">
36+
<localize key="blueprints_blankBlueprint">Blank</localize>
37+
</span>
38+
</a>
39+
</li>
40+
</ul>
41+
</div>
42+
2043
<div ng-switch-when="edit">
2144

2245
<fieldset ng-repeat="tab in model.node.tabs">
Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,60 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<configuration>
33
<runtime>
44
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
55
<dependentAssembly>
6-
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral"/>
7-
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0"/>
6+
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
7+
<bindingRedirect oldVersion="0.0.0.0-10.0.0.0" newVersion="10.0.0.0" />
88
</dependentAssembly>
99
<dependentAssembly>
10-
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
11-
<bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0"/>
10+
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" culture="neutral" />
11+
<bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
1212
</dependentAssembly>
1313
<dependentAssembly>
14-
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
15-
<bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0"/>
14+
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" culture="neutral" />
15+
<bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
1616
</dependentAssembly>
1717
<dependentAssembly>
18-
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
19-
<bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0"/>
18+
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" culture="neutral" />
19+
<bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
2020
</dependentAssembly>
2121
<dependentAssembly>
22-
<assemblyIdentity name="System.Web.WebPages.Razor" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
23-
<bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0"/>
22+
<assemblyIdentity name="System.Web.WebPages.Razor" publicKeyToken="31bf3856ad364e35" culture="neutral" />
23+
<bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
2424
</dependentAssembly>
2525
<dependentAssembly>
26-
<assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
27-
<bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0"/>
26+
<assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral" />
27+
<bindingRedirect oldVersion="0.0.0.0-3.1.0.0" newVersion="3.1.0.0" />
2828
</dependentAssembly>
2929
<dependentAssembly>
30-
<assemblyIdentity name="Microsoft.Owin.Security.OAuth" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
31-
<bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0"/>
30+
<assemblyIdentity name="Microsoft.Owin.Security.OAuth" publicKeyToken="31bf3856ad364e35" culture="neutral" />
31+
<bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" />
3232
</dependentAssembly>
3333
<dependentAssembly>
34-
<assemblyIdentity name="Microsoft.Owin.Security" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
35-
<bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0"/>
34+
<assemblyIdentity name="Microsoft.Owin.Security" publicKeyToken="31bf3856ad364e35" culture="neutral" />
35+
<bindingRedirect oldVersion="0.0.0.0-3.1.0.0" newVersion="3.1.0.0" />
3636
</dependentAssembly>
3737
<dependentAssembly>
38-
<assemblyIdentity name="Microsoft.Owin.Security.Cookies" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
39-
<bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0"/>
38+
<assemblyIdentity name="Microsoft.Owin.Security.Cookies" publicKeyToken="31bf3856ad364e35" culture="neutral" />
39+
<bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" />
4040
</dependentAssembly>
4141
<dependentAssembly>
42-
<assemblyIdentity name="MySql.Data" publicKeyToken="c5687fc88969c44d" culture="neutral"/>
43-
<bindingRedirect oldVersion="0.0.0.0-6.9.9.0" newVersion="6.9.9.0"/>
42+
<assemblyIdentity name="MySql.Data" publicKeyToken="c5687fc88969c44d" culture="neutral" />
43+
<bindingRedirect oldVersion="0.0.0.0-6.9.9.0" newVersion="6.9.9.0" />
4444
</dependentAssembly>
4545
<dependentAssembly>
46-
<assemblyIdentity name="System.Net.Http.Formatting" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
47-
<bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0"/>
46+
<assemblyIdentity name="System.Net.Http.Formatting" publicKeyToken="31bf3856ad364e35" culture="neutral" />
47+
<bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
48+
</dependentAssembly>
49+
<dependentAssembly>
50+
<assemblyIdentity name="log4net" publicKeyToken="669e0ddf0bb1aa2a" culture="neutral" />
51+
<bindingRedirect oldVersion="0.0.0.0-2.0.8.0" newVersion="2.0.8.0" />
4852
</dependentAssembly>
4953
</assemblyBinding>
5054
</runtime>
5155
<system.data>
5256
<DbProviderFactories>
53-
<remove invariant="MySql.Data.MySqlClient"/>
54-
<add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.9.9.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"/>
57+
<remove invariant="MySql.Data.MySqlClient" />
58+
<add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.9.9.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
5559
</DbProviderFactories>
5660
</system.data></configuration>

0 commit comments

Comments
 (0)