75 lines
2.5 KiB
Text
75 lines
2.5 KiB
Text
@page "/Issues"
|
|
@attribute [Authorize(Roles = RoleService.AdministratorRoleName)]
|
|
@inject IssueService IssueService
|
|
@inject NavigationManager NavigationManager
|
|
@inject IMessageService MessageService
|
|
@inject ILogger<Index> Logger
|
|
|
|
<PageHeader Title="Issues" />
|
|
|
|
<DataTable
|
|
@ref="Table"
|
|
TItem="Issue"
|
|
Size="@TableSize.Small"
|
|
Responsive
|
|
Searchable
|
|
SearchProperty="i => i.Game.Title">
|
|
<RightToolbar>
|
|
<Button OnClick="() => Add()" Type="ButtonType.Primary">Add Issue</Button>
|
|
</RightToolbar>
|
|
<Columns>
|
|
<BoundDataColumn Property="i => i.Game.Title" Title="Game" Include="Game" Sortable />
|
|
<BoundDataColumn Property="i => i.CreatedOn" Title="Opened" Sortable DefaultSortOrder="SortDirection.Descending">
|
|
<LocalTime Value="context.CreatedOn" Relative />
|
|
</BoundDataColumn>
|
|
<BoundDataColumn Property="i => i.CreatedBy != null ? i.CreatedBy.UserName : String.Empty" Title="Created By" Include="CreatedBy" Sortable />
|
|
<BoundDataColumn Property="i => i.ResolvedOn" Title="Resolved" Sortable>
|
|
<LocalTime Value="context.ResolvedOn" />
|
|
</BoundDataColumn>
|
|
<BoundDataColumn Property="i => i.ResolvedBy != null ? i.ResolvedBy.UserName : String.Empty" Title="Resolved By" Include="ResolvedBy" Sortable />
|
|
<DataColumn TData="string" Title="Status" Sortable Filterable>
|
|
@if (context.ResolvedOn == null)
|
|
{
|
|
<Badge Color="BadgeColor.Blue" Text="Open" />
|
|
}
|
|
else
|
|
{
|
|
<Badge Status="BadgeStatus.Success" Text="Resolved" />
|
|
}
|
|
</DataColumn>
|
|
|
|
<DataActions TData="string">
|
|
<a href="/Issues/@(context.Id)" class="ant-btn ant-btn-primary">Edit</a>
|
|
|
|
<Popconfirm OnConfirm="() => Delete(context)" Title="Are you sure you want to delete this issue?">
|
|
<Button Icon="@IconType.Outline.Close" Type="ButtonType.Text" Danger />
|
|
</Popconfirm>
|
|
</DataActions>
|
|
</Columns>
|
|
</DataTable>
|
|
|
|
@code {
|
|
DataTable<Issue> Table;
|
|
|
|
void Add()
|
|
{
|
|
NavigationManager.NavigateTo("/Issues/Add");
|
|
}
|
|
|
|
async Task Delete(Issue issue)
|
|
{
|
|
try
|
|
{
|
|
await IssueService.DeleteAsync(issue);
|
|
|
|
MessageService.Success("Issue was successfully deleted!");
|
|
|
|
Table.ReloadData();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageService.Error("Could not delete issue!");
|
|
Logger.LogError(ex, "Could not delete issue!");
|
|
}
|
|
}
|
|
}
|