Skip to content

Commit

Permalink
#417 - Progress on template list design.
Browse files Browse the repository at this point in the history
  • Loading branch information
maraf committed Jun 14, 2022
1 parent e64c498 commit 9f2f0a2
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 8 deletions.
10 changes: 5 additions & 5 deletions src/Money.Blazor.Host/Pages/ExpenseTemplates.razor
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
<div class="card-body">
@if (model.Amount != null)
{
<p>
@model.Amount
</p>
<h3 class="m-0">
@CurrencyFormatter.Format(model.Amount)
</h3>
}

@if (!model.CategoryKey.IsEmpty)
{
<p>
@model.CategoryKey
<p class="m-0 @FindCategoryColor(model.CategoryKey)?.SelectAccent("back-dark", "back-light")">
<span class="badge" style="background-color: @FindCategoryColor(model.CategoryKey)?.ToHashCode()">@FindCategoryName(model.CategoryKey)</span>
</p>
}

Expand Down
21 changes: 21 additions & 0 deletions src/Money.Blazor.Host/Pages/ExpenseTemplates.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using Neptuo.Events;
using Neptuo.Events.Handlers;
using Neptuo.Logging;
using Neptuo.Models.Keys;
using Neptuo.Queries;
using Neptuo.Queries.Handlers;
using System;
Expand All @@ -28,8 +29,13 @@ public partial class ExpenseTemplates : IDisposable, IEventHandler<ExpenseTempla
[Inject]
protected IQueryDispatcher Queries { get; set; }

[Inject]
protected CurrencyFormatterFactory CurrencyFormatterFactory { get; set; }

protected CurrencyFormatter CurrencyFormatter { get; private set; }
protected ExpenseTemplateCreate Modal { get; set; }
protected List<ExpenseTemplateModel> Models { get; } = new List<ExpenseTemplateModel>();
protected List<CategoryModel> Categories { get; private set; }

protected async override Task OnInitializedAsync()
{
Expand All @@ -39,9 +45,24 @@ protected async override Task OnInitializedAsync()

await base.OnInitializedAsync();

Categories = await Queries.QueryAsync(new ListAllCategory(true));
CurrencyFormatter = await CurrencyFormatterFactory.CreateAsync();

await ReloadAsync();
}

protected string FindCategoryName(IKey categoryKey)
{
var category = Categories.FirstOrDefault(c => c.Key.Equals(categoryKey));
return category?.Name;
}

protected Color? FindCategoryColor(IKey categoryKey)
{
var category = Categories.FirstOrDefault(c => c.Key.Equals(categoryKey));
return category?.Color;
}

private async Task ReloadAsync()
{
Models.Clear();
Expand Down
3 changes: 1 addition & 2 deletions src/Money.Blazor.Host/wwwroot/css/site.css
Original file line number Diff line number Diff line change
Expand Up @@ -306,8 +306,7 @@ h4 {
max-width: 900px;
margin: 0 auto; }
.overview .sort {
float: right;
margin-right: 35px; }
float: right; }

.search {
max-width: 900px;
Expand Down
2 changes: 1 addition & 1 deletion src/Money.Blazor.Host/wwwroot/css/site.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 9f2f0a2

Please sign in to comment.