Persist field picker across page reloads
parent
611cd889ae
commit
f404420007
|
@ -1,9 +1,11 @@
|
||||||
@page "/Games"
|
@page "/Games"
|
||||||
@using LANCommander.Extensions;
|
@using LANCommander.Extensions;
|
||||||
@using System.ComponentModel.DataAnnotations;
|
@using System.ComponentModel.DataAnnotations;
|
||||||
|
@using Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage;
|
||||||
@attribute [Authorize]
|
@attribute [Authorize]
|
||||||
@inject GameService GameService
|
@inject GameService GameService
|
||||||
@inject NavigationManager NavigationManager
|
@inject NavigationManager NavigationManager
|
||||||
|
@inject ProtectedLocalStorage BrowserStorage
|
||||||
|
|
||||||
<PageHeader Title="Games">
|
<PageHeader Title="Games">
|
||||||
<PageHeaderExtra>
|
<PageHeaderExtra>
|
||||||
|
@ -11,7 +13,7 @@
|
||||||
</PageHeaderExtra>
|
</PageHeaderExtra>
|
||||||
</PageHeader>
|
</PageHeader>
|
||||||
|
|
||||||
<Drawer Closable="true" Visible="@FieldPickerVisible" Placement="right" Title="@("Fields")" OnClose="() => FieldPickerVisible = false">
|
<Drawer Closable="true" Visible="@FieldPickerVisible" Placement="right" Title="@("Fields")" OnClose="() => CloseFieldPicker()">
|
||||||
<Space Direction="@DirectionVHType.Vertical">
|
<Space Direction="@DirectionVHType.Vertical">
|
||||||
<SpaceItem><Switch Checked="FieldVisible(Field.Icon)" OnChange="(state) => ChangeFieldVisibility(Field.Icon, state)" /> @Field.Icon.GetDisplayName()</SpaceItem>
|
<SpaceItem><Switch Checked="FieldVisible(Field.Icon)" OnChange="(state) => ChangeFieldVisibility(Field.Icon, state)" /> @Field.Icon.GetDisplayName()</SpaceItem>
|
||||||
<SpaceItem><Switch Checked="FieldVisible(Field.Title)" OnChange="(state) => ChangeFieldVisibility(Field.Title, state)" /> @Field.Title.GetDisplayName()</SpaceItem>
|
<SpaceItem><Switch Checked="FieldVisible(Field.Title)" OnChange="(state) => ChangeFieldVisibility(Field.Title, state)" /> @Field.Title.GetDisplayName()</SpaceItem>
|
||||||
|
@ -163,7 +165,7 @@
|
||||||
<ActionColumn Title="" Style="text-align: right">
|
<ActionColumn Title="" Style="text-align: right">
|
||||||
<TitleTemplate>
|
<TitleTemplate>
|
||||||
<div style="text-align: right">
|
<div style="text-align: right">
|
||||||
<Button Icon="@IconType.Outline.Edit" Type="@ButtonType.Text" OnClick="() => FieldPickerVisible = true" />
|
<Button Icon="@IconType.Outline.Edit" Type="@ButtonType.Text" OnClick="() => OpenFieldPicker()" />
|
||||||
</div>
|
</div>
|
||||||
</TitleTemplate>
|
</TitleTemplate>
|
||||||
<ChildContent>
|
<ChildContent>
|
||||||
|
@ -233,7 +235,7 @@
|
||||||
ArchiveSize,
|
ArchiveSize,
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnAfterRender(bool firstRender)
|
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||||
{
|
{
|
||||||
if (firstRender)
|
if (firstRender)
|
||||||
{
|
{
|
||||||
|
@ -241,6 +243,11 @@
|
||||||
|
|
||||||
Loading = false;
|
Loading = false;
|
||||||
|
|
||||||
|
var storedFieldVisibility = await BrowserStorage.GetAsync<Dictionary<Field, bool>>("Views.Games.FieldPicker");
|
||||||
|
|
||||||
|
if (storedFieldVisibility.Success && storedFieldVisibility.Value != null)
|
||||||
|
FieldVisibility = storedFieldVisibility.Value;
|
||||||
|
|
||||||
StateHasChanged();
|
StateHasChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -287,4 +294,16 @@
|
||||||
|
|
||||||
Loading = false;
|
Loading = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task OpenFieldPicker()
|
||||||
|
{
|
||||||
|
FieldPickerVisible = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task CloseFieldPicker()
|
||||||
|
{
|
||||||
|
FieldPickerVisible = false;
|
||||||
|
|
||||||
|
await BrowserStorage.SetAsync("Views.Games.FieldPicker", FieldVisibility);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue