Skip to content
This repository was archived by the owner on Dec 13, 2021. It is now read-only.

Commit 7e3ad47

Browse files
authored
Merge pull request #8 from umco/develop
Preparing v1.0.0 release
2 parents ec376fd + 1711cb4 commit 7e3ad47

14 files changed

+220
-90
lines changed

README.md

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
[![Build status](https://img.shields.io/appveyor/ci/UMCO/umbraco-property-list.svg)](https://ci.appveyor.com/project/UMCO/umbraco-property-list)
44
[![NuGet release](https://img.shields.io/nuget/v/Our.Umbraco.PropertyList.svg)](https://www.nuget.org/packages/Our.Umbraco.PropertyList)
5+
[![Our Umbraco project page](https://img.shields.io/badge/our-umbraco-orange.svg)](https://our.umbraco.org/projects/backoffice-extensions/property-list)
56

67
Property List is a property editor for making repeatable lists of a datatype for Umbraco 7.6+
78

@@ -11,8 +12,13 @@ Property List is a property editor for making repeatable lists of a datatype for
1112

1213
> *Note:* Property List has been developed against **Umbraco v7.6.0** and will support that version and above.
1314
14-
Property List can be installed from either NuGet package repositories, or build manually from the source-code:
15+
Property List can be installed from either Our Umbraco, NuGet package repositories, or build manually from the source-code:
1516

17+
#### Our Umbraco package repository
18+
19+
To install from Our Umbraco, please download the package from:
20+
21+
> <https://our.umbraco.org/projects/backoffice-extensions/property-list>
1622
1723
#### NuGet package repository
1824

@@ -50,23 +56,13 @@ Anyone and everyone is welcome to contribute. Please take a moment to review the
5056
* [Feature requests](CONTRIBUTING.md#features)
5157
* [Pull requests](CONTRIBUTING.md#pull-requests)
5258

53-
### TODO
54-
55-
What's left to do?
56-
57-
- [ ] Deploy ValueConnector
58-
- [ ] Pre Value Editor
59-
- [ ] Add DataType dependency
60-
- [ ] Value Editor
61-
- [ ] Processing all list item DataTypes
62-
63-
6459
---
6560

6661
## Contact
6762

6863
Have a question?
6964

65+
* [Property List Forum](https://our.umbraco.org/projects/backoffice-extensions/property-list/property-list-feedback) on Our Umbraco
7066
* [Raise an issue](https://github.com/umco/umbraco-property-list/issues) on GitHub
7167

7268
## Dev Team

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ version: 1.0.0.{build}
66
# UMBRACO_PACKAGE_PRERELEASE_SUFFIX if a rtm release build this should be blank, otherwise if empty will default to alpha
77
# example UMBRACO_PACKAGE_PRERELEASE_SUFFIX=beta
88
init:
9-
- set UMBRACO_PACKAGE_PRERELEASE_SUFFIX=beta2
9+
- set UMBRACO_PACKAGE_PRERELEASE_SUFFIX=
1010

1111
cache:
1212
- src\packages -> **\packages.config # preserve "packages" directory in the root of build folder but will reset it if packages.config is modified

docs/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Property List
2+
## Documentation
3+
4+
* [Property List - Developers Guide](developers-guide.md)

docs/developers-guide.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Property List - Developers Guide
2+

src/Our.Umbraco.PropertyList/Bootstrap.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
using Newtonsoft.Json;
2-
using Our.Umbraco.PropertyList.ValueConverters;
1+
using System;
2+
using Newtonsoft.Json;
33
using Umbraco.Core;
44
using Umbraco.Core.Sync;
55
using Umbraco.Web.Cache;
@@ -17,15 +17,16 @@ protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplica
1717

1818
// NOTE: The properties for the JSON payload are available here: (Currently there isn't a public API to deserialize the payload)
1919
// https://github.com/umbraco/Umbraco-CMS/blob/release-7.6.0/src/Umbraco.Web/Cache/DataTypeCacheRefresher.cs#L66-L70
20-
// TODO: Once `DataTypeCacheRefresher.DeserializeFromJsonPayload` is public, we can deserialize correctly.
20+
// TODO: Once Umbraco's `DataTypeCacheRefresher.DeserializeFromJsonPayload` is public, we can deserialize correctly.
2121
// https://github.com/umbraco/Umbraco-CMS/blob/release-7.6.0/src/Umbraco.Web/Cache/DataTypeCacheRefresher.cs#L27
22-
var payload = JsonConvert.DeserializeAnonymousType((string)e.MessageObject, new[] { new { Id = default(int) } });
22+
var payload = JsonConvert.DeserializeAnonymousType((string)e.MessageObject, new[] { new { Id = default(int), UniqueId = Guid.Empty } });
2323
if (payload == null)
2424
return;
2525

2626
foreach (var item in payload)
2727
{
28-
PropertyListValueConverter.ClearDataTypeCache(item.Id);
28+
PropertyEditors.PropertyListValidator.ClearDataTypeCache(item.UniqueId);
29+
ValueConverters.PropertyListValueConverter.ClearDataTypeCache(item.Id);
2930
}
3031
};
3132
}

src/Our.Umbraco.PropertyList/Our.Umbraco.PropertyList.csproj

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -43,32 +43,18 @@
4343
<HintPath>..\packages\UmbracoCms.Core.7.6.0\lib\net45\interfaces.dll</HintPath>
4444
<Private>False</Private>
4545
</Reference>
46-
<Reference Include="log4net, Version=2.0.8.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
47-
<HintPath>..\packages\UmbracoCms.Core.7.6.0\lib\net45\log4net.dll</HintPath>
48-
<Private>False</Private>
49-
</Reference>
50-
<Reference Include="MiniProfiler, Version=2.1.0.0, Culture=neutral, PublicKeyToken=b44f9351044011a3, processorArchitecture=MSIL">
51-
<HintPath>..\packages\MiniProfiler.2.1.0\lib\net40\MiniProfiler.dll</HintPath>
52-
<Private>False</Private>
53-
</Reference>
5446
<Reference Include="Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
5547
<HintPath>..\packages\Newtonsoft.Json.10.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
5648
<Private>False</Private>
5749
</Reference>
5850
<Reference Include="System" />
5951
<Reference Include="System.ComponentModel.DataAnnotations" />
60-
<Reference Include="System.Core" />
6152
<Reference Include="System.Web" />
6253
<Reference Include="System.Web.Http, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
6354
<HintPath>..\packages\Microsoft.AspNet.WebApi.Core.5.2.3\lib\net45\System.Web.Http.dll</HintPath>
6455
<Private>False</Private>
6556
</Reference>
66-
<Reference Include="System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
67-
<HintPath>..\packages\Microsoft.AspNet.Mvc.5.2.3\lib\net45\System.Web.Mvc.dll</HintPath>
68-
<Private>False</Private>
69-
</Reference>
7057
<Reference Include="System.Xml.Linq" />
71-
<Reference Include="Microsoft.CSharp" />
7258
<Reference Include="System.Net.Http" />
7359
<Reference Include="System.Xml" />
7460
<Reference Include="umbraco, Version=1.0.6331.7975, Culture=neutral, processorArchitecture=MSIL">
@@ -82,6 +68,7 @@
8268
</ItemGroup>
8369
<ItemGroup>
8470
<Compile Include="Bootstrap.cs" />
71+
<Compile Include="PropertyListConstants.cs" />
8572
<Compile Include="ValueConverters\PropertyListValueConverter.cs" />
8673
<Compile Include="Models\PropertyListValue.cs" />
8774
<Compile Include="Properties\AssemblyInfo.cs" />

src/Our.Umbraco.PropertyList/PropertyEditors/PropertyListPreValueEditor.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using Umbraco.Core.IO;
22
using Umbraco.Core.PropertyEditors;
3+
using static Our.Umbraco.PropertyList.PropertyListConstants;
34

45
namespace Our.Umbraco.PropertyList.PropertyEditors
56
{
@@ -11,7 +12,7 @@ public PropertyListPreValueEditor()
1112
// In terms of inheritance, we'd like the "dataType" field to always be at the top.
1213
Fields.Insert(0, new PreValueField
1314
{
14-
Key = "dataType",
15+
Key = PreValueKeys.DataType,
1516
Name = "Data Type",
1617
View = IOHelper.ResolveUrl("~/App_Plugins/PropertyList/views/propertylist.datatypepicker.html"),
1718
Description = "Select a data type."
@@ -22,21 +23,21 @@ public PropertyListPreValueEditor()
2223
{
2324
new PreValueField
2425
{
25-
Key = "minItems",
26+
Key = PreValueKeys.MinItems,
2627
Name = "Min Items",
2728
View = "number",
2829
Description = "Set the minimum number of items allowed."
2930
},
3031
new PreValueField
3132
{
32-
Key = "maxItems",
33+
Key = PreValueKeys.MaxItems,
3334
Name = "Max Items",
3435
View = "number",
3536
Description = "Set the maximum number of items allowed."
3637
},
3738
new PreValueField
3839
{
39-
Key = "hideLabel",
40+
Key = PreValueKeys.HideLabel,
4041
Name = "Hide Label",
4142
View = "boolean",
4243
Description = "Set whether to hide the editor label and have the list take up the full width of the editor window."

src/Our.Umbraco.PropertyList/PropertyEditors/PropertyListPropertyEditor.cs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,14 @@
22
using ClientDependency.Core;
33
using Umbraco.Core.PropertyEditors;
44
using Umbraco.Web.PropertyEditors;
5+
using static Our.Umbraco.PropertyList.PropertyListConstants;
56

67
namespace Our.Umbraco.PropertyList.PropertyEditors
78
{
8-
[PropertyEditor(PropertyEditorAlias, PropertyEditorName, "JSON", PropertyEditorViewPath, Group = "Lists", Icon = "icon-bulleted-list", IsParameterEditor = false)]
9-
[PropertyEditorAsset(ClientDependencyType.Javascript, "~/App_Plugins/PropertyList/js/propertylist.js")]
9+
[PropertyEditor(PropertyEditorKeys.Alias, PropertyEditorKeys.Name, PropertyEditorValueTypes.Json, PropertyEditorKeys.ViewPath, Group = PropertyEditorKeys.Group, Icon = PropertyEditorKeys.Icon, IsParameterEditor = false)]
10+
[PropertyEditorAsset(ClientDependencyType.Javascript, PropertyEditorKeys.JavaScriptPath)]
1011
public class PropertyListPropertyEditor : PropertyEditor
1112
{
12-
public const string PropertyEditorAlias = "Our.Umbraco.PropertyList";
13-
public const string PropertyEditorName = "Property List";
14-
public const string PropertyEditorViewPath = "~/App_Plugins/PropertyList/Views/propertylist.html";
15-
16-
internal const string DefaultTextstringPropertyEditorGuid = "0cc0eba1-9960-42c9-bf9b-60e150b429ae"; // Guid for default Textstring
17-
1813
private IDictionary<string, object> _defaultPreValues;
1914
public override IDictionary<string, object> DefaultPreValues
2015
{
@@ -26,9 +21,10 @@ public PropertyListPropertyEditor()
2621
{
2722
_defaultPreValues = new Dictionary<string, object>
2823
{
29-
{ "dataType", DefaultTextstringPropertyEditorGuid },
30-
{ "minItems", 0 },
31-
{ "maxItems", 0 }
24+
{ PreValueKeys.DataType, DataTypeGuids.DefaultTextstring },
25+
{ PreValueKeys.MinItems, 0 },
26+
{ PreValueKeys.MaxItems, 0 },
27+
{ PreValueKeys.HideLabel, 0 }
3228
};
3329
}
3430

src/Our.Umbraco.PropertyList/PropertyEditors/PropertyListPropertyValueEditor.cs

Lines changed: 36 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
using Umbraco.Core.PropertyEditors;
1212
using Umbraco.Core.Services;
1313
using Umbraco.Web.PropertyEditors;
14+
using static Our.Umbraco.PropertyList.PropertyListConstants;
1415

1516
namespace Our.Umbraco.PropertyList.PropertyEditors
1617
{
@@ -26,13 +27,9 @@ public override void ConfigureForDisplay(PreValueCollection preValues)
2627
{
2728
base.ConfigureForDisplay(preValues);
2829

29-
if (preValues.PreValuesAsDictionary.ContainsKey("hideLabel"))
30+
if (preValues.PreValuesAsDictionary.ContainsKey(PreValueKeys.HideLabel))
3031
{
31-
var boolAttempt = preValues.PreValuesAsDictionary["hideLabel"].Value.TryConvertTo<bool>();
32-
if (boolAttempt.Success)
33-
{
34-
HideLabel = boolAttempt.Result;
35-
}
32+
HideLabel = preValues.PreValuesAsDictionary[PreValueKeys.HideLabel].Value == "1";
3633
}
3734
}
3835

@@ -48,7 +45,7 @@ public override object ConvertDbToEditor(Property property, PropertyType propert
4845
if (propertyValue.DetectIsJson() == false)
4946
{
5047
var items = string.Join("', '", propertyValue.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries));
51-
propertyValue = $"{{ dtd: '{PropertyListPropertyEditor.DefaultTextstringPropertyEditorGuid}', values: [ '{items}' ] }}";
48+
propertyValue = $"{{ dtd: '{DataTypeGuids.DefaultTextstring}', values: [ '{items}' ] }}";
5249
}
5350

5451
var model = JsonConvert.DeserializeObject<PropertyListValue>(propertyValue);
@@ -57,16 +54,19 @@ public override object ConvertDbToEditor(Property property, PropertyType propert
5754

5855
// Get the associated datatype definition
5956
var dtd = dataTypeService.GetDataTypeDefinitionById(model.DataTypeGuid);
57+
if (dtd == null)
58+
return base.ConvertDbToEditor(property, propertyType, dataTypeService);
6059

6160
// Lookup the property editor
6261
var propEditor = PropertyEditorResolver.Current.GetByAlias(dtd.PropertyEditorAlias);
63-
var propType = new PropertyType(dtd);
62+
if (propEditor == null)
63+
return base.ConvertDbToEditor(property, propertyType, dataTypeService);
64+
65+
var propType = new PropertyType(dtd, propertyType.Alias);
6466

6567
for (var i = 0; i < model.Values.Count; i++)
6668
{
67-
var obj = model.Values[i];
68-
69-
var prop = new Property(propType, obj?.ToString());
69+
var prop = new Property(propType, model.Values[i]);
7070
var newValue = propEditor.ValueEditor.ConvertDbToEditor(prop, propType, dataTypeService);
7171

7272
model.Values[i] = (newValue == null) ? null : JToken.FromObject(newValue);
@@ -87,13 +87,18 @@ public override string ConvertDbToString(Property property, PropertyType propert
8787
return base.ConvertDbToString(property, propertyType, dataTypeService);
8888

8989
var dtd = dataTypeService.GetDataTypeDefinitionById(model.DataTypeGuid);
90+
if (dtd == null)
91+
return base.ConvertDbToString(property, propertyType, dataTypeService);
92+
9093
var propEditor = PropertyEditorResolver.Current.GetByAlias(dtd.PropertyEditorAlias);
91-
var propType = new PropertyType(dtd);
94+
if (propEditor == null)
95+
return base.ConvertDbToString(property, propertyType, dataTypeService);
96+
97+
var propType = new PropertyType(dtd, propertyType.Alias);
9298

9399
for (var i = 0; i < model.Values.Count; i++)
94100
{
95-
var obj = model.Values[i];
96-
var prop = new Property(propType, obj?.ToString());
101+
var prop = new Property(propType, model.Values[i]);
97102
var newValue = propEditor.ValueEditor.ConvertDbToString(prop, propType, dataTypeService);
98103

99104
model.Values[i] = newValue;
@@ -113,13 +118,18 @@ public override XNode ConvertDbToXml(Property property, PropertyType propertyTyp
113118
return base.ConvertDbToXml(property, propertyType, dataTypeService);
114119

115120
var dtd = dataTypeService.GetDataTypeDefinitionById(model.DataTypeGuid);
121+
if (dtd == null)
122+
return base.ConvertDbToXml(property, propertyType, dataTypeService);
123+
116124
var propEditor = PropertyEditorResolver.Current.GetByAlias(dtd.PropertyEditorAlias);
117-
var propType = new PropertyType(dtd);
125+
if (propEditor == null)
126+
return base.ConvertDbToXml(property, propertyType, dataTypeService);
127+
128+
var propType = new PropertyType(dtd, propertyType.Alias);
118129

119130
for (var i = 0; i < model.Values.Count; i++)
120131
{
121-
var obj = model.Values[i];
122-
var prop = new Property(propType, obj?.ToString());
132+
var prop = new Property(propType, model.Values[i]);
123133
var newValue = propEditor.ValueEditor.ConvertDbToXml(prop, propType, dataTypeService);
124134
model.Values[i] = newValue;
125135
}
@@ -140,9 +150,18 @@ public override object ConvertEditorToDb(ContentPropertyData editorValue, object
140150
return base.ConvertEditorToDb(editorValue, currentValue);
141151

142152
var dataTypeService = ApplicationContext.Current.Services.DataTypeService;
153+
143154
var dtd = dataTypeService.GetDataTypeDefinitionById(model.DataTypeGuid);
155+
if (dtd == null)
156+
return base.ConvertEditorToDb(editorValue, currentValue);
157+
144158
var preValues = dataTypeService.GetPreValuesCollectionByDataTypeId(dtd.Id);
159+
if (preValues == null)
160+
return base.ConvertEditorToDb(editorValue, currentValue);
161+
145162
var propEditor = PropertyEditorResolver.Current.GetByAlias(dtd.PropertyEditorAlias);
163+
if (propEditor == null)
164+
return base.ConvertEditorToDb(editorValue, currentValue);
146165

147166
for (var i = 0; i < model.Values.Count; i++)
148167
{

0 commit comments

Comments
 (0)