42 lines
1.3 KiB
Plaintext
42 lines
1.3 KiB
Plaintext
@namespace Oqtane.Modules.Admin.Pages
|
|
@inherits ModuleBase
|
|
@inject NavigationManager NavigationManager
|
|
@inject IPageService PageService
|
|
|
|
@if (PageState.Pages != null)
|
|
{
|
|
<ActionLink Action="Add" Text="Add Page" Style="float: right; margin: 10px;" />
|
|
|
|
<Pager Items="@PageState.Pages.Where(item => !item.IsDeleted)">
|
|
<Header>
|
|
<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>
|
|
</Row>
|
|
</Pager>
|
|
}
|
|
|
|
@code {
|
|
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Admin; } }
|
|
|
|
private async Task Delete(Page Page)
|
|
{
|
|
try
|
|
{
|
|
Page.IsDeleted = true;
|
|
await PageService.UpdatePageAsync(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);
|
|
}
|
|
}
|
|
}
|