Initial commit
This commit is contained in:
58
Oqtane.Client/Skins/Controls/Menu.razor
Normal file
58
Oqtane.Client/Skins/Controls/Menu.razor
Normal file
@ -0,0 +1,58 @@
|
||||
@using Microsoft.AspNetCore.Components.Routing
|
||||
@using Oqtane.Skins
|
||||
@using Oqtane.Services
|
||||
@using Oqtane.Models;
|
||||
@inherits SkinObjectBase
|
||||
@inject IPageService PageService
|
||||
@inject IUserService UserService
|
||||
|
||||
<ul class="nav flex-column">
|
||||
@if (parent != null)
|
||||
{
|
||||
string url = PageState.Alias + parent.Path;
|
||||
<li class="nav-item px-3">
|
||||
<NavLink class="nav-link" href="@parent.Path" Match="NavLinkMatch.All">
|
||||
<span class="oi oi-media-skip-backward" aria-hidden="true"></span> Back
|
||||
</NavLink>
|
||||
</li>
|
||||
}
|
||||
@foreach (var p in pages)
|
||||
{
|
||||
if (p.IsNavigation && UserService.IsAuthorized(PageState.User, p.ViewPermissions))
|
||||
{
|
||||
string url = PageState.Alias + p.Path;
|
||||
<li class="nav-item px-3">
|
||||
<NavLink class="nav-link" href="@url" Match="NavLinkMatch.All">
|
||||
<span class="oi @p.Icon" aria-hidden="true"></span> @p.Name
|
||||
</NavLink>
|
||||
</li>
|
||||
}
|
||||
}
|
||||
</ul>
|
||||
|
||||
@functions {
|
||||
List<Page> pages;
|
||||
Page parent = null;
|
||||
|
||||
protected override void OnInit()
|
||||
{
|
||||
// if current page has no children
|
||||
if (PageState.Pages.Where(item => item.ParentId == PageState.Page.PageId).FirstOrDefault() == null)
|
||||
{
|
||||
// display list of pages which have same parent as current page
|
||||
pages = PageState.Pages.Where(item => item.ParentId == PageState.Page.ParentId).ToList();
|
||||
// if current page has parent
|
||||
if (PageState.Page.ParentId != null)
|
||||
{
|
||||
parent = PageState.Pages.Where(item => item.PageId == PageState.Page.ParentId).FirstOrDefault();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// display list of pages which are children of current page
|
||||
pages = PageState.Pages.Where(item => item.ParentId == PageState.Page.PageId).ToList();
|
||||
// current page is parent
|
||||
parent = PageState.Pages.Where(item => item.ParentId == PageState.Page.ParentId).FirstOrDefault();
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user