Merge pull request #819 from eduardosmaniotto/bugfix/merchant-and-loading
bugfix: standardize loading states and add save spinner to Create pages (cherry picked from commit 7fb61714feea55d4c765b094c2e5f513ee5da3ba)
This commit is contained in:
@@ -16,6 +16,7 @@ using MUnique.OpenMU.DataModel.Configuration;
|
||||
using MUnique.OpenMU.DataModel.Entities;
|
||||
using MUnique.OpenMU.Persistence;
|
||||
using MUnique.OpenMU.Web.AdminPanel.Properties;
|
||||
using MUnique.OpenMU.Web.Shared.Services;
|
||||
|
||||
/// <summary>
|
||||
/// Razor page which shows objects of the specified type in a grid.
|
||||
@@ -68,6 +69,12 @@ public partial class Merchants : ComponentBase, IAsyncDisposable
|
||||
[Inject]
|
||||
public ILogger<Merchants> Logger { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the loading overlay service.
|
||||
/// </summary>
|
||||
[Inject]
|
||||
public LoadingOverlayService LoadingService { get; set; } = null!;
|
||||
|
||||
private IQueryable<MerchantStorageViewModel>? ViewModels => this._viewModels?.AsQueryable();
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -134,6 +141,7 @@ public partial class Merchants : ComponentBase, IAsyncDisposable
|
||||
|
||||
private async Task LoadDataAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
using var loading = this.LoadingService.ShowLoadingIndicator();
|
||||
try
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
@@ -192,8 +200,13 @@ public partial class Merchants : ComponentBase, IAsyncDisposable
|
||||
{
|
||||
if (this._persistenceContext?.HasChanges is true)
|
||||
{
|
||||
var previousMerchantId = this._selectedMerchant?.Id;
|
||||
await this.DataSource.DiscardChangesAsync().ConfigureAwait(true);
|
||||
await this.LoadDataAsync(this._disposeCts?.Token ?? default).ConfigureAwait(true);
|
||||
if (previousMerchantId is { } id && this._viewModels is not null)
|
||||
{
|
||||
this._selectedMerchant = this._viewModels.FirstOrDefault(vm => vm.Id == id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user