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:
Shaun Walker
2019-11-04 23:29:35 -05:00
parent 156f5b5f94
commit ab564f7244
32 changed files with 737 additions and 732 deletions

View File

@ -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>&nbsp;</th>
<th>&nbsp;</th>
<th>Name</th>
<th>&nbsp;</th>
<th>&nbsp;</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);
}
}
}