Skip to content
This repository was archived by the owner on Jun 18, 2018. It is now read-only.

Commit dac2bb0

Browse files
committed
Copied over amends from the Umbraco core version of NC.
1 parent a86678f commit dac2bb0

File tree

11 files changed

+104
-77
lines changed

11 files changed

+104
-77
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ A nested content property editor for Umbraco 7 that allows you to use Doc Types
1313

1414
### Installation
1515

16-
> *Note:* Nested Content has been developed against **Umbraco v7.1.4** and will support that version and above.
16+
> *Note:* Nested Content has been developed against **Umbraco v7.1.5** and will support that version and above.
1717
1818
Nested Content can be installed from either Our Umbraco or NuGet package repositories, or build manually from the source-code:
1919

src/Our.Umbraco.NestedContent/Extensions/PreValueCollectionExtensions.cs

Lines changed: 0 additions & 14 deletions
This file was deleted.

src/Our.Umbraco.NestedContent/Extensions/PublishedPropertyTypeExtensions.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public static bool IsSingleNestedContentProperty(this PublishedPropertyType publ
2727
}
2828

2929
var preValueCollection = NestedContentHelper.GetPreValuesCollectionByDataTypeId(publishedProperty.DataTypeId);
30-
var preValueDictionary = preValueCollection.AsPreValueDictionary();
30+
var preValueDictionary = preValueCollection.PreValuesAsDictionary.ToDictionary(x => x.Key, x => x.Value.Value);
3131

3232
int minItems, maxItems;
3333
return preValueDictionary.ContainsKey("minItems") &&
@@ -46,7 +46,7 @@ public static object ConvertPropertyToNestedContent(this PublishedPropertyType p
4646
var processedValue = new List<IPublishedContent>();
4747

4848
var preValueCollection = NestedContentHelper.GetPreValuesCollectionByDataTypeId(propertyType.DataTypeId);
49-
var preValueDictionary = preValueCollection.AsPreValueDictionary();
49+
var preValueDictionary = preValueCollection.PreValuesAsDictionary.ToDictionary(x => x.Key, x => x.Value.Value);
5050

5151
for (var i = 0; i < rawValue.Count; i++)
5252
{
@@ -102,7 +102,7 @@ public static object ConvertPropertyToNestedContent(this PublishedPropertyType p
102102
i,
103103
preview);
104104

105-
if (PublishedContentModelFactoryResolver.HasCurrent)
105+
if (PublishedContentModelFactoryResolver.HasCurrent && PublishedContentModelFactoryResolver.Current.HasValue)
106106
{
107107
// Let the current model factory create a typed model to wrap our model
108108
content = PublishedContentModelFactoryResolver.Current.Factory.CreateModel(content);

src/Our.Umbraco.NestedContent/Helpers/NestedContentHelper.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public static void ConvertItemValueFromV011(JObject item, int dtdId, ref PreValu
7171
ConvertPreValueCollectionFromV011(preValues);
7272

7373
// - get the content types prevalue as JArray
74-
var preValuesAsDictionary = preValues.AsPreValueDictionary();
74+
var preValuesAsDictionary = preValues.PreValuesAsDictionary.ToDictionary(x => x.Key, x => x.Value.Value);
7575
if (!preValuesAsDictionary.ContainsKey(ContentTypesPreValueKey) || string.IsNullOrEmpty(preValuesAsDictionary[ContentTypesPreValueKey]) != false)
7676
{
7777
return;
@@ -92,7 +92,7 @@ public static void ConvertPreValueCollectionFromV011(PreValueCollection preValue
9292
return;
9393
}
9494

95-
var persistedPreValuesAsDictionary = preValueCollection.AsPreValueDictionary();
95+
var persistedPreValuesAsDictionary = preValueCollection.PreValuesAsDictionary.ToDictionary(x => x.Key, x => x.Value.Value);
9696

9797
// do we have a "docTypeGuid" prevalue and no "contentTypes" prevalue?
9898
if (persistedPreValuesAsDictionary.ContainsKey("docTypeGuid") == false || persistedPreValuesAsDictionary.ContainsKey(ContentTypesPreValueKey))
@@ -230,8 +230,6 @@ public static void RemapDocTypeTabAlias(string docTypeAlias, string oldAlias, st
230230
}
231231
}
232232

233-
// TODO: RemapNestedContentNameTemplate?
234-
235233
private static IEnumerable<JsonDbRow> GetPropertyDataRows(string docTypeAlias)
236234
{
237235
var db = ApplicationContext.Current.DatabaseContext.Database;

src/Our.Umbraco.NestedContent/Our.Umbraco.NestedContent.csproj

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@
8686
<Compile Include="Extensions\PublishedPropertyTypeExtensions.cs" />
8787
<Compile Include="Converters\SingleNestedContentValueConverter.cs" />
8888
<Compile Include="Converters\NestedContentValueConverter.cs" />
89-
<Compile Include="Extensions\PreValueCollectionExtensions.cs" />
9089
<Compile Include="Helpers\NestedContentHelper.cs" />
9190
<Compile Include="Models\DetachedPublishedContent.cs" />
9291
<Compile Include="Models\DetachedPublishedProperty.cs" />
@@ -112,13 +111,8 @@
112111
</ItemGroup>
113112
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
114113
<PropertyGroup>
115-
<PostBuildEvent>IF %25ComputerName%25 == MBP13-PC-BC (
116-
IF NOT "$(SolutionDir)" == "*Undefined*" (
117-
xcopy /s /y "$(TargetPath)" "C:\Users\Matt\Work\Sandbox\Umbraco\UmbracoUHangoutDemo\bin"
118-
xcopy /s /y "$(TargetDir)$(ProjectName).pdb" "C:\Users\Matt\Work\Sandbox\Umbraco\UmbracoUHangoutDemo\bin"
119-
xcopy /s /y "$(ProjectDir)Web\UI\*.*" "C:\Users\Matt\Work\Sandbox\Umbraco\UmbracoUHangoutDemo"
120-
)
121-
)</PostBuildEvent>
114+
<PostBuildEvent>
115+
</PostBuildEvent>
122116
</PropertyGroup>
123117
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
124118
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">

src/Our.Umbraco.NestedContent/PropertyEditors/NestedContentPropertyEditor.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
using System.Text.RegularExpressions;
66
using Newtonsoft.Json;
77
using Newtonsoft.Json.Linq;
8-
using Our.Umbraco.NestedContent.Extensions;
98
using Our.Umbraco.NestedContent.Helpers;
109
using Umbraco.Core;
1110
using Umbraco.Core.Models;
@@ -107,7 +106,7 @@ public override void ConfigureForDisplay(PreValueCollection preValues)
107106
{
108107
base.ConfigureForDisplay(preValues);
109108

110-
var asDictionary = preValues.AsPreValueDictionary();
109+
var asDictionary = preValues.PreValuesAsDictionary.ToDictionary(x => x.Key, x => x.Value.Value);
111110
if (asDictionary.ContainsKey("hideLabel"))
112111
{
113112
var boolAttempt = asDictionary["hideLabel"].TryConvertTo<bool>();

src/Our.Umbraco.NestedContent/Web/UI/App_Plugins/NestedContent/Css/nestedcontent.css

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,25 @@
1-
.nested-content
1+
.nested-content
22
{
33
text-align: center;
44
}
55

6-
.nested-content__item
6+
.nested-content--not-supported
7+
{
8+
opacity: 0.3;
9+
pointer-events: none;
10+
}
11+
12+
.nested-content-overlay
13+
{
14+
position: absolute;
15+
top: 0;
16+
left: 0;
17+
width: 100%;
18+
height: 100%;
19+
z-index: 1000;
20+
}
21+
22+
.nested-content__item
723
{
824
position: relative;
925
text-align: left;
@@ -18,7 +34,7 @@
1834
background: #f8f8f8;
1935
}
2036

21-
.nested-content__item.ui-sortable-placeholder
37+
.nested-content__item.ui-sortable-placeholder
2238
{
2339
background: #f8f8f8;
2440
border: 1px dashed #d9d9d9;
@@ -37,18 +53,18 @@
3753
margin: 0;
3854
}
3955

40-
.nested-content__header-bar
56+
.nested-content__header-bar
4157
{
42-
padding: 15px 20px;
58+
padding: 15px 20px;
4359
border-bottom: 1px dashed #e0e0e0;
4460
text-align: right;
4561
cursor: pointer;
4662
background-color: white;
4763

48-
-moz-user-select: none;
49-
-khtml-user-select: none;
50-
-webkit-user-select: none;
51-
-o-user-select: none;
64+
-moz-user-select: none;
65+
-khtml-user-select: none;
66+
-webkit-user-select: none;
67+
-o-user-select: none;
5268
}
5369

5470
.nested-content__heading
@@ -57,14 +73,14 @@
5773
line-height: 20px;
5874
}
5975

60-
.nested-content__heading i
76+
.nested-content__heading i
6177
{
6278
vertical-align: text-top;
6379
color: #999; /* same icon color as the icons in the item type picker */
6480
margin-right: 10px;
6581
}
6682

67-
.nested-content__icons
83+
.nested-content__icons
6884
{
6985
margin: -6px 0;
7086
opacity: 0;
@@ -116,19 +132,19 @@
116132
color: white;
117133
}
118134

119-
.nested-content__icon--disabled
135+
.nested-content__icon--disabled
120136
{
121137
opacity: 0.3;
122138
}
123139

124140

125-
.nested-content__footer-bar
141+
.nested-content__footer-bar
126142
{
127143
text-align: center;
128144
padding-top: 20px;
129145
}
130146

131-
.nested-content__content
147+
.nested-content__content
132148
{
133149
border-bottom: 1px dashed #e0e0e0;
134150
}
@@ -142,7 +158,7 @@
142158
display: none !important;
143159
}
144160

145-
.nested-content__help-text
161+
.nested-content__help-text
146162
{
147163
display: inline-block;
148164
padding: 10px 20px 10px 20px;
@@ -171,7 +187,7 @@
171187
margin-left: 10px;
172188
}
173189

174-
.form-horizontal .nested-content--narrow .controls-row
190+
.form-horizontal .nested-content--narrow .controls-row
175191
{
176192
margin-left: 40% !important;
177193
}

src/Our.Umbraco.NestedContent/Web/UI/App_Plugins/NestedContent/Js/nestedcontent.controllers.js

Lines changed: 38 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@
2626
handle: ".icon-navigation"
2727
};
2828

29-
$scope.selectedDocTypeTabs = {};
29+
$scope.docTypeTabs = {};
3030

3131
ncResources.getContentTypes().then(function (docTypes) {
3232
$scope.model.docTypes = docTypes;
3333

3434
// Populate document type tab dictionary
35-
docTypes.forEach(function(value) {
36-
$scope.selectedDocTypeTabs[value.alias] = value.tabs;
35+
docTypes.forEach(function (value) {
36+
$scope.docTypeTabs[value.alias] = value.tabs;
3737
});
3838
});
3939

@@ -53,9 +53,8 @@ angular.module("umbraco").controller("Our.Umbraco.NestedContent.Controllers.Nest
5353
"contentResource",
5454
"localizationService",
5555
"iconHelper",
56-
"Our.Umbraco.NestedContent.Resources.NestedContentResources",
5756

58-
function ($scope, $interpolate, $filter, $timeout, contentResource, localizationService, iconHelper, ncResources) {
57+
function ($scope, $interpolate, $filter, $timeout, contentResource, localizationService, iconHelper) {
5958

6059
//$scope.model.config.contentTypes;
6160
//$scope.model.config.minItems;
@@ -265,6 +264,17 @@ angular.module("umbraco").controller("Our.Umbraco.NestedContent.Controllers.Nest
265264
});
266265
}
267266

267+
var notSupported = [
268+
"Umbraco.CheckBoxList",
269+
"Umbraco.DropDownMultiple",
270+
"Umbraco.MacroContainer",
271+
"Umbraco.RadioButtonList",
272+
"Umbraco.MultipleTextstring",
273+
"Umbraco.Tags",
274+
"Umbraco.UploadField",
275+
"Umbraco.ImageCropper"
276+
];
277+
268278
// Initialize
269279
var scaffoldsLoaded = 0;
270280
$scope.scaffolds = [];
@@ -277,6 +287,14 @@ angular.module("umbraco").controller("Our.Umbraco.NestedContent.Controllers.Nest
277287
scaffold.tabs = [];
278288
if (tab) {
279289
scaffold.tabs.push(tab);
290+
291+
angular.forEach(tab.properties,
292+
function (property) {
293+
if (_.find(notSupported, function (x) { return x === property.editor; })) {
294+
property.notSupported = true;
295+
property.notSupportedMessage = "Property " + property.label + " uses editor " + property.editor + " which is not supported by Nested Content.";
296+
}
297+
});
280298
}
281299

282300
// Store the scaffold object
@@ -335,7 +353,7 @@ angular.module("umbraco").controller("Our.Umbraco.NestedContent.Controllers.Nest
335353
var initNode = function (scaffold, item) {
336354
var node = angular.copy(scaffold);
337355

338-
node.id = guid();
356+
node.id = item && item.id ? item.id : UUID.generate();
339357
node.ncContentTypeAlias = scaffold.contentTypeAlias;
340358

341359
for (var t = 0; t < node.tabs.length; t++) {
@@ -404,13 +422,21 @@ angular.module("umbraco").controller("Our.Umbraco.NestedContent.Controllers.Nest
404422
unsubscribe();
405423
});
406424

407-
var guid = function () {
408-
function _p8(s) {
409-
var p = (Math.random().toString(16) + "000000000").substr(2, 8);
410-
return s ? "-" + p.substr(0, 4) + "-" + p.substr(4, 4) : p;
425+
var UUID = (function () {
426+
var self = {};
427+
var lut = []; for (var i = 0; i < 256; i++) { lut[i] = (i < 16 ? '0' : '') + (i).toString(16); }
428+
self.generate = function () {
429+
var d0 = Math.random() * 0xffffffff | 0;
430+
var d1 = Math.random() * 0xffffffff | 0;
431+
var d2 = Math.random() * 0xffffffff | 0;
432+
var d3 = Math.random() * 0xffffffff | 0;
433+
return lut[d0 & 0xff] + lut[d0 >> 8 & 0xff] + lut[d0 >> 16 & 0xff] + lut[d0 >> 24 & 0xff] + '-' +
434+
lut[d1 & 0xff] + lut[d1 >> 8 & 0xff] + '-' + lut[d1 >> 16 & 0x0f | 0x40] + lut[d1 >> 24 & 0xff] + '-' +
435+
lut[d2 & 0x3f | 0x80] + lut[d2 >> 8 & 0xff] + '-' + lut[d2 >> 16 & 0xff] + lut[d2 >> 24 & 0xff] +
436+
lut[d3 & 0xff] + lut[d3 >> 8 & 0xff] + lut[d3 >> 16 & 0xff] + lut[d3 >> 24 & 0xff];
411437
}
412-
return _p8() + _p8(true) + _p8(true) + _p8();
413-
};
438+
return self;
439+
})();
414440
}
415441

416442
]);

src/Our.Umbraco.NestedContent/Web/UI/App_Plugins/NestedContent/Views/nestedcontent.doctypepicker.html

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
<tr>
66
<th/>
77
<th>
8-
Document Type
8+
<localize key="content_documentType">Document Type</localize>
99
</th>
1010
<th>
11-
Tab
11+
<localize key="editcontenttype_tab">Tab</localize>
1212
</th>
1313
<th>
14-
Name Template
14+
<localize key="template_template">Template</localize>
1515
</th>
1616
<th />
1717
</tr>
@@ -27,31 +27,35 @@
2727
</td>
2828
<td>
2929
<select id="{{model.alias}}_tab_select"
30-
ng-options="t for t in selectedDocTypeTabs[config.ncAlias]"
30+
ng-options="t for t in docTypeTabs[config.ncAlias]"
3131
ng-model="config.ncTabAlias" required></select>
3232
</td>
3333
<td>
3434
<input type="text" ng-model="config.nameTemplate" />
3535
</td>
3636
<td>
37-
<a class="btn btn-danger" ng-click="remove($index)" ng-show="model.value.length > 1">Remove</a>
37+
<a class="btn btn-danger" ng-click="remove($index)" ng-show="model.value.length > 1">
38+
<localize key="general_delete">Delete</localize>
39+
</a>
3840
</td>
3941
</tr>
4042
</tbody>
4143
</table>
4244
<div>
43-
<a class="btn" ng-click="add()">Add</a>
45+
<a class="btn" ng-click="add()">
46+
<localize key="general_add">Add</localize>
47+
</a>
4448
<i class="icon icon-help-alt medium nested-content__help-icon" ng-click="showHelpText = !showHelpText"></i>
4549
</div>
4650
</div>
4751
<br/>
4852
<div class="nested-content__help-text" ng-show="showHelpText">
4953
<p>
50-
<b>Tab:</b><br/>
51-
Select the tab who's properties should be displayed. If left blank, the first tab on the doc type will be used.
54+
<b><localize key="editcontenttype_tab">Tab</localize>:</b><br/>
55+
Select the tab who's properties should be displayed. If left blank, the first tab on the doc type will be used.
5256
</p>
5357
<p>
54-
<b>Name template:</b><br/>
58+
<b><localize key="template_template">Template</localize>:</b><br/>
5559
Enter an angular expression to evaluate against each item for its name. Use <code ng-non-bindable>{{$index}}</code> to display the item index
5660
</p>
5761
</div>

0 commit comments

Comments
 (0)