Hierarchical page management improvements
This commit is contained in:
@ -21,56 +21,80 @@
|
||||
<div class="overlay-content">
|
||||
<ul class="nav flex-column">
|
||||
<li class="nav-item px-3">
|
||||
<NavLink class="btn btn-primary" href="@PageUrl("Add")" Match="NavLinkMatch.All">Add Page</NavLink>
|
||||
<NavLink class="btn btn-primary mx-auto" href="@PageUrl("Add")">Add Page</NavLink>
|
||||
</li>
|
||||
<li class="nav-item px-3">
|
||||
<NavLink class="btn btn-primary" href="@PageUrl("Edit")" Match="NavLinkMatch.All">Edit Page</NavLink>
|
||||
<NavLink class="btn btn-primary mx-auto" href="@PageUrl("Edit")">Edit Page</NavLink>
|
||||
</li>
|
||||
<li class="nav-item px-3">
|
||||
<NavLink class="btn btn-primary" href="@PageUrl("Delete")" Match="NavLinkMatch.All">Delete Page</NavLink>
|
||||
<NavLink class="btn btn-primary mx-auto" href="@PageUrl("Delete")">Delete Page</NavLink>
|
||||
</li>
|
||||
</ul>
|
||||
<hr style="width: 100%; color: white; height: 1px; background-color:white;" />
|
||||
<div class="container">
|
||||
<div class="form-group">
|
||||
<label for="Module" class="control-label" style="color: white !important;">Module: </label>
|
||||
@if (moduledefinitions != null)
|
||||
{
|
||||
<select class="form-control" @bind="@moduledefinitionname">
|
||||
<option value=""><Select Module></option>
|
||||
@foreach (var moduledefinition in moduledefinitions)
|
||||
<table class="table table-borderless">
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Module" class="control-label" style="color: white !important;">Module: </label>
|
||||
</td>
|
||||
<td>
|
||||
@if (moduledefinitions != null)
|
||||
{
|
||||
<option value="@moduledefinition.ModuleDefinitionName">@moduledefinition.Name</option>
|
||||
<select class="form-control" @bind="@moduledefinitionname">
|
||||
<option value=""><Select Module></option>
|
||||
@foreach (var moduledefinition in moduledefinitions)
|
||||
{
|
||||
<option value="@moduledefinition.ModuleDefinitionName">@moduledefinition.Name</option>
|
||||
}
|
||||
</select>
|
||||
}
|
||||
</select>
|
||||
}
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="Pane" class="control-label" style="color: white !important;">Pane: </label>
|
||||
<select class="form-control" @bind="@pane">
|
||||
<option value=""><Select Pane></option>
|
||||
@foreach (string pane in PageState.Page.Panes.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries))
|
||||
{
|
||||
<option value="@pane">@pane Pane</option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="Title" class="control-label" style="color: white !important;">Title: </label>
|
||||
<input type="text" name="Title" class="form-control" @bind="@title" />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="Container" class="control-label" style="color: white !important;">Container: </label>
|
||||
<select class="form-control" @bind="@containertype">
|
||||
<option value=""><Select Container></option>
|
||||
@foreach (KeyValuePair<string, string> container in containers)
|
||||
{
|
||||
<option value="@container.Key">@container.Value</option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
<button type="button" class="btn btn-primary" @onclick="AddModule">Add Module To Page</button>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Pane" class="control-label" style="color: white !important;">Pane: </label>
|
||||
</td>
|
||||
<td>
|
||||
<select class="form-control" @bind="@pane">
|
||||
<option value=""><Select Pane></option>
|
||||
@foreach (string pane in PageState.Page.Panes.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries))
|
||||
{
|
||||
<option value="@pane">@pane Pane</option>
|
||||
}
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Title" class="control-label" style="color: white !important;">Title: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" name="Title" class="form-control" @bind="@title" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Container" class="control-label" style="color: white !important;">Container: </label>
|
||||
</td>
|
||||
<td>
|
||||
<select class="form-control" @bind="@containertype">
|
||||
<option value=""><Select Container></option>
|
||||
@foreach (KeyValuePair<string, string> container in containers)
|
||||
{
|
||||
<option value="@container.Key">@container.Value</option>
|
||||
}
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<button type="button" class="btn btn-primary mx-auto" style="width: 100%;" @onclick="@AddModule">Add Module To Page</button>
|
||||
</div>
|
||||
<hr style="width: 100%; color: white; height: 1px; background-color:white;" />
|
||||
<ul class="nav flex-column">
|
||||
<li class="nav-item px-3">
|
||||
<NavLink class="btn btn-primary mx-auto" href="@NavigateUrl("admin")">Admin Dashboard</NavLink>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -6,57 +6,53 @@
|
||||
@using Oqtane.Security
|
||||
@namespace Oqtane.Themes.Controls
|
||||
@inherits ThemeObjectBase
|
||||
@inject IPageService PageService
|
||||
@inject IUserService UserService
|
||||
|
||||
<ul class="nav flex-column">
|
||||
@if (parent != null)
|
||||
{
|
||||
string url = NavigateUrl();
|
||||
<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 && UserSecurity.IsAuthorized(PageState.User, "View", p.Permissions))
|
||||
{
|
||||
string url = NavigateUrl(p.Path);
|
||||
<li class="nav-item px-3">
|
||||
<NavLink @key="@p.PageId" class="nav-link" href="@url" Match="NavLinkMatch.All">
|
||||
<span class="oi @p.Icon" aria-hidden="true"></span> @p.Name
|
||||
</NavLink>
|
||||
</li>
|
||||
}
|
||||
}
|
||||
</ul>
|
||||
@if (menu != "")
|
||||
{
|
||||
@((MarkupString)menu)
|
||||
}
|
||||
|
||||
@code {
|
||||
List<Page> pages;
|
||||
Page parent = null;
|
||||
string menu = "";
|
||||
|
||||
protected override Task OnParametersSetAsync()
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
// if current page has no children
|
||||
if (PageState.Pages.Where(item => item.ParentId == PageState.Page.PageId).FirstOrDefault() == null)
|
||||
int level = -1;
|
||||
int securitylevel = int.MaxValue;
|
||||
|
||||
menu = "<ul class=\"nav flex-column\">\n";
|
||||
|
||||
foreach (Page p in PageState.Pages.Where(item => item.IsNavigation))
|
||||
{
|
||||
// display list of pages which have same parent as current page
|
||||
pages = PageState.Pages.Where(item => item.ParentId == PageState.Page.ParentId).OrderBy(item => item.Order).ToList();
|
||||
// if current page has parent
|
||||
if (PageState.Page.ParentId != null)
|
||||
if (UserSecurity.IsAuthorized(PageState.User, "View", p.Permissions) && p.Level <= securitylevel)
|
||||
{
|
||||
parent = PageState.Pages.Where(item => item.PageId == PageState.Page.ParentId).FirstOrDefault();
|
||||
securitylevel = int.MaxValue;
|
||||
|
||||
menu += "<li class=\"nav-item px-3\">";
|
||||
menu += "<a href=\"" + NavigateUrl(p.Path) + "\" class=\"nav-link\" style=\"padding-left: " + ((p.Level + 1) * 15).ToString() + "px !important;\">";
|
||||
if (p.HasChildren)
|
||||
{
|
||||
menu += "<i class=\"oi oi-chevron-right\"></i>";
|
||||
}
|
||||
if (p.Icon != "")
|
||||
{
|
||||
menu += "<span class=\"oi " + p.Icon + "\" aria-hidden=\"true\"></span>";
|
||||
}
|
||||
menu += p.Name;
|
||||
menu += "</a>\n";
|
||||
menu += "</li>\n";
|
||||
|
||||
level = p.Level;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (securitylevel == int.MaxValue)
|
||||
{
|
||||
securitylevel = p.Level;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// display list of pages which are children of current page
|
||||
pages = PageState.Pages.Where(item => item.ParentId == PageState.Page.PageId).OrderBy(item => item.Order).ToList();
|
||||
// current page is parent
|
||||
parent = PageState.Pages.Where(item => item.ParentId == PageState.Page.ParentId).FirstOrDefault();
|
||||
}
|
||||
return Task.CompletedTask;
|
||||
menu += "</ul>";
|
||||
}
|
||||
}
|
||||
|
@ -1,69 +0,0 @@
|
||||
@using Microsoft.AspNetCore.Components.Routing
|
||||
@using Microsoft.AspNetCore.Components.Web
|
||||
@using Oqtane.Themes
|
||||
@using Oqtane.Services
|
||||
@using Oqtane.Models;
|
||||
@using Oqtane.Security
|
||||
@namespace Oqtane.Themes.Controls
|
||||
@inherits ThemeObjectBase
|
||||
@inject IUserService UserService
|
||||
|
||||
@if (menu != "")
|
||||
{
|
||||
@((MarkupString)menu)
|
||||
}
|
||||
|
||||
@code {
|
||||
string menu = "";
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
int level = -1;
|
||||
int securitylevel = int.MaxValue;
|
||||
|
||||
menu = "<ul class=\"nav flex-column\">\n";
|
||||
foreach (Page p in PageState.Pages.Where(item => item.IsNavigation))
|
||||
{
|
||||
for (int l = p.Level; l < level; l++)
|
||||
{
|
||||
menu += "</ul>\n";
|
||||
menu += "</div>\n";
|
||||
}
|
||||
if (UserSecurity.IsAuthorized(PageState.User, "View", p.Permissions) && p.Level <= securitylevel)
|
||||
{
|
||||
securitylevel = int.MaxValue;
|
||||
if (p.HasChildren)
|
||||
{
|
||||
menu += "<li class=\"nav-item px-3\">\n";
|
||||
menu += "<a class=\"nav-link collapsed\" href=\"#submenu" + p.PageId.ToString() + "\" data-toggle=\"collapse\" data-target=\"#submenu" + p.PageId.ToString() + "\">";
|
||||
menu += "<span class=\"oi " + p.Icon + "\" aria-hidden=\"true\"></span>" + p.Name;
|
||||
menu += "</a>\n";
|
||||
menu += "<div class=\"collapse\" id=\"submenu" + p.PageId.ToString() + "\" aria-expanded=\"false\">\n";
|
||||
menu += "<ul class=\"nav flex-column\">\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
menu += "<li class=\"nav-item px-3\">\n";
|
||||
menu += "<a class=\"nav-link\" href=\"" + NavigateUrl(p.Path) + "\">";
|
||||
menu += "<span class=\"oi " + p.Icon + "\" aria-hidden=\"true\"></span>" + p.Name;
|
||||
menu += "</a>\n";
|
||||
menu += "</li>\n";
|
||||
}
|
||||
level = p.Level;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (securitylevel == int.MaxValue)
|
||||
{
|
||||
securitylevel = p.Level;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int l = 0; l < level; l++)
|
||||
{
|
||||
menu += "</ul>\n";
|
||||
menu += "</div>\n";
|
||||
}
|
||||
menu += "</ul>";
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user