Use shared page state classes
This commit is contained in:
@ -26,7 +26,7 @@
|
||||
</RadzenRow>
|
||||
<RadzenRow>
|
||||
<RadzenColumn SizeMD="12">
|
||||
<RadzenDataGrid @ref="@campaignsDataGrid" TItem="Campaign" Data="@campaigns" RowExpand="@RowExpandAsync" RowCollapse="@RowCollapse" IsLoading="@(state != CampaignsPageState.Idle)" AllowFiltering="true" AllowPaging="true" ShowPagingSummary="true" PageSizeOptions=@(new int[] { 5, 10, 20, 30 }) AllowSorting="true" AllowColumnResize="true" ExpandMode="DataGridExpandMode.Single">
|
||||
<RadzenDataGrid @ref="@campaignsDataGrid" TItem="Campaign" Data="@campaigns" RowExpand="@RowExpandAsync" RowCollapse="@RowCollapse" IsLoading="@(state != PageState.Idle)" AllowFiltering="true" AllowPaging="true" ShowPagingSummary="true" PageSizeOptions=@(new int[] { 5, 10, 20, 30 }) AllowSorting="true" AllowColumnResize="true" ExpandMode="DataGridExpandMode.Single">
|
||||
<Template Context="campaign">
|
||||
<RadzenDataGrid @ref="@operationsDataGrid" Data="@campaign.Operations" AllowFiltering="true" AllowPaging="true" ShowPagingSummary="true" PageSizeOptions=@(new int[] { 5, 10, 20, 30 }) AllowSorting="true" AllowColumnResize="true">
|
||||
<Columns>
|
||||
@ -61,14 +61,7 @@
|
||||
</AuthorizedContent>
|
||||
|
||||
@code {
|
||||
enum CampaignsPageState
|
||||
{
|
||||
Init,
|
||||
Loading,
|
||||
Idle
|
||||
}
|
||||
|
||||
CampaignsPageState state;
|
||||
PageState state;
|
||||
RadzenDataGrid<Campaign> campaignsDataGrid;
|
||||
RadzenDataGrid<Operation> operationsDataGrid;
|
||||
IEnumerable<Campaign>? campaigns;
|
||||
@ -80,7 +73,7 @@
|
||||
|
||||
if (firstRender)
|
||||
{
|
||||
ChangeState(CampaignsPageState.Loading);
|
||||
ChangeState(PageState.Loading);
|
||||
|
||||
var state = await AuthenticationStateProvider.GetAuthenticationStateAsync();
|
||||
if (state.User.IsInRole(AppRole.ADMINISTRATOR_TYPE) || state.User.IsInRole(AppRole.OPERATOR_TYPE))
|
||||
@ -99,7 +92,7 @@
|
||||
ResultWaitState.OnOperationEnded += OnOperationEnded;
|
||||
}
|
||||
|
||||
ChangeState(CampaignsPageState.Idle);
|
||||
ChangeState(PageState.Idle);
|
||||
}
|
||||
}
|
||||
|
||||
@ -123,7 +116,7 @@
|
||||
campaign.Operations = null;
|
||||
}
|
||||
|
||||
void ChangeState(CampaignsPageState state)
|
||||
void ChangeState(PageState state)
|
||||
{
|
||||
if (this.state == state) return;
|
||||
|
||||
@ -139,7 +132,7 @@
|
||||
|
||||
async Task RefreshCampaigns()
|
||||
{
|
||||
await InvokeAsync(() => ChangeState(CampaignsPageState.Loading));
|
||||
await InvokeAsync(() => ChangeState(PageState.Loading));
|
||||
|
||||
var refreshedCampaigns = await HeadquartersService.GetCampaignsAsync();
|
||||
|
||||
@ -148,7 +141,7 @@
|
||||
campaigns = refreshedCampaigns;
|
||||
expandedCampaign = null;
|
||||
|
||||
ChangeState(CampaignsPageState.Idle);
|
||||
ChangeState(PageState.Idle);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user