Skip to content

Commit

Permalink
#322 - More navigations.
Browse files Browse the repository at this point in the history
From trends to year overview.
From month category overview to month trends.
  • Loading branch information
maraf committed May 18, 2021
1 parent b38d2da commit 925f9ed
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 5 deletions.
16 changes: 14 additions & 2 deletions src/Money.Blazor.Host/Pages/Overview.razor
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,18 @@
<Title Icon="calendar" Main="@Title" Sub="@SubTitle">
<ButtonContent>
<ExpenseCreateButton OnClick="CreateModal.Show" />
@{
var trendsButton = TrendsTitleUrl();
}
@if (trendsButton != null)
{
<button class="btn btn-secondary" @onclick="(() => Navigator.Open(trendsButton.Value.url))">
<Icon Prefix="fas" Identifier="chart-bar" />
<span class="d-none d-md-inline">
@trendsButton.Value.title
</span>
</button>
}
</ButtonContent>
</Title>
<ExceptionPanel />
Expand All @@ -14,7 +26,7 @@
<Loading Context="@Loading" IsOverlay="true">
@{
var incomeUrl = ListIncomeUrl();
var trendsUrl = TrendsUrl();
var trendsUrl = TrendsSelectedPeriodUrl();
}
@if (incomeUrl != null || trendsUrl != null)
{
Expand Down Expand Up @@ -64,4 +76,4 @@

<OutcomeAmount @ref="AmountEditModal" OutcomeKey="@SelectedItem?.Key" Amount="@(SelectedItem?.Amount?.Value ?? 0)" Currency="@SelectedItem?.Amount?.Currency" />
<OutcomeDescription @ref="DescriptionEditModal" OutcomeKey="@SelectedItem?.Key" Description="@SelectedItem?.Description" />
<OutcomeWhen @ref="WhenEditModal" OutcomeKey="@SelectedItem?.Key" When="@(SelectedItem?.When ?? DateTime.MinValue)" />
<OutcomeWhen @ref=" DescriptionEditModal" OutcomeKey="@SelectedItem?.Key" When="@(SelectedItem?.When ?? DateTime.MinValue)" />
5 changes: 4 additions & 1 deletion src/Money.Blazor.Host/Pages/Overview.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,10 @@ protected virtual T CreateSelectedItemFromParameters()
protected virtual string ListIncomeUrl()
=> null;

protected virtual string TrendsUrl()
protected virtual string TrendsSelectedPeriodUrl()
=> null;

protected virtual (string title, string url)? TrendsTitleUrl()
=> null;

protected async void Reload()
Expand Down
8 changes: 8 additions & 0 deletions src/Money.Blazor.Host/Pages/OverviewMonth.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,13 @@ protected override string ListIncomeUrl()

return null;
}

protected override (string title, string url)? TrendsTitleUrl()
{
if (CategoryKey.IsEmpty)
return null;

return ("Month trends", Navigator.UrlTrends(new YearModel(SelectedPeriod.Year), CategoryKey));
}
}
}
2 changes: 1 addition & 1 deletion src/Money.Blazor.Host/Pages/OverviewYear.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ protected override IQuery<List<OutcomeOverviewModel>> CreateItemsQuery(int pageI
protected override bool IsContained(DateTime when)
=> SelectedPeriod == when;

protected override string TrendsUrl()
protected override string TrendsSelectedPeriodUrl()
{
if (CategoryKey.IsEmpty)
return null;
Expand Down
9 changes: 8 additions & 1 deletion src/Money.Blazor.Host/Pages/TrendsMonth.razor
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
@page "/{Year:int}/trends/{CategoryGuid:guid}"

<Title Main="@($"Trends of category {CategoryName} in {Year}")" Sub="See how the category expenses change in time" />
<Title Main="@($"Trends of category {CategoryName} in {Year}")" Sub="See how the category expenses change in time">
<ButtonContent>
<button class="btn btn-secondary" @onclick="(() => Navigator.OpenOverview(SelectedPeriod, CategoryKey))">
<Icon Prefix="fas" Identifier="list-ul" />
Year overview
</button>
</ButtonContent>
</Title>

@if (Models == null)
{
Expand Down

0 comments on commit 925f9ed

Please sign in to comment.