Add game add button in detail
This commit is contained in:
@@ -1,14 +1,22 @@
|
|||||||
@page "/Detail/{GameId:int}"
|
@page "/Detail/{GameId:int}"
|
||||||
@using GameIdeas.BlazorApp.Helpers
|
@using GameIdeas.BlazorApp.Helpers
|
||||||
|
@using GameIdeas.BlazorApp.Pages.Games.Components
|
||||||
|
@using GameIdeas.BlazorApp.Shared.Components
|
||||||
|
@using GameIdeas.BlazorApp.Shared.Components.ButtonAdd
|
||||||
@using GameIdeas.BlazorApp.Shared.Components.Header
|
@using GameIdeas.BlazorApp.Shared.Components.Header
|
||||||
@using GameIdeas.BlazorApp.Shared.Components.Interest
|
@using GameIdeas.BlazorApp.Shared.Components.Interest
|
||||||
|
@using GameIdeas.BlazorApp.Shared.Components.Popup
|
||||||
@using GameIdeas.BlazorApp.Shared.Components.ReadMore
|
@using GameIdeas.BlazorApp.Shared.Components.ReadMore
|
||||||
@using GameIdeas.BlazorApp.Shared.Constants
|
@using GameIdeas.BlazorApp.Shared.Constants
|
||||||
@using GameIdeas.Shared.Constants
|
@using GameIdeas.Shared.Constants
|
||||||
|
|
||||||
|
@inherits GameBaseComponent
|
||||||
@layout MainLayout
|
@layout MainLayout
|
||||||
|
|
||||||
<HeaderGameIdeas>
|
<HeaderGameIdeas>
|
||||||
|
<div class="button">
|
||||||
|
<ButtonAdd AddTypeChanged="HandleAddClicked" />
|
||||||
|
</div>
|
||||||
</HeaderGameIdeas>
|
</HeaderGameIdeas>
|
||||||
|
|
||||||
<div class="detail-container">
|
<div class="detail-container">
|
||||||
@@ -97,4 +105,8 @@
|
|||||||
|
|
||||||
<div class="section">
|
<div class="section">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<Popup @ref=ManualAddPopup BackdropFilterClicked="HandleBackdropManualAddClicked" Closable=false>
|
||||||
|
<GameCreationForm Categories="Categories" OnSubmit="HandleSubmitNewGame" />
|
||||||
|
</Popup>
|
||||||
@@ -6,7 +6,7 @@ namespace GameIdeas.BlazorApp.Pages.Detail;
|
|||||||
|
|
||||||
public partial class GameDetail
|
public partial class GameDetail
|
||||||
{
|
{
|
||||||
[Inject] private IGameGateway GameGateway { get; set; } = default!;
|
[Inject] private NavigationManager NavigationManager { get; set; } = default!;
|
||||||
[Parameter] public int GameId { get; set; }
|
[Parameter] public int GameId { get; set; }
|
||||||
|
|
||||||
private GameDetailDto Game = new();
|
private GameDetailDto Game = new();
|
||||||
@@ -16,4 +16,9 @@ public partial class GameDetail
|
|||||||
Game = await GameGateway.GetGameById(GameId);
|
Game = await GameGateway.GetGameById(GameId);
|
||||||
await base.OnInitializedAsync();
|
await base.OnInitializedAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void HandleSubmitNewGame()
|
||||||
|
{
|
||||||
|
NavigationManager.NavigateTo("/");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -90,7 +90,13 @@
|
|||||||
background: var(--input-selected);
|
background: var(--input-selected);
|
||||||
}
|
}
|
||||||
|
|
||||||
@media screen and (min-width: 700px) and (max-width: 1000px) {
|
.button {
|
||||||
|
display: flex;
|
||||||
|
width: 100%;
|
||||||
|
justify-content: end;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media screen and (max-width: 1000px) {
|
||||||
.section {
|
.section {
|
||||||
padding: 20px;
|
padding: 20px;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -118,3 +118,20 @@
|
|||||||
.buttons button:hover {
|
.buttons button:hover {
|
||||||
background: var(--violet-selected);
|
background: var(--violet-selected);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@media screen and (max-width: 400px) {
|
||||||
|
.input-game {
|
||||||
|
grid-template-columns: auto 1fr;
|
||||||
|
}
|
||||||
|
|
||||||
|
#label-description {
|
||||||
|
width: auto !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media screen and (max-width: 700px) {
|
||||||
|
.game-form {
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
@using GameIdeas.BlazorApp.Shared.Components.Header
|
@using GameIdeas.BlazorApp.Shared.Components.Header
|
||||||
@using GameIdeas.BlazorApp.Shared.Components.Popup
|
@using GameIdeas.BlazorApp.Shared.Components.Popup
|
||||||
@using GameIdeas.Resources
|
@using GameIdeas.Resources
|
||||||
|
@inherits GameBaseComponent
|
||||||
@layout MainLayout
|
@layout MainLayout
|
||||||
|
|
||||||
<PageTitle>@ResourcesKey.GamesIdeas</PageTitle>
|
<PageTitle>@ResourcesKey.GamesIdeas</PageTitle>
|
||||||
|
|||||||
@@ -1,22 +1,15 @@
|
|||||||
using GameIdeas.BlazorApp.Pages.Games.Filter;
|
using GameIdeas.BlazorApp.Pages.Games.Filter;
|
||||||
using GameIdeas.BlazorApp.Pages.Games.Gateways;
|
using GameIdeas.BlazorApp.Shared.Components;
|
||||||
using GameIdeas.BlazorApp.Shared.Components.Popup;
|
|
||||||
using GameIdeas.BlazorApp.Shared.Models;
|
using GameIdeas.BlazorApp.Shared.Models;
|
||||||
using GameIdeas.Shared.Dto;
|
using GameIdeas.Shared.Dto;
|
||||||
using GameIdeas.Shared.Enum;
|
using GameIdeas.Shared.Enum;
|
||||||
using Microsoft.AspNetCore.Components;
|
|
||||||
|
|
||||||
namespace GameIdeas.BlazorApp.Pages.Games;
|
namespace GameIdeas.BlazorApp.Pages.Games;
|
||||||
|
|
||||||
public partial class Games
|
public partial class Games : GameBaseComponent
|
||||||
{
|
{
|
||||||
[Inject] private IGameGateway GameGateway { get; set; } = default!;
|
|
||||||
|
|
||||||
private DisplayType DisplayType = DisplayType.List;
|
private DisplayType DisplayType = DisplayType.List;
|
||||||
private GameFilterParams GameFilter = new();
|
private GameFilterParams GameFilter = new();
|
||||||
private Popup? ManualAddPopup;
|
|
||||||
private bool IsLoading = false;
|
|
||||||
private CategoriesDto? Categories;
|
|
||||||
private IEnumerable<GameDto> GamesDto = [];
|
private IEnumerable<GameDto> GamesDto = [];
|
||||||
private int CurrentPage;
|
private int CurrentPage;
|
||||||
|
|
||||||
@@ -33,32 +26,12 @@ public partial class Games
|
|||||||
await base.OnInitializedAsync();
|
await base.OnInitializedAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void HandleAddClicked(AddType addType)
|
private async Task HandleFetchDatas(bool displayLoader = true)
|
||||||
{
|
|
||||||
switch (addType)
|
|
||||||
{
|
|
||||||
case AddType.Manual:
|
|
||||||
ManualAddPopup?.Open();
|
|
||||||
break;
|
|
||||||
case AddType.Auto:
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void HandleBackdropManualAddClicked()
|
|
||||||
{
|
|
||||||
ManualAddPopup?.Close();
|
|
||||||
}
|
|
||||||
private async Task HandleFetchDatas(bool loadCategories = true, bool displayLoader = true)
|
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
IsLoading = displayLoader;
|
IsLoading = displayLoader;
|
||||||
|
|
||||||
if (loadCategories)
|
|
||||||
Categories = await GameGateway.FetchCategories();
|
|
||||||
|
|
||||||
GamesDto = await GameGateway.FetchGames(GameFilter, CurrentPage);
|
GamesDto = await GameGateway.FetchGames(GameFilter, CurrentPage);
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
@@ -73,6 +46,6 @@ public partial class Games
|
|||||||
private async Task HandleFilterChanged(GameFilterParams args)
|
private async Task HandleFilterChanged(GameFilterParams args)
|
||||||
{
|
{
|
||||||
GameFilter = args;
|
GameFilter = args;
|
||||||
await HandleFetchDatas(loadCategories: false, displayLoader: false);
|
await HandleFetchDatas(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
using GameIdeas.BlazorApp.Pages.Games.Filter;
|
||||||
|
using GameIdeas.BlazorApp.Pages.Games.Gateways;
|
||||||
|
using GameIdeas.BlazorApp.Shared.Models;
|
||||||
|
using GameIdeas.Shared.Dto;
|
||||||
|
using Microsoft.AspNetCore.Components;
|
||||||
|
|
||||||
|
namespace GameIdeas.BlazorApp.Shared.Components;
|
||||||
|
|
||||||
|
public class GameBaseComponent : ComponentBase
|
||||||
|
{
|
||||||
|
[Inject] protected IGameGateway GameGateway { get; set; } = default!;
|
||||||
|
|
||||||
|
protected Popup.Popup? ManualAddPopup;
|
||||||
|
protected CategoriesDto? Categories;
|
||||||
|
protected bool IsLoading = false;
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
await HandleFetchCategories();
|
||||||
|
await base.OnInitializedAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task HandleFetchCategories()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
IsLoading = true;
|
||||||
|
|
||||||
|
Categories = await GameGateway.FetchCategories();
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
IsLoading = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void HandleAddClicked(AddType addType)
|
||||||
|
{
|
||||||
|
switch (addType)
|
||||||
|
{
|
||||||
|
case AddType.Manual:
|
||||||
|
ManualAddPopup?.Open();
|
||||||
|
break;
|
||||||
|
case AddType.Auto:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void HandleBackdropManualAddClicked()
|
||||||
|
{
|
||||||
|
ManualAddPopup?.Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user