multiple person edit page fixes

This commit is contained in:
2024-10-05 19:58:52 +02:00
Unverified
parent b561e242bb
commit 7b58b1ec38
6 changed files with 39 additions and 35 deletions

View File

@@ -80,7 +80,7 @@ public partial class PersonEditFormComponent : ComponentBase
void PostSuccess(PersonResponse data) void PostSuccess(PersonResponse data)
{ {
NavigationManager.NavigateTo($"person/{data.Id}/edit"); NavigationManager.NavigateTo($"person/{data.Id}/edit", true);
} }
void BadRequest(IDictionary<string, string[]> errors) void BadRequest(IDictionary<string, string[]> errors)

View File

@@ -6,10 +6,12 @@
<InputFile class="form-control content-width" OnChange="Load" disabled="@(!Id.HasValue)" autocomplete="off"/> <InputFile class="form-control content-width" OnChange="Load" disabled="@(!Id.HasValue)" autocomplete="off"/>
@if (_pictureChanged || _pictureSaved is not null) @if (_pictureChanged || _pictureSaved is not null)
{ {
<div class="d-flex gap-1 content-width"> <div class="content-width">
@if (_pictureChanged) @if (_pictureChanged)
{ {
<div class="flex-fill"> <div class="container-grid">
<div class="row gx-1">
<div class="col">
<button type="button" class="btn btn-secondary btn-block btn-stretch-x" @onclick="Save" disabled=@(!Id.HasValue || _pictureSaving || _pictureDeleting) autocomplete="off"> <button type="button" class="btn btn-secondary btn-block btn-stretch-x" @onclick="Save" disabled=@(!Id.HasValue || _pictureSaving || _pictureDeleting) autocomplete="off">
@if (!_pictureSaving) @if (!_pictureSaving)
{ {
@@ -22,13 +24,14 @@
} }
</button> </button>
</div> </div>
<div class="flex-fill"> <div class="col">
<button type="button" class="btn btn-danger btn-block btn-stretch-x" @onclick="Cancel" disabled=@(!Id.HasValue || _pictureSaving || _pictureDeleting) autocomplete="off">Drop changes</button> <button type="button" class="btn btn-danger btn-block btn-stretch-x" @onclick="Cancel" disabled=@(!Id.HasValue || _pictureSaving || _pictureDeleting) autocomplete="off">Drop changes</button>
</div> </div>
</div>
</div>
} }
else if (_pictureSaved is not null) else if (_pictureSaved is not null)
{ {
<div class="flex-fill">
<button type="button" class="btn btn-danger btn-block btn-stretch-x" @onclick="Delete" disabled=@(!Id.HasValue || _pictureSaving || _pictureDeleting) autocomplete="off"> <button type="button" class="btn btn-danger btn-block btn-stretch-x" @onclick="Delete" disabled=@(!Id.HasValue || _pictureSaving || _pictureDeleting) autocomplete="off">
@if (!_pictureSaving) @if (!_pictureSaving)
{ {
@@ -40,7 +43,6 @@
<span>Deleting...</span> <span>Deleting...</span>
} }
</button> </button>
</div>
} }
</div> </div>
} }
@@ -60,6 +62,6 @@
/* CLASSES */ /* CLASSES */
.content-width { .content-width {
width: @(ContentWidth); width: @(ContentWidth)px;
} }
</style> </style>

View File

@@ -51,6 +51,7 @@
PictureGetTask="@(async (id, action) => await PersonsWebAPIService.GetPersonPhoto(id, action))" PictureGetTask="@(async (id, action) => await PersonsWebAPIService.GetPersonPhoto(id, action))"
PicturePutTask="@(async (id, data, action) => await PersonsWebAPIService.PutPersonPhoto(id, new PersonPhotoRequest(data), action))" PicturePutTask="@(async (id, data, action) => await PersonsWebAPIService.PutPersonPhoto(id, new PersonPhotoRequest(data), action))"
PictureDeleteTask="@(async (id, action) => await PersonsWebAPIService.DeletePersonPhoto(id, action))" PictureDeleteTask="@(async (id, action) => await PersonsWebAPIService.DeletePersonPhoto(id, action))"
PicturePlaceholder="/assets/person_picture.png"
Class="h-100"/> Class="h-100"/>
</div> </div>
<div class="col"> <div class="col">

View File

@@ -10,6 +10,7 @@ public partial class PersonEditPage : ComponentBase
{ {
#region SERVICES #region SERVICES
[Inject] private NavigationManager NavigationManager { get; set; } = default!;
[Inject] private IAuthenticationService AuthenticationService { get; set; } = default!; [Inject] private IAuthenticationService AuthenticationService { get; set; } = default!;
[Inject] private IPersonsWebAPIService PersonsWebAPIService { get; set; } = default!; [Inject] private IPersonsWebAPIService PersonsWebAPIService { get; set; } = default!;
@@ -61,7 +62,7 @@ public partial class PersonEditPage : ComponentBase
{ {
endTasks.AddRange( endTasks.AddRange(
[ [
PersonsWebAPIService.GetPerson(Id.Value, data => _person = data) PersonsWebAPIService.GetPerson(Id.Value, data => _person = data, () => NavigationManager.NavigateTo("/person/new", true))
]); ]);
} }

View File

@@ -86,9 +86,9 @@
"PutPerson": "/{0}", "PutPerson": "/{0}",
"DeletePerson": "/{0}", "DeletePerson": "/{0}",
"GetPersonsViewRank": "/view", "GetPersonsViewRank": "/view",
"GetPersonPhoto": "/{0}/poster", "GetPersonPhoto": "/{0}/photo",
"PutPersonPhoto": "/{0}/poster", "PutPersonPhoto": "/{0}/photo",
"DeletePersonPhoto": "/{0}/poster" "DeletePersonPhoto": "/{0}/photo"
} }
} }
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 747 KiB