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

@@ -0,0 +1,156 @@
.success-checkmark {
width: 80px;
height: 80px;
margin: 0 auto;
}
.success-checkmark .check-icon {
width: 80px;
height: 80px;
position: relative;
border-radius: 50%;
box-sizing: content-box;
border: 4px solid var(--mud-palette-success);
}
.success-checkmark .check-icon::before {
top: 3px;
left: -2px;
width: 30px;
transform-origin: 100% 50%;
border-radius: 100px 0 0 100px;
}
.success-checkmark .check-icon::after {
top: 0;
left: 30px;
width: 60px;
transform-origin: 0 50%;
border-radius: 0 100px 100px 0;
animation: rotate-circle 4.25s ease-in;
}
.success-checkmark .check-icon::before,
.success-checkmark .check-icon::after {
content: '';
height: 100px;
position: absolute;
transform: rotate(-45deg);
z-index: 2;
}
.icon-line {
height: 5px;
background-color: var(--mud-palette-success);
display: block;
border-radius: 2px;
position: absolute;
z-index: 10;
}
.icon-line.line-tip {
top: 46px;
left: 14px;
width: 25px;
transform: rotate(45deg);
animation: icon-line-tip 0.75s;
}
.icon-line.line-long {
top: 38px;
right: 8px;
width: 47px;
transform: rotate(-45deg);
animation: icon-line-long 0.75s;
}
.icon-circle {
top: -4px;
left: -4px;
z-index: 10;
width: 80px;
height: 80px;
border-radius: 50%;
position: absolute;
box-sizing: content-box;
border: 4px solid var(--mud-palette-success);
}
.icon-fix {
top: 8px;
width: 5px;
left: 26px;
z-index: 1;
height: 85px;
position: absolute;
transform: rotate(-45deg);
}
@keyframes rotate-circle {
0% { transform: rotate(-45deg); }
5% { transform: rotate(-45deg); }
12% { transform: rotate(-405deg); }
100% { transform: rotate(-405deg); }
}
@keyframes icon-line-tip {
0% {
width: 0;
left: 1px;
top: 19px;
}
54% {
width: 0;
left: 1px;
top: 19px;
}
70% {
width: 50px;
left: -8px;
top: 37px;
}
84% {
width: 17px;
left: 21px;
top: 48px;
}
100% {
width: 25px;
left: 14px;
top: 45px;
}
}
@keyframes icon-line-long {
0% {
width: 0;
right: 46px;
top: 54px;
}
65% {
width: 0;
right: 46px;
top: 54px;
}
84% {
width: 55px;
right: 0px;
top: 35px;
}
100% {
width: 47px;
right: 8px;
top: 38px;
}
}

View File

@@ -7,6 +7,7 @@
@using SteUp.Shared.Core.Messages.Scheda
@inject NewSchedaService NewScheda
@inject IIspezioniService IspezioniService
@inject IDialogService Dialog
@implements IDisposable
<HeaderLayout Title="Ispezione" BackTo="Indietro" Back="true"/>
@@ -29,14 +30,19 @@
</MudChip>
</div>
<div class="action-scheda-group">
<MudIconButton Variant="Variant.Filled" Icon="@Icons.Material.Rounded.Add" Color="Color.Warning" Size="Size.Medium"/>
<MudIconButton Variant="Variant.Filled" Icon="@Icons.Material.Rounded.Add"
Color="Color.Warning" Size="Size.Medium"
OnClick="@(() => CreateNewScheda(group.Key))"/>
</div>
</div>
</TitleContent>
<ChildContent>
@foreach (var scheda in group.Value)
{
<SchedaCard Scheda="scheda"/>
<SchedaCard Scheda="scheda" OnSchedaDeleted="OnSchedaDeleted"
OnSchedaModified="OnSchedaModified"
CodMdep="@SteupDataService.InspectionPageState.Ispezione.CodMdep"
Data="@SteupDataService.InspectionPageState.Ispezione.Data"/>
}
</ChildContent>
</MudExpansionPanel>
@@ -46,6 +52,7 @@
</div>
@code {
private List<Scheda> SchedeList { get; set; } = [];
private Dictionary<JtbFasiDto, List<Scheda>> SchedeGrouped { get; set; } = [];
protected override void OnInitialized()
@@ -61,22 +68,55 @@
InvokeAsync(async () =>
{
var schede = await IspezioniService.GetAllSchedeOfIspezioneAsync(
SchedeList = await IspezioniService.GetAllSchedeOfIspezioneAsync(
ispezione.CodMdep, ispezione.Data, ispezione.Rilevatore
);
SchedeGrouped = schede
.Where(s => s.Reparto != null)
.GroupBy(s => s.CodJfas)
.ToDictionary(
g => g.First().Reparto!,
g => g.ToList()
);
GroupSchede();
StateHasChanged();
});
}
private void GroupSchede()
{
SchedeGrouped = SchedeList
.Where(s => s.Reparto != null)
.GroupBy(s => s.CodJfas)
.ToDictionary(
g => g.First().Reparto!,
g => g.ToList()
);
}
private void OnSchedaModified(Scheda obj)
{
var index = SchedeList.FindIndex(x => x.Id.Equals(obj.Id));
if (index > 0) SchedeList[index] = obj;
GroupSchede();
StateHasChanged();
}
private void OnSchedaDeleted(Scheda obj)
{
SchedeList.Remove(obj);
GroupSchede();
StateHasChanged();
}
private async Task CreateNewScheda(JtbFasiDto jtbFasi)
{
var modal = await ModalHelper.OpenFormScheda(
Dialog,
SteupDataService.InspectionPageState.Ispezione.CodMdep,
SteupDataService.InspectionPageState.Ispezione.Data,
new Scheda { Reparto = jtbFasi },
true
);
if (modal is {Canceled: false}) LoadSchede();
}
void IDisposable.Dispose()
{
NewScheda.OnNewScheda -= LoadSchede;

View File

@@ -13,7 +13,8 @@
<div class="container ispezioni">
@if (Ispezioni.IsNullOrEmpty())
{
<NoDataAvailable Text="Nessuna ispezione effettuata" ImageSource="_content/SteUp.Shared/images/undraw_file-search_cbur.svg"/>
<NoDataAvailable Text="Nessuna ispezione effettuata"
ImageSource="_content/SteUp.Shared/images/undraw_file-search_cbur.svg"/>
}
else
{

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();

View File

@@ -1,6 +1,7 @@
using MudBlazor;
using SteUp.Shared.Components.SingleElements.Modal;
using SteUp.Shared.Core.Dto;
using SteUp.Shared.Core.Entities;
namespace SteUp.Shared.Core.Helpers;
@@ -23,14 +24,19 @@ public abstract class ModalHelper
return await modal.Result;
}
public static async Task<DialogResult?> OpenFormScheda(IDialogService dialog, string codMdep, DateOnly data)
public static async Task<DialogResult?> OpenFormScheda(IDialogService dialog, string codMdep, DateOnly data,
Scheda? scheda = null, bool isNew = false)
{
scheda = isNew && scheda == null ? new Scheda() : scheda;
var modal = await dialog.ShowAsync<ModalFormScheda>(
"ModalFormScheda",
new DialogParameters<ModalFormScheda>
{
{ x => x.CodMdep, codMdep },
{ x => x.Data, data },
{ x => x.IsNew, isNew },
{ x => x.Scheda, scheda }
},
new DialogOptions
{
@@ -39,10 +45,10 @@ public abstract class ModalHelper
NoHeader = true
}
);
return await modal.Result;
}
public static async Task<DialogResult?> OpenAddAttached(IDialogService dialog)
{
var modal = await dialog.ShowAsync<ModalAddAttached>(
@@ -59,8 +65,9 @@ public abstract class ModalHelper
return await modal.Result;
}
public static async Task<DialogResult?> OpenSuggestActivityDescription(IDialogService dialog, List<StbActivityTyperDto>? activityTypers)
public static async Task<DialogResult?> OpenSuggestActivityDescription(IDialogService dialog,
List<StbActivityTyperDto>? activityTypers)
{
var modal = await dialog.ShowAsync<ModalSuggestDescription>(
"Suggest activity description",
@@ -76,7 +83,7 @@ public abstract class ModalHelper
BackdropClick = true
}
);
return await modal.Result;
}
}