MRB webassembly
This commit is contained in:
74
MesaFabApproval.Client/Pages/Components/UserSelector.razor
Normal file
74
MesaFabApproval.Client/Pages/Components/UserSelector.razor
Normal file
@ -0,0 +1,74 @@
|
||||
@inject IUserService userService
|
||||
@inject ISnackbar snackbar
|
||||
@inject MesaFabApprovalAuthStateProvider authStateProvider
|
||||
|
||||
<MudDialog>
|
||||
<DialogContent>
|
||||
@if (allUsers is not null) {
|
||||
<MudPaper Class="p-2">
|
||||
<MudSelect T="User"
|
||||
Label="Select a User"
|
||||
Required
|
||||
Variant="Variant.Outlined"
|
||||
AnchorOrigin="Origin.BottomCenter"
|
||||
@bind-Value=selectedUser
|
||||
Text="@(selectedUser is null ? "" : selectedUser.GetFullName())">
|
||||
@foreach (User user in allUsers) {
|
||||
<MudSelectItem Value="@user">
|
||||
@user.GetFullName()
|
||||
</MudSelectItem>
|
||||
}
|
||||
</MudSelect>
|
||||
</MudPaper>
|
||||
}
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<MudButton Variant="Variant.Filled"
|
||||
Color="Color.Tertiary"
|
||||
Class="m1-auto"
|
||||
OnClick=Submit>
|
||||
<MudText>Submit</MudText>
|
||||
</MudButton>
|
||||
<MudButton Variant="Variant.Filled"
|
||||
Color="Color.Secondary"
|
||||
Class="m1-auto"
|
||||
OnClick=Cancel>
|
||||
<MudText>Cancel</MudText>
|
||||
</MudButton>
|
||||
</DialogActions>
|
||||
</MudDialog>
|
||||
|
||||
<MudOverlay Visible=processing DarkBackground="true" AutoClose="false">
|
||||
<MudProgressCircular Color="Color.Info" Size="Size.Medium" Indeterminate="true" />
|
||||
</MudOverlay>
|
||||
|
||||
@code {
|
||||
[CascadingParameter] MudDialogInstance MudDialog { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public User selectedUser { get; set; }
|
||||
|
||||
private bool processing = false;
|
||||
|
||||
private IEnumerable<User> allUsers = new List<User>();
|
||||
|
||||
protected override async Task OnInitializedAsync() {
|
||||
try {
|
||||
processing = true;
|
||||
selectedUser = authStateProvider.CurrentUser;
|
||||
allUsers = await userService.GetAllActiveUsers();
|
||||
processing = false;
|
||||
} catch (Exception ex) {
|
||||
processing = false;
|
||||
snackbar.Add($"Unable to get all users, because {ex.Message}", Severity.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void Submit() {
|
||||
MudDialog.Close(DialogResult.Ok(selectedUser));
|
||||
}
|
||||
|
||||
private void Cancel() {
|
||||
MudDialog.Close(DialogResult.Cancel());
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user