This repository has been archived on 2025-05-14. You can view files and clone it, but cannot push or open issues or pull requests.
Mitchel Sellers f8a048e5ac ActionLink Improvements
Adjustment to ActionLink component to support custom button classes.  Adjustment of all button styles inside of the project to swap to either btn-danger for delete operations or btn-secondary for cancel operations for consistency.
2019-05-17 23:55:55 -05:00

211 lines
6.4 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
<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="">&lt;Select Parent&gt;</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">Theme: </label>
</td>
<td>
<select class="form-control" bind="@themetype">
<option value="">&lt;Select Theme&gt;</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="">&lt;Select Layout&gt;</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-secondary" href="@NavigateUrl()">Cancel</NavLink>
@functions {
public override SecurityAccessLevelEnum SecurityAccessLevel { get { return SecurityAccessLevelEnum.Admin; } }
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;
protected override async Task OnInitAsync()
{
List<Theme> Themes = await ThemeService.GetThemesAsync();
foreach (Theme theme in Themes)
{
foreach (string themeControl in theme.ThemeControls.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries))
{
themes.Add(themeControl, theme.Name + " - " + @Utilities.GetTypeNameClass(themeControl));
}
foreach (string panelayout in theme.PaneLayouts.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries))
{
panelayouts.Add(panelayout, theme.Name + " - " + @Utilities.GetTypeNameClass(panelayout));
}
}
PageId = Int32.Parse(PageState.QueryString["id"]);
Page p = PageState.Pages.Where(item => item.PageId == PageId).FirstOrDefault();
if (p != null)
{
name = p.Name;
path = p.Path;
if (p.ParentId == null)
{
parentid = "";
}
else
{
parentid = p.ParentId.ToString();
}
order = p.Order.ToString();
isnavigation = p.IsNavigation.ToString();
themetype = p.ThemeType;
layouttype = p.LayoutType;
icon = p.Icon;
viewpermissions = p.ViewPermissions;
editpermissions = p.EditPermissions;
}
}
private async Task SavePage()
{
Page p = PageState.Page;
p.PageId = Int32.Parse(PageState.QueryString["id"]);
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.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.UpdatePageAsync(p);
UriHelper.NavigateTo(NavigateUrl(path));
}
}