From 058b4d890a129bd46d63df5edf595080ea98d651 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Fi=C5=A1era?= Date: Sat, 26 Nov 2022 11:02:09 +0100 Subject: [PATCH] #444 - Collapsible templates selection. --- .../Components/OutcomeCreate.razor | 81 ++++++++++--------- .../Components/OutcomeCreate.razor.cs | 6 +- .../ExpenseTemplateEntity.cs | 2 +- 3 files changed, 50 insertions(+), 39 deletions(-) diff --git a/src/Money.Blazor.Host/Components/OutcomeCreate.razor b/src/Money.Blazor.Host/Components/OutcomeCreate.razor index e9d3cfd1..3b092f2e 100644 --- a/src/Money.Blazor.Host/Components/OutcomeCreate.razor +++ b/src/Money.Blazor.Host/Components/OutcomeCreate.razor @@ -4,48 +4,55 @@ @if (Templates != null) { - -
- @foreach (var model in Templates) - { -
-
-
-
- - @CurrencyFormatter.Format(model.Amount, CurrencyFormatter.FormatZero.Placehoder) - -
+ + @if (AreTemplatesOpened) + { + +
+ @foreach (var model in Templates) + { +
+
+
+
+ + @CurrencyFormatter.Format(model.Amount, CurrencyFormatter.FormatZero.Placehoder) + +
- @if (!model.CategoryKey.IsEmpty) - { -

- @FindCategoryName(model.CategoryKey) -

- } + @if (!model.CategoryKey.IsEmpty) + { +

+ @FindCategoryName(model.CategoryKey) +

+ } - @if (!String.IsNullOrEmpty(model.Description)) - { -

- - @model.Description + @if (!String.IsNullOrEmpty(model.Description)) + { +

+ + @model.Description - @if (model.IsFixed) - { - Fixed - } - -

- } + @if (model.IsFixed) + { + Fixed + } + +

+ } +
-
- } -
+ } +
+ } }
diff --git a/src/Money.Blazor.Host/Components/OutcomeCreate.razor.cs b/src/Money.Blazor.Host/Components/OutcomeCreate.razor.cs index 51b76757..150f85bf 100644 --- a/src/Money.Blazor.Host/Components/OutcomeCreate.razor.cs +++ b/src/Money.Blazor.Host/Components/OutcomeCreate.razor.cs @@ -71,6 +71,8 @@ public partial class OutcomeCreate : System.IDisposable [Parameter] public bool IsFixed { get; set; } + protected bool AreTemplatesOpened { get; set; } + private bool isAttachedToComponentContainer; protected override void OnInitialized() @@ -192,7 +194,6 @@ protected void ApplyTemplate(ExpenseTemplateModel model) { Amount = model.Amount.Value; Currency = model.Amount.Currency; - IsFixed = model.IsFixed; } if (!String.IsNullOrEmpty(model.Description)) @@ -200,6 +201,9 @@ protected void ApplyTemplate(ExpenseTemplateModel model) if (!model.CategoryKey.IsEmpty) CategoryKey = model.CategoryKey; + + IsFixed = model.IsFixed; + AreTemplatesOpened = false; } protected string FindCategoryName(IKey categoryKey) diff --git a/src/Money.Models.EntityFrameworkCore/ExpenseTemplateEntity.cs b/src/Money.Models.EntityFrameworkCore/ExpenseTemplateEntity.cs index cffedcda..c1dea998 100644 --- a/src/Money.Models.EntityFrameworkCore/ExpenseTemplateEntity.cs +++ b/src/Money.Models.EntityFrameworkCore/ExpenseTemplateEntity.cs @@ -37,7 +37,7 @@ public ExpenseTemplateEntity(ExpenseTemplateCreated payload) if (!payload.CategoryKey.IsEmpty) CategoryId = payload.CategoryKey.AsGuidKey().Guid; - IsFixed = true; + IsFixed = payload.IsFixed; } public ExpenseTemplateModel ToModel(int version) => version == 1