From 0727706864fc36e0dc0bbac2bde52907f765e35f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Fi=C5=A1era?= Date: Fri, 8 Mar 2019 23:23:32 +0100 Subject: [PATCH] #218 - Integrate loading in Categories and Currencies. --- src/Money.UI.Blazor/Pages/Categories.cshtml | 52 +++++++------- .../Pages/Categories.cshtml.cs | 6 +- src/Money.UI.Blazor/Pages/Currencies.cshtml | 70 ++++++++++--------- .../Pages/Currencies.cshtml.cs | 6 +- 4 files changed, 73 insertions(+), 61 deletions(-) diff --git a/src/Money.UI.Blazor/Pages/Categories.cshtml b/src/Money.UI.Blazor/Pages/Categories.cshtml index e72d968a..4be24515 100644 --- a/src/Money.UI.Blazor/Pages/Categories.cshtml +++ b/src/Money.UI.Blazor/Pages/Categories.cshtml @@ -7,35 +7,37 @@ -@if (Models.Count == 0) -{ - -} -else -{ - @foreach (var item in Models) + + @if (Models.Count == 0) { -
- @if (item.Icon != null) - { - @item.Icon - } - - @item.Name - - - @item.Description - + + } + else + { + @foreach (var item in Models) + { +
+ @if (item.Icon != null) + { + @item.Icon + } + + @item.Name + + + @item.Description + - -
+ } } -} + diff --git a/src/Money.UI.Blazor/Pages/Categories.cshtml.cs b/src/Money.UI.Blazor/Pages/Categories.cshtml.cs index 0f7974a3..05ede2f9 100644 --- a/src/Money.UI.Blazor/Pages/Categories.cshtml.cs +++ b/src/Money.UI.Blazor/Pages/Categories.cshtml.cs @@ -3,6 +3,7 @@ using Money.Events; using Money.Models; using Money.Models.Confirmation; +using Money.Models.Loading; using Money.Models.Queries; using Neptuo.Commands; using Neptuo.Events; @@ -42,13 +43,16 @@ public class CategoriesBase : BlazorComponent, protected List Models { get; private set; } = new List(); protected CategoryModel Selected { get; set; } protected DeleteContext Delete { get; } = new DeleteContext(); + protected LoadingContext Loading { get; } = new LoadingContext(); protected override async Task OnInitAsync() { BindEvents(); Delete.Confirmed += async model => await Commands.HandleAsync(new DeleteCategory(model.Key)); Delete.MessageFormatter = model => $"Do you really want to delete category '{model.Name}'?"; - await LoadDataAsync(); + + using (Loading.Start()) + await LoadDataAsync(); } protected async void Reload() diff --git a/src/Money.UI.Blazor/Pages/Currencies.cshtml b/src/Money.UI.Blazor/Pages/Currencies.cshtml index dfd948d4..bfa87830 100644 --- a/src/Money.UI.Blazor/Pages/Currencies.cshtml +++ b/src/Money.UI.Blazor/Pages/Currencies.cshtml @@ -7,50 +7,52 @@ -@if (Models.Count == 0) -{ - -} -else -{ - @foreach (var item in Models) + + @if (Models.Count == 0) { -
-
- - @item.Symbol - -
-
-

This currency has unique code @item.UniqueCode.

- @if (item.IsDefault) - { -

This is a default currency used for displaying outcomes.

- } - - + } } -} + diff --git a/src/Money.UI.Blazor/Pages/Currencies.cshtml.cs b/src/Money.UI.Blazor/Pages/Currencies.cshtml.cs index cd150556..8694562e 100644 --- a/src/Money.UI.Blazor/Pages/Currencies.cshtml.cs +++ b/src/Money.UI.Blazor/Pages/Currencies.cshtml.cs @@ -3,6 +3,7 @@ using Money.Events; using Money.Models; using Money.Models.Confirmation; +using Money.Models.Loading; using Money.Models.Queries; using Neptuo.Commands; using Neptuo.Events; @@ -59,13 +60,16 @@ protected bool IsCreateExchangeRateVisible public List Models { get; private set; } = new List(); public CurrencyModel Selected { get; protected set; } protected DeleteContext Delete { get; } = new DeleteContext(); + protected LoadingContext Loading { get; } = new LoadingContext(); protected override async Task OnInitAsync() { BindEvents(); Delete.Confirmed += async model => await Commands.HandleAsync(new DeleteCurrency(model.UniqueCode)); Delete.MessageFormatter = model => $"Do you really want to delete currency '{model.Symbol}'?"; - await LoadDataAsync(); + + using (Loading.Start()) + await LoadDataAsync(); } protected async void OnEvent()