Skip to content

Commit

Permalink
Merge pull request #99 from leekelleher/dev/v1.4.1
Browse files Browse the repository at this point in the history
Preparing v1.4.1 release
  • Loading branch information
leekelleher authored Apr 21, 2021
2 parents 8e1474e + bd465a7 commit 8e8343e
Show file tree
Hide file tree
Showing 26 changed files with 206 additions and 23 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.4.0
1.4.1
Binary file modified docs/editors/code-editor--configuration-editor.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/editors/code-editor--property-editor-01.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 7 additions & 1 deletion docs/editors/data-list.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public IEnumerable<ConfigurationField> Fields => new ConfigurationField[]
}
}
```
#### Providing custom values for published content
#### Providing custom values for published content models

As explained in the [*How to get the value?*](#how-to-get-the-value) section, the values from your data source will be either `string` or `IEnumerable<string>` by default.

Expand Down Expand Up @@ -184,6 +184,12 @@ This interface contains two properties, `View` and `DefaultConfig` _(optional)_,

The `View` property should set the path of the AngularJS view file. This can be whatever you want it to be. The only requirement is that the AngularJS controller (for the view) will be passed the data source items, (an object array - a serialization of the `DataListItem` model), accessible by `$scope.model.config.items`.

#### Using dependency injection (IoC/DI)

It is worth noting that both the `IDataListSource` and `IDataListEditor` types support [Umbraco's approach for injecting dependencies](https://our.umbraco.com/documentation/reference/using-ioc/#injecting-dependencies). You can use any registered services, factories, helpers by adding them to the class constructor of your custom data-source/list-editor.
For an example, you can see how this is done with the [`UmbracoContentDataListSource` data-source](https://github.com/leekelleher/umbraco-contentment/blob/develop/src/Umbraco.Community.Contentment/DataEditors/DataList/DataSources/UmbracoContentDataListSource.cs#L23-L27).

### How to get the value?

Expand Down
Binary file modified docs/editors/number-input--configuration-editor.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/editors/number-input--property-editor-01.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/editors/text-input--configuration-editor.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/editors/text-input--property-editor-01.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public sealed class ButtonsDataListEditor : IDataListEditor
{ ShowDescriptionsConfigurationField.ShowDescriptions, Constants.Values.True },
}
},
new AllowClearConfigurationField(),
new ConfigurationField
{
Key = "enableMultiple",
Expand Down
22 changes: 22 additions & 0 deletions src/Umbraco.Community.Contentment/DataEditors/Buttons/buttons.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ angular.module("umbraco").controller("Umbraco.Community.Contentment.DataEditors.
// console.log("buttons.model", $scope.model);

var defaultConfig = {
allowClear: 0,
defaultIcon: "icon-science",
defaultValue: [],
items: [],
Expand Down Expand Up @@ -59,6 +60,27 @@ angular.module("umbraco").controller("Umbraco.Community.Contentment.DataEditors.
});

vm.select = select;

if ($scope.umbProperty) {

vm.propertyActions = [];

if (Object.toBoolean(config.allowClear) === true) {
vm.propertyActions.push({
labelKey: "buttons_clearSelection",
icon: "trash",
method: clear
});
}

$scope.umbProperty.setPropertyActions(vm.propertyActions);
}
};

function clear() {
$scope.model.value = [];
vm.items.forEach(x => x.selected = false);
setDirty();
};

function select(item) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,23 +55,13 @@ public UmbracoEntityDataListSource(IEntityService entityService)

public IEnumerable<ConfigurationField> Fields => new ConfigurationField[]
{
new ConfigurationField
{
Key = NotesConfigurationField.Notes,
Name = nameof(NotesConfigurationField.Notes),
View = NotesDataEditor.DataEditorViewPath,
Config = new Dictionary<string, object>
{
{ "notes", @"<details class=""well well-small"">
new NotesConfigurationField(@"<details class=""well well-small"">
<summary><strong>A note about supported Umbraco entity types.</strong></summary>
<div class=""mt3"">
<p>Umbraco's `EntityService` API has limited support for querying entity types by <abbr title=""Globally Unique Identifier"">GUID</abbr> or <abbr title=""Umbraco Data Identifier"">UDI</abbr>.</p>
<p>Supported entity types are available in the list below.</p>
</div>
</details>" }
},
HideLabel = true
},
</details>", true),
new ConfigurationField
{
Key = "entityType",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ angular.module("umbraco").controller("Umbraco.Community.Contentment.DataEditors.
// TODO: [LK:2021-04-13] Ensure that the edits are valid.
});
}
}, {
labelKey: "clipboard_labelForRemoveAllEntries",
icon: "trash",
method: function () {
$scope.model.value = [];
}
}]);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@

angular.module("umbraco").controller("Umbraco.Community.Contentment.DataEditors.DataTable.Controller", [
"$scope",
function ($scope) {
"Umbraco.Community.Contentment.Services.DevMode",
function ($scope, devModeService) {

// console.log("datatable.model", $scope.model);

Expand All @@ -24,6 +25,10 @@ angular.module("umbraco").controller("Umbraco.Community.Contentment.DataEditors.

$scope.model.value = $scope.model.value || [];

if (Number.isInteger(config.maxItems) === false) {
config.maxItems = Number.parseInt(config.maxItems) || defaultConfig.maxItems;
}

vm.headings = config.fields.map(function (x) { return x.label });
vm.items = [];

Expand All @@ -49,10 +54,10 @@ angular.module("umbraco").controller("Umbraco.Community.Contentment.DataEditors.

vm.usePrevalueEditors = Object.toBoolean(config.usePrevalueEditors) ? true : null;

vm.allowAdd = (config.maxItems === 0 || config.maxItems === "0") || vm.items.length < config.maxItems;
vm.allowAdd = config.maxItems === 0 || vm.items.length < config.maxItems;
vm.allowRemove = true;

vm.sortable = Object.toBoolean(config.disableSorting) === false && (config.maxItems !== 1 && config.maxItems !== "1");
vm.sortable = Object.toBoolean(config.disableSorting) === false && config.maxItems !== 1;

vm.sortableOptions = {
axis: "y",
Expand Down Expand Up @@ -81,22 +86,46 @@ angular.module("umbraco").controller("Umbraco.Community.Contentment.DataEditors.

vm.add = add;
vm.remove = remove;

if ($scope.umbProperty) {
$scope.umbProperty.setPropertyActions([{
labelKey: "contentment_editRawValue",
icon: "brackets",
method: function () {
devModeService.editValue($scope.model, function () {
// TODO: [LK:2021-04-20] Ensure that the edits are valid.
});
}
}, {
labelKey: "clipboard_labelForRemoveAllEntries",
icon: "trash",
method: function () {
clear();
}
}]);
}
};

function add() {
vm.items.push(angular.copy(config.fields)); // TODO: Replace AngularJS dependency. [LK:2020-12-17]

if ((config.maxItems !== 0 && config.maxItems !== "0") && vm.items.length >= config.maxItems) {
if (config.maxItems !== 0 && vm.items.length >= config.maxItems) {
vm.allowAdd = false;
}

setDirty();
};

function clear() {
vm.items = [];
$scope.model.value = [];
setDirty();
};

function remove($index) {
vm.items.splice($index, 1);

if ((config.maxItems === 0 || config.maxItems === "0") || vm.items.length < config.maxItems) {
if (config.maxItems === 0 || vm.items.length < config.maxItems) {
vm.allowAdd = true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public sealed class ItemPickerDataListEditor : IDataListEditor
}
},
new MaxItemsConfigurationField(),
new AllowClearConfigurationField(),
new ConfigurationField
{
Key = "allowDuplicates",
Expand Down
10 changes: 10 additions & 0 deletions src/Umbraco.Community.Contentment/DataEditors/ItemPicker/README.md
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
## Item Picker

### Used interally by

Item Picker is a cornerstone of Contentment, primarily used by Data List providers.


### Future scope

No.
I'd considered to make this as a standalone property-editor, but it didn't make much sense outside of Data List.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ angular.module("umbraco").controller("Umbraco.Community.Contentment.DataEditors.
// console.log("item-picker.model", $scope.model);

var defaultConfig = {
allowClear: 0,
allowDuplicates: 0,
confirmRemoval: 0,
defaultIcon: "icon-science",
Expand Down Expand Up @@ -83,6 +84,21 @@ angular.module("umbraco").controller("Umbraco.Community.Contentment.DataEditors.
}
}
}

if ($scope.umbProperty) {

vm.propertyActions = [];

if (Object.toBoolean(config.allowClear) === true) {
vm.propertyActions.push({
labelKey: "buttons_clearSelection",
icon: "trash",
method: clear
});
}

$scope.umbProperty.setPropertyActions(vm.propertyActions);
}
};

function add() {
Expand Down Expand Up @@ -125,6 +141,12 @@ angular.module("umbraco").controller("Umbraco.Community.Contentment.DataEditors.
});
};

function clear() {
vm.items = [];
$scope.model.value = [];
setDirty();
};

function remove($index) {
if (config.confirmRemoval === true) {
var keys = ["contentment_removeItemMessage", "general_remove", "general_cancel", "contentment_removeItemButton"];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ angular.module("umbraco").controller("Umbraco.Community.Contentment.DataEditors.

function init() {

$scope.model.value = $scope.model.value || config.defaultValue;
if ($scope.model.value !== 0) {
$scope.model.value = $scope.model.value || config.defaultValue;
}

vm.maximum = config.maximum;
vm.minimum = config.minimum;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public sealed class RadioButtonListDataListEditor : IDataListEditor
{
new ShowDescriptionsConfigurationField(),
new ShowIconsConfigurationField(),
new AllowClearConfigurationField(),
};

public Dictionary<string, object> DefaultValues => default;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ angular.module("umbraco").controller("Umbraco.Community.Contentment.DataEditors.
// console.log("radiobuttonlist.model", $scope.model);

var defaultConfig = {
allowClear: 0,
items: [],
showDescriptions: 0,
showIcons: 0,
Expand All @@ -34,6 +35,24 @@ angular.module("umbraco").controller("Umbraco.Community.Contentment.DataEditors.
vm.uniqueId = $scope.model.hasOwnProperty("dataTypeKey")
? [$scope.model.alias, $scope.model.dataTypeKey.substring(0, 8)].join("-")
: $scope.model.alias;

if ($scope.umbProperty) {

vm.propertyActions = [];

if (Object.toBoolean(config.allowClear) === true) {
vm.propertyActions.push({
labelKey: "buttons_clearSelection",
icon: "trash",
method: function () {
$scope.model.value = null;
// setDirty();
}
});
}

$scope.umbProperty.setPropertyActions(vm.propertyActions);
}
};

init();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public sealed class TagsDataListEditor : IDataListEditor
public IEnumerable<ConfigurationField> Fields => new ConfigurationField[]
{
new ShowIconsConfigurationField(),
new AllowClearConfigurationField(),
new ConfigurationField
{
Key ="confirmRemoval",
Expand Down
21 changes: 21 additions & 0 deletions src/Umbraco.Community.Contentment/DataEditors/Tags/tags.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ angular.module("umbraco").controller("Umbraco.Community.Contentment.DataEditors.
//console.log("tags.model", $scope.model);

var defaultConfig = {
allowClear: 0,
confirmRemoval: 0,
defaultValue: [],
items: [],
Expand Down Expand Up @@ -97,6 +98,20 @@ angular.module("umbraco").controller("Umbraco.Community.Contentment.DataEditors.

});

if ($scope.umbProperty) {

vm.propertyActions = [];

if (Object.toBoolean(config.allowClear) === true) {
vm.propertyActions.push({
labelKey: "buttons_clearSelection",
icon: "trash",
method: clear
});
}

$scope.umbProperty.setPropertyActions(vm.propertyActions);
}
};

function add($event, item) {
Expand All @@ -112,6 +127,12 @@ angular.module("umbraco").controller("Umbraco.Community.Contentment.DataEditors.
});
};

function clear() {
vm.items = [];
$scope.model.value = [];
setDirty();
};

function keyDown($event) {
if ($event.keyCode == 13) {
var tt = vm.editor.data("ttTypeahead");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public sealed class TemplatedListDataListEditor : IDataListEditor
{ "maxLines", 30 },
}
},
new AllowClearConfigurationField(),
new ConfigurationField
{
Key = "enableMultiple",
Expand All @@ -74,7 +75,7 @@ public bool HasMultipleValues(Dictionary<string, object> config)
return config.TryGetValueAs("enableMultiple", out bool enableMultiple) == true && enableMultiple == true;
}

public OverlaySize OverlaySize => OverlaySize.Small;
public OverlaySize OverlaySize => OverlaySize.Medium;

public string View => DataEditorViewPath;
}
Expand Down
Loading

0 comments on commit 8e8343e

Please sign in to comment.