modified all admin UIs to position action buttons on the left side of grids and implemented ActionDialog throughout rather than dedicated delete components
This commit is contained in:
@ -1,181 +0,0 @@
|
||||
@namespace Oqtane.Modules.Admin.Pages
|
||||
@inherits ModuleBase
|
||||
@inject NavigationManager NavigationManager
|
||||
@inject IPageService PageService
|
||||
@inject IThemeService ThemeService
|
||||
|
||||
<table class="table table-borderless">
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Name: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input class="form-control" @bind="@name" disabled />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Path: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input class="form-control" @bind="@path" disabled />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Parent: </label>
|
||||
</td>
|
||||
<td>
|
||||
<select class="form-control" @bind="@parentid" disabled>
|
||||
<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">Navigation? </label>
|
||||
</td>
|
||||
<td>
|
||||
<select class="form-control" @bind="@isnavigation" disabled>
|
||||
<option value="True">Yes</option>
|
||||
<option value="False">No</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Default Mode? </label>
|
||||
</td>
|
||||
<td>
|
||||
<select class="form-control" @bind="@mode" disabled>
|
||||
<option value="view">View Mode</option>
|
||||
<option value="edit">Edit Mode</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Theme: </label>
|
||||
</td>
|
||||
<td>
|
||||
<select class="form-control" @bind="@themetype" disabled>
|
||||
<option value=""><Select Theme></option>
|
||||
@foreach (KeyValuePair<string, string> item in themes)
|
||||
{
|
||||
if (item.Key == themetype)
|
||||
{
|
||||
<option value="@item.Key" selected>@item.Value</option>
|
||||
}
|
||||
else
|
||||
{
|
||||
<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" disabled>
|
||||
<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" disabled />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<button type="button" class="btn btn-danger" @onclick="DeletePage">Delete</button>
|
||||
<NavLink class="btn btn-secondary" href="@NavigateUrl()">Cancel</NavLink>
|
||||
<br />
|
||||
<br />
|
||||
<AuditInfo CreatedBy="@createdby" CreatedOn="@createdon" ModifiedBy="@modifiedby" ModifiedOn="@modifiedon" DeletedBy="@deletedby" DeletedOn="@deletedon"></AuditInfo>
|
||||
|
||||
@code {
|
||||
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.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 isnavigation;
|
||||
string mode;
|
||||
string themetype;
|
||||
string layouttype;
|
||||
string icon;
|
||||
string permissions;
|
||||
string createdby;
|
||||
DateTime createdon;
|
||||
string modifiedby;
|
||||
DateTime modifiedon;
|
||||
string deletedby;
|
||||
DateTime? deletedon;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
themes = ThemeService.GetThemeTypes(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;
|
||||
isnavigation = page.IsNavigation.ToString();
|
||||
mode = (page.EditMode) ? "edit" : "view";
|
||||
themetype = page.ThemeType;
|
||||
panelayouts = ThemeService.GetPaneLayoutTypes(PageState.Themes, themetype);
|
||||
layouttype = page.LayoutType;
|
||||
icon = page.Icon;
|
||||
permissions = page.Permissions;
|
||||
createdby = page.CreatedBy;
|
||||
createdon = page.CreatedOn;
|
||||
modifiedby = page.ModifiedBy;
|
||||
modifiedon = page.ModifiedOn;
|
||||
deletedby = page.DeletedBy;
|
||||
deletedon = page.DeletedOn;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await logger.LogError(ex, "Error Loading Page {PageId} {Error}", PageId, ex.Message);
|
||||
AddModuleMessage("Error Loading Page", MessageType.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task DeletePage()
|
||||
{
|
||||
try
|
||||
{
|
||||
await PageService.DeletePageAsync(PageId);
|
||||
await logger.LogInformation("Page Deleted {PageId}", PageId);
|
||||
NavigationManager.NavigateTo(NavigateUrl("", Reload.Site)); // redirect to home page
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await logger.LogError(ex, "Error Deleting Page {PageId} {Error}", PageId, ex.Message);
|
||||
AddModuleMessage("Error Deleting Page", MessageType.Error);
|
||||
}
|
||||
}
|
||||
}
|
@ -5,18 +5,18 @@
|
||||
|
||||
@if (PageState.Pages != null)
|
||||
{
|
||||
<ActionLink Action="Add" Text="Add Page" Style="float: right; margin: 10px;" />
|
||||
<ActionLink Action="Add" Text="Add Page" />
|
||||
|
||||
<Pager Items="@PageState.Pages.Where(item => !item.IsDeleted)">
|
||||
<Header>
|
||||
<th> </th>
|
||||
<th> </th>
|
||||
<th>Name</th>
|
||||
<th> </th>
|
||||
<th> </th>
|
||||
</Header>
|
||||
<Row>
|
||||
<td>@(new string('-', context.Level * 2))@(context.Name)</td>
|
||||
<td><ActionLink Action="Edit" Parameters="@($"id=" + context.PageId.ToString())" /></td>
|
||||
<td><button @onclick="@(() => Delete(context))" class="btn btn-danger">Delete</button></td>
|
||||
<td><ActionDialog Header="Delete Page" Message="@("Are You Sure You Wish To Delete The " + context.Name + " Page?")" Action="Delete" Security="SecurityAccessLevel.Admin" Class="btn btn-danger" OnClick="@(async () => await DeletePage(context))" /></td>
|
||||
<td>@(new string('-', context.Level * 2))@(context.Name)</td>
|
||||
</Row>
|
||||
</Pager>
|
||||
}
|
||||
@ -24,18 +24,19 @@
|
||||
@code {
|
||||
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Admin; } }
|
||||
|
||||
private async Task Delete(Page Page)
|
||||
private async Task DeletePage(Page Page)
|
||||
{
|
||||
try
|
||||
{
|
||||
Page.IsDeleted = true;
|
||||
await PageService.UpdatePageAsync(Page);
|
||||
await logger.LogInformation("Page Deleted {Page}", Page);
|
||||
NavigationManager.NavigateTo(NavigateUrl("admin/pages", Reload.Site));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await logger.LogError(ex, "Error Loading Pages {Error}", ex.Message);
|
||||
AddModuleMessage("Error Loading Pages", MessageType.Error);
|
||||
await logger.LogError(ex, "Error Deleting Page {Page} {Error}", Page, ex.Message);
|
||||
AddModuleMessage("Error Deleting Page", MessageType.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user