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:
@@ -0,0 +1,8 @@
|
|||||||
|
namespace GameIdeas.BlazorApp.Pages.Games.Components;
|
||||||
|
|
||||||
|
public enum DetailOptions
|
||||||
|
{
|
||||||
|
Detail,
|
||||||
|
Edit,
|
||||||
|
Delete
|
||||||
|
}
|
||||||
@@ -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;
|
using Microsoft.AspNetCore.Components;
|
||||||
|
|
||||||
namespace GameIdeas.BlazorApp.Pages.Games.Components;
|
namespace GameIdeas.BlazorApp.Pages.Games.Components;
|
||||||
@@ -6,10 +8,48 @@ namespace GameIdeas.BlazorApp.Pages.Games.Components;
|
|||||||
public class GameBase : ComponentBase
|
public class GameBase : ComponentBase
|
||||||
{
|
{
|
||||||
[Parameter] public GameDto GameDto { get; set; } = new();
|
[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!;
|
[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
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
@using GameIdeas.BlazorApp.Helpers
|
@using GameIdeas.BlazorApp.Helpers
|
||||||
@using GameIdeas.BlazorApp.Shared.Components.Interest
|
@using GameIdeas.BlazorApp.Shared.Components.Interest
|
||||||
|
@using GameIdeas.BlazorApp.Shared.Components.Select
|
||||||
|
@using GameIdeas.BlazorApp.Shared.Components.Select.Models
|
||||||
@using GameIdeas.BlazorApp.Shared.Constants
|
@using GameIdeas.BlazorApp.Shared.Constants
|
||||||
@inherits GameBase
|
@inherits GameBase
|
||||||
|
|
||||||
@@ -33,5 +35,8 @@
|
|||||||
|
|
||||||
<Interest Value="GameDto.Interest" />
|
<Interest Value="GameDto.Interest" />
|
||||||
|
|
||||||
<button class="detail">@Icons.Triangle</button>
|
<Select TItem="DetailOptions" THeader="object" Type="SelectType.Single" QuickAdd="false" Theme="SelectTheme.Navigation"
|
||||||
|
Params="SelectParams" ValuesChanged="HandlerSelectValuesChanged">
|
||||||
|
<button class="detail">@Icons.Triangle</button>
|
||||||
|
</Select>
|
||||||
</div>
|
</div>
|
||||||
@@ -69,7 +69,7 @@
|
|||||||
text-decoration: underline;
|
text-decoration: underline;
|
||||||
}
|
}
|
||||||
|
|
||||||
.detail {
|
::deep .detail {
|
||||||
transform: scale(0.6, 1) rotate(-90deg);
|
transform: scale(0.6, 1) rotate(-90deg);
|
||||||
background: none;
|
background: none;
|
||||||
border: none;
|
border: none;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
namespace GameIdeas.Resources;
|
namespace GameIdeas.Resources;
|
||||||
|
|
||||||
public class Translations(TranslationService translationService)
|
public class Translations (TranslationService translationService)
|
||||||
{
|
{
|
||||||
public string GamesIdeas => translationService.Translate(nameof(GamesIdeas));
|
public string GamesIdeas => translationService.Translate(nameof(GamesIdeas));
|
||||||
public string ManualAdd => translationService.Translate(nameof(ManualAdd));
|
public string ManualAdd => translationService.Translate(nameof(ManualAdd));
|
||||||
@@ -68,6 +68,9 @@ public class Translations(TranslationService translationService)
|
|||||||
public string About => translationService.Translate(nameof(About));
|
public string About => translationService.Translate(nameof(About));
|
||||||
public string ReadMore => translationService.Translate(nameof(ReadMore));
|
public string ReadMore => translationService.Translate(nameof(ReadMore));
|
||||||
public string ReadLess => translationService.Translate(nameof(ReadLess));
|
public string ReadLess => translationService.Translate(nameof(ReadLess));
|
||||||
|
public string Detail => translationService.Translate(nameof(Detail));
|
||||||
|
public string Edit => translationService.Translate(nameof(Edit));
|
||||||
|
public string Delete => translationService.Translate(nameof(Delete));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class ResourcesKey
|
public static class ResourcesKey
|
||||||
@@ -144,4 +147,7 @@ public static class ResourcesKey
|
|||||||
public static string About => _instance?.About ?? throw new InvalidOperationException("ResourcesKey.About is not initialized.");
|
public static string About => _instance?.About ?? throw new InvalidOperationException("ResourcesKey.About is not initialized.");
|
||||||
public static string ReadMore => _instance?.ReadMore ?? throw new InvalidOperationException("ResourcesKey.ReadMore is not initialized.");
|
public static string ReadMore => _instance?.ReadMore ?? throw new InvalidOperationException("ResourcesKey.ReadMore is not initialized.");
|
||||||
public static string ReadLess => _instance?.ReadLess ?? throw new InvalidOperationException("ResourcesKey.ReadLess is not initialized.");
|
public static string ReadLess => _instance?.ReadLess ?? throw new InvalidOperationException("ResourcesKey.ReadLess is not initialized.");
|
||||||
|
public static string Detail => _instance?.Detail ?? throw new InvalidOperationException("ResourcesKey.Detail is not initialized.");
|
||||||
|
public static string Edit => _instance?.Edit ?? throw new InvalidOperationException("ResourcesKey.Edit is not initialized.");
|
||||||
|
public static string Delete => _instance?.Delete ?? throw new InvalidOperationException("ResourcesKey.Delete is not initialized.");
|
||||||
}
|
}
|
||||||
@@ -63,5 +63,8 @@
|
|||||||
"Informations": "Informations",
|
"Informations": "Informations",
|
||||||
"About": "À propos",
|
"About": "À propos",
|
||||||
"ReadMore": "Afficher",
|
"ReadMore": "Afficher",
|
||||||
"ReadLess": "Réduire"
|
"ReadLess": "Réduire",
|
||||||
|
"Detail": "Détail",
|
||||||
|
"Edit": "Modifier",
|
||||||
|
"Delete": "Supprimer"
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user