c454474f49
Ispezione: - Stato sync visibile: badge per-scheda (Da inviare/Inviato) e contatore "N da inviare" per reparto (nuovo SchedaSyncHelper) - Completamento: progresso reale nell'overlay + spunta di successo; NON completa se una scheda fallisce (resta editabile, schede "Da inviare") - Export reparto/completamento blindati: conferma + guardia anti doppio-tap, try/finally che libera sempre l'overlay - Accento corallo unico per l'azione "invia"; target di tocco >=44px; empty state; solo il primo pannello espanso di default - Tasto "Invia" nascosto sulle schede gia inviate - Messaggio d'errore comprensibile in campo (dettaglio tecnico nei log) - Fix OnSchedaModified (index >= 0) Aspetto card: - SchedaCard e InspectionCard: superficie Carta + hairline border + ombra morbida (nuovo token --card-box-shadow); pagina con tinta Grigio Campo - SchedaCard compattata Form scheda (ModalFormScheda): - Tasto Salva/Aggiorna full-width - Fix "Suggerisci note descrittive": la nota selezionata ora viene inserita nel campo (metodo async sul thread UI + OnAfterChangeValue) StatusEnum: etichette in sentence-case Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
192 lines
7.1 KiB
Plaintext
192 lines
7.1 KiB
Plaintext
@using SteUp.Shared.Components.Layout.Overlay
|
|
@using SteUp.Shared.Components.SingleElements.MessageBox
|
|
@using SteUp.Shared.Core.Dto
|
|
@using SteUp.Shared.Core.Entities
|
|
@using SteUp.Shared.Core.Enum
|
|
@using SteUp.Shared.Core.Interface.IntegryApi
|
|
@using SteUp.Shared.Core.Interface.LocalDb
|
|
@using SteUp.Shared.Core.Interface.System
|
|
@inject IIspezioniService IspezioniService
|
|
@inject IIntegrySteupService IntegrySteupService
|
|
@inject IDialogService Dialog
|
|
@inject IFileManager FileManager
|
|
|
|
<div class="scheda-card">
|
|
<div class="scheda-body-section">
|
|
<div class="title-section">
|
|
<div class="scheda-title-group">
|
|
<MudText Class="scheda-title" Typo="Typo.subtitle1">
|
|
<b>@Scheda.ActivityTypeId</b>
|
|
</MudText>
|
|
|
|
@{
|
|
var syncState = Scheda.GetSyncState();
|
|
}
|
|
<MudChip T="string" Class="sync-badge" Icon="@syncState.GetIcon()"
|
|
Size="Size.Small" Variant="Variant.Filled" Color="@syncState.GetColor()">
|
|
@syncState.ToLabel()
|
|
</MudChip>
|
|
</div>
|
|
|
|
<div class="sub-info-section">
|
|
<MudChip T="string" Icon="@Icons.Material.Rounded.PhotoCamera" Size="Size.Small" Color="Color.Default">
|
|
@Scheda.ImageNames.Count()
|
|
</MudChip>
|
|
<MudChip T="string" Icon="@Icons.Material.Rounded.QrCode2" Size="Size.Small" Color="Color.Default">
|
|
@Scheda.Articoli.Count
|
|
</MudChip>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="scheda-card-action">
|
|
@if (Ispezione.Stato != StatusEnum.Completata)
|
|
{
|
|
<div class="action-secondary">
|
|
<MudFab Color="Color.Default" Size="Size.Medium" StartIcon="@Icons.Material.Rounded.Edit"
|
|
aria-label="Modifica scheda" OnClick="@UpdateScheda"/>
|
|
<MudFab Color="Color.Error" Size="Size.Medium" StartIcon="@Icons.Material.Rounded.Delete"
|
|
aria-label="Elimina scheda" OnClick="@DeleteScheda"/>
|
|
</div>
|
|
@if (NetworkService.IsNetworkAvailable() && syncState == SyncState.DaInviare)
|
|
{
|
|
<MudFab Color="Color.Primary" Size="Size.Medium" StartIcon="@Icons.Material.Rounded.CloudUpload"
|
|
Label="Invia" aria-label="Invia scheda al server" OnClick="@ExportScheda"/>
|
|
}
|
|
}
|
|
else
|
|
{
|
|
<div class="action-secondary">
|
|
<MudFab Color="Color.Default" Size="Size.Medium" StartIcon="@Icons.Material.Rounded.RemoveRedEye"
|
|
aria-label="Visualizza scheda" OnClick="@ViewScheda"/>
|
|
</div>
|
|
<MudFab Color="Color.Primary" Size="Size.Medium" StartIcon="@Icons.Material.Rounded.CloudUpload"
|
|
Label="Invia foto" aria-label="Invia foto al server" OnClick="@ExportImg"/>
|
|
}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<SpinnerOverlay VisibleOverlay="VisibleOverlay"/>
|
|
<ConfirmMessageBox @ref="_messageBox" YesText="Cancella" YesColor="Color.Error"
|
|
Message="Confermi la cancellazione della scheda corrente?"/>
|
|
|
|
@code{
|
|
[Parameter] public Ispezione Ispezione { get; set; } = new();
|
|
[Parameter] public required Scheda Scheda { get; set; }
|
|
[Parameter] public EventCallback<Scheda> OnSchedaModified { get; set; }
|
|
[Parameter] public EventCallback<Scheda> OnSchedaDeleted { get; set; }
|
|
|
|
private bool VisibleOverlay { get; set; }
|
|
|
|
private ConfirmMessageBox _messageBox = null!;
|
|
|
|
private async Task UpdateScheda()
|
|
{
|
|
var modal = await Dialog.OpenFormScheda(Ispezione.CodMdep, Ispezione.Data, false, Scheda);
|
|
if (modal is { Canceled: false, Data: Scheda scheda }) await OnSchedaModified.InvokeAsync(scheda);
|
|
}
|
|
|
|
private async Task DeleteScheda()
|
|
{
|
|
var result = await _messageBox.ShowAsync();
|
|
|
|
if (result is true)
|
|
{
|
|
VisibleOverlay = true;
|
|
StateHasChanged();
|
|
|
|
if (Scheda.ActivityId != null)
|
|
await IntegrySteupService.DeleteScheda(Scheda.ActivityId);
|
|
|
|
if (Scheda.ImageNames != null)
|
|
{
|
|
foreach (var fileName in Scheda.ImageNames)
|
|
{
|
|
FileManager.RemoveInspectionFile(Ispezione, fileName);
|
|
}
|
|
}
|
|
|
|
var deleteScheda = await IspezioniService.DeleteSchedaAsync(Scheda.Id);
|
|
if (deleteScheda) await OnSchedaDeleted.InvokeAsync(Scheda);
|
|
|
|
VisibleOverlay = false;
|
|
StateHasChanged();
|
|
}
|
|
}
|
|
|
|
private void ViewScheda() =>
|
|
_ = Dialog.OpenFormScheda(Ispezione.CodMdep, Ispezione.Data, false, Scheda, true);
|
|
|
|
private async Task ExportScheda()
|
|
{
|
|
// Guardia anti doppio-tap: invio irreversibile al server.
|
|
if (VisibleOverlay) return;
|
|
|
|
VisibleOverlay = true;
|
|
StateHasChanged();
|
|
|
|
try
|
|
{
|
|
var apiResponse = await IntegrySteupService.SaveScheda(
|
|
new SaveRequestDto
|
|
{
|
|
LocalIdScheda = Scheda.Id,
|
|
ActivityTypeId = Scheda.ActivityTypeId,
|
|
CodJfas = Scheda.CodJfas,
|
|
CodMdep = Ispezione.CodMdep,
|
|
DataCreazione = Ispezione.Data,
|
|
Note = Scheda.Note,
|
|
PersonaRif = Scheda.Responsabile,
|
|
Barcodes = Scheda.Articoli.ConvertAll(x => x.Barcode),
|
|
Scandeza = (ScadenzaEnum)Scheda.Scadenza,
|
|
ParentActivityId = Scheda.Ispezione?.ActivityId
|
|
}
|
|
);
|
|
|
|
if (apiResponse != null)
|
|
{
|
|
Scheda.ActivityId = apiResponse.ActivityIdScheda;
|
|
SteupDataService.InspectionPageState.Ispezione.ActivityId = apiResponse.ActivityIdIspezione;
|
|
|
|
await IspezioniService.UpdateActivityIdIspezioneAsync(Ispezione.CodMdep, Ispezione.Data,
|
|
UserSession.User.Username, apiResponse.ActivityIdIspezione
|
|
);
|
|
await IspezioniService.UpdateActivityIdSchedaAsync(Scheda.Id, Scheda.ActivityId);
|
|
|
|
// Notifica il genitore così il contatore "da inviare" del reparto si aggiorna.
|
|
await OnSchedaModified.InvokeAsync(Scheda);
|
|
}
|
|
}
|
|
finally
|
|
{
|
|
VisibleOverlay = false;
|
|
StateHasChanged();
|
|
}
|
|
}
|
|
|
|
private async Task ExportImg()
|
|
{
|
|
if (VisibleOverlay || Scheda.ImageNames == null) return;
|
|
|
|
VisibleOverlay = true;
|
|
StateHasChanged();
|
|
|
|
try
|
|
{
|
|
var fileList = (await FileManager.GetInspectionFiles(Ispezione, Scheda.ImageNames))?
|
|
.Where(x => x.ToUpload).ToList();
|
|
|
|
if (fileList == null) return;
|
|
|
|
foreach (var file in fileList)
|
|
{
|
|
await IntegrySteupService.UploadFile(Scheda.ActivityId!, file.FileBytes!, file.Name!);
|
|
}
|
|
}
|
|
finally
|
|
{
|
|
VisibleOverlay = false;
|
|
StateHasChanged();
|
|
}
|
|
}
|
|
} |