62 lines
2.0 KiB
Plaintext
62 lines
2.0 KiB
Plaintext
@using System.Globalization
|
|
@using MudBlazor
|
|
|
|
<MudDialog>
|
|
<DialogContent>
|
|
<MudStack Spacing="3" Class="pa-2">
|
|
<MudSelect @bind-Value="_selectedYear" Label="Jahr" Variant="Variant.Outlined">
|
|
@foreach (var year in _years)
|
|
{
|
|
<MudSelectItem Value="@year">@year</MudSelectItem>
|
|
}
|
|
</MudSelect>
|
|
<MudSelect @bind-Value="_selectedMonth" Label="Monat" Variant="Variant.Outlined">
|
|
@foreach (var month in _months)
|
|
{
|
|
<MudSelectItem Value="@month.Value">@month.Name</MudSelectItem>
|
|
}
|
|
</MudSelect>
|
|
</MudStack>
|
|
</DialogContent>
|
|
<DialogActions>
|
|
<MudButton OnClick="Cancel">Abbrechen</MudButton>
|
|
<MudButton Color="Color.Primary" Variant="Variant.Filled" OnClick="Submit">Herunterladen</MudButton>
|
|
</DialogActions>
|
|
</MudDialog>
|
|
|
|
@code {
|
|
[CascadingParameter] IMudDialogInstance MudDialog { get; set; } = null!;
|
|
|
|
private int _selectedYear = DateTime.Today.Year;
|
|
private int _selectedMonth = DateTime.Today.Month;
|
|
|
|
private List<int> _years = Enumerable.Range(DateTime.Today.Year - 5, 6).OrderByDescending(y => y).ToList();
|
|
|
|
private class MonthOption
|
|
{
|
|
public int Value { get; set; }
|
|
public string Name { get; set; } = "";
|
|
}
|
|
|
|
private List<MonthOption> _months = [];
|
|
|
|
protected override void OnInitialized()
|
|
{
|
|
var deCulture = new CultureInfo("de-DE");
|
|
_months = Enumerable.Range(1, 12).Select(m => new MonthOption
|
|
{
|
|
Value = m,
|
|
Name = deCulture.DateTimeFormat.GetMonthName(m)
|
|
}).ToList();
|
|
}
|
|
|
|
public class MonthSelectorResult
|
|
{
|
|
public int Year { get; set; }
|
|
public int Month { get; set; }
|
|
}
|
|
|
|
void Submit() => MudDialog.Close(DialogResult.Ok(new MonthSelectorResult { Year = _selectedYear, Month = _selectedMonth }));
|
|
void Cancel() => MudDialog.Cancel();
|
|
}
|