Skip to content

Commit

Permalink
Merge pull request #90 from AaronSadlerUK/develop
Browse files Browse the repository at this point in the history
Added Description and Parent properties
  • Loading branch information
AaronSadlerUK authored May 30, 2024
2 parents 0d2f16c + 0974abc commit dcd3a43
Show file tree
Hide file tree
Showing 14 changed files with 48 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/dotnet-build-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ jobs:
with:
name: ${{steps.gitversion.outputs.fullSemVer}}
tag_name: ${{steps.gitversion.outputs.fullSemVer}}
prerelease: true
prerelease: false
generate_release_notes: true
files: |
./build.out/Our.Umbraco.UmbNav.Web.${{steps.gitversion.outputs.nuGetVersionV2}}.nupkg
Expand Down
1 change: 1 addition & 0 deletions TestSiteV13/uSync/v9/DataTypes/HomeUmbNavUmbNav.config
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"AllowDisplayAsLabel": true,
"AllowImageIcon": false,
"AllowLabels": true,
"AllowMenuItemDescriptions": false,
"ExpandOnHover": true,
"ExpandOnHoverTimeout": 500,
"HideIncludeChildren": false,
Expand Down
2 changes: 1 addition & 1 deletion src/UmbNav.Api/UmbNav.Api.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<PackageProjectUrl>https://github.com/AaronSadlerUK/Our.Umbraco.UmbNav</PackageProjectUrl>
<Authors>Aaron Sadler</Authors>
<Company>UmbHost Limited</Company>
<Copyright>2022 UmbHost Limited</Copyright>
<Copyright>$([System.DateTime]::Now.ToString(`yyyy`)) UmbHost Limited</Copyright>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<AssemblyVersion>2.0.2</AssemblyVersion>
Expand Down
2 changes: 1 addition & 1 deletion src/UmbNav.Core/Interfaces/IUmbNavMenuBuilderService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ namespace UmbNav.Core.Interfaces
public interface IUmbNavMenuBuilderService
{
IEnumerable<UmbNavItem> BuildMenu(IEnumerable<UmbNavItem> items, int level = 0, bool removeNaviHideItems = false,
bool removeNoopener = false, bool removeNoreferrer = false, bool removeIncludeChildNodes = false);
bool removeNoopener = false, bool removeNoreferrer = false, bool removeIncludeChildNodes = false, bool allowMenuItemDescriptions = false);
}
}
6 changes: 6 additions & 0 deletions src/UmbNav.Core/Models/UmbNavItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ public class UmbNavItem
[JsonProperty("title")]
public string Title { get; set; }

[JsonProperty("menuitemdescription")]
public string Description { get; set; }

[JsonProperty("target")]
public string Target { get; set; }

Expand All @@ -36,6 +39,9 @@ public class UmbNavItem
[JsonProperty("children")]
public IEnumerable<UmbNavItem> Children { get; set; }

[JsonIgnore]
public UmbNavItem Parent { get; set; }

[JsonIgnore]
public IPublishedContent Content { get; set; }

Expand Down
4 changes: 4 additions & 0 deletions src/UmbNav.Core/PropertyEditors/UmbNavConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,9 @@ public class UmbNavConfiguration

[ConfigurationField("showTopAddButton", "Show \"Add Item\" Button", "boolean", Description = "Show the \"Add Item\" button above the nav items in the editor")]
public bool ShowTopAddButton { get; set; } = true;

[ConfigurationField("allowMenuItemDescriptions", "Allow Menu Item Descriptions", "boolean",
Description = "Add a text field to the menu item to contain a description")]
public bool AllowMenuItemDescriptions { get; set; } = false;
}
}
12 changes: 11 additions & 1 deletion src/UmbNav.Core/Services/UmbNavMenuBuilderService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public UmbNavMenuBuilderService(IPublishedSnapshotAccessor publishedSnapshotAcce
}

public IEnumerable<UmbNavItem> BuildMenu(IEnumerable<UmbNavItem> items, int level = 0, bool removeNaviHideItems = false,
bool removeNoopener = false, bool removeNoreferrer = false, bool removeIncludeChildNodes = false)
bool removeNoopener = false, bool removeNoreferrer = false, bool removeIncludeChildNodes = false, bool allowMenuItemDescriptions = false)
{
var umbNavItems = items.ToList();
var removeItems = new List<UmbNavItem>();
Expand Down Expand Up @@ -70,6 +70,11 @@ public IEnumerable<UmbNavItem> BuildMenu(IEnumerable<UmbNavItem> items, int leve
item.Title = item.Name;
}

if (!allowMenuItemDescriptions)
{
item.Description = null;
}

//if (!item.DisplayAsLabel)
//{
// continue;
Expand All @@ -79,6 +84,11 @@ public IEnumerable<UmbNavItem> BuildMenu(IEnumerable<UmbNavItem> items, int leve
var children = new List<UmbNavItem>();
if (item.Children != null && item.Children.Any())
{
foreach (var child in item.Children)
{
child.Parent = item;
}

children = item.Children.ToList();
}

Expand Down
2 changes: 1 addition & 1 deletion src/UmbNav.Core/UmbNav.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<PackageProjectUrl>https://github.com/AaronSadlerUK/Our.Umbraco.UmbNav</PackageProjectUrl>
<Authors>Aaron Sadler</Authors>
<Company>UmbHost Limited</Company>
<Copyright>2023 UmbHost Limited</Copyright>
<Copyright>$([System.DateTime]::Now.ToString(`yyyy`)) UmbHost Limited</Copyright>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<AssemblyVersion>2.0.3</AssemblyVersion>
Expand Down
4 changes: 3 additions & 1 deletion src/UmbNav.Core/ValueConverters/UmbNavValueConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public class UmbNavValueConverter : PropertyValueConverterBase
private bool _removeNoopener;
private bool _removeNoreferrer;
private bool _removeIncludeChildNodes;
private bool _allowMenuItemDescriptions;

public UmbNavValueConverter(ILogger logger, IUmbNavMenuBuilderService umbNavMenuBuilderService)
{
Expand Down Expand Up @@ -49,13 +50,14 @@ public override object ConvertIntermediateToObject(IPublishedElement owner, IPub
_removeNoopener = configuration.HideNoopener;
_removeNoreferrer = configuration.HideNoreferrer;
_removeIncludeChildNodes = configuration.HideIncludeChildren;
_allowMenuItemDescriptions = configuration.AllowMenuItemDescriptions;
}

try
{
var items = JsonConvert.DeserializeObject<IEnumerable<UmbNavItem>>(inter.ToString());

return _umbNavMenuBuilderService.BuildMenu(items, 0, _removeNaviHideItems, _removeNoopener, _removeNoreferrer, _removeIncludeChildNodes);
return _umbNavMenuBuilderService.BuildMenu(items, 0, _removeNaviHideItems, _removeNoopener, _removeNoreferrer, _removeIncludeChildNodes, _allowMenuItemDescriptions);
}
catch (Exception ex)
{
Expand Down
2 changes: 1 addition & 1 deletion src/UmbNav.Web/UmbNav.Web.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<PackageProjectUrl>https://github.com/AaronSadlerUK/Our.Umbraco.UmbNav</PackageProjectUrl>
<Authors>Aaron Sadler</Authors>
<Company>UmbHost Limited</Company>
<Copyright>2023 UmbHost Limited</Copyright>
<Copyright>$([System.DateTime]::Now.ToString(`yyyy`)) UmbHost Limited</Copyright>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<AssemblyVersion>2.0.8</AssemblyVersion>
Expand Down
2 changes: 2 additions & 0 deletions src/UmbNav.Web/wwwroot/js/umbnav.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@
hideIncludeChildren: dialogOptions.config.hideIncludeChildren,
allowLabels: dialogOptions.config.allowLabels,
allowDisplayAsLabel: dialogOptions.config.allowDisplayAsLabel,
allowMenuItemDescriptions: dialogOptions.config.allowMenuItemDescriptions,
currentTarget: item,
submit: function (model) {

Expand Down Expand Up @@ -188,6 +189,7 @@
description: url,
collapsed: data.collapsed,
title: data.title,
menuitemdescription: data.menuitemdescription,
target: data.target,
noopener: data.noopener,
noreferrer: data.noreferrer,
Expand Down
1 change: 1 addition & 0 deletions src/UmbNav.Web/wwwroot/js/umbnav.settings.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
$scope.showCustomClasses = $scope.model.allowCustomClasses === true;
$scope.showImageIcon = $scope.model.allowImageIcon === true;
$scope.allowLabels = $scope.model.allowLabels === true;
$scope.allowMenuItemDescriptions = $scope.model.allowMenuItemDescriptions === true;
$scope.showAdvancedBlock = showAdvanced();
if (!$scope.allowLabels) {
$scope.model.target.itemType = 'link';
Expand Down
2 changes: 2 additions & 0 deletions src/UmbNav.Web/wwwroot/lang/en-us.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
<key alias="label">Label</key>
<key alias="menuItem">Menu Item</key>
<key alias="title">Title</key>
<key alias="description">Description</key>
<key alias="descriptionPlaceholder">Enter a description...</key>
<key alias="itemType">Menu Item Type</key>
<key alias="linkTypeDescription">Select menu item type</key>
<key alias="displayAsLabel">Display as label</key>
Expand Down
14 changes: 13 additions & 1 deletion src/UmbNav.Web/wwwroot/views/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,12 @@
ng-model="model.target.title"
ng-required="!model.target.name" />
</umb-control-group>

<umb-control-group label="@umbnav_description" ng-if="allowMenuItemDescriptions === true">
<textarea localize="placeholder"
placeholder="@umbnav_descriptionPlaceholder"
class="umb-property-editor umb-textstring"
ng-model="model.target.menuitemdescription"></textarea>
</umb-control-group>
<umb-control-group ng-if="showTarget && model.target.itemType == 'link'" label="@content_target">
<umb-checkbox model="vm.openInNewWindow"
on-change="vm.toggleOpenInNewWindow(model, value)"
Expand Down Expand Up @@ -128,6 +133,13 @@ <h5>
ng-model="model.target.title"
ng-required="!model.target.name" />
</umb-control-group>
<umb-control-group label="@umbnav_description" ng-if="allowMenuItemDescriptions">
<textarea localize="placeholder"
placeholder="@umbnav_descriptionPlaceholder"
class="umb-property-editor umb-textstring"
ng-model="model.target.menuitemdescription"></textarea>
</umb-control-group>
Show Description: {{allowMenuItemDescriptions}}
</div>
</umb-box-content>
</umb-box>
Expand Down

0 comments on commit dcd3a43

Please sign in to comment.