-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#372 - Refactor period selector. Select year in balances.
- Loading branch information
Showing
7 changed files
with
129 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
@typeparam T | ||
|
||
<button type="button" class="btn btn-primary" @onclick="OpenSelectorAsync"> | ||
@Selected?.ToString() | ||
<Icon Identifier="caret-down" /> | ||
</button> | ||
|
||
@if (Previous != null && Previous.Count > 0) | ||
{ | ||
<span class="d-none d-md-inline"> | ||
@foreach (var prev in Previous) | ||
{ | ||
<a class="btn btn-link" href="@LinkFactory(prev)"> | ||
@prev | ||
</a> | ||
} | ||
</span> | ||
} | ||
|
||
<Modal @ref="SelectorModal" Title="Select a period" TitleIcon="calendar" BodyCssClass="p-0"> | ||
<Loading Context="@Loading"> | ||
<LoadingContent> | ||
<div class="p-3"> | ||
<i>Loading...</i> | ||
</div> | ||
</LoadingContent> | ||
<ChildContent> | ||
@if (Periods != null) | ||
{ | ||
if (Periods.Count > 0) | ||
{ | ||
<div class="list-group list-group-flush"> | ||
@foreach (var item in Periods) | ||
{ | ||
<a @onclick="@(() => SelectorModal.Hide())" href="@LinkFactory(item)" class="list-group-item @(item.Equals(Selected) ? "active" : null)"> | ||
@item.ToString() | ||
</a> | ||
} | ||
</div> | ||
} | ||
else | ||
{ | ||
<div class="p-3"> | ||
<Alert Title="No data." Mode="@AlertMode.Warning" /> | ||
</div> | ||
} | ||
} | ||
</ChildContent> | ||
</Loading> | ||
</Modal> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
using Microsoft.AspNetCore.Components; | ||
using Money.Components.Bootstrap; | ||
using Money.Models.Loading; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Money.Components | ||
{ | ||
public partial class PeriodSelector<T> | ||
{ | ||
[Parameter] | ||
public T Selected { get; set; } | ||
|
||
[Parameter] | ||
public IReadOnlyCollection<T> Previous { get; set; } | ||
|
||
[Parameter] | ||
public Func<T, string> LinkFactory { get; set; } | ||
|
||
[Parameter] | ||
public Func<Task<IReadOnlyCollection<T>>> ExactGetter { get; set; } | ||
|
||
protected LoadingContext Loading { get; } = new LoadingContext(); | ||
protected Modal SelectorModal { get; set; } | ||
protected IReadOnlyCollection<T> Periods { get; private set; } | ||
|
||
protected async Task LoadAsync() | ||
{ | ||
using (Loading.Start()) | ||
Periods = await ExactGetter(); | ||
} | ||
|
||
protected async Task OpenSelectorAsync() | ||
{ | ||
SelectorModal.Show(); | ||
await LoadAsync(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters