Skip to content

Commit

Permalink
Merge pull request #91 from saritasa-nest/feature/SN-751-use-snackbar…
Browse files Browse the repository at this point in the history
…-in-edit-entity-page

Feature/sn 751 use snackbar in edit entity page
  • Loading branch information
AlexanderMakarov124 authored Oct 8, 2024
2 parents 9b368d0 + a91e673 commit c2e7884
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 18 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,7 @@

0.3.0-alpha [2024-10-07]
[+] Exclude all entities from admin panel.
[+} Include entity properties if NetForgeProperty attribute is set.
[+} Include entity properties if NetForgeProperty attribute is set.

0.3.1-alpha [2024-10-08]
[*] Replaced MudAlert with Snackbar control on edit entity page
2 changes: 1 addition & 1 deletion VERSION.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.3.0-alpha
0.3.1-alpha
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ public static void Register(IServiceCollection services)

services.AddRazorPages();
services.AddServerSideBlazor();
services.AddMudServices();
services.AddMudServices(config =>
{
config.SnackbarConfiguration.PreventDuplicates = false;
});
services.AddMemoryCache();
services.AddScoped<INavigationService, NavigationService>();
services.AddScoped<IEntityService, EntityService>();
Expand Down
8 changes: 0 additions & 8 deletions src/Saritasa.NetForge.Blazor/Pages/EditEntity.razor
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,6 @@ else if (ViewModel.IsEntityExists)
</MudButton>
</div>

@if (ViewModel.IsUpdated)
{
<MudAlert Variant="Variant.Outlined"
Severity="Severity.Success">
Update was completed successfully
</MudAlert>
}

@if (ViewModel.Errors is not null && ViewModel.Errors.Count != 0)
{
<MudAlert Variant="Variant.Outlined"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.ComponentModel.DataAnnotations;
using Saritasa.NetForge.Mvvm.Utils;
using System.Reflection;
using MudBlazor;

namespace Saritasa.NetForge.Mvvm.ViewModels.EditEntity;

Expand All @@ -28,6 +29,7 @@ public class EditEntityViewModel : ValidationEntityViewModel
private readonly IEntityService entityService;
private readonly IOrmDataService dataService;
private readonly IServiceProvider serviceProvider;
private readonly ISnackbar snackbar;

/// <summary>
/// Constructor.
Expand All @@ -37,26 +39,23 @@ public EditEntityViewModel(
string instancePrimaryKey,
IEntityService entityService,
IOrmDataService dataService,
IServiceProvider serviceProvider)
IServiceProvider serviceProvider,
ISnackbar snackbar)
{
Model = new EditEntityModel { StringId = stringId };
InstancePrimaryKey = instancePrimaryKey;

this.entityService = entityService;
this.dataService = dataService;
this.serviceProvider = serviceProvider;
this.snackbar = snackbar;
}

/// <summary>
/// Whether the entity exists.
/// </summary>
public bool IsEntityExists { get; private set; } = true;

/// <summary>
/// Is entity was updated.
/// </summary>
public bool IsUpdated { get; set; }

/// <summary>
/// Errors encountered while entity updating.
/// </summary>
Expand Down Expand Up @@ -165,6 +164,6 @@ public async Task UpdateEntityAsync()
// We do clone because UpdateAsync method returns Model.OriginalEntityInstance
// so we don't want Model.EntityInstance and Model.OriginalEntityInstance to have the same reference.
Model.EntityInstance = updatedEntity.CloneJson();
IsUpdated = true;
snackbar.Add("Update was completed successfully", Severity.Success);
}
}

0 comments on commit c2e7884

Please sign in to comment.