Add more action for game row
All checks were successful
Game Ideas build for PR / build_test (pull_request) Successful in 1m3s
All checks were successful
Game Ideas build for PR / build_test (pull_request) Successful in 1m3s
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
using GameIdeas.Shared.Dto;
|
||||
using GameIdeas.BlazorApp.Shared.Components.Select.Models;
|
||||
using GameIdeas.Resources;
|
||||
using GameIdeas.Shared.Dto;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
|
||||
namespace GameIdeas.BlazorApp.Pages.Games.Components;
|
||||
@@ -6,10 +8,48 @@ namespace GameIdeas.BlazorApp.Pages.Games.Components;
|
||||
public class GameBase : ComponentBase
|
||||
{
|
||||
[Parameter] public GameDto GameDto { get; set; } = new();
|
||||
[Parameter] public EventCallback<GameDto> OnDelete { get; set; } = new();
|
||||
[Parameter] public EventCallback<GameDto> OnEdit { get; set; } = new();
|
||||
[Inject] public NavigationManager NavigationManager { get; set; } = default!;
|
||||
|
||||
protected void HandleDetailClicked()
|
||||
protected SelectParams<DetailOptions, object> SelectParams = default!;
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
NavigationManager.NavigateTo($"/Games/Detail/{GameDto.Id}");
|
||||
SelectParams = new()
|
||||
{
|
||||
Items = [DetailOptions.Detail, DetailOptions.Edit, DetailOptions.Delete],
|
||||
GetItemLabel = GetDetailOptionsLabel
|
||||
};
|
||||
}
|
||||
|
||||
protected async Task HandlerSelectValuesChanged(IEnumerable<DetailOptions> detailOptions)
|
||||
{
|
||||
var option = detailOptions.First();
|
||||
switch (option)
|
||||
{
|
||||
case DetailOptions.Detail:
|
||||
NavigationManager.NavigateTo($"/Games/Detail/{GameDto.Id}");
|
||||
break;
|
||||
case DetailOptions.Edit:
|
||||
await OnEdit.InvokeAsync(GameDto);
|
||||
break;
|
||||
case DetailOptions.Delete:
|
||||
await OnDelete.InvokeAsync(GameDto);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private string GetDetailOptionsLabel(DetailOptions options)
|
||||
{
|
||||
return options switch
|
||||
{
|
||||
DetailOptions.Detail => ResourcesKey.Detail,
|
||||
DetailOptions.Edit => ResourcesKey.Edit,
|
||||
DetailOptions.Delete => ResourcesKey.Delete,
|
||||
_ => ResourcesKey.Unknown
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user