feat: implement preview work units preference with local storage support
All checks were successful
Publish Container / publish (push) Successful in 3m16s
All checks were successful
Publish Container / publish (push) Successful in 3m16s
This commit is contained in:
parent
158906fa28
commit
0991128b30
4 changed files with 104 additions and 5 deletions
|
|
@ -199,6 +199,8 @@ else
|
|||
@code {
|
||||
[Parameter] public string? YearMonth { get; set; }
|
||||
|
||||
private const string IncludePreviewPreferenceKey = "worktracker.includePreviewWorkUnits";
|
||||
|
||||
private DateOnly firstOfMonth;
|
||||
private bool loading = true;
|
||||
private List<CalendarCell?[]> weeks = [];
|
||||
|
|
@ -222,6 +224,22 @@ else
|
|||
await LoadMonth();
|
||||
}
|
||||
|
||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||
{
|
||||
if (!firstRender)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var savedIncludePreview = await JS.InvokeAsync<bool?>("workTrackerPreferences.getBool", IncludePreviewPreferenceKey);
|
||||
if (savedIncludePreview.HasValue && savedIncludePreview.Value != includePreviewTotals)
|
||||
{
|
||||
includePreviewTotals = savedIncludePreview.Value;
|
||||
await LoadMonth();
|
||||
await InvokeAsync(StateHasChanged);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task LoadMonth()
|
||||
{
|
||||
loading = true;
|
||||
|
|
@ -269,6 +287,7 @@ else
|
|||
private async Task OnIncludePreviewTotalsChanged(ChangeEventArgs e)
|
||||
{
|
||||
includePreviewTotals = e.Value is bool value && value;
|
||||
await JS.InvokeVoidAsync("workTrackerPreferences.setBool", IncludePreviewPreferenceKey, includePreviewTotals);
|
||||
await LoadMonth();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
@using System.Globalization
|
||||
@inject global::WorkTracker.Services.WorkDays.IWorkDayService WorkDayService
|
||||
@inject IJSRuntime JS
|
||||
|
||||
<PageTitle>Monthly Summary</PageTitle>
|
||||
|
||||
|
|
@ -209,6 +210,7 @@ else if (viewMode == SummaryViewMode.Timesheet && timesheet is not null)
|
|||
[Parameter] public string? YearMonth { get; set; }
|
||||
|
||||
private static readonly CultureInfo ItalianCulture = CultureInfo.GetCultureInfo("it-IT");
|
||||
private const string IncludePreviewPreferenceKey = "worktracker.includePreviewWorkUnits";
|
||||
|
||||
private DateOnly currentMonth;
|
||||
private bool loading = true;
|
||||
|
|
@ -231,9 +233,26 @@ else if (viewMode == SummaryViewMode.Timesheet && timesheet is not null)
|
|||
await LoadSummary();
|
||||
}
|
||||
|
||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||
{
|
||||
if (!firstRender)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var savedIncludePreview = await JS.InvokeAsync<bool?>("workTrackerPreferences.getBool", IncludePreviewPreferenceKey);
|
||||
if (savedIncludePreview.HasValue && savedIncludePreview.Value != includePreview)
|
||||
{
|
||||
includePreview = savedIncludePreview.Value;
|
||||
await LoadSummary();
|
||||
await InvokeAsync(StateHasChanged);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task OnIncludePreviewChanged(ChangeEventArgs e)
|
||||
{
|
||||
includePreview = e.Value is bool value && value;
|
||||
await JS.InvokeVoidAsync("workTrackerPreferences.setBool", IncludePreviewPreferenceKey, includePreview);
|
||||
await LoadSummary();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue