diff --git a/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/Components/DetailOptions.cs b/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/Components/DetailOptions.cs new file mode 100644 index 0000000..4913684 --- /dev/null +++ b/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/Components/DetailOptions.cs @@ -0,0 +1,8 @@ +namespace GameIdeas.BlazorApp.Pages.Games.Components; + +public enum DetailOptions +{ + Detail, + Edit, + Delete +} diff --git a/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/Components/GameBase.cs b/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/Components/GameBase.cs index 14e4339..a04dd88 100644 --- a/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/Components/GameBase.cs +++ b/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/Components/GameBase.cs @@ -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 OnDelete { get; set; } = new(); + [Parameter] public EventCallback OnEdit { get; set; } = new(); [Inject] public NavigationManager NavigationManager { get; set; } = default!; - protected void HandleDetailClicked() + protected SelectParams 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) + { + 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 + }; } } diff --git a/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/Components/GameRow.razor b/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/Components/GameRow.razor index 5ecb8ac..1510d62 100644 --- a/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/Components/GameRow.razor +++ b/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/Components/GameRow.razor @@ -1,5 +1,7 @@ @using GameIdeas.BlazorApp.Helpers @using GameIdeas.BlazorApp.Shared.Components.Interest +@using GameIdeas.BlazorApp.Shared.Components.Select +@using GameIdeas.BlazorApp.Shared.Components.Select.Models @using GameIdeas.BlazorApp.Shared.Constants @inherits GameBase @@ -33,5 +35,8 @@ - + \ No newline at end of file diff --git a/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/Components/GameRow.razor.css b/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/Components/GameRow.razor.css index 6d2fab0..ab958ce 100644 --- a/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/Components/GameRow.razor.css +++ b/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/Components/GameRow.razor.css @@ -69,7 +69,7 @@ text-decoration: underline; } -.detail { +::deep .detail { transform: scale(0.6, 1) rotate(-90deg); background: none; border: none; diff --git a/src/GameIdeas/GameIdeas.Resources/CreateStaticResourceKey.cs b/src/GameIdeas/GameIdeas.Resources/CreateStaticResourceKey.cs index d40c808..c8f4b8e 100644 --- a/src/GameIdeas/GameIdeas.Resources/CreateStaticResourceKey.cs +++ b/src/GameIdeas/GameIdeas.Resources/CreateStaticResourceKey.cs @@ -1,7 +1,7 @@ namespace GameIdeas.Resources; -public class Translations(TranslationService translationService) +public class Translations (TranslationService translationService) { public string GamesIdeas => translationService.Translate(nameof(GamesIdeas)); 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 ReadMore => translationService.Translate(nameof(ReadMore)); 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 @@ -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 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 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."); } \ No newline at end of file diff --git a/src/GameIdeas/Server/GameIdeas.WebAPI/Files/GameIdeas.fr.json b/src/GameIdeas/Server/GameIdeas.WebAPI/Files/GameIdeas.fr.json index 7507151..2c846b8 100644 --- a/src/GameIdeas/Server/GameIdeas.WebAPI/Files/GameIdeas.fr.json +++ b/src/GameIdeas/Server/GameIdeas.WebAPI/Files/GameIdeas.fr.json @@ -63,5 +63,8 @@ "Informations": "Informations", "About": "À propos", "ReadMore": "Afficher", - "ReadLess": "Réduire" + "ReadLess": "Réduire", + "Detail": "Détail", + "Edit": "Modifier", + "Delete": "Supprimer" } \ No newline at end of file