Initial commit
This commit is contained in:
187
Oqtane.Client/Modules/Admin/Pages/Add.razor
Normal file
187
Oqtane.Client/Modules/Admin/Pages/Add.razor
Normal file
@ -0,0 +1,187 @@
|
||||
@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 ISkinService SkinService
|
||||
|
||||
<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 p in PageState.Pages)
|
||||
{
|
||||
<option value="@p.PageId">@p.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">Skin: </label>
|
||||
</td>
|
||||
<td>
|
||||
<select class="form-control" bind="@skintype">
|
||||
<option value=""><Select Skin></option>
|
||||
@foreach (KeyValuePair<string, string> skin in skins)
|
||||
{
|
||||
<option value="@skin.Key">@skin.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 class="btn btn-success" onclick="@SavePage">Save</button>
|
||||
<NavLink class="btn btn" href="@NavigateUrl()">Cancel</NavLink>
|
||||
|
||||
@functions {
|
||||
public override SecurityAccessLevelEnum SecurityAccessLevel { get { return SecurityAccessLevelEnum.Admin; } }
|
||||
|
||||
Dictionary<string, string> skins = new Dictionary<string, string>();
|
||||
Dictionary<string, string> panelayouts = new Dictionary<string, string>();
|
||||
|
||||
string name;
|
||||
string path;
|
||||
string parentid;
|
||||
string order = "";
|
||||
string isnavigation = "True";
|
||||
string skintype;
|
||||
string layouttype = "";
|
||||
string icon = "";
|
||||
string viewpermissions = "All Users";
|
||||
string editpermissions = "Administrators";
|
||||
|
||||
protected override async Task OnInitAsync()
|
||||
{
|
||||
List<Skin> Skins = await SkinService.GetSkinsAsync();
|
||||
foreach (Skin skin in Skins)
|
||||
{
|
||||
foreach (string skincontrol in skin.SkinControls.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries))
|
||||
{
|
||||
skins.Add(skincontrol, skin.Name + " - " + @Utilities.GetTypeNameClass(skincontrol));
|
||||
}
|
||||
foreach (string panelayout in skin.PaneLayouts.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries))
|
||||
{
|
||||
panelayouts.Add(panelayout, skin.Name + " - " + @Utilities.GetTypeNameClass(panelayout));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async Task SavePage()
|
||||
{
|
||||
Page p = new Page();
|
||||
p.SiteId = PageState.Page.SiteId;
|
||||
if (string.IsNullOrEmpty(parentid))
|
||||
{
|
||||
p.ParentId = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
p.ParentId = Int32.Parse(parentid);
|
||||
}
|
||||
p.Name = name;
|
||||
p.Path = path;
|
||||
p.Order = (order == null ? 1 : Int32.Parse(order));
|
||||
p.IsNavigation = (isnavigation == null ? true : Boolean.Parse(isnavigation));
|
||||
p.SkinType = skintype;
|
||||
p.LayoutType = (layouttype == null ? "" : layouttype);
|
||||
p.Icon = (icon == null ? "" : icon);
|
||||
Type type;
|
||||
if (!string.IsNullOrEmpty(layouttype))
|
||||
{
|
||||
type = Type.GetType(layouttype);
|
||||
}
|
||||
else
|
||||
{
|
||||
type = Type.GetType(skintype);
|
||||
}
|
||||
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);
|
||||
StateHasChanged();
|
||||
UriHelper.NavigateTo(NavigateUrl(path, true));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user