Hierarchical page management improvements
This commit is contained in:
parent
61dc27cf32
commit
7d353c2205
|
@ -12,7 +12,7 @@
|
|||
<ul class="list-group">
|
||||
@foreach (var p in pages)
|
||||
{
|
||||
if (p.IsNavigation && UserSecurity.IsAuthorized(PageState.User, "View", p.Permissions))
|
||||
if (UserSecurity.IsAuthorized(PageState.User, "View", p.Permissions))
|
||||
{
|
||||
string url = NavigateUrl(p.Path);
|
||||
<li class="list-group-item">
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
<label for="Name" class="control-label">Permissions: </label>
|
||||
</td>
|
||||
<td>
|
||||
<PermissionGrid EntityName="Module" Permissions="@permissions" @ref="permissiongrid" @ref:suppressField />
|
||||
<PermissionGrid EntityName="Module" Permissions="@permissions" @ref="permissiongrid" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
|
|
@ -23,6 +23,14 @@
|
|||
<input class="form-control" @bind="@name" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Path: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input class="form-control" @bind="@path" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Parent: </label>
|
||||
|
@ -126,7 +134,7 @@
|
|||
<label for="Name" class="control-label">Permissions: </label>
|
||||
</td>
|
||||
<td>
|
||||
<PermissionGrid EntityName="Page" Permissions="@permissions" @ref="permissiongrid" @ref:suppressField />
|
||||
<PermissionGrid EntityName="Page" Permissions="@permissions" @ref="permissiongrid" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
@ -142,7 +150,8 @@
|
|||
Dictionary<string, string> panelayouts = new Dictionary<string, string>();
|
||||
|
||||
List<Page> pages;
|
||||
string name = "";
|
||||
string name;
|
||||
string path = "";
|
||||
string parentid;
|
||||
string insert = ">>";
|
||||
List<Page> children;
|
||||
|
@ -160,8 +169,8 @@
|
|||
{
|
||||
try
|
||||
{
|
||||
pages = PageState.Pages.Where(item => item.IsNavigation).ToList();
|
||||
children = PageState.Pages.Where(item => item.ParentId == null && item.IsNavigation).OrderBy(item => item.Order).ToList();
|
||||
pages = PageState.Pages;
|
||||
children = PageState.Pages.Where(item => item.ParentId == null).ToList();
|
||||
|
||||
themes = ThemeService.GetThemeTypes(PageState.Themes);
|
||||
panelayouts = ThemeService.GetPaneLayoutTypes(PageState.Themes);
|
||||
|
@ -184,11 +193,11 @@
|
|||
parentid = (string)e.Value;
|
||||
if (string.IsNullOrEmpty(parentid))
|
||||
{
|
||||
children = PageState.Pages.Where(item => item.ParentId == null && item.IsNavigation).OrderBy(item => item.Order).ToList();
|
||||
children = PageState.Pages.Where(item => item.ParentId == null).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
children = PageState.Pages.Where(item => item.ParentId == int.Parse(parentid) && item.IsNavigation).OrderBy(item => item.Order).ToList();
|
||||
children = PageState.Pages.Where(item => item.ParentId == int.Parse(parentid)).ToList();
|
||||
}
|
||||
StateHasChanged();
|
||||
}
|
||||
|
@ -205,16 +214,31 @@
|
|||
Page page = new Page();
|
||||
page.SiteId = PageState.Page.SiteId;
|
||||
page.Name = name;
|
||||
if (path == "")
|
||||
{
|
||||
path = name;
|
||||
}
|
||||
if (path.Contains("/"))
|
||||
{
|
||||
path = path.Substring(path.LastIndexOf("/") + 1);
|
||||
}
|
||||
if (string.IsNullOrEmpty(parentid))
|
||||
{
|
||||
page.ParentId = null;
|
||||
page.Path = page.Name.ToLower();
|
||||
page.Path = Utilities.GetFriendlyUrl(path);
|
||||
}
|
||||
else
|
||||
{
|
||||
page.ParentId = Int32.Parse(parentid);
|
||||
Page parent = PageState.Pages.Where(item => item.ParentId == page.ParentId).FirstOrDefault();
|
||||
page.Path = parent.Path + "/" + page.Name.ToLower();
|
||||
Page parent = PageState.Pages.Where(item => item.PageId == page.ParentId).FirstOrDefault();
|
||||
if (parent.Path == "")
|
||||
{
|
||||
page.Path = Utilities.GetFriendlyUrl(parent.Name) + "/" + Utilities.GetFriendlyUrl(path);
|
||||
}
|
||||
else
|
||||
{
|
||||
page.Path = parent.Path + "/" + Utilities.GetFriendlyUrl(path);
|
||||
}
|
||||
}
|
||||
Page child;
|
||||
switch (insert)
|
||||
|
@ -255,7 +279,7 @@
|
|||
await PageService.UpdatePageOrderAsync(page.SiteId, page.ParentId);
|
||||
|
||||
PageState.Reload = Constants.ReloadSite;
|
||||
NavigationManager.NavigateTo(NavigateUrl());
|
||||
NavigationManager.NavigateTo(NavigateUrl(page.Path));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
|
@ -108,7 +108,7 @@
|
|||
<label for="Name" class="control-label">Permissions: </label>
|
||||
</td>
|
||||
<td>
|
||||
<PermissionGrid EntityName="Page" Permissions="@permissions" @ref="permissiongrid" @ref:suppressField />
|
||||
<PermissionGrid EntityName="Page" Permissions="@permissions" @ref="permissiongrid" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
<label for="Name" class="control-label">Path: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input class="form-control" @bind="@path" readonly />
|
||||
<input class="form-control" @bind="@path" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
@ -40,7 +40,14 @@
|
|||
<option value=""><Site Root></option>
|
||||
@foreach (Page page in pages)
|
||||
{
|
||||
<option value="@(page.PageId)">@(new string('-', page.Level * 2))@(page.Name)</option>
|
||||
if (page.PageId.ToString() == parentid)
|
||||
{
|
||||
<option value="@(page.PageId)" selected>@(new string('-', page.Level * 2))@(page.Name)</option>
|
||||
}
|
||||
else
|
||||
{
|
||||
<option value="@(page.PageId)">@(new string('-', page.Level * 2))@(page.Name)</option>
|
||||
}
|
||||
}
|
||||
</select>
|
||||
</td>
|
||||
|
@ -51,7 +58,10 @@
|
|||
</td>
|
||||
<td>
|
||||
<select class="form-control" @bind="@insert">
|
||||
<option value=""><Maintain Current Location></option>
|
||||
@if (parentid == currentparentid)
|
||||
{
|
||||
<option value=""><Maintain Current Location></option>
|
||||
}
|
||||
<option value="<<">To Beginning</option>
|
||||
@if (children != null && children.Count > 0)
|
||||
{
|
||||
|
@ -135,7 +145,7 @@
|
|||
<label for="Name" class="control-label">Permissions: </label>
|
||||
</td>
|
||||
<td>
|
||||
<PermissionGrid EntityName="Page" Permissions="@permissions" @ref="permissiongrid" @ref:suppressField />
|
||||
<PermissionGrid EntityName="Page" Permissions="@permissions" @ref="permissiongrid" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
@ -157,6 +167,7 @@
|
|||
int PageId;
|
||||
string name;
|
||||
string path;
|
||||
string currentparentid;
|
||||
string parentid;
|
||||
string insert = "";
|
||||
List<Page> children;
|
||||
|
@ -178,8 +189,8 @@
|
|||
{
|
||||
try
|
||||
{
|
||||
pages = PageState.Pages.Where(item => item.IsNavigation).ToList();
|
||||
children = PageState.Pages.Where(item => item.ParentId == null && item.IsNavigation).OrderBy(item => item.Order).ToList();
|
||||
pages = PageState.Pages;
|
||||
children = PageState.Pages.Where(item => item.ParentId == null).ToList();
|
||||
|
||||
themes = ThemeService.GetThemeTypes(PageState.Themes);
|
||||
panelayouts = ThemeService.GetPaneLayoutTypes(PageState.Themes);
|
||||
|
@ -190,6 +201,10 @@
|
|||
{
|
||||
name = page.Name;
|
||||
path = page.Path;
|
||||
if (path.Contains("/"))
|
||||
{
|
||||
path = path.Substring(path.LastIndexOf("/") + 1);
|
||||
}
|
||||
if (page.ParentId == null)
|
||||
{
|
||||
parentid = "";
|
||||
|
@ -198,6 +213,7 @@
|
|||
{
|
||||
parentid = page.ParentId.ToString();
|
||||
}
|
||||
currentparentid = parentid;
|
||||
isnavigation = page.IsNavigation.ToString();
|
||||
editmode = page.EditMode.ToString();
|
||||
themetype = page.ThemeType;
|
||||
|
@ -223,11 +239,19 @@
|
|||
parentid = (string)e.Value;
|
||||
if (string.IsNullOrEmpty(parentid))
|
||||
{
|
||||
children = PageState.Pages.Where(item => item.ParentId == null && item.IsNavigation).OrderBy(item => item.Order).ToList();
|
||||
children = PageState.Pages.Where(item => item.ParentId == null).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
children = PageState.Pages.Where(item => item.ParentId == int.Parse(parentid) && item.IsNavigation).OrderBy(item => item.Order).ToList();
|
||||
children = PageState.Pages.Where(item => item.ParentId == int.Parse(parentid)).ToList();
|
||||
}
|
||||
if (parentid == currentparentid)
|
||||
{
|
||||
insert = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
insert = ">>";
|
||||
}
|
||||
StateHasChanged();
|
||||
}
|
||||
|
@ -241,20 +265,35 @@
|
|||
{
|
||||
try
|
||||
{
|
||||
Page page = PageState.Page;
|
||||
int? currentparentid = page.ParentId;
|
||||
page.PageId = Int32.Parse(PageState.QueryString["id"]);
|
||||
Page page = PageState.Pages.Where(item => item.PageId == PageId).FirstOrDefault();
|
||||
string currentpath = page.Path;
|
||||
|
||||
page.Name = name;
|
||||
if (path == "")
|
||||
{
|
||||
path = name;
|
||||
}
|
||||
if (path.Contains("/"))
|
||||
{
|
||||
path = path.Substring(path.LastIndexOf("/") + 1);
|
||||
}
|
||||
if (string.IsNullOrEmpty(parentid))
|
||||
{
|
||||
page.ParentId = null;
|
||||
page.Path = page.Name.ToLower();
|
||||
page.Path = Utilities.GetFriendlyUrl(path);
|
||||
}
|
||||
else
|
||||
{
|
||||
page.ParentId = Int32.Parse(parentid);
|
||||
Page parent = PageState.Pages.Where(item => item.ParentId == page.ParentId).FirstOrDefault();
|
||||
page.Path = parent.Path + "/" + page.Name.ToLower();
|
||||
Page parent = PageState.Pages.Where(item => item.PageId == page.ParentId).FirstOrDefault();
|
||||
if (parent.Path == "")
|
||||
{
|
||||
page.Path = Utilities.GetFriendlyUrl(parent.Name) + "/" + Utilities.GetFriendlyUrl(path);
|
||||
}
|
||||
else
|
||||
{
|
||||
page.Path = parent.Path + "/" + Utilities.GetFriendlyUrl(path);
|
||||
}
|
||||
}
|
||||
if (insert != "")
|
||||
{
|
||||
|
@ -296,10 +335,27 @@
|
|||
page.Permissions = permissiongrid.GetPermissions();
|
||||
await PageService.UpdatePageAsync(page);
|
||||
await PageService.UpdatePageOrderAsync(page.SiteId, page.ParentId);
|
||||
await PageService.UpdatePageOrderAsync(page.SiteId, currentparentid);
|
||||
if (currentparentid == "")
|
||||
{
|
||||
await PageService.UpdatePageOrderAsync(page.SiteId, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
await PageService.UpdatePageOrderAsync(page.SiteId, int.Parse(currentparentid));
|
||||
}
|
||||
|
||||
// update child paths
|
||||
if (parentid != currentparentid)
|
||||
{
|
||||
foreach (Page p in PageState.Pages.Where(item => item.Path.StartsWith(currentpath)))
|
||||
{
|
||||
p.Path = p.Path.Replace(currentpath, page.Path);
|
||||
await PageService.UpdatePageAsync(p);
|
||||
}
|
||||
}
|
||||
|
||||
PageState.Reload = Constants.ReloadSite;
|
||||
NavigationManager.NavigateTo(NavigateUrl());
|
||||
NavigationManager.NavigateTo(NavigateUrl(page.Path));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
|
@ -140,8 +140,12 @@
|
|||
pages = PageState.Pages;
|
||||
}
|
||||
|
||||
// get Url path and querystring
|
||||
// get Url path and querystring ( and remove anchors )
|
||||
string path = new Uri(_absoluteUri).PathAndQuery.Substring(1);
|
||||
if (path.IndexOf("#") != -1)
|
||||
{
|
||||
path = path.Substring(0, path.IndexOf("#"));
|
||||
}
|
||||
|
||||
// parse querystring and remove
|
||||
Dictionary<string, string> querystring = new Dictionary<string, string>();
|
||||
|
@ -189,6 +193,13 @@
|
|||
{
|
||||
page = PageState.Page;
|
||||
}
|
||||
// failsafe in case router cannot locate the home page for the site
|
||||
if (page == null && path == "")
|
||||
{
|
||||
page = pages.FirstOrDefault();
|
||||
path = page.Path;
|
||||
}
|
||||
|
||||
// check if page has changed
|
||||
if (page.Path != path)
|
||||
{
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
using Oqtane.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
|
||||
namespace Oqtane.Shared
|
||||
{
|
||||
|
@ -66,5 +64,128 @@ namespace Oqtane.Shared
|
|||
string[] fragments = typename.Split('.');
|
||||
return fragments[fragments.Length - 1];
|
||||
}
|
||||
|
||||
public static string GetFriendlyUrl(string text)
|
||||
{
|
||||
string result = "";
|
||||
if (text != null)
|
||||
{
|
||||
var normalizedString = text.ToLowerInvariant().Normalize(NormalizationForm.FormD);
|
||||
var stringBuilder = new StringBuilder();
|
||||
var stringLength = normalizedString.Length;
|
||||
var prevdash = false;
|
||||
char c;
|
||||
for (int i = 0; i < stringLength; i++)
|
||||
{
|
||||
c = normalizedString[i];
|
||||
switch (CharUnicodeInfo.GetUnicodeCategory(c))
|
||||
{
|
||||
case UnicodeCategory.LowercaseLetter:
|
||||
case UnicodeCategory.UppercaseLetter:
|
||||
case UnicodeCategory.DecimalDigitNumber:
|
||||
if (c < 128)
|
||||
stringBuilder.Append(c);
|
||||
else
|
||||
stringBuilder.Append(RemapInternationalCharToAscii(c));
|
||||
prevdash = false;
|
||||
break;
|
||||
case UnicodeCategory.SpaceSeparator:
|
||||
case UnicodeCategory.ConnectorPunctuation:
|
||||
case UnicodeCategory.DashPunctuation:
|
||||
case UnicodeCategory.OtherPunctuation:
|
||||
case UnicodeCategory.MathSymbol:
|
||||
if (!prevdash)
|
||||
{
|
||||
stringBuilder.Append('-');
|
||||
prevdash = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
result = stringBuilder.ToString().Trim('-');
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private static string RemapInternationalCharToAscii(char c)
|
||||
{
|
||||
string s = c.ToString().ToLowerInvariant();
|
||||
if ("àåáâäãåą".Contains(s))
|
||||
{
|
||||
return "a";
|
||||
}
|
||||
else if ("èéêëę".Contains(s))
|
||||
{
|
||||
return "e";
|
||||
}
|
||||
else if ("ìíîïı".Contains(s))
|
||||
{
|
||||
return "i";
|
||||
}
|
||||
else if ("òóôõöøőð".Contains(s))
|
||||
{
|
||||
return "o";
|
||||
}
|
||||
else if ("ùúûüŭů".Contains(s))
|
||||
{
|
||||
return "u";
|
||||
}
|
||||
else if ("çćčĉ".Contains(s))
|
||||
{
|
||||
return "c";
|
||||
}
|
||||
else if ("żźž".Contains(s))
|
||||
{
|
||||
return "z";
|
||||
}
|
||||
else if ("śşšŝ".Contains(s))
|
||||
{
|
||||
return "s";
|
||||
}
|
||||
else if ("ñń".Contains(s))
|
||||
{
|
||||
return "n";
|
||||
}
|
||||
else if ("ýÿ".Contains(s))
|
||||
{
|
||||
return "y";
|
||||
}
|
||||
else if ("ğĝ".Contains(s))
|
||||
{
|
||||
return "g";
|
||||
}
|
||||
else if (c == 'ř')
|
||||
{
|
||||
return "r";
|
||||
}
|
||||
else if (c == 'ł')
|
||||
{
|
||||
return "l";
|
||||
}
|
||||
else if (c == 'đ')
|
||||
{
|
||||
return "d";
|
||||
}
|
||||
else if (c == 'ß')
|
||||
{
|
||||
return "ss";
|
||||
}
|
||||
else if (c == 'þ')
|
||||
{
|
||||
return "th";
|
||||
}
|
||||
else if (c == 'ĥ')
|
||||
{
|
||||
return "h";
|
||||
}
|
||||
else if (c == 'ĵ')
|
||||
{
|
||||
return "j";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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>";
|
||||
}
|
||||
}
|
|
@ -439,49 +439,49 @@ GO
|
|||
INSERT [dbo].[Permission] ([SiteId], [EntityName], [EntityId], [PermissionName], [RoleId], [UserId], [IsAuthorized], [CreatedBy], [CreatedOn], [ModifiedBy], [ModifiedOn]) VALUES (1, 'Page', 3, 'Edit', 1, null, 1, '', getdate(), '', getdate())
|
||||
GO
|
||||
INSERT [dbo].[Page] ([PageId], [SiteId], [Name], [Path], [ThemeType], [Icon], [Panes], [ParentId], [Order], [IsNavigation], [LayoutType], [EditMode], [CreatedBy], [CreatedOn], [ModifiedBy], [ModifiedOn])
|
||||
VALUES (4, 1, N'Admin', N'admin', N'Oqtane.Themes.Theme2.Theme2, Oqtane.Client', N'oi-home', N'Top;Bottom', NULL, 7, 1, N'', '', 1, getdate(), '', getdate())
|
||||
VALUES (4, 1, N'Admin', N'admin', N'Oqtane.Themes.Theme2.Theme2, Oqtane.Client', N'oi-home', N'Top;Bottom', NULL, 7, 0, N'', '', 1, getdate(), '', getdate())
|
||||
GO
|
||||
INSERT [dbo].[Permission] ([SiteId], [EntityName], [EntityId], [PermissionName], [RoleId], [UserId], [IsAuthorized], [CreatedBy], [CreatedOn], [ModifiedBy], [ModifiedOn]) VALUES (1, 'Page', 4, 'View', 1, null, 1, '', getdate(), '', getdate())
|
||||
GO
|
||||
INSERT [dbo].[Permission] ([SiteId], [EntityName], [EntityId], [PermissionName], [RoleId], [UserId], [IsAuthorized], [CreatedBy], [CreatedOn], [ModifiedBy], [ModifiedOn]) VALUES (1, 'Page', 4, 'Edit', 1, null, 1, '', getdate(), '', getdate())
|
||||
GO
|
||||
INSERT [dbo].[Page] ([PageId], [SiteId], [Name], [Path], [ThemeType], [Icon], [Panes], [ParentId], [Order], [IsNavigation], [LayoutType], [EditMode], [CreatedBy], [CreatedOn], [ModifiedBy], [ModifiedOn])
|
||||
VALUES (8, 1, N'Site Management', N'admin/sites', N'Oqtane.Themes.Theme2.Theme2, Oqtane.Client', N'', N'Top;Bottom', 4, 1, 1, N'', 1, '', getdate(), '', getdate())
|
||||
VALUES (8, 1, N'Site Management', N'admin/sites', N'Oqtane.Themes.Theme2.Theme2, Oqtane.Client', N'', N'Top;Bottom', 4, 1, 0, N'', 1, '', getdate(), '', getdate())
|
||||
GO
|
||||
INSERT [dbo].[Permission] ([SiteId], [EntityName], [EntityId], [PermissionName], [RoleId], [UserId], [IsAuthorized], [CreatedBy], [CreatedOn], [ModifiedBy], [ModifiedOn]) VALUES (1, 'Page', 8, 'View', 1, null, 1, '', getdate(), '', getdate())
|
||||
GO
|
||||
INSERT [dbo].[Permission] ([SiteId], [EntityName], [EntityId], [PermissionName], [RoleId], [UserId], [IsAuthorized], [CreatedBy], [CreatedOn], [ModifiedBy], [ModifiedOn]) VALUES (1, 'Page', 8, 'Edit', 1, null, 1, '', getdate(), '', getdate())
|
||||
GO
|
||||
INSERT [dbo].[Page] ([PageId], [SiteId], [Name], [Path], [ThemeType], [Icon], [Panes], [ParentId], [Order], [IsNavigation], [LayoutType], [EditMode], [CreatedBy], [CreatedOn], [ModifiedBy], [ModifiedOn])
|
||||
VALUES (5, 1, N'Page Management', N'admin/pages', N'Oqtane.Themes.Theme2.Theme2, Oqtane.Client', N'', N'Top;Bottom', 4, 3, 1, N'', 1, '', getdate(), '', getdate())
|
||||
VALUES (5, 1, N'Page Management', N'admin/pages', N'Oqtane.Themes.Theme2.Theme2, Oqtane.Client', N'', N'Top;Bottom', 4, 3, 0, N'', 1, '', getdate(), '', getdate())
|
||||
GO
|
||||
INSERT [dbo].[Permission] ([SiteId], [EntityName], [EntityId], [PermissionName], [RoleId], [UserId], [IsAuthorized], [CreatedBy], [CreatedOn], [ModifiedBy], [ModifiedOn]) VALUES (1, 'Page', 5, 'View', 1, null, 1, '', getdate(), '', getdate())
|
||||
GO
|
||||
INSERT [dbo].[Permission] ([SiteId], [EntityName], [EntityId], [PermissionName], [RoleId], [UserId], [IsAuthorized], [CreatedBy], [CreatedOn], [ModifiedBy], [ModifiedOn]) VALUES (1, 'Page', 5, 'Edit', 1, null, 1, '', getdate(), '', getdate())
|
||||
GO
|
||||
INSERT [dbo].[Page] ([PageId], [SiteId], [Name], [Path], [ThemeType], [Icon], [Panes], [ParentId], [Order], [IsNavigation], [LayoutType], [EditMode], [CreatedBy], [CreatedOn], [ModifiedBy], [ModifiedOn])
|
||||
VALUES (10, 1, N'Module Management', N'admin/modules', N'Oqtane.Themes.Theme2.Theme2, Oqtane.Client', N'', N'Top;Bottom', 4, 5, 1, N'', 1, '', getdate(), '', getdate())
|
||||
VALUES (10, 1, N'Module Management', N'admin/modules', N'Oqtane.Themes.Theme2.Theme2, Oqtane.Client', N'', N'Top;Bottom', 4, 5, 0, N'', 1, '', getdate(), '', getdate())
|
||||
GO
|
||||
INSERT [dbo].[Permission] ([SiteId], [EntityName], [EntityId], [PermissionName], [RoleId], [UserId], [IsAuthorized], [CreatedBy], [CreatedOn], [ModifiedBy], [ModifiedOn]) VALUES (1, 'Page', 10, 'View', 1, null, 1, '', getdate(), '', getdate())
|
||||
GO
|
||||
INSERT [dbo].[Permission] ([SiteId], [EntityName], [EntityId], [PermissionName], [RoleId], [UserId], [IsAuthorized], [CreatedBy], [CreatedOn], [ModifiedBy], [ModifiedOn]) VALUES (1, 'Page', 10, 'Edit', 1, null, 1, '', getdate(), '', getdate())
|
||||
GO
|
||||
INSERT [dbo].[Page] ([PageId], [SiteId], [Name], [Path], [ThemeType], [Icon], [Panes], [ParentId], [Order], [IsNavigation], [LayoutType], [EditMode], [CreatedBy], [CreatedOn], [ModifiedBy], [ModifiedOn])
|
||||
VALUES (11, 1, N'Theme Management', N'admin/themes', N'Oqtane.Themes.Theme2.Theme2, Oqtane.Client', N'', N'Top;Bottom', 4, 7, 1, N'', 1, '', getdate(), '', getdate())
|
||||
VALUES (11, 1, N'Theme Management', N'admin/themes', N'Oqtane.Themes.Theme2.Theme2, Oqtane.Client', N'', N'Top;Bottom', 4, 7, 0, N'', 1, '', getdate(), '', getdate())
|
||||
GO
|
||||
INSERT [dbo].[Permission] ([SiteId], [EntityName], [EntityId], [PermissionName], [RoleId], [UserId], [IsAuthorized], [CreatedBy], [CreatedOn], [ModifiedBy], [ModifiedOn]) VALUES (1, 'Page', 11, 'View', 1, null, 1, '', getdate(), '', getdate())
|
||||
GO
|
||||
INSERT [dbo].[Permission] ([SiteId], [EntityName], [EntityId], [PermissionName], [RoleId], [UserId], [IsAuthorized], [CreatedBy], [CreatedOn], [ModifiedBy], [ModifiedOn]) VALUES (1, 'Page', 11, 'Edit', 1, null, 1, '', getdate(), '', getdate())
|
||||
GO
|
||||
INSERT [dbo].[Page] ([PageId], [SiteId], [Name], [Path], [ThemeType], [Icon], [Panes], [ParentId], [Order], [IsNavigation], [LayoutType], [EditMode], [CreatedBy], [CreatedOn], [ModifiedBy], [ModifiedOn])
|
||||
VALUES (9, 1, N'User Management', N'admin/users', N'Oqtane.Themes.Theme2.Theme2, Oqtane.Client', N'', N'Top;Bottom', 4, 9, 1, N'', 1, '', getdate(), '', getdate())
|
||||
VALUES (9, 1, N'User Management', N'admin/users', N'Oqtane.Themes.Theme2.Theme2, Oqtane.Client', N'', N'Top;Bottom', 4, 9, 0, N'', 1, '', getdate(), '', getdate())
|
||||
GO
|
||||
INSERT [dbo].[Permission] ([SiteId], [EntityName], [EntityId], [PermissionName], [RoleId], [UserId], [IsAuthorized], [CreatedBy], [CreatedOn], [ModifiedBy], [ModifiedOn]) VALUES (1, 'Page', 9, 'View', 1, null, 1, '', getdate(), '', getdate())
|
||||
GO
|
||||
INSERT [dbo].[Permission] ([SiteId], [EntityName], [EntityId], [PermissionName], [RoleId], [UserId], [IsAuthorized], [CreatedBy], [CreatedOn], [ModifiedBy], [ModifiedOn]) VALUES (1, 'Page', 9, 'Edit', 1, null, 1, '', getdate(), '', getdate())
|
||||
GO
|
||||
INSERT [dbo].[Page] ([PageId], [SiteId], [Name], [Path], [ThemeType], [Icon], [Panes], [ParentId], [Order], [IsNavigation], [LayoutType], [EditMode], [CreatedBy], [CreatedOn], [ModifiedBy], [ModifiedOn])
|
||||
VALUES (16, 1, N'Role Management', N'admin/roles', N'Oqtane.Themes.Theme2.Theme2, Oqtane.Client', N'', N'Top;Bottom', 4, 11, 1, N'', 1, '', getdate(), '', getdate())
|
||||
VALUES (16, 1, N'Role Management', N'admin/roles', N'Oqtane.Themes.Theme2.Theme2, Oqtane.Client', N'', N'Top;Bottom', 4, 11, 0, N'', 1, '', getdate(), '', getdate())
|
||||
GO
|
||||
INSERT [dbo].[Permission] ([SiteId], [EntityName], [EntityId], [PermissionName], [RoleId], [UserId], [IsAuthorized], [CreatedBy], [CreatedOn], [ModifiedBy], [ModifiedOn]) VALUES (1, 'Page', 16, 'View', 1, null, 1, '', getdate(), '', getdate())
|
||||
GO
|
||||
|
|
|
@ -76,14 +76,6 @@ app {
|
|||
color: white;
|
||||
}
|
||||
|
||||
.nav-link[data-toggle].collapsed:after {
|
||||
content: "▾";
|
||||
}
|
||||
|
||||
.nav-link[data-toggle]:not(.collapsed):after {
|
||||
content: "▴";
|
||||
}
|
||||
|
||||
.content {
|
||||
padding-top: 1.1rem;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user