PersonRolesEditActorComponent fix
This commit is contained in:
@@ -21,6 +21,12 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(_error))
|
||||
{
|
||||
<div class="col-auto align-self-center">
|
||||
<span class="text-danger">@(_error)</span>
|
||||
</div>
|
||||
}
|
||||
<div class="col-auto">
|
||||
<button type="button" class="btn btn-secondary" @onclick="@(CancelEdit)">Cancel</button>
|
||||
</div>
|
||||
|
||||
@@ -32,6 +32,7 @@ public partial class PersonRolesEditActorComponent : ComponentBase
|
||||
#region FIELDS
|
||||
|
||||
private bool _loaded;
|
||||
private string? _error;
|
||||
|
||||
private Dictionary<Guid, (ActorRoleResponse Data, bool Deleting)> _roles = [];
|
||||
private Dictionary<short, string> _roleTypes = [];
|
||||
@@ -76,6 +77,7 @@ public partial class PersonRolesEditActorComponent : ComponentBase
|
||||
|
||||
private void CancelEdit()
|
||||
{
|
||||
_error = null;
|
||||
_editingMode = false;
|
||||
}
|
||||
|
||||
@@ -104,14 +106,27 @@ public partial class PersonRolesEditActorComponent : ComponentBase
|
||||
_editingMode = false;
|
||||
}
|
||||
|
||||
void BadRequest(IDictionary<string, string[]> errors)
|
||||
{
|
||||
_error = errors.SelectMany(x => x.Value).FirstOrDefault() ?? "Unknown error";
|
||||
_saving = false;
|
||||
}
|
||||
|
||||
void Unauthorized()
|
||||
{
|
||||
_error = "You do not have permission to do this";
|
||||
_saving = false;
|
||||
}
|
||||
|
||||
_error = null;
|
||||
_saving = true;
|
||||
if (_editedId.HasValue)
|
||||
{
|
||||
await RolesWebAPIService.PutActorRole(_editedId.Value, _editedModel as ActorRoleUniversalRequest, SuccessPut);
|
||||
await RolesWebAPIService.PutActorRole(_editedId.Value, _editedModel as ActorRoleUniversalRequest, SuccessPut, BadRequest, Unauthorized);
|
||||
}
|
||||
else
|
||||
{
|
||||
await PersonsWebAPIService.PostPersonActorRole(Id!.Value, _editedModel as ActorRolePersonRequest, SuccessPost);
|
||||
await PersonsWebAPIService.PostPersonActorRole(Id!.Value, _editedModel as ActorRolePersonRequest, SuccessPost, BadRequest, Unauthorized);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user