231 lines
6.9 KiB
Plaintext
231 lines
6.9 KiB
Plaintext
@using Microsoft.AspNetCore.Components.Routing
|
|
@using Oqtane.Models
|
|
@using Oqtane.Services
|
|
@using Oqtane.Modules
|
|
@using Oqtane.Shared
|
|
@using Oqtane.Client.Modules.Controls
|
|
@inherits ModuleBase
|
|
@inject IUriHelper UriHelper
|
|
@inject IPageService PageService
|
|
@inject IThemeService ThemeService
|
|
|
|
@message
|
|
|
|
<table class="form-group">
|
|
<tr>
|
|
<td>
|
|
<label for="Name" class="control-label">Name: </label>
|
|
</td>
|
|
<td>
|
|
<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>
|
|
</td>
|
|
<td>
|
|
<select class="form-control" @bind="@parentid">
|
|
<option value=""><Select Parent></option>
|
|
@foreach (Page page in PageState.Pages)
|
|
{
|
|
<option value="@(page.PageId)">@(page.Name)</option>
|
|
}
|
|
</select>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td>
|
|
<label for="Name" class="control-label">Order: </label>
|
|
</td>
|
|
<td>
|
|
<input class="form-control" @bind="@order" />
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td>
|
|
<label for="Name" class="control-label">Navigation? </label>
|
|
</td>
|
|
<td>
|
|
<select class="form-control" @bind="@isnavigation">
|
|
<option value="True">Yes</option>
|
|
<option value="False">No</option>
|
|
</select>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td>
|
|
<label for="Name" class="control-label">Theme: </label>
|
|
</td>
|
|
<td>
|
|
<select class="form-control" @bind="@themetype">
|
|
<option value=""><Select Theme></option>
|
|
@foreach (KeyValuePair<string, string> item in themes)
|
|
{
|
|
<option value="@item.Key">@item.Value</option>
|
|
}
|
|
</select>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td>
|
|
<label for="Name" class="control-label">Layout: </label>
|
|
</td>
|
|
<td>
|
|
<select class="form-control" @bind="@layouttype">
|
|
<option value=""><Select Layout></option>
|
|
@foreach (KeyValuePair<string, string> panelayout in panelayouts)
|
|
{
|
|
<option value="@panelayout.Key">@panelayout.Value</option>
|
|
}
|
|
</select>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td>
|
|
<label for="Name" class="control-label">Icon: </label>
|
|
</td>
|
|
<td>
|
|
<input class="form-control" @bind="@icon" />
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td>
|
|
<label for="Name" class="control-label">View Permissions: </label>
|
|
</td>
|
|
<td>
|
|
<input class="form-control" @bind="@viewpermissions" />
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td>
|
|
<label for="Name" class="control-label">Edit Permissions: </label>
|
|
</td>
|
|
<td>
|
|
<input class="form-control" @bind="@editpermissions" />
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
<button type="button" class="btn btn-success" @onclick="@SavePage">Save</button>
|
|
<NavLink class="btn btn-secondary" href="@NavigateUrl()">Cancel</NavLink>
|
|
<br /><br />
|
|
<AuditInfo CreatedBy="@createdby" CreatedOn="@createdon" ModifiedBy="@modifiedby" ModifiedOn="@modifiedon"></AuditInfo>
|
|
|
|
@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>();
|
|
|
|
int PageId;
|
|
string name;
|
|
string path;
|
|
string parentid;
|
|
string order;
|
|
string isnavigation;
|
|
string themetype;
|
|
string layouttype;
|
|
string icon;
|
|
string viewpermissions;
|
|
string editpermissions;
|
|
string createdby;
|
|
DateTime createdon;
|
|
string modifiedby;
|
|
DateTime modifiedon;
|
|
|
|
protected override void OnInitialized()
|
|
{
|
|
try
|
|
{
|
|
themes = ThemeService.GetThemeTypes(PageState.Themes);
|
|
panelayouts = ThemeService.GetPaneLayoutTypes(PageState.Themes);
|
|
|
|
PageId = Int32.Parse(PageState.QueryString["id"]);
|
|
Page page = PageState.Pages.Where(item => item.PageId == PageId).FirstOrDefault();
|
|
if (page != null)
|
|
{
|
|
name = page.Name;
|
|
path = page.Path;
|
|
if (page.ParentId == null)
|
|
{
|
|
parentid = "";
|
|
}
|
|
else
|
|
{
|
|
parentid = page.ParentId.ToString();
|
|
}
|
|
order = page.Order.ToString();
|
|
isnavigation = page.IsNavigation.ToString();
|
|
themetype = page.ThemeType;
|
|
layouttype = page.LayoutType;
|
|
icon = page.Icon;
|
|
viewpermissions = page.ViewPermissions;
|
|
editpermissions = page.EditPermissions;
|
|
createdby = page.CreatedBy;
|
|
createdon = page.CreatedOn;
|
|
modifiedby = page.ModifiedBy;
|
|
modifiedon = page.ModifiedOn;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
message = ex.Message;
|
|
}
|
|
}
|
|
|
|
private async Task SavePage()
|
|
{
|
|
try
|
|
{
|
|
Page page = PageState.Page;
|
|
page.PageId = Int32.Parse(PageState.QueryString["id"]);
|
|
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.UpdatePageAsync(page);
|
|
|
|
PageState.Reload = Constants.ReloadSite;
|
|
UriHelper.NavigateTo(NavigateUrl(path));
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
message = ex.Message;
|
|
}
|
|
}
|
|
}
|