Use shared page state classes

This commit is contained in:
2025-11-13 09:28:43 +09:00
parent 68cca6501f
commit 9bd8778e34
6 changed files with 65 additions and 76 deletions

View File

@ -25,7 +25,7 @@
</RadzenRow>
<RadzenRow>
<RadzenColumn SizeMD="12">
<RadzenDataGrid @ref="@dataGrid" TItem="Operation" Data="@operations" IsLoading="@(state != OperationPageState.Idle)" AllowFiltering="true" AllowPaging="true" ShowPagingSummary="true" PageSizeOptions=@(new int[] { 5, 10, 20, 30 }) AllowSorting="true" AllowColumnResize="true">
<RadzenDataGrid @ref="@dataGrid" TItem="Operation" Data="@operations" IsLoading="@(state != PageState.Idle)" AllowFiltering="true" AllowPaging="true" ShowPagingSummary="true" PageSizeOptions=@(new int[] { 5, 10, 20, 30 }) AllowSorting="true" AllowColumnResize="true">
<Columns>
<RadzenDataGridColumn TItem="Operation" Property="@nameof(Operation.Id)" Title="ID" SortOrder="SortOrder.Descending" Resizable="false" Width="100px" MaxWidth="100px" />
<RadzenDataGridColumn TItem="Operation" Property="@nameof(Operation.CampaignId)" Title="ID кампании" Resizable="false" Width="100px" MaxWidth="100px" />
@ -44,14 +44,7 @@
</AuthorizedContent>
@code {
enum OperationPageState
{
Init,
Loading,
Idle
}
OperationPageState state;
PageState state;
RadzenDataGrid<Operation> dataGrid;
ICollection<Operation>? operations;
@ -61,7 +54,7 @@
if (firstRender)
{
ChangeState(OperationPageState.Loading);
ChangeState(PageState.Loading);
var state = await AuthenticationStateProvider.GetAuthenticationStateAsync();
if (state.User.IsInRole(AppRole.ADMINISTRATOR_TYPE) || state.User.IsInRole(AppRole.OPERATOR_TYPE))
@ -76,11 +69,11 @@
ResultWaitState.OnOperationEnded += OnOperationEnded;
}
ChangeState(OperationPageState.Idle);
ChangeState(PageState.Idle);
}
}
void ChangeState(OperationPageState state)
void ChangeState(PageState state)
{
if (this.state == state) return;