Merge pull request #96 from mateuszskoczek/fetaures/picture_editor_fix

multiple person edit page fixes
This commit is contained in:
2024-10-05 20:00:45 +02:00
committed by GitHub
Unverified
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,41 +6,43 @@
<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">
<button type="button" class="btn btn-secondary btn-block btn-stretch-x" @onclick="Save" disabled=@(!Id.HasValue || _pictureSaving || _pictureDeleting) autocomplete="off"> <div class="row gx-1">
@if (!_pictureSaving) <div class="col">
{ <button type="button" class="btn btn-secondary btn-block btn-stretch-x" @onclick="Save" disabled=@(!Id.HasValue || _pictureSaving || _pictureDeleting) autocomplete="off">
<span>Save</span> @if (!_pictureSaving)
} {
else <span>Save</span>
{ }
<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span> else
<span>Saving...</span> {
} <span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>
</button> <span>Saving...</span>
</div> }
<div class="flex-fill"> </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 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>
</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) {
{ <span>Delete</span>
<span>Delete</span> }
} else
else {
{ <span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>
<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span> <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