Skip to content

Commit

Permalink
Merge pull request #5 from AaronSadlerUK/feature/4-umbnavitem-does-no…
Browse files Browse the repository at this point in the history
…t-contain-a-definiti

4 'UmbNavItem' does not contain a definition for 'Content'
  • Loading branch information
AaronSadlerUK committed Aug 5, 2021
2 parents 060954e + 9c0fccf commit 6f197af
Show file tree
Hide file tree
Showing 9 changed files with 201 additions and 30 deletions.
13 changes: 13 additions & 0 deletions TestSite/Views/Partials/Navigation/TopNavigation.cshtml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@inherits Umbraco.Web.Mvc.UmbracoViewPage
@using UmbNav.Core.Enums
@using UmbNav.Core.Extensions
@using UmbNav.Core.Models
@using Umbraco.Web;
Expand All @@ -8,9 +9,21 @@
}
@foreach (var item in umbNav)
{
var hideChildren = false;
if (item.ItemType == UmbNavItemType.Content && item.Content != null && item.Content.HasProperty("hideChildren"))
{
hideChildren = item.Content.Value<bool>("hideChildren");
}
if (item.Image != null)
{
@item.Image.Url()
}
<a class="nav-link @item.CustomClasses" href="@item.Url()" target="@item.Target" rel="@item.Noopener @item.Noreferrer">@item.Title</a>
if (!hideChildren)
{
foreach (var child in item.Children)
{
<a class="nav-link @child.CustomClasses" href="@child.Url()" target="@child.Target" rel="@child.Noopener @child.Noreferrer">@child.Title</a>
}
}
}
6 changes: 4 additions & 2 deletions TestSite/uSync/v8/Content/people.config
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
"name": "1 column layout",
"sections": [
{
"grid": 12,
"allowAll": true,
"grid": "12",
"rows": []
}
]
Expand All @@ -28,6 +27,9 @@
<featuredPeople>
<Value><![CDATA[]]></Value>
</featuredPeople>
<hideChildren>
<Value><![CDATA[0]]></Value>
</hideChildren>
<keywords>
<Value><![CDATA[[]]]></Value>
</keywords>
Expand Down
157 changes: 135 additions & 22 deletions TestSite/uSync/v8/Content/umbnav.config
Original file line number Diff line number Diff line change
Expand Up @@ -13,45 +13,158 @@
<Template />
</Info>
<Properties>
<mNTP>
<Value><![CDATA[umb://document/616d0f54b8b0450ebe0d2ca4c06672a2,umb://document/eab72f13b22e46d5b2709c196e49a53b]]></Value>
</mNTP>
<umbNavPE>
<Value><![CDATA[[
{
"id": 1123,
"id": 1104,
"udi": "umb://document/ca4249ed2b234337b52263cabe5587d1",
"name": "Home",
"description": "/",
"url": "/",
"children": [],
"children": [
{
"id": 1105,
"udi": "umb://document/ec4aafcc0c254f25a8fe705bfae1d324",
"name": "Products",
"description": "/products/",
"url": "/products/",
"children": [],
"icon": "icon-shopping-basket color-black",
"published": true,
"naviHide": false,
"culture": "undefined",
"noopener": "noopener",
"noreferrer": "noreferrer",
"includeChildNodes": true,
"collapsed": false
}
],
"icon": "icon-home color-black",
"published": true,
"naviHide": false,
"culture": "undefined",
"collapsed": true,
"hideLoggedOut": false,
"itemType": "link",
"imageUrl": "1139",
"image": [
{
"name": "Jan Skovgaard",
"id": 1140,
"udi": "umb://media/cf1ab8dcad0f4a8e974b87b84777b0d6",
"icon": "icon-picture",
"trashed": false,
"key": "cf1ab8dc-ad0f-4a8e-974b-87b84777b0d6",
"parentId": 1129,
"alias": null,
"path": "-1,1129,1140",
"metaData": {
"ContentTypeAlias": "Image",
"UpdateDate": "2021-07-08 13:23:19",
"MediaPath": "/media/g2afpl2w/18720470241_ff77768544_h.jpg",
"IsContainer": false
},
"thumbnail": "/umbraco/backoffice/UmbracoApi/Images/GetBigThumbnail?originalImagePath=%2Fmedia%2Fg2afpl2w%2F18720470241_ff77768544_h.jpg&rnd=0.9369279073083674",
"image": "/media/g2afpl2w/18720470241_ff77768544_h.jpg",
"updateDate": "2021-07-08 13:23:19",
"filtered": null,
"isFolder": false,
"width": "150",
"height": 150,
"aspectRatio": 1,
"selectable": true,
"flexStyle": {
"flex": "1 1 150px",
"max-width": "150px",
"min-width": "100px",
"min-height": "100px"
},
"selected": true
}
]
},
{
"description": "http://www.google.com",
"title": "Hide",
"url": "http://www.google.com",
"children": [
{
"title": "Label",
"children": [],
"icon": "icon-tag",
"itemType": "nolink",
"collapsed": false,
"image": [
{
"name": "Jeavon Leopold",
"id": 1143,
"udi": "umb://media/c0969cab13ab4de9819a848619ac2b5d",
"icon": "icon-picture",
"trashed": false,
"key": "c0969cab-13ab-4de9-819a-848619ac2b5d",
"parentId": 1129,
"alias": null,
"path": "-1,1129,1143",
"metaData": {
"ContentTypeAlias": "Image",
"UpdateDate": "2021-07-08 13:23:20",
"MediaPath": "/media/bilhgyx5/18095416144_44a566a5f4_h.jpg",
"IsContainer": false
},
"thumbnail": "/umbraco/backoffice/UmbracoApi/Images/GetBigThumbnail?originalImagePath=%2Fmedia%2Fbilhgyx5%2F18095416144_44a566a5f4_h.jpg&rnd=0.7586798823010312",
"image": "/media/bilhgyx5/18095416144_44a566a5f4_h.jpg",
"updateDate": "2021-07-08 13:23:20",
"filtered": null,
"isFolder": false,
"width": "150",
"height": 150,
"aspectRatio": 1,
"selectable": true,
"flexStyle": {
"flex": "1 1 150px",
"max-width": "150px",
"min-width": "100px",
"min-height": "100px"
},
"selected": true
}
],
"customClasses": "test"
}
],
"icon": "icon-link",
"itemType": "link",
"collapsed": false
},
{
"id": 1128,
"udi": "umb://document/ec4aafcc0c254f25a8fe705bfae1d324",
"name": "Products",
"description": "/products/",
"url": "/products/",
"children": [],
"icon": "icon-shopping-basket color-black",
"id": 1114,
"udi": "umb://document/e8ad9b65cff64952ac5befe56a60db62",
"name": "People",
"description": "/people/",
"url": "/people/",
"children": [
{
"id": 1115,
"udi": "umb://document/616d0f54b8b0450ebe0d2ca4c06672a2",
"name": "Jan Skovgaard",
"description": "/people/jan-skovgaard/",
"url": "/people/jan-skovgaard/",
"children": [],
"icon": "icon-user-female color-black",
"published": true,
"naviHide": false,
"culture": "undefined",
"itemType": "link"
}
],
"icon": "icon-user-females-alt color-black",
"published": true,
"naviHide": false,
"culture": "undefined",
"noopener": "noopener",
"noreferrer": "noreferrer"
},
{
"description": "#",
"title": "Hide Me",
"hideIfLoggedIn": true,
"url": "#",
"children": [],
"icon": "icon-link",
"hideLoggedIn": false,
"anchor": "#",
"hideLoggedOut": true
"itemType": "link"
}
]]]></Value>
</umbNavPE>
Expand Down
16 changes: 16 additions & 0 deletions TestSite/uSync/v8/ContentTypes/people.config
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,22 @@
<ValidationRegExpMessage></ValidationRegExpMessage>
<LabelOnTop>false</LabelOnTop>
</GenericProperty>
<GenericProperty>
<Key>f134ee73-3bf0-44e4-9df8-033aac8bcc6e</Key>
<Name>Hide Children</Name>
<Alias>hideChildren</Alias>
<Definition>92897bc6-a5f3-4ffe-ae27-f2e7e33dda49</Definition>
<Type>Umbraco.TrueFalse</Type>
<Mandatory>false</Mandatory>
<Validation></Validation>
<Description><![CDATA[]]></Description>
<SortOrder>3</SortOrder>
<Tab>Content</Tab>
<Variations>Nothing</Variations>
<MandatoryMessage></MandatoryMessage>
<ValidationRegExpMessage></ValidationRegExpMessage>
<LabelOnTop>false</LabelOnTop>
</GenericProperty>
</GenericProperties>
<Tabs>
<Tab>
Expand Down
20 changes: 20 additions & 0 deletions TestSite/uSync/v8/ContentTypes/umbnav.config
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,22 @@
</Info>
<Structure />
<GenericProperties>
<GenericProperty>
<Key>459215bf-43ef-4469-8874-4bd0b952a0bc</Key>
<Name>MNTP</Name>
<Alias>mNTP</Alias>
<Definition>4885450e-a60f-42bb-984a-43988baf5283</Definition>
<Type>Umbraco.MultiNodeTreePicker</Type>
<Mandatory>false</Mandatory>
<Validation></Validation>
<Description><![CDATA[]]></Description>
<SortOrder>0</SortOrder>
<Tab>MNTP</Tab>
<Variations>Nothing</Variations>
<MandatoryMessage></MandatoryMessage>
<ValidationRegExpMessage></ValidationRegExpMessage>
<LabelOnTop>false</LabelOnTop>
</GenericProperty>
<GenericProperty>
<Key>ed5df192-95cb-4923-a462-d52a09892147</Key>
<Name>UmbNavPE</Name>
Expand All @@ -37,5 +53,9 @@
<Caption>UmbNav</Caption>
<SortOrder>0</SortOrder>
</Tab>
<Tab>
<Caption>MNTP</Caption>
<SortOrder>1</SortOrder>
</Tab>
</Tabs>
</ContentType>
11 changes: 7 additions & 4 deletions TestSite/uSync/v8/DataTypes/UmbNav.config
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,17 @@
<DatabaseType>Ntext</DatabaseType>
</Info>
<Config><![CDATA[{
"MaxDepth": 1,
"MaxDepth": 0,
"RemoveNaviHideItems": false,
"ExpandOnHover": true,
"ExpandOnHoverTimeout": 2500,
"ExpandOnHover": false,
"ExpandOnHoverTimeout": 0,
"HideNoopener": false,
"HideNoreferrer": false,
"HideIncludeChildren": false,
"AllowDisplay": true,
"HideLabel": true
"AllowCustomClasses": true,
"HideLabel": true,
"AllowImageIcon": true,
"AllowLabels": false
}]]></Config>
</DataType>
2 changes: 1 addition & 1 deletion TestSite/uSync/v8/usync.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<uSync version="8.9.5.0" format="8.9.0">
<Date>2021-07-24T12:17:18</Date>
<Date>2021-08-05T14:58:56</Date>
</uSync>
5 changes: 4 additions & 1 deletion src/UmbNav.Core/Models/UmbNavItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ public class UmbNavItem

[JsonIgnore]
internal IPublishedContent PublishedContentItem { get; set; }


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

[JsonIgnore]
public UmbNavItemType ItemType { get; set; }

Expand Down
1 change: 1 addition & 0 deletions src/UmbNav.Core/Services/UmbNavMenuBuilderService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ public IEnumerable<UmbNavItem> BuildMenu(IEnumerable<UmbNavItem> items, int leve
if (umbracoContent != null)
{
item.ItemType = UmbNavItemType.Content;
item.Content = umbracoContent;

if (removeNaviHideItems && !umbracoContent.IsVisible())
{
Expand Down

0 comments on commit 6f197af

Please sign in to comment.