Page to view saves for a game
This commit is contained in:
parent
413cbf364e
commit
3c9cf37e2d
2 changed files with 69 additions and 0 deletions
|
@ -26,6 +26,9 @@
|
||||||
</PropertyColumn>
|
</PropertyColumn>
|
||||||
<ActionColumn Title="">
|
<ActionColumn Title="">
|
||||||
<Space Direction="DirectionVHType.Horizontal">
|
<Space Direction="DirectionVHType.Horizontal">
|
||||||
|
<SpaceItem>
|
||||||
|
<Button OnClick="() => ViewSaves(context)">Saves</Button>
|
||||||
|
</SpaceItem>
|
||||||
<SpaceItem>
|
<SpaceItem>
|
||||||
<Button OnClick="() => Edit(context)">Edit</Button>
|
<Button OnClick="() => Edit(context)">Edit</Button>
|
||||||
</SpaceItem>
|
</SpaceItem>
|
||||||
|
@ -65,6 +68,11 @@
|
||||||
NavigationManager.NavigateTo("/Games/Add");
|
NavigationManager.NavigateTo("/Games/Add");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void ViewSaves(Game game)
|
||||||
|
{
|
||||||
|
NavigationManager.NavigateTo($"/Games/{game.Id}/Saves", true);
|
||||||
|
}
|
||||||
|
|
||||||
private void Edit(Game game)
|
private void Edit(Game game)
|
||||||
{
|
{
|
||||||
NavigationManager.NavigateTo($"/Games/{game.Id}/Edit", true);
|
NavigationManager.NavigateTo($"/Games/{game.Id}/Edit", true);
|
||||||
|
|
61
LANCommander/Pages/Games/Saves.razor
Normal file
61
LANCommander/Pages/Games/Saves.razor
Normal file
|
@ -0,0 +1,61 @@
|
||||||
|
@page "/Games/{id:guid}/Saves"
|
||||||
|
@using LANCommander.Models;
|
||||||
|
@using System.IO.Compression;
|
||||||
|
@attribute [Authorize(Roles = "Administrator")]
|
||||||
|
@inject GameService GameService
|
||||||
|
@inject CompanyService CompanyService
|
||||||
|
@inject GenreService GenreService
|
||||||
|
@inject TagService TagService
|
||||||
|
@inject ArchiveService ArchiveService
|
||||||
|
@inject ScriptService ScriptService
|
||||||
|
@inject IMessageService MessageService
|
||||||
|
@inject NavigationManager NavigationManager
|
||||||
|
@inject ModalService ModalService
|
||||||
|
@inject GameSaveService GameSaveService
|
||||||
|
|
||||||
|
<Table TItem="GameSave" DataSource="@GameSaves" Loading="@Loading">
|
||||||
|
<PropertyColumn Property="g => g.User" Sortable>
|
||||||
|
@context.User?.UserName
|
||||||
|
</PropertyColumn>
|
||||||
|
<PropertyColumn Property="g => g.CreatedOn" Format="MM/dd/yyyy hh:mm tt" Sortable />
|
||||||
|
<PropertyColumn Property="g => g.CreatedBy" Sortable>
|
||||||
|
@context.CreatedBy?.UserName
|
||||||
|
</PropertyColumn>
|
||||||
|
<ActionColumn Title="">
|
||||||
|
<Space Direction="DirectionVHType.Horizontal">
|
||||||
|
<SpaceItem>
|
||||||
|
<Popconfirm OnConfirm="() => Delete(context)" Title="Are you sure you want to delete this game save?">
|
||||||
|
<Button Icon="@IconType.Outline.Close" Type="@ButtonType.Text" Danger />
|
||||||
|
</Popconfirm>
|
||||||
|
</SpaceItem>
|
||||||
|
</Space>
|
||||||
|
</ActionColumn>
|
||||||
|
</Table>
|
||||||
|
|
||||||
|
@code {
|
||||||
|
[Parameter] public Guid Id { get; set; }
|
||||||
|
|
||||||
|
ICollection<GameSave> GameSaves { get; set; } = new List<GameSave>();
|
||||||
|
|
||||||
|
bool Loading = true;
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
GameSaves = GameSaveService.Get(gs => gs.GameId == Id).OrderBy(gs => gs.User.UserName).ThenByDescending(gs => gs.CreatedOn).ToList();
|
||||||
|
|
||||||
|
Loading = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task Delete(GameSave gameSave)
|
||||||
|
{
|
||||||
|
GameSaves = new List<GameSave>();
|
||||||
|
|
||||||
|
Loading = true;
|
||||||
|
|
||||||
|
await GameSaveService.Delete(gameSave);
|
||||||
|
|
||||||
|
GameSaves = GameSaveService.Get().ToList();
|
||||||
|
|
||||||
|
Loading = false;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue