Skip to content

Commit

Permalink
#346 - Editor for date format.
Browse files Browse the repository at this point in the history
  • Loading branch information
maraf committed May 20, 2021
1 parent a2a004e commit 9355df6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Money.Api/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@
"RequireUppercase": false
}
},
"UserProperties": [ "PriceDecimalDigits" ]
"UserProperties": [ "PriceDecimalDigits", "DateFormat" ]
}
13 changes: 12 additions & 1 deletion src/Money.Blazor.Host/Pages/Users/Settings.razor
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<div class="row my-4 mx-1">
@foreach (var viewModel in ViewModels)
{
{
<div class="col-auto mb-4">
<button class="btn btn-block btn-light" @onclick="viewModel.Edit">
@if (viewModel.Icon != null)
Expand All @@ -30,4 +30,15 @@
<Buttons>
<button class="btn btn-primary" @onclick="(async () => { await PriceDecimals.SetAsync(); PriceDecimalsEditor.Hide(); })">Set</button>
</Buttons>
</Modal>

<Modal @ref="DateFormatEditor" Title="Set date format">
<ChildContent>
<div class="form-group">
<input type="text" class="form-control" @bind="DateFormat.CurrentValue" data-autofocus />
</div>
</ChildContent>
<Buttons>
<button class="btn btn-primary" @onclick="(async () => { await DateFormat.SetAsync(); DateFormatEditor.Hide(); })">Set</button>
</Buttons>
</Modal>
4 changes: 4 additions & 0 deletions src/Money.Blazor.Host/Pages/Users/Settings.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ public partial class Settings : System.IDisposable,
protected PropertyViewModel PriceDecimals { get; set; }
protected Modal PriceDecimalsEditor { get; set; }

protected PropertyViewModel DateFormat { get; set; }
protected Modal DateFormatEditor { get; set; }

protected List<UserPropertyModel> Models { get; set; }
protected List<PropertyViewModel> ViewModels { get; } = new List<PropertyViewModel>();

Expand All @@ -44,6 +47,7 @@ protected async override Task OnInitializedAsync()
EventHandlers.Add<UserPropertyChanged>(this);

PriceDecimals = AddProperty("PriceDecimalDigits", "Price decimal digits", () => PriceDecimalsEditor.Show(), icon: "pound-sign", defaultValue: "2");
DateFormat = AddProperty("DateFormat", "Date format", () => DateFormatEditor.Show(), icon: "calendar-day", defaultValue: CultureInfo.CurrentUICulture.DateTimeFormat.ShortDatePattern);

await LoadAsync();
}
Expand Down

0 comments on commit 9355df6

Please sign in to comment.