Skip to content

Commit

Permalink
Added data type option to hide the property editor label and description
Browse files Browse the repository at this point in the history
  • Loading branch information
abjerner committed May 18, 2023
1 parent c41866a commit 9d9a1f0
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 2 deletions.
16 changes: 16 additions & 0 deletions src/Limbo.Umbraco.Vimeo/PropertyEditors/VimeoConfiguration.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using Newtonsoft.Json;
using Umbraco.Cms.Core.PropertyEditors;

#pragma warning disable CS1591

namespace Limbo.Umbraco.Vimeo.PropertyEditors {

public class VimeoConfiguration {

[ConfigurationField("hideLabel", "Hide label", "boolean")]
[JsonProperty("hideLabel")]
public bool HideLabel { get; set; }

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using Umbraco.Cms.Core.IO;
using Umbraco.Cms.Core.PropertyEditors;
using Umbraco.Cms.Core.Services;

#pragma warning disable CS1591

namespace Limbo.Umbraco.Vimeo.PropertyEditors {

public class VimeoConfigurationEditor : ConfigurationEditor<VimeoConfiguration> {

public VimeoConfigurationEditor(IIOHelper ioHelper, IEditorConfigurationParser editorConfigurationParser) : base(ioHelper, editorConfigurationParser) { }

}

}
16 changes: 14 additions & 2 deletions src/Limbo.Umbraco.Vimeo/PropertyEditors/VimeoEditor.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.IO;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.PropertyEditors;
using Umbraco.Cms.Core.Services;

#pragma warning disable 1591

Expand All @@ -11,6 +13,9 @@ namespace Limbo.Umbraco.Vimeo.PropertyEditors {
[DataEditor(EditorAlias, EditorName, EditorView, ValueType = ValueTypes.Json, Group = "Limbo", Icon = EditorIcon)]
public class VimeoEditor : DataEditor {

private readonly IIOHelper _ioHelper;
private readonly IEditorConfigurationParser _editorConfigurationParser;

#region Constants

internal const string EditorAlias = "Limbo.Umbraco.Vimeo";
Expand All @@ -25,7 +30,10 @@ public class VimeoEditor : DataEditor {

#region Constructors

public VimeoEditor(IDataValueEditorFactory dataValueEditorFactory) : base(dataValueEditorFactory) { }
public VimeoEditor(IIOHelper ioHelper, IEditorConfigurationParser editorConfigurationParser, IDataValueEditorFactory dataValueEditorFactory) : base(dataValueEditorFactory) {
_ioHelper = ioHelper;
_editorConfigurationParser = editorConfigurationParser;
}

#endregion

Expand All @@ -37,6 +45,10 @@ public override IDataValueEditor GetValueEditor(object? configuration) {
return editor;
}

protected override IConfigurationEditor CreateConfigurationEditor() {
return new VimeoConfigurationEditor(_ioHelper, _editorConfigurationParser);
}

#endregion

}
Expand Down
3 changes: 3 additions & 0 deletions src/Limbo.Umbraco.Vimeo/wwwroot/Scripts/Controllers/Video.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@

function init() {

if (!$scope.model.config) $scope.model.config = {};
$scope.model.hideLabel = $scope.model.config.hideLabel === true;

if (!$scope.model.value || $scope.model.value === "null") {
$scope.model.value = null;
return;
Expand Down

0 comments on commit 9d9a1f0

Please sign in to comment.