2a0054aa30
Adotta lo stile condiviso delle app Integry: superfici piatte, raggi ampi, spaziature a scala fissa, gerarchia data dallo spazio prima che dalla decorazione. La palette storica di SteUP resta intatta; sono stati aggiunti solo i ruoli che mancavano (workspace, surfaceMuted, divider, inkMuted e le triplette dei toni semantici). Fondamenta - tokens.css: ruoli colore, scale di spazio/raggi/tipografia, curve di movimento e scala z-index semantica. Unica fonte di verita': pilotano anche le variabili CSS di MudBlazor. - Inter variabile ospitata in locale (133KB) al posto di Nunito da Google Fonts: l'app lavora offline, un font che arriva dalla rete in campo non arriva. - base.css: shell applicativa e comportamenti da app nativa — niente selezione testo, niente menu al tocco lungo, niente lampo grigio sul tap, niente rimbalzo elastico, niente zoom a doppio tocco, scroll con inerzia. - mudblazor-overrides.css: MudBlazor appiattito (elevation 0, nessun tint, target 44/48, etichette in caso naturale). - Rimossi Bootstrap (CSS, icone e JS) e i 996 righe di CSS con ambito per componente del vecchio sistema: erano tutti inutilizzati. Struttura - Navigazione flottante in basso con icona piena sulla voce attiva; da 720px diventa colonna laterale. Il MudFabMenu e' sostituito da un bottom sheet: stessa funzione, bersagli molto piu' grandi. - Testata alta col titolo a sinistra, fusa con la pagina. - Nel form scheda il salvataggio sta in una barra ancorata in fondo, non in coda a uno scroll lungo. - Scelta di punto vendita e articoli a schermo intero con ricerca; la selezione multipla usa righe da 56px invece di un menu a tendina. - Urgenza scelta a pillole invece che da una select. Stato e riscontro - StatusBadgeHelper: tono, icona ed etichetta di ogni stato in un punto solo, cosi' lo stesso stato si presenta identico ovunque. - Scheletri al posto degli spinner; l'overlay bloccante dice sempre cosa sta facendo; gli stati vuoti suggeriscono la mossa successiva. - Rimosso il ritardo artificiale di 250ms in InspectionCard, che non attendeva nulla. DESIGN.md riscritto sul nuovo sistema. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
263 lines
9.4 KiB
Plaintext
263 lines
9.4 KiB
Plaintext
@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.Helpers
|
|
@using SteUp.Shared.Core.Interface.IntegryApi
|
|
@using SteUp.Shared.Core.Interface.LocalDb
|
|
@using SteUp.Shared.Core.Interface.System
|
|
@using Microsoft.Extensions.Logging
|
|
@inject IIspezioniService IspezioniService
|
|
@inject IIntegrySteupService IntegrySteupService
|
|
@inject IDialogService Dialog
|
|
@inject IFileManager FileManager
|
|
@inject ILogger<SchedaCard> Logger
|
|
|
|
<div class="list-card" aria-label="@SemanticLabel">
|
|
<div class="list-card__head">
|
|
<div class="list-card__ident">
|
|
<div class="t-ident">@Scheda.DescrizioneReparto</div>
|
|
<h3 class="list-card__title">@Titolo</h3>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="list-card__badges badge-row">
|
|
<Badge Spec="@SyncState.ToBadge()"/>
|
|
<Badge Spec="@ScadenzaBadge" />
|
|
</div>
|
|
|
|
@if (!Scheda.Note.IsNullOrEmpty())
|
|
{
|
|
<p class="list-card__meta t-prose">@Scheda.Note</p>
|
|
}
|
|
|
|
<div class="list-card__footer">
|
|
<i class="icon ri-qr-code-line" aria-hidden="true"></i>
|
|
<span>@ArticoliLabel</span>
|
|
<span aria-hidden="true">·</span>
|
|
<i class="icon ri-camera-line" aria-hidden="true"></i>
|
|
<span>@FotoLabel</span>
|
|
</div>
|
|
|
|
<div class="list-card__actions">
|
|
@if (ReadOnly)
|
|
{
|
|
<MudButton Variant="Variant.Outlined" FullWidth="true"
|
|
StartIcon="@Icons.Material.Rounded.Visibility" OnClick="@ViewScheda">
|
|
Apri
|
|
</MudButton>
|
|
|
|
@if (Scheda.ImageNames?.Count > 0)
|
|
{
|
|
<MudButton Variant="Variant.Filled" Color="Color.Primary" FullWidth="true"
|
|
StartIcon="@Icons.Material.Rounded.CloudUpload" OnClick="@ExportImg">
|
|
Invia foto
|
|
</MudButton>
|
|
}
|
|
}
|
|
else
|
|
{
|
|
<MudButton Variant="Variant.Outlined" FullWidth="true"
|
|
StartIcon="@Icons.Material.Rounded.Edit" OnClick="@UpdateScheda">
|
|
@(IsBozza ? "Completa" : "Modifica")
|
|
</MudButton>
|
|
|
|
@if (NetworkService.IsNetworkAvailable() && SyncState == Core.Helpers.SyncState.DaInviare)
|
|
{
|
|
<MudButton Variant="Variant.Filled" Color="Color.Primary" FullWidth="true"
|
|
StartIcon="@Icons.Material.Rounded.CloudUpload" OnClick="@ExportScheda">
|
|
Invia
|
|
</MudButton>
|
|
}
|
|
}
|
|
</div>
|
|
|
|
@if (!ReadOnly)
|
|
{
|
|
<MudButton Class="mt-2" Variant="Variant.Text" FullWidth="true"
|
|
StartIcon="@Icons.Material.Rounded.DeleteOutline"
|
|
Style="color: var(--danger-ink)" OnClick="@DeleteScheda">
|
|
Elimina scheda
|
|
</MudButton>
|
|
}
|
|
</div>
|
|
|
|
<ConfirmMessageBox @ref="_messageBox" NoText="Annulla" YesText="Elimina" YesColor="Color.Error"
|
|
Message="La scheda verrà eliminata dal dispositivo e, se già inviata, anche dal server. L'operazione non è reversibile."/>
|
|
|
|
@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; }
|
|
[Parameter] public EventCallback<bool> OnBusyChanged { get; set; }
|
|
|
|
private ConfirmMessageBox _messageBox = null!;
|
|
private bool _busy;
|
|
|
|
private bool ReadOnly => Ispezione.Stato == StatusEnum.Completata;
|
|
private SyncState SyncState => Scheda.GetSyncState();
|
|
private bool IsBozza => SyncState == Core.Helpers.SyncState.Bozza;
|
|
|
|
// Una bozza puo' non avere ancora il motivo: meglio dirlo che lasciare un vuoto.
|
|
private string Titolo => Scheda.ActivityTypeId.IsNullOrEmpty()
|
|
? "Motivo da indicare"
|
|
: Scheda.ActivityTypeId!;
|
|
|
|
private StatusBadgeHelper.BadgeSpec ScadenzaBadge => (ScadenzaEnum)Scheda.Scadenza switch
|
|
{
|
|
ScadenzaEnum.Altissima24Ore => new StatusBadgeHelper.BadgeSpec("danger", "ri-alarm-warning-line", "Entro 24 ore"),
|
|
ScadenzaEnum.Alta1Settimana => new StatusBadgeHelper.BadgeSpec("warning", "ri-time-line", "Entro 1 settimana"),
|
|
ScadenzaEnum.Media1Mese => new StatusBadgeHelper.BadgeSpec("info", "ri-calendar-line", "Entro 1 mese"),
|
|
_ => new StatusBadgeHelper.BadgeSpec("neutral", "ri-calendar-line", "Entro 2 mesi")
|
|
};
|
|
|
|
private string ArticoliLabel => Scheda.Articoli.Count == 1
|
|
? "1 articolo"
|
|
: $"{Scheda.Articoli.Count} articoli";
|
|
|
|
private string FotoLabel => Scheda.ImageNames?.Count switch
|
|
{
|
|
null or 0 => "nessuna foto",
|
|
1 => "1 foto",
|
|
var n => $"{n} foto"
|
|
};
|
|
|
|
private string SemanticLabel =>
|
|
$"Scheda {Titolo}, reparto {Scheda.DescrizioneReparto}, {SyncState.ToBadge().Label}, {ArticoliLabel}, {FotoLabel}";
|
|
|
|
private async Task SetBusy(bool value)
|
|
{
|
|
_busy = value;
|
|
await OnBusyChanged.InvokeAsync(value);
|
|
StateHasChanged();
|
|
}
|
|
|
|
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 void ViewScheda() =>
|
|
_ = Dialog.OpenFormScheda(Ispezione.CodMdep, Ispezione.Data, false, Scheda, true);
|
|
|
|
private async Task DeleteScheda()
|
|
{
|
|
var result = await _messageBox.ShowAsync();
|
|
if (result is not true) return;
|
|
|
|
await SetBusy(true);
|
|
|
|
try
|
|
{
|
|
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);
|
|
}
|
|
finally
|
|
{
|
|
await SetBusy(false);
|
|
}
|
|
}
|
|
|
|
private async Task ExportScheda()
|
|
{
|
|
// Guardia anti doppio-tap: invio irreversibile al server.
|
|
if (_busy) return;
|
|
await SetBusy(true);
|
|
|
|
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,
|
|
// Aggancia all'ispezione esistente sul server (evita di crearne una nuova a ogni invio).
|
|
ParentActivityId = SteupDataService.InspectionPageState.Ispezione.ActivityId
|
|
}
|
|
);
|
|
|
|
if (apiResponse == null)
|
|
{
|
|
Snackbar.Add("Invio non riuscito. La scheda resta sul dispositivo, riprova.", Severity.Error);
|
|
return;
|
|
}
|
|
|
|
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);
|
|
|
|
Snackbar.Add("Scheda inviata", Severity.Success);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
Snackbar.Add("Invio non riuscito. La scheda resta sul dispositivo, riprova.", Severity.Error);
|
|
Logger.LogError(e, e.Message);
|
|
}
|
|
finally
|
|
{
|
|
await SetBusy(false);
|
|
}
|
|
}
|
|
|
|
private async Task ExportImg()
|
|
{
|
|
if (_busy || Scheda.ImageNames == null) return;
|
|
await SetBusy(true);
|
|
|
|
try
|
|
{
|
|
var fileList = (await FileManager.GetInspectionFiles(Ispezione, Scheda.ImageNames))?
|
|
.Where(x => x.ToUpload).ToList();
|
|
|
|
if (fileList == null || fileList.Count == 0)
|
|
{
|
|
Snackbar.Add("Nessuna nuova foto da inviare", Severity.Info);
|
|
return;
|
|
}
|
|
|
|
foreach (var file in fileList)
|
|
{
|
|
await IntegrySteupService.UploadFile(Scheda.ActivityId!, file.FileBytes!, file.Name!);
|
|
}
|
|
|
|
Snackbar.Add(fileList.Count == 1 ? "Foto inviata" : $"{fileList.Count} foto inviate", Severity.Success);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
Snackbar.Add("Invio foto non riuscito, riprova.", Severity.Error);
|
|
Logger.LogError(e, e.Message);
|
|
}
|
|
finally
|
|
{
|
|
await SetBusy(false);
|
|
}
|
|
}
|
|
}
|