Create game from form #15
@@ -72,6 +72,9 @@
|
||||
<div id="label-description">@ResourcesKey.Description :</div>
|
||||
<InputTextArea class="description" @bind-Value=GameDto.Description />
|
||||
</div>
|
||||
<div class="bottom-container">
|
||||
<ValidationSummary class="invalid-content" />
|
||||
|
||||
<div class="buttons">
|
||||
<button type="reset" class="cancel" @onclick=HandleOnCancel>
|
||||
@ResourcesKey.Reset
|
||||
@@ -80,4 +83,5 @@
|
||||
@ResourcesKey.Save
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</EditForm>
|
||||
@@ -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;
|
||||
}
|
||||
.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;
|
||||
}
|
||||
|
||||
@@ -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<GameDto>
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -93,8 +93,7 @@ public partial class Select<TItem, THeader>
|
||||
}
|
||||
private async Task HandleSubmitAdd()
|
||||
{
|
||||
if (Regex.IsMatch(AddLabel, GlobalConstants.RegexName) &&
|
||||
Params.AddItem != null)
|
||||
if (Params.AddItem != null)
|
||||
{
|
||||
Values ??= [];
|
||||
Values.Add(Params.AddItem(AddLabel));
|
||||
|
||||
@@ -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.");
|
||||
}
|
||||
@@ -2,5 +2,6 @@
|
||||
|
||||
public class GlobalConstants
|
||||
{
|
||||
public const string RegexName = @"[\w()\-_ ]*";
|
||||
|
||||
}
|
||||
|
||||
@@ -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'"
|
||||
}
|
||||
Reference in New Issue
Block a user