Page management cleanup
This commit is contained in:
@ -8,6 +8,8 @@
|
||||
@inject IPageService PageService
|
||||
@inject IThemeService ThemeService
|
||||
|
||||
@message
|
||||
|
||||
<table class="form-group">
|
||||
<tr>
|
||||
<td>
|
||||
@ -32,9 +34,9 @@
|
||||
<td>
|
||||
<select class="form-control" @bind="@parentid">
|
||||
<option value=""><Select Parent></option>
|
||||
@foreach (Page p in PageState.Pages)
|
||||
@foreach (Page page in PageState.Pages)
|
||||
{
|
||||
<option value="@p.PageId">@p.Name</option>
|
||||
<option value="@(page.PageId)">@(page.Name)</option>
|
||||
}
|
||||
</select>
|
||||
</td>
|
||||
@ -53,8 +55,8 @@
|
||||
</td>
|
||||
<td>
|
||||
<select class="form-control" @bind="@isnavigation">
|
||||
<option value="true">Yes</option>
|
||||
<option value="false">No</option>
|
||||
<option value="True">Yes</option>
|
||||
<option value="False">No</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
@ -117,6 +119,8 @@
|
||||
@code {
|
||||
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Admin; } }
|
||||
|
||||
string message = "";
|
||||
|
||||
Dictionary<string, string> themes = new Dictionary<string, string>();
|
||||
Dictionary<string, string> panelayouts = new Dictionary<string, string>();
|
||||
|
||||
@ -133,44 +137,59 @@
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
themes = ThemeService.GetThemeTypes(PageState.Themes);
|
||||
panelayouts = ThemeService.GetPaneLayoutTypes(PageState.Themes);
|
||||
try
|
||||
{
|
||||
themes = ThemeService.GetThemeTypes(PageState.Themes);
|
||||
panelayouts = ThemeService.GetPaneLayoutTypes(PageState.Themes);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
message = ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task SavePage()
|
||||
{
|
||||
Page p = new Page();
|
||||
p.SiteId = PageState.Page.SiteId;
|
||||
if (string.IsNullOrEmpty(parentid))
|
||||
try
|
||||
{
|
||||
p.ParentId = null;
|
||||
Page page = new Page();
|
||||
page.SiteId = PageState.Page.SiteId;
|
||||
if (string.IsNullOrEmpty(parentid))
|
||||
{
|
||||
page.ParentId = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
page.ParentId = Int32.Parse(parentid);
|
||||
}
|
||||
page.Name = name;
|
||||
page.Path = path;
|
||||
page.Order = (order == null ? 1 : Int32.Parse(order));
|
||||
page.IsNavigation = (isnavigation == null ? true : Boolean.Parse(isnavigation));
|
||||
page.ThemeType = themetype;
|
||||
page.LayoutType = (layouttype == null ? "" : layouttype);
|
||||
page.Icon = (icon == null ? "" : icon);
|
||||
Type type;
|
||||
if (!string.IsNullOrEmpty(layouttype))
|
||||
{
|
||||
type = Type.GetType(layouttype);
|
||||
}
|
||||
else
|
||||
{
|
||||
type = Type.GetType(themetype);
|
||||
}
|
||||
System.Reflection.PropertyInfo property = type.GetProperty("Panes");
|
||||
page.Panes = (string)property.GetValue(Activator.CreateInstance(type), null);
|
||||
page.ViewPermissions = viewpermissions;
|
||||
page.EditPermissions = editpermissions;
|
||||
await PageService.AddPageAsync(page);
|
||||
|
||||
PageState.Reload = Constants.ReloadSite;
|
||||
UriHelper.NavigateTo(NavigateUrl(path));
|
||||
}
|
||||
else
|
||||
catch (Exception ex)
|
||||
{
|
||||
p.ParentId = Int32.Parse(parentid);
|
||||
message = ex.Message;
|
||||
}
|
||||
p.Name = name;
|
||||
p.Path = path;
|
||||
p.Order = (order == null ? 1 : Int32.Parse(order));
|
||||
p.IsNavigation = (isnavigation == null ? true : Boolean.Parse(isnavigation));
|
||||
p.ThemeType = themetype;
|
||||
p.LayoutType = (layouttype == null ? "" : layouttype);
|
||||
p.Icon = (icon == null ? "" : icon);
|
||||
Type type;
|
||||
if (!string.IsNullOrEmpty(layouttype))
|
||||
{
|
||||
type = Type.GetType(layouttype);
|
||||
}
|
||||
else
|
||||
{
|
||||
type = Type.GetType(themetype);
|
||||
}
|
||||
System.Reflection.PropertyInfo property = type.GetProperty("Panes");
|
||||
p.Panes = (string)property.GetValue(Activator.CreateInstance(type), null);
|
||||
p.ViewPermissions = viewpermissions;
|
||||
p.EditPermissions = editpermissions;
|
||||
await PageService.AddPageAsync(p);
|
||||
PageState.Reload = Constants.ReloadSite;
|
||||
UriHelper.NavigateTo(NavigateUrl(path));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user