Files
SteUP_Dotnet/SteUp.Shared/Core/Helpers/ModalHelper.cs
2026-03-02 16:12:58 +01:00

160 lines
5.0 KiB
C#

using MudBlazor;
using SteUp.Shared.Components.SingleElements.Modal;
using SteUp.Shared.Components.SingleElements.Modal.ExceptionModal;
using SteUp.Shared.Core.Dto;
using SteUp.Shared.Core.Entities;
namespace SteUp.Shared.Core.Helpers;
public static class ModalHelper
{
extension(IDialogService dialog)
{
public async Task<DialogResult?> OpenSelectShop()
{
var modal = await dialog.ShowAsync<ModalSelectShop>(
"ModalSelectShop",
new DialogParameters(),
new DialogOptions
{
FullScreen = false,
CloseButton = false,
NoHeader = true,
BackdropClick = true
}
);
return await modal.Result;
}
public async Task<DialogResult?> OpenFormScheda(string codMdep, DateTime data,
bool isNew = false, Scheda? scheda = null, bool readOnly = 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.ReadOnly, readOnly },
{ x => x.Scheda, scheda }
},
new DialogOptions
{
FullScreen = true,
CloseButton = false,
NoHeader = true
}
);
return await modal.Result;
}
public async Task<DialogResult?> OpenAddAttached()
{
var modal = await dialog.ShowAsync<ModalAddAttached>(
"Add attached",
new DialogParameters(),
new DialogOptions
{
FullScreen = false,
CloseButton = false,
NoHeader = true,
BackdropClick = false
}
);
return await modal.Result;
}
public async Task<DialogResult?> OpenSuggestActivityDescription(List<StbActivityTyperDto>? activityTypers)
{
var modal = await dialog.ShowAsync<ModalSuggestDescription>(
"Suggest activity description",
new DialogParameters<ModalSuggestDescription>
{
{ x => x.ActivityTypers, activityTypers }
},
new DialogOptions
{
FullScreen = false,
CloseButton = false,
NoHeader = true,
BackdropClick = true
}
);
return await modal.Result;
}
public async Task<DialogResult?> OpenSelectArt(List<ArticoliInGrigliaDto>? articoli)
{
var modal = await dialog.ShowAsync<ModalSelectArt>(
"ModalSelectArt",
new DialogParameters<ModalSelectArt>
{
{ x => x.Articoli, articoli }
},
new DialogOptions
{
FullScreen = false,
CloseButton = false,
NoHeader = true,
BackdropClick = true,
FullWidth = true,
MaxWidth = MaxWidth.ExtraLarge
}
);
return await modal.Result;
}
public async Task ShowError(string message)
{
var modal = await dialog.ShowAsync<ModalError>(
"ModalError",
new DialogParameters<ModalError>
{
{ x => x.ErrorMessage, message }
},
new DialogOptions
{
FullScreen = false,
CloseButton = false,
NoHeader = true,
BackdropClick = true,
FullWidth = true,
MaxWidth = MaxWidth.ExtraLarge
}
);
await modal.Result;
}
public async Task ShowWarning(string message)
{
var modal = await dialog.ShowAsync<ModalError>(
"ModalError",
new DialogParameters<ModalError>
{
{ x => x.ErrorMessage, message },
{ x => x.IsWarning, true }
},
new DialogOptions
{
FullScreen = false,
CloseButton = false,
NoHeader = true,
BackdropClick = true,
FullWidth = true,
MaxWidth = MaxWidth.ExtraLarge
}
);
await modal.Result;
}
}
}