From 63af58f5bbde680d76a457347564a67090e85efb Mon Sep 17 00:00:00 2001 From: Maxime Adler Date: Mon, 14 Apr 2025 14:40:41 +0200 Subject: [PATCH 1/8] Add items in search celect --- .../Games/Components/GameCreationForm.razor | 25 ++++++---- .../Pages/Games/Filter/GameFilter.razor.cs | 4 +- .../Pages/Games/Header/GameHeader.razor | 3 +- .../Pages/Games/Header/GameHeader.razor.cs | 1 + .../BackdropFilter/BackdropFilter.razor.css | 6 ++- .../Shared/Components/Popup/Popup.razor.css | 8 +--- .../Components/Select/Models/SelectParams.cs | 5 +- .../Shared/Components/Select/Select.razor | 17 +++++-- .../Shared/Components/Select/Select.razor.cs | 48 ++++++++++++++----- .../Shared/Components/Select/Select.razor.css | 26 ++++++++++ .../SelectSearch/SelectSearch.razor | 2 +- .../SelectSearch/SelectSearch.razor.cs | 6 ++- .../CreateStaticResourceKey.cs | 2 + .../Constants/GlobalConstants.cs | 3 +- .../GameIdeas.WebAPI/Files/GameIdeas.fr.json | 3 +- 15 files changed, 115 insertions(+), 44 deletions(-) diff --git a/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/Components/GameCreationForm.razor b/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/Components/GameCreationForm.razor index c223842..02ae4db 100644 --- a/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/Components/GameCreationForm.razor +++ b/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/Components/GameCreationForm.razor @@ -19,13 +19,15 @@
@ResourcesKey.Developers :
- +
@ResourcesKey.Publishers :
- +
@@ -37,19 +39,22 @@
@ResourcesKey.Properties :
- +
@ResourcesKey.Tags :
- +
@ResourcesKey.Platforms :
- +
diff --git a/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/Filter/GameFilter.razor.cs b/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/Filter/GameFilter.razor.cs index b116719..c5f2c1e 100644 --- a/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/Filter/GameFilter.razor.cs +++ b/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/Filter/GameFilter.razor.cs @@ -36,10 +36,10 @@ public partial class GameFilter { Headers = SortTypes, GetHeaderLabel = header => header.Label, - DefaultHeader = SortTypes.FirstOrDefault(h => h.SortType == SortType.Ascending), + DefaultHeaders = SortTypes.Where(h => h.SortType == SortType.Ascending).ToList(), Items = GameProperties, GetItemLabel = item => item.Label, - DefaultItem = GameProperties.FirstOrDefault(p => p.Label == "Titre") + DefaultItems = GameProperties.Where(p => p.Label == "Titre").ToList() }; } diff --git a/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/Header/GameHeader.razor b/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/Header/GameHeader.razor index dd57a3a..2e55110 100644 --- a/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/Header/GameHeader.razor +++ b/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/Header/GameHeader.razor @@ -23,8 +23,7 @@ + + + + + } + @if (Params.Headers != null) { - @foreach (var header in Params.Headers) + @foreach (var header in Params.Headers.Union(HeaderValues ?? [])) { } @if (Params.Items != null) { - @foreach (var item in Params.Items) + @foreach (var item in Params.Items.Union(Values ?? [])) { [Parameter] public SelectTheme Theme { get; set; } [Parameter] public SelectType Type { get; set; } = SelectType.Single; [Parameter] public bool DisableClicked { get; set; } = false; + [Parameter] public bool QuickAdd { get; set; } = false; private bool IsContentOpen = false; + private string AddLabel = string.Empty; + private EditContext? QuickAddEditContext; public void Close() => IsContentOpen = false; @@ -23,6 +30,21 @@ public partial class Select public void Open() => IsContentOpen = true; + protected override void OnInitialized() + { + QuickAddEditContext = new EditContext(AddLabel); + + if (Params.DefaultItems.Count != 0) + { + Values.AddRange(Params.DefaultItems); + } + + if (Params.DefaultHeaders.Count != 0) + { + HeaderValues.AddRange(Params.DefaultHeaders); + } + } + private void HandleButtonClicked() { if (!DisableClicked) @@ -32,19 +54,6 @@ public partial class Select private void HandleContentClosed() => IsContentOpen = false; - protected override void OnInitialized() - { - if (Params.DefaultItem != null) - { - Values.Add(Params.DefaultItem); - } - - if (Params.DefaultHeader != null) - { - HeaderValues.Add(Params.DefaultHeader); - } - } - private async Task HandleValueClicked(TItem value) { if (Type != SelectType.Multiple || Values == null) @@ -82,4 +91,17 @@ public partial class Select await HeaderValuesChanged.InvokeAsync(HeaderValues); } + private async Task HandleSubmitAdd() + { + if (Regex.IsMatch(AddLabel, GlobalConstants.RegexSelectRow) && + Params.AddItem != null) + { + Values ??= []; + Values.Add(Params.AddItem(AddLabel)); + + AddLabel = string.Empty; + + await ValuesChanged.InvokeAsync(Values); + } + } } \ No newline at end of file diff --git a/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/Select/Select.razor.css b/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/Select/Select.razor.css index 7dce1f0..2f564c1 100644 --- a/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/Select/Select.razor.css +++ b/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/Select/Select.razor.css @@ -29,6 +29,20 @@ display: none; } +.add-item { + align-content: center; + height: 24px; + padding: 0 10px; +} + +.add-item input { + width: 100%; + color: var(--white); + border: none; + outline: none; + background: transparent; +} + .dropdown::-webkit-scrollbar { width: 10px; } @@ -72,4 +86,16 @@ border-bottom: 2px solid var(--input-selected); } +/***** Sort Theme *****/ +.creation .content { + border-radius: var(--small-radius); + box-sizing: border-box; + border: solid 1px var(--violet); +} + +.creation .content .line { + display: block; + margin: 2px 6px; + border-bottom: 2px solid var(--input-selected); +} diff --git a/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/SelectSearch/SelectSearch.razor b/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/SelectSearch/SelectSearch.razor index e169a80..a9e74bb 100644 --- a/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/SelectSearch/SelectSearch.razor +++ b/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/SelectSearch/SelectSearch.razor @@ -6,7 +6,7 @@ @typeparam TItem + + }
diff --git a/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/Search/SearchInput.razor.cs b/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/Search/SearchInput.razor.cs index 3ee67df..2d151d5 100644 --- a/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/Search/SearchInput.razor.cs +++ b/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/Search/SearchInput.razor.cs @@ -39,9 +39,7 @@ public partial class SearchInput } private async Task HandleSearchClicked() { - await TextChanged.InvokeAsync(Text); await SearchClicked.InvokeAsync(); - await InputText.FocusAsync(); } private async Task HandleFocusIn() { diff --git a/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/SelectSearch/SelectSearch.razor.cs b/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/SelectSearch/SelectSearch.razor.cs index 029f89d..bc2ac8e 100644 --- a/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/SelectSearch/SelectSearch.razor.cs +++ b/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/SelectSearch/SelectSearch.razor.cs @@ -35,12 +35,13 @@ public partial class SelectSearch { Values = values.ToList(); SearchInput?.SetText(string.Join(", ", Values.Select(GetLabel))); - await ValuesChanged.InvokeAsync(values.ToList()); + await ValuesChanged.InvokeAsync(Values.ToList()); } - private void HandleClearClicked() + private async Task HandleClearClicked() { Values = []; + await ValuesChanged.InvokeAsync(Values.ToList()); } private void HandleFocusIn() -- 2.39.5 From 3447fa6eb1ce5834505f1bb19ecc69e3a330ef4c Mon Sep 17 00:00:00 2001 From: Maxime Adler Date: Mon, 14 Apr 2025 16:23:45 +0200 Subject: [PATCH 3/8] Add validation and gateway creation --- .../Games/Components/GameCreationForm.razor | 14 ++-- .../Components/GameCreationForm.razor.cs | 4 +- .../Components/GameCreationForm.razor.css | 9 ++- .../Pages/Games/Components/GameValidation.cs | 25 +++++++ .../Pages/Games/Gateways/GameGateway.cs | 14 ++++ .../Pages/Games/Gateways/IGameGateway.cs | 1 + .../Shared/Components/Popup/Popup.razor | 2 +- .../Shared/Components/Select/Select.razor.cs | 2 +- .../Shared/Constants/Endpoints.cs | 2 +- .../Exceptions/GameCreationException.cs | 3 + .../GameIdeas.BlazorApp/wwwroot/css/app.css | 4 -- .../CreateStaticResourceKey.cs | 2 + .../Constants/GlobalConstants.cs | 2 +- .../GameIdeas.WebAPI/Files/GameIdeas.fr.json | 66 ++++++++++--------- 14 files changed, 101 insertions(+), 49 deletions(-) create mode 100644 src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/Components/GameValidation.cs create mode 100644 src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Exceptions/GameCreationException.cs diff --git a/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/Components/GameCreationForm.razor b/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/Components/GameCreationForm.razor index f257949..bfe8e8e 100644 --- a/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/Components/GameCreationForm.razor +++ b/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/Components/GameCreationForm.razor @@ -1,21 +1,23 @@ -@using GameIdeas.BlazorApp.Shared.Components.SelectSearch +@using Blazored.FluentValidation +@using GameIdeas.BlazorApp.Shared.Components.SelectSearch @using GameIdeas.BlazorApp.Shared.Components.Slider @using GameIdeas.Shared.Dto +
@ResourcesKey.Title :
- +
@ResourcesKey.ReleaseDate :
- +
@ResourcesKey.StorageSizeMo :
- +
@ResourcesKey.Developers :
@@ -61,14 +63,14 @@ {
@platform.Label :
- +
}
@ResourcesKey.Description :
- +
+
+ +
+
\ No newline at end of file diff --git a/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/Components/GameCreationForm.razor.css b/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/Components/GameCreationForm.razor.css index 9a7779e..cb261c1 100644 --- a/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/Components/GameCreationForm.razor.css +++ b/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/Components/GameCreationForm.razor.css @@ -1,6 +1,7 @@ .game-form { display: flex; flex-direction: row; + justify-content: space-between; gap: 20px; } @@ -35,10 +36,14 @@ color: var(--white); } - ::deep input[type="date"]::-webkit-calendar-picker-indicator { - filter: invert(1); - cursor: pointer; - } +::deep input[type="date"]::-webkit-calendar-picker-indicator { + filter: invert(1); + cursor: pointer; +} + +::deep input[type="number"]::-webkit-inner-spin-button { + -webkit-appearance: none; +} ::deep textarea { resize: vertical; @@ -68,6 +73,43 @@ align-content: center; } -input[type="number"]::-webkit-inner-spin-button { - -webkit-appearance: none; -} \ No newline at end of file +.bottom-container { + margin-top: 8px; + height: 28px; + display: flex; + flex-direction: row; + justify-content: space-between; + align-items: center; +} + +::deep .invalid-content { + display: flex; + flex-wrap: wrap; + flex-shrink: 1; + margin: 0; + padding: 0; + list-style: none; + height: auto; + text-wrap: nowrap; +} + +::deep .invalid-content li { + margin-right: 8px; +} + +.buttons { + height: 100%; + display: flex; + flex-direction: row; + gap: 8px; +} + +.buttons button { + border: none; + outline: none; + background: var(--violet); + border-radius: var(--small-radius); + color: var(--white); + font-weight: bold; + padding: 0 10px; +} diff --git a/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/Components/GameValidation.cs b/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/Components/GameValidation.cs index 69ce686..12eff58 100644 --- a/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/Components/GameValidation.cs +++ b/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/Components/GameValidation.cs @@ -1,5 +1,5 @@ using FluentValidation; -using GameIdeas.Shared.Constants; +using GameIdeas.Resources; using GameIdeas.Shared.Dto; namespace GameIdeas.BlazorApp.Pages.Games.Components; @@ -9,17 +9,10 @@ public class GameValidation : AbstractValidator public GameValidation() { RuleFor(g => g.Title) - .NotEmpty() - .NotNull() - .Matches(GlobalConstants.RegexName); - - RuleFor(g => g.ReleaseDate) - .NotEmpty() - .NotNull(); + .NotEmpty().WithMessage(ResourcesKey.InvalidTitle); RuleFor(g => g.Interest) - .NotNull() - .GreaterThanOrEqualTo(1) - .LessThanOrEqualTo(5); + .GreaterThanOrEqualTo(1).WithMessage(ResourcesKey.InvalidInterest) + .LessThanOrEqualTo(5).WithMessage(ResourcesKey.InvalidInterest); } } diff --git a/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/Popup/Popup.razor.cs b/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/Popup/Popup.razor.cs index af8af70..c749d38 100644 --- a/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/Popup/Popup.razor.cs +++ b/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/Popup/Popup.razor.cs @@ -31,16 +31,18 @@ public partial class Popup { IsOpen = true; await BackdropFilter?.Show()!; - StateChanged?.Invoke(null, IsOpen); StateHasChanged(); + + StateChanged?.Invoke(null, IsOpen); } public async Task Close() { IsOpen = false; await BackdropFilter?.Hide()!; - StateChanged?.Invoke(null, IsOpen); StateHasChanged(); + + StateChanged?.Invoke(null, IsOpen); } private async Task HandleBackdropFilterClicked() diff --git a/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/Select/Select.razor.cs b/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/Select/Select.razor.cs index 336911a..d243500 100644 --- a/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/Select/Select.razor.cs +++ b/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/Select/Select.razor.cs @@ -93,8 +93,7 @@ public partial class Select } private async Task HandleSubmitAdd() { - if (Regex.IsMatch(AddLabel, GlobalConstants.RegexName) && - Params.AddItem != null) + if (Params.AddItem != null) { Values ??= []; Values.Add(Params.AddItem(AddLabel)); diff --git a/src/GameIdeas/GameIdeas.Resources/CreateStaticResourceKey.cs b/src/GameIdeas/GameIdeas.Resources/CreateStaticResourceKey.cs index 879572e..f39a66e 100644 --- a/src/GameIdeas/GameIdeas.Resources/CreateStaticResourceKey.cs +++ b/src/GameIdeas/GameIdeas.Resources/CreateStaticResourceKey.cs @@ -36,6 +36,8 @@ public class Translations (TranslationService translationService) public string ErrorFetchCategories => translationService.Translate(nameof(ErrorFetchCategories)); public string PlaceholderAdd => translationService.Translate(nameof(PlaceholderAdd)); public string ErrorCreateGame => translationService.Translate(nameof(ErrorCreateGame)); + public string InvalidTitle => translationService.Translate(nameof(InvalidTitle)); + public string InvalidInterest => translationService.Translate(nameof(InvalidInterest)); } public static class ResourcesKey @@ -80,4 +82,6 @@ public static class ResourcesKey public static string ErrorFetchCategories => _instance?.ErrorFetchCategories ?? throw new InvalidOperationException("ResourcesKey.ErrorFetchCategories is not initialized."); public static string PlaceholderAdd => _instance?.PlaceholderAdd ?? throw new InvalidOperationException("ResourcesKey.PlaceholderAdd is not initialized."); public static string ErrorCreateGame => _instance?.ErrorCreateGame ?? throw new InvalidOperationException("ResourcesKey.ErrorCreateGame is not initialized."); + public static string InvalidTitle => _instance?.InvalidTitle ?? throw new InvalidOperationException("ResourcesKey.InvalidTitle is not initialized."); + public static string InvalidInterest => _instance?.InvalidInterest ?? throw new InvalidOperationException("ResourcesKey.InvalidInterest is not initialized."); } \ No newline at end of file diff --git a/src/GameIdeas/GameIdeas.Shared/Constants/GlobalConstants.cs b/src/GameIdeas/GameIdeas.Shared/Constants/GlobalConstants.cs index 1d809f1..373c8b2 100644 --- a/src/GameIdeas/GameIdeas.Shared/Constants/GlobalConstants.cs +++ b/src/GameIdeas/GameIdeas.Shared/Constants/GlobalConstants.cs @@ -2,5 +2,6 @@ public class GlobalConstants { - public const string RegexName = @"[\w()\-_ ]*"; + } + \ 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 fa2f7c5..0dcf122 100644 --- a/src/GameIdeas/Server/GameIdeas.WebAPI/Files/GameIdeas.fr.json +++ b/src/GameIdeas/Server/GameIdeas.WebAPI/Files/GameIdeas.fr.json @@ -1,36 +1,37 @@ { - "GamesIdeas": "Game Ideas", - "ManualAdd": "Manuel", - "AutoAdd": "Automatique", - "Login": "Se connecter", - "Logout": "Se déconnecter", - "EnterUsername": "Nom d'utilisateur", - "EnterPassword": "Mot de passe", - "UserManager": "Gestion des utilisateurs", - "Filters": "Les filtres", - "LastAdd": "Les ajouts récents", - "Research": "Rechercher", - "Platforms": "Plateformes", - "Tags": "Genres", - "Publishers": "Editeurs", - "Developers": "Développeurs", - "StorageSize": "Taille d'espace", - "StorageSizeMo": "Taille d'espace en Mo", - "LastModification": "Dernière modifications", - "ReleaseDate": "Date de parution", - "Title": "Titre", - "Interest": "Intérêt", - "Properties": "Propriétés", - "Description": "Description", - "Save": "Enregister", - "Reset": "Annuler", - "ErrorWhenPostingData": "Erreur lors de la requête POST", - "ErrorWhenPutingData": "Erreur lors de la requête PUT", - "ErrorWhenDeletingData": "Erreur lors de la requête DELETE", - "ErrorWhenFetchingData": "Erreur lors de la requête GET", - "RequestFailedStatusFormat": "Erreur lors de la réponse, code {0}", - "ErrorFetchCategories": "Erreur lors de la récupération des catégories", - "PlaceholderAdd": "Ajouter un nouveau", - "ErrorCreateGame": "Erreur lors de la Création d'un jeu" - + "GamesIdeas": "Game Ideas", + "ManualAdd": "Manuel", + "AutoAdd": "Automatique", + "Login": "Se connecter", + "Logout": "Se déconnecter", + "EnterUsername": "Nom d'utilisateur", + "EnterPassword": "Mot de passe", + "UserManager": "Gestion des utilisateurs", + "Filters": "Les filtres", + "LastAdd": "Les ajouts récents", + "Research": "Rechercher", + "Platforms": "Plateformes", + "Tags": "Genres", + "Publishers": "Editeurs", + "Developers": "Développeurs", + "StorageSize": "Taille d'espace", + "StorageSizeMo": "Taille d'espace en Mo", + "LastModification": "Dernière modifications", + "ReleaseDate": "Date de parution", + "Title": "Titre", + "Interest": "Intérêt", + "Properties": "Propriétés", + "Description": "Description", + "Save": "Enregister", + "Reset": "Annuler", + "ErrorWhenPostingData": "Erreur lors de la requête POST", + "ErrorWhenPutingData": "Erreur lors de la requête PUT", + "ErrorWhenDeletingData": "Erreur lors de la requête DELETE", + "ErrorWhenFetchingData": "Erreur lors de la requête GET", + "RequestFailedStatusFormat": "Erreur lors de la réponse, code {0}", + "ErrorFetchCategories": "Erreur lors de la récupération des catégories", + "PlaceholderAdd": "Ajouter un nouveau", + "ErrorCreateGame": "Erreur lors de la Création d'un jeu", + "InvalidTitle": "Le titre est incorrect", + "InvalidInterest": "L'interêt est incorrect'" } \ No newline at end of file -- 2.39.5 From ab0ab54f61be1a0a0a265135f0f83f03a623915f Mon Sep 17 00:00:00 2001 From: Maxime Adler Date: Tue, 15 Apr 2025 11:13:32 +0200 Subject: [PATCH 5/8] Correct style and add loader --- .../Games/Components/GameCreationForm.razor | 44 +++++++++++-------- .../Components/GameCreationForm.razor.cs | 14 +++--- .../Components/GameCreationForm.razor.css | 7 ++- .../Pages/Games/GameBase.razor | 2 +- .../BackdropFilter/BackdropFilter.razor.css | 2 +- .../CircleLoader/CircleLoader.razor | 3 ++ .../CircleLoader/CircleLoader.razor.css | 31 +++++++++++++ .../Shared/Components/Popup/Popup.razor | 19 ++++---- .../Shared/Components/Popup/Popup.razor.cs | 8 ---- .../Shared/Components/Popup/Popup.razor.css | 6 ++- .../Shared/Components/Slider/Slider.razor.css | 2 +- .../SliderRange/SliderRange.razor.css | 2 +- .../GameIdeas.BlazorApp/wwwroot/css/app.css | 3 +- 13 files changed, 93 insertions(+), 50 deletions(-) create mode 100644 src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/CircleLoader/CircleLoader.razor create mode 100644 src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/CircleLoader/CircleLoader.razor.css diff --git a/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/Components/GameCreationForm.razor b/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/Components/GameCreationForm.razor index fe0612b..49c858c 100644 --- a/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/Components/GameCreationForm.razor +++ b/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/Components/GameCreationForm.razor @@ -1,4 +1,5 @@ @using Blazored.FluentValidation +@using GameIdeas.BlazorApp.Shared.Components.CircleLoader @using GameIdeas.BlazorApp.Shared.Components.SelectSearch @using GameIdeas.BlazorApp.Shared.Components.Slider @using GameIdeas.Shared.Dto @@ -22,14 +23,14 @@
@ResourcesKey.Developers :
+ Items="Categories?.Developers" @bind-Values=GameDto.Developers + AddItem="@(str => new DeveloperDto() { Name = str })" />
@ResourcesKey.Publishers :
+ Items="Categories?.Publishers" @bind-Values=GameDto.Publishers + AddItem="@(str => new PublisherDto() { Name = str })" />
@@ -42,21 +43,21 @@
@ResourcesKey.Properties :
+ Items="Categories?.Properties" @bind-Values=GameDto.Properties + AddItem="@(str => new PropertyDto() { Label = str })" />
@ResourcesKey.Tags :
+ Items="Categories?.Tags" @bind-Values=GameDto.Tags + AddItem="@(str => new TagDto() { Label = str })" />
@ResourcesKey.Platforms :
+ Items="Categories?.Platforms" @bind-Values=GameDto.Platforms + AddItem="@(str => new PlatformDto() { Label = str })" />
@foreach (var platform in GameDto.Platforms ?? []) @@ -75,13 +76,18 @@
-
- - +
+ + +
-
- \ No newline at end of file + + +@if (IsLoading) +{ + +} \ No newline at end of file diff --git a/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/Components/GameCreationForm.razor.cs b/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/Components/GameCreationForm.razor.cs index d9384cb..9911a85 100644 --- a/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/Components/GameCreationForm.razor.cs +++ b/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/Components/GameCreationForm.razor.cs @@ -20,22 +20,18 @@ public partial class GameCreationForm private EditContext? EditContext; private readonly SelectTheme Theme = SelectTheme.Creation; private readonly SliderParams SliderParams = new() { Gap = 1, Min = 1, Max = 5 }; + private bool IsLoading = true; protected override async Task OnInitializedAsync() { EditContext = new(GameDto); - - if (Popup != null) - { - Popup.StateChanged += async (_, isOpen) => await HandlePopupStateChanged(); - } - await base.OnInitializedAsync(); } - private async Task HandlePopupStateChanged() + protected override async Task OnAfterRenderAsync(bool firstRender) { await Js.InvokeVoidAsync("resizeGameForm"); + } private void HandleOnCancel() @@ -50,6 +46,10 @@ public partial class GameCreationForm return; } + IsLoading = true; + await GameGateway.CreateGame(GameDto); + + IsLoading = false; } } \ No newline at end of file diff --git a/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/Components/GameCreationForm.razor.css b/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/Components/GameCreationForm.razor.css index cb261c1..f1fb03f 100644 --- a/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/Components/GameCreationForm.razor.css +++ b/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/Components/GameCreationForm.razor.css @@ -78,7 +78,6 @@ height: 28px; display: flex; flex-direction: row; - justify-content: space-between; align-items: center; } @@ -98,6 +97,7 @@ } .buttons { + margin-left: auto; height: 100%; display: flex; flex-direction: row; @@ -112,4 +112,9 @@ color: var(--white); font-weight: bold; padding: 0 10px; + cursor: pointer; +} + +.buttons button:hover { + background: var(--violet-selected); } diff --git a/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/GameBase.razor b/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/GameBase.razor index e32a814..404ea88 100644 --- a/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/GameBase.razor +++ b/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/GameBase.razor @@ -24,6 +24,6 @@
- + diff --git a/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/BackdropFilter/BackdropFilter.razor.css b/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/BackdropFilter/BackdropFilter.razor.css index cc30289..76a6919 100644 --- a/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/BackdropFilter/BackdropFilter.razor.css +++ b/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/BackdropFilter/BackdropFilter.razor.css @@ -1,5 +1,5 @@ .backdrop-filter { - position: absolute; + position: fixed; top: 0; left: 0; width: 100%; diff --git a/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/CircleLoader/CircleLoader.razor b/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/CircleLoader/CircleLoader.razor new file mode 100644 index 0000000..1af8145 --- /dev/null +++ b/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/CircleLoader/CircleLoader.razor @@ -0,0 +1,3 @@ +
+ + diff --git a/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/CircleLoader/CircleLoader.razor.css b/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/CircleLoader/CircleLoader.razor.css new file mode 100644 index 0000000..6eee889 --- /dev/null +++ b/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/CircleLoader/CircleLoader.razor.css @@ -0,0 +1,31 @@ +.overlay { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + background-color: rgba(0, 0, 0, 0.5); + display: flex; + align-items: center; + justify-content: center; + z-index: var(--overlay); +} + +.loader { + border: 8px solid var(--violet-selected); + border-top: 8px solid var(--violet); + border-radius: 50%; + width: 60px; + height: 60px; + animation: spin 1s linear infinite; +} + +@keyframes spin { + 0% { + transform: rotate(0deg); + } + + 100% { + transform: rotate(360deg); + } +} diff --git a/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/Popup/Popup.razor b/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/Popup/Popup.razor index 237fac8..fb626b3 100644 --- a/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/Popup/Popup.razor +++ b/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/Popup/Popup.razor @@ -2,15 +2,18 @@ @using GameIdeas.BlazorApp.Shared.Constants -