Skip to content

Commit

Permalink
Merge pull request #116 from leekelleher/dev/v1.4.4
Browse files Browse the repository at this point in the history
Preparing v1.4.4 release
  • Loading branch information
leekelleher authored Jun 8, 2021
2 parents 4b1ff3d + 4e2a095 commit 1a989c0
Show file tree
Hide file tree
Showing 18 changed files with 115 additions and 31 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.4.3
1.4.4
7 changes: 7 additions & 0 deletions docs/editors/data-list.md
Original file line number Diff line number Diff line change
Expand Up @@ -259,3 +259,10 @@ For the **List editor**, select **Item Picker**, _maybe configure it with a nice
![Country picker example, using Data List property-editor, with remote XML data source and Item Picker editor](data-list--example-02-countries.png)


### Further reading

If you are interesting in real-world usage of Data List, here are some articles for further inspiration...

- [Content Editor defined dropdowns/checkboxlists and radiobuttonlists in Umbraco v8 with Contentment](https://dev.to/timgeyssens/content-editor-defined-dropdowns-checkboxlists-and-radiobuttonlists-in-umbraco-v8-with-contentment-123f) - a post by Tim Geyssens.
- [Umbraco Image Crop Picker using Contentment Data List](https://dev.to/leekelleher/umbraco-image-crop-picker-using-contentment-data-list-5coi) - a post by Lee Kelleher (me).
- [Creating an Author Picker Using Contentment](https://skrift.io/issues/creating-an-author-picker-using-contentment/) - Paul Seal's article for Skrift magazine, June 2021.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public sealed class ButtonsDataListEditor : IDataListEditor
{
Key = "defaultIcon",
Name = "Default icon",
Description = "Select an icon to be displayed as the default icon, (for when no icon is available).",
Description = "Select an icon to be displayed as the default icon,<br><em>(for when no icon is available)</em>.",
View = IOHelper.ResolveUrl("~/umbraco/views/propertyeditors/listview/icon.prevalues.html"),
},
new ConfigurationField
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ angular.module("umbraco").controller("Umbraco.Community.Contentment.DataEditors.
});
}

$scope.umbProperty.setPropertyActions(vm.propertyActions);
if (vm.propertyActions.length > 0) {
$scope.umbProperty.setPropertyActions(vm.propertyActions);
}
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ namespace Umbraco.Community.Contentment.DataEditors
{
internal static class ContentBlocksViewHelper
{
private class FakeController : Controller { }
[Core.Composing.HideFromTypeFinder]
private class ContentBlocksFakeController : ControllerBase { protected override void ExecuteCore() { } }

private static readonly RazorViewEngine _viewEngine = new RazorViewEngine
{
Expand All @@ -30,9 +31,9 @@ internal static string RenderPartial(string partialName, ViewDataDictionary view
{
var httpContext = new HttpContextWrapper(HttpContext.Current);

var routeData = new RouteData { Values = { { "controller", nameof(FakeController) } } };
var routeData = new RouteData { Values = { { "controller", nameof(ContentBlocksFakeController) } } };

var controllerContext = new ControllerContext(new RequestContext(httpContext, routeData), new FakeController());
var controllerContext = new ControllerContext(new RequestContext(httpContext, routeData), new ContentBlocksFakeController());

var viewResult = _viewEngine.FindPartialView(controllerContext, partialName, false);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
using System.Collections.Generic;
using System.Linq;
using Examine;
using Examine.LuceneEngine.Providers;
using Examine.Search;
using Umbraco.Core;
using Umbraco.Core.IO;
using Umbraco.Core.PropertyEditors;
using Umbraco.Examine;
using UmbConstants = Umbraco.Core.Constants;

namespace Umbraco.Community.Contentment.DataEditors
Expand All @@ -20,8 +22,41 @@ public sealed class ExamineDataListSource : IDataListSource
private readonly IExamineManager _examineManager;

private const string _defaultNameField = "nodeName";
private const string _defaultValueField = "__Key";
private const string _defaultIconField = "__Icon";
private const string _defaultValueField = UmbracoExamineIndex.NodeKeyFieldName;
private const string _defaultIconField = UmbracoExamineIndex.IconFieldName;

private readonly Dictionary<string, object> _examineFieldConfig = new Dictionary<string, object>
{
{
Constants.Conventions.ConfigurationFieldAliases.Items,
new[]
{
LuceneIndex.CategoryFieldName,
LuceneIndex.ItemIdFieldName,
LuceneIndex.ItemTypeFieldName,
UmbracoExamineIndex.IconFieldName,
UmbracoExamineIndex.IndexPathFieldName,
UmbracoExamineIndex.NodeKeyFieldName,
UmbracoExamineIndex.PublishedFieldName,
UmbracoExamineIndex.UmbracoFileFieldName,
"createDate",
"creatorID",
"creatorName",
"icon",
"id",
"level",
_defaultNameField,
"nodeType",
"parentID",
"path",
"templateID",
"updateDate",
"urlName",
"writerID",
"writerName",
}.Select(x => new DataListItem { Name = x, Value = x })
},
};

public ExamineDataListSource(IExamineManager examineManager)
{
Expand Down Expand Up @@ -74,28 +109,32 @@ public ExamineDataListSource(IExamineManager examineManager)
Key = "nameField",
Name = "Name Field",
Description = "Enter the field name to select the name from the Examine record.",
View = "textstring",
View = IOHelper.ResolveUrl(TextInputDataEditor.DataEditorViewPath),
Config = _examineFieldConfig
},
new ConfigurationField
{
Key = "valueField",
Name = "Value Field",
Description = "Enter the field name to select the value (key) from the Examine record.",
View = "textstring",
View = IOHelper.ResolveUrl(TextInputDataEditor.DataEditorViewPath),
Config = _examineFieldConfig
},
new ConfigurationField
{
Key = "iconField",
Name = "Icon Field",
Description = "<em>(optional)</em> Enter the field name to select the icon from the Examine record.",
View = "textstring",
View = IOHelper.ResolveUrl(TextInputDataEditor.DataEditorViewPath),
Config = _examineFieldConfig
},
new ConfigurationField
{
Key = "descriptionField",
Name = "Description Field",
Description = "<em>(optional)</em> Enter the field name to select the description from the Examine record.",
View = "textstring",
View = IOHelper.ResolveUrl(TextInputDataEditor.DataEditorViewPath),
Config = _examineFieldConfig
},
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public UmbracoContentPropertiesDataListSource(IContentTypeService contentTypeSer

public string Name => "Umbraco Content Properties";

public string Description => "Populate the data source from a Content Type's properties.";
public string Description => "Populate a data source using a Content Type's properties.";

public string Icon => "icon-umbraco";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ public IEnumerable<ConfigurationField> Fields
.Select(x => new DataListItem
{
Icon = Icon,
Description = x.EditorAlias,
Name = x.Name,
Value = Udi.Create(UmbConstants.UdiEntityType.DataType, x.Key).ToString(),
});
Expand All @@ -54,7 +53,6 @@ public IEnumerable<ConfigurationField> Fields
Config = new Dictionary<string, object>
{
{ Constants.Conventions.ConfigurationFieldAliases.Items, items },
{ ShowDescriptionsConfigurationField.ShowDescriptions, Constants.Values.True },
{ ShowIconsConfigurationField.ShowIcons, Constants.Values.True },
{ Constants.Conventions.ConfigurationFieldAliases.DefaultValue, items.FirstOrDefault()?.Value }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,30 @@ public sealed class UserDefinedDataListSource : IDataListSource
{ "confirmRemoval", Constants.Values.True },
{ EnableDevModeConfigurationField.EnableDevMode, Constants.Values.True },
{ MaxItemsConfigurationField.MaxItems, 0 },
{ NotesConfigurationField.Notes, @"
<details class=""well well-small"">
<summary><strong><em>Advanced:</em> Paste in the raw JSON?</strong></summary>
<p>If you have copied the raw JSON from the Data List preview panel, <button class=""btn-reset"" ng-click=""vm.edit()""><strong>you can paste it in here</strong></button>.</p>
<p>The JSON format must be an array of the Data List item structure.<br />For example...</p>
<umb-code-snippet language=""'JSON'"">[
{
""name"": ""Ready"",
""value"": ""value1"",
""icon"": ""icon-stop-alt color-red"",
""description"": ""One for the money.""
}, {
""name"": ""Steady"",
""value"": ""value2"",
""icon"": ""icon-stop-alt color-orange"",
""description"": ""Two for the show.""
}, {
""name"": ""Go!"",
""value"": ""value3"",
""icon"": ""icon-stop-alt color-green"",
""description"": ""Three to get ready. Now go, cat, go.""
}
]</umb-code-snippet>
</details>" },
},
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

<div class="contentment" ng-controller="Umbraco.Community.Contentment.DataEditors.DataList.Editor.Controller as vm">

<div ng-if="vm.notes" class="umb-readonlyvalue" lk-bind-html-template="vm.notes"></div>

<div ui-sortable="vm.sortableOptions" ng-model="model.value">
<div class="lk-data-list-item" ng-repeat="item in model.value">

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ angular.module("umbraco").controller("Umbraco.Community.Contentment.DataEditors.
defaultIcon: "icon-stop",
enableDevMode: 0,
maxItems: 0,
notes: null,
};
var config = Object.assign({}, defaultConfig, $scope.model.config);

Expand Down Expand Up @@ -48,19 +49,18 @@ angular.module("umbraco").controller("Umbraco.Community.Contentment.DataEditors.
}
};

vm.notes = config.notes;

vm.add = add;
vm.edit = edit;
vm.open = open;
vm.remove = remove;

if (Object.toBoolean(config.enableDevMode) === true && $scope.umbProperty) {
$scope.umbProperty.setPropertyActions([{
labelKey: "contentment_editRawValue",
icon: "brackets",
method: function () {
devModeService.editValue($scope.model, function () {
// TODO: [LK:2021-04-13] Ensure that the edits are valid.
});
}
method: edit
}, {
labelKey: "clipboard_labelForRemoveAllEntries",
icon: "trash",
Expand All @@ -87,6 +87,12 @@ angular.module("umbraco").controller("Umbraco.Community.Contentment.DataEditors.

};

function edit() {
devModeService.editValue($scope.model, function () {
// NOTE: Any future validation can be done here.
});
};

function open(item) {

var parts = item.icon.split(" ");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public sealed class ItemPickerDataListEditor : IDataListEditor
{
Key = "defaultIcon",
Name = "Default icon",
Description = "Select an icon to be displayed as the default icon, (for when no icon is available).",
Description = "Select an icon to be displayed as the default icon,<br><em>(for when no icon is available)</em>.",
View = IOHelper.ResolveUrl("~/umbraco/views/propertyeditors/listview/icon.prevalues.html"),
},
new ConfigurationField
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ angular.module("umbraco").controller("Umbraco.Community.Contentment.DataEditors.
});
}

$scope.umbProperty.setPropertyActions(vm.propertyActions);
if (vm.propertyActions.length > 0) {
$scope.umbProperty.setPropertyActions(vm.propertyActions);
}
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,4 @@
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at https://mozilla.org/MPL/2.0/. -->

<div class="umb-readonlyvalue">
<div lk-bind-html-template="model.config.notes"></div>
</div>
<div class="umb-readonlyvalue" lk-bind-html-template="model.config.notes"></div>
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ angular.module("umbraco").controller("Umbraco.Community.Contentment.DataEditors.
});
}

$scope.umbProperty.setPropertyActions(vm.propertyActions);
if (vm.propertyActions.length > 0) {
$scope.umbProperty.setPropertyActions(vm.propertyActions);
}
}
};

Expand Down
5 changes: 3 additions & 2 deletions src/Umbraco.Community.Contentment/DataEditors/Tags/tags.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,9 @@ angular.module("umbraco").controller("Umbraco.Community.Contentment.DataEditors.
});
}

$scope.umbProperty.setPropertyActions(vm.propertyActions);
if (vm.propertyActions.length > 0) {
$scope.umbProperty.setPropertyActions(vm.propertyActions);
}
}
};

Expand Down Expand Up @@ -150,7 +152,6 @@ angular.module("umbraco").controller("Umbraco.Community.Contentment.DataEditors.
};

function keyUp($event, $index) {
console.log("keyUp", $event.keyCode, $index);
if ($event.keyCode === 8 || $event.keyCode === 46) {
remove($index);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ angular.module("umbraco").controller("Umbraco.Community.Contentment.DataEditors.
});
}

$scope.umbProperty.setPropertyActions(vm.propertyActions);
if (vm.propertyActions.length > 0) {
$scope.umbProperty.setPropertyActions(vm.propertyActions);
}
}
};

Expand Down
4 changes: 2 additions & 2 deletions src/Umbraco.Community.Contentment/Properties/VersionInfo.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System.Reflection;

[assembly: AssemblyVersion("1.4")]
[assembly: AssemblyFileVersion("1.4.3")]
[assembly: AssemblyInformationalVersion("1.4.3")]
[assembly: AssemblyFileVersion("1.4.4")]
[assembly: AssemblyInformationalVersion("1.4.4")]

0 comments on commit 1a989c0

Please sign in to comment.