Allow save for game edit and enable snackbar
parent
74750b1dc9
commit
6c96bc5ee8
|
@ -1,11 +1,12 @@
|
||||||
@page "/Games/{id:guid}/Edit"
|
@page "/Games/{id:guid}/Edit"
|
||||||
@inject GameService GameService
|
@inject GameService GameService
|
||||||
@inject IDialogService DialogService
|
@inject IDialogService DialogService
|
||||||
|
@inject ISnackbar Snackbar
|
||||||
|
|
||||||
<MudGrid>
|
<MudGrid>
|
||||||
<MudItem xs="12">
|
<MudItem xs="12">
|
||||||
<MudPaper Class="pa-4">
|
<MudPaper Class="pa-4">
|
||||||
<MudForm>
|
<MudForm @bind-IsValid="@Success" @bind-Errors="@Errors">
|
||||||
<MudTextField @bind-Value="Game.Title" Label="Title" For="@(() => Game.Title)" Adornment="Adornment.End" AdornmentIcon="@Icons.Material.Filled.Search" OnAdornmentClick="LookupGameMetadata" />
|
<MudTextField @bind-Value="Game.Title" Label="Title" For="@(() => Game.Title)" Adornment="Adornment.End" AdornmentIcon="@Icons.Material.Filled.Search" OnAdornmentClick="LookupGameMetadata" />
|
||||||
<MudTextField @bind-Value="Game.SortTitle" Label="Sort Title" For="@(() => Game.SortTitle)" />
|
<MudTextField @bind-Value="Game.SortTitle" Label="Sort Title" For="@(() => Game.SortTitle)" />
|
||||||
<MudTextField @bind-Value="Game.Icon" Label="Icon" Adornment="Adornment.End" AdornmentIcon="@Icons.Material.Filled.Folder" OnAdornmentClick="BrowseForIcon" />
|
<MudTextField @bind-Value="Game.Icon" Label="Icon" Adornment="Adornment.End" AdornmentIcon="@Icons.Material.Filled.Folder" OnAdornmentClick="BrowseForIcon" />
|
||||||
|
@ -42,7 +43,7 @@
|
||||||
</MudChipSet>
|
</MudChipSet>
|
||||||
|
|
||||||
<div class="d-flex align-center justify-space-between">
|
<div class="d-flex align-center justify-space-between">
|
||||||
<MudButton Variant="Variant.Filled" Color="Color.Primary" Disabled="@(!Success)">Save</MudButton>
|
<MudButton Variant="Variant.Filled" Color="Color.Primary" Disabled="@(!Success)" OnClick="Save">Save</MudButton>
|
||||||
</div>
|
</div>
|
||||||
</MudForm>
|
</MudForm>
|
||||||
</MudPaper>
|
</MudPaper>
|
||||||
|
@ -63,9 +64,18 @@
|
||||||
Game = await GameService.Get(Id);
|
Game = await GameService.Get(Id);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Save()
|
private async Task Save()
|
||||||
{
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Game = await GameService.Update(Game);
|
||||||
|
|
||||||
|
Snackbar.Add("Game updated!", Severity.Success);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Snackbar.Add("An unknown error occurred!", Severity.Error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void BrowseForIcon()
|
private async void BrowseForIcon()
|
||||||
|
|
|
@ -7,6 +7,7 @@ using Microsoft.AspNetCore.Identity;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.IdentityModel.Tokens;
|
using Microsoft.IdentityModel.Tokens;
|
||||||
|
using MudBlazor;
|
||||||
using MudBlazor.Services;
|
using MudBlazor.Services;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
|
@ -70,7 +71,18 @@ builder.Services.AddControllersWithViews().AddJsonOptions(x =>
|
||||||
x.JsonSerializerOptions.ReferenceHandler = System.Text.Json.Serialization.ReferenceHandler.IgnoreCycles;
|
x.JsonSerializerOptions.ReferenceHandler = System.Text.Json.Serialization.ReferenceHandler.IgnoreCycles;
|
||||||
});
|
});
|
||||||
|
|
||||||
builder.Services.AddMudServices();
|
builder.Services.AddMudServices(config =>
|
||||||
|
{
|
||||||
|
config.SnackbarConfiguration.PositionClass = Defaults.Classes.Position.BottomLeft;
|
||||||
|
|
||||||
|
config.SnackbarConfiguration.PreventDuplicates = false;
|
||||||
|
config.SnackbarConfiguration.NewestOnTop = false;
|
||||||
|
config.SnackbarConfiguration.ShowCloseIcon = true;
|
||||||
|
config.SnackbarConfiguration.VisibleStateDuration = 10000;
|
||||||
|
config.SnackbarConfiguration.HideTransitionDuration = 500;
|
||||||
|
config.SnackbarConfiguration.ShowTransitionDuration = 500;
|
||||||
|
config.SnackbarConfiguration.SnackbarVariant = Variant.Filled;
|
||||||
|
});
|
||||||
|
|
||||||
builder.Services.AddScoped<SettingService>();
|
builder.Services.AddScoped<SettingService>();
|
||||||
builder.Services.AddScoped<ArchiveService>();
|
builder.Services.AddScoped<ArchiveService>();
|
||||||
|
|
Loading…
Reference in New Issue