Skip to content

Commit

Permalink
Added support for hiding the property editor label and description
Browse files Browse the repository at this point in the history
  • Loading branch information
abjerner committed May 22, 2023
1 parent 108b0e5 commit 3700c9b
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 3 deletions.
16 changes: 16 additions & 0 deletions src/Limbo.Umbraco.YouTube/PropertyEditors/YouTubeConfiguration.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.YouTube.PropertyEditors {

public class YouTubeConfiguration {

[ConfigurationField("hideLabel", "Hide label", "boolean", Description = "Select whether the label and description of properties using this data type should be hidden.<br /><br />Hiding the label and description can be useful in some cases - eg. to give the video picker a bit more horizontal space.")]
[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.YouTube.PropertyEditors {

public class YouTubeConfigurationEditor : ConfigurationEditor<YouTubeConfiguration> {

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

}

}
27 changes: 25 additions & 2 deletions src/Limbo.Umbraco.YouTube/PropertyEditors/YouTubeEditor.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using Umbraco.Cms.Core.PropertyEditors;
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 @@ -10,6 +13,9 @@ namespace Limbo.Umbraco.YouTube.PropertyEditors {
[DataEditor(EditorAlias, EditorName, EditorView, ValueType = ValueTypes.Json, Group = "Limbo", Icon = EditorIcon)]
public class YouTubeEditor : DataEditor {

private readonly IIOHelper _ioHelper;
private readonly IEditorConfigurationParser _editorConfigurationParser;

#region Constants

internal const string EditorAlias = "Limbo.Umbraco.YouTube";
Expand All @@ -24,7 +30,24 @@ public class YouTubeEditor : DataEditor {

#region Constructors

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

#endregion

#region Member methods

public override IDataValueEditor GetValueEditor(object? configuration) {
IDataValueEditor editor = base.GetValueEditor(configuration);
if (editor is DataValueEditor dve) dve.View += $"?v={YouTubePackage.InformationalVersion}";
return editor;
}

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

#endregion

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
}, 20);
}
}

if (!rawVideoData) {
vm.videoId = null;
vm.title = null,
Expand All @@ -103,6 +103,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 3700c9b

Please sign in to comment.