Gestite azioni in pagina ispezione

This commit is contained in:
2026-02-23 15:40:59 +01:00
parent efefd3499b
commit aaffaa3a2a
122 changed files with 307 additions and 1265 deletions

View File

@@ -1,4 +1,9 @@
@using SteUp.Shared.Core.Entities
@using SteUp.Shared.Components.Layout.Overlay
@using SteUp.Shared.Components.SingleElements.MessageBox
@using SteUp.Shared.Core.Entities
@using SteUp.Shared.Core.Interface.LocalDb
@inject IIspezioniService IspezioniService
@inject IDialogService Dialog
<div class="scheda-card">
<div class="scheda-body-section">
@@ -6,7 +11,7 @@
<MudText Class="scheda-title" Typo="Typo.subtitle1">
<b>@Scheda.ActivityTypeId</b>
</MudText>
<div class="sub-info-section">
<MudChip T="string" Icon="@Icons.Material.Rounded.PhotoCamera" Size="Size.Small" Color="Color.Default">
0
@@ -16,15 +21,46 @@
</MudChip>
</div>
</div>
<div class="scheda-card-action">
<MudButton Variant="Variant.Filled" StartIcon="@Icons.Material.Rounded.Edit" Color="Color.Info" Size="Size.Small">Modifica</MudButton>
<MudButton Variant="Variant.Filled" StartIcon="@Icons.Material.Rounded.Delete" Color="Color.Error" Size="Size.Small">Cancella</MudButton>
<MudButton Variant="Variant.Filled" StartIcon="@Icons.Material.Rounded.Edit"
Color="Color.Info" Size="Size.Small" OnClick="@UpdateScheda">
Modifica
</MudButton>
<MudButton Variant="Variant.Filled" StartIcon="@Icons.Material.Rounded.Delete"
Color="Color.Error" Size="Size.Small" OnClick="@DeleteScheda">
Cancella
</MudButton>
</div>
</div>
</div>
<ConfirmDeleteMessageBox @ref="_deleteMessageBox" Message="Confermi la cancellazione della scheda corrente?"/>
@code{
[Parameter] public string CodMdep { get; set; } = string.Empty;
[Parameter] public DateOnly Data { get; set; }
[Parameter] public required Scheda Scheda { get; set; }
[Parameter] public EventCallback<Scheda> OnSchedaModified { get; set; }
[Parameter] public EventCallback<Scheda> OnSchedaDeleted { get; set; }
private ConfirmDeleteMessageBox _deleteMessageBox = null!;
private async Task UpdateScheda()
{
var modal = await ModalHelper.OpenFormScheda(Dialog, CodMdep, Data, Scheda);
if (modal is { Canceled: false, Data: Scheda scheda }) await OnSchedaModified.InvokeAsync(scheda);
}
private async Task DeleteScheda()
{
var result = await _deleteMessageBox.ShowAsync();
if (result is true)
{
var deleteScheda = await IspezioniService.DeleteSchedaAsync(Scheda.Id);
if (deleteScheda) await OnSchedaDeleted.InvokeAsync(Scheda);
}
}
}

View File

@@ -0,0 +1,23 @@
<MudMessageBox @ref="_confirmDelete" Title="Attenzione!" CancelText="Annulla">
<MessageContent>
@Message
</MessageContent>
<YesButton>
<MudButton Size="Size.Small" Variant="Variant.Filled" Color="Color.Error">
Cancella
</MudButton>
</YesButton>
</MudMessageBox>
@code
{
[Parameter] public string Message { get; set; } = string.Empty;
private MudMessageBox? _confirmDelete;
public async Task<bool?> ShowAsync()
{
if (_confirmDelete == null) return null;
return await _confirmDelete.ShowAsync();
}
}

View File

@@ -1,6 +1,5 @@
@using SteUp.Shared.Components.Layout
@using SteUp.Shared.Components.Layout.Overlay
@using SteUp.Shared.Components.Layout.Spinner
@using SteUp.Shared.Components.SingleElements.Card.ModalForm
@using SteUp.Shared.Components.SingleElements.MessageBox
@using SteUp.Shared.Core.Dto
@@ -132,11 +131,9 @@
[CascadingParameter] private IMudDialogInstance MudDialog { get; set; } = null!;
[Parameter] public required string CodMdep { get; set; }
[Parameter] public required DateOnly Data { get; set; }
private Scheda Scheda { get; set; } = new();
private bool IsNew { get; set; }
private bool IsLoading { get; set; }
[Parameter] public bool IsNew { get; set; }
[Parameter] public Scheda Scheda { get; set; } = new();
private bool IsView => !NetworkService.ConnectionAvailable;
//Overlay
@@ -162,7 +159,10 @@
VisibleOverlay = true;
StateHasChanged();
await IspezioniService.AddSchedaAsync(CodMdep, Data, UserSession.User.Username, Scheda);
if (IsNew)
await IspezioniService.AddSchedaAsync(CodMdep, Data, UserSession.User.Username, Scheda);
else
await IspezioniService.UpdateSchedaAsync(Scheda);
SuccessAnimation = true;
StateHasChanged();