Migliorati form Cliente e PersonaRif

This commit is contained in:
2025-07-16 17:24:41 +02:00
parent 8c521dc81e
commit b2064ad71e
14 changed files with 381 additions and 94 deletions

View File

@@ -3,7 +3,7 @@ using Android.Runtime;
namespace salesbook.Maui
{
[Application]
[Application(HardwareAccelerated = true)]
public class MainApplication : MauiApplication
{
public MainApplication(IntPtr handle, JniHandleOwnership ownership)

View File

@@ -1,12 +1,17 @@
@page "/User/{CodAnag}"
@page "/User/{CodContact}/{IsContact:bool}"
@attribute [Authorize]
@using AutoMapper
@using salesbook.Shared.Components.Layout
@using salesbook.Shared.Core.Entity
@using salesbook.Shared.Core.Interface
@using salesbook.Shared.Components.Layout.Spinner
@using salesbook.Shared.Core.Dto
@using salesbook.Shared.Components.SingleElements
@inject IManageDataService ManageData
@inject IMapper Mapper
@inject IDialogService Dialog
<HeaderLayout BackTo="Indietro" Back="true" BackOnTop="true" Title="" ShowProfile="false"/>
<HeaderLayout BackTo="Indietro" LabelSave="Modifica" OnSave="() => OpenUserForm(Anag)" Back="true" BackOnTop="true" Title="" ShowProfile="false" />
@if (IsLoading)
{
@@ -45,50 +50,42 @@ else
</div>
}
@if (!string.IsNullOrEmpty(Anag.PartIva))
{
<div>
<span class="info-title">P. IVA</span>
<span class="info-text">
@if (string.IsNullOrEmpty(Anag.PartIva))
{
@("Nessuna partita iva configurata")
}
else
{
@Anag.PartIva
}
</span>
</div>
}
</div>
<div class="section-personal-info">
@if (!string.IsNullOrEmpty(Anag.EMail))
{
<div>
<span class="info-title">E-mail</span>
<span class="info-text">
@if (string.IsNullOrEmpty(Anag.EMail))
{
@("Nessuna mail configurata")
}
else
{
@Anag.EMail
}
</span>
</div>
}
</div>
</div>
</div>
<MudTabs Elevation="2" Rounded="true" PanelClass="pt-6" Style="width: 100%" Centered="true">
<MudTabs TabPanelClass="custom-tab-panel" Elevation="2" Rounded="true" PanelClass="pt-2" Centered="true">
<MudTabPanel Text="Contatti">
@if (PersRif is { Count: > 0 })
{
<div class="container-pers-rif">
<div style="margin-top: 1rem;" class="container-pers-rif">
<Virtualize Items="PersRif" Context="person">
@{
var index = PersRif.IndexOf(person);
var isLast = index == PersRif.Count - 1;
}
<ContactCard Contact="person" />
<ContactCard Contact="person"/>
@if (!isLast)
{
<div class="divider"></div>
@@ -101,25 +98,34 @@ else
<MudButton Class="button-settings infoText"
FullWidth="true"
Size="Size.Medium"
OnClick="OpenPersRifForm"
Variant="Variant.Outlined">
Aggiungi contatto
</MudButton>
</div>
</MudTabPanel>
<MudTabPanel Text="Commesse">
@if (Commesse.IsNullOrEmpty())
{
<NoDataAvailable Text="Nessuna commessa presente"/>
}
else
{
<Virtualize Items="Commesse" Context="commessa">
<CommessaCard Commessa="commessa" />
<CommessaCard Commessa="commessa"/>
</Virtualize>
}
</MudTabPanel>
</MudTabs>
</div>
}
@code {
[Parameter] public string CodAnag { get; set; }
[Parameter] public string CodContact { get; set; }
[Parameter] public bool IsContact { get; set; }
private AnagClie Anag { get; set; } = new();
private List<VtbCliePersRif>? PersRif { get; set; }
private ContactDTO Anag { get; set; } = new();
private List<PersRifDTO>? PersRif { get; set; }
private List<JtbComt> Commesse { get; set; }
private bool IsLoading { get; set; } = true;
@@ -131,12 +137,37 @@ else
private async Task LoadData()
{
Anag = (await ManageData.GetTable<AnagClie>(x => x.CodAnag.Equals(CodAnag))).Last();
PersRif = await ManageData.GetTable<VtbCliePersRif>(x => x.CodAnag.Equals(Anag.CodAnag));
Commesse = await ManageData.GetTable<JtbComt>(x => x.CodAnag != null && x.CodAnag.Equals(CodAnag));
if (IsContact)
{
var clie = (await ManageData.GetTable<AnagClie>(x => x.CodAnag.Equals(CodContact))).Last();
Anag = Mapper.Map<ContactDTO>(clie);
var pers = await ManageData.GetTable<VtbCliePersRif>(x => x.CodAnag.Equals(Anag.CodContact));
PersRif = Mapper.Map<List<PersRifDTO>>(pers);
}
else
{
var pros = (await ManageData.GetTable<PtbPros>(x => x.CodPpro.Equals(CodContact))).Last();
Anag = Mapper.Map<ContactDTO>(pros);
var pers = await ManageData.GetTable<PtbProsRif>(x => x.CodPpro.Equals(Anag.CodContact));
PersRif = Mapper.Map<List<PersRifDTO>>(pers);
}
Commesse = await ManageData.GetTable<JtbComt>(x => x.CodAnag != null && x.CodAnag.Equals(CodContact));
IsLoading = false;
StateHasChanged();
}
private async Task OpenPersRifForm()
{
var result = await ModalHelpers.OpenPersRifForm(Dialog, null);
}
private async Task OpenUserForm(ContactDTO anag)
{
var result = await ModalHelpers.OpenUserForm(Dialog, anag);
}
}

View File

@@ -145,3 +145,10 @@
margin: 0 0 0 3.5rem;
width: unset;
}
.custom-tab-panel {
width: 100%;
display: flex;
gap: 1rem;
flex-direction: column;
}

View File

@@ -20,13 +20,13 @@
<MudIconButton Class="closeIcon" Icon="@Icons.Material.Filled.Close" OnClick="() => FilterUsers(true)"/>
}
<MudIconButton Class="rounded-button" OnClick="ToggleFilter" Icon="@Icons.Material.Rounded.FilterList" Variant="Variant.Filled" Color="Color.Secondary" Size="Size.Small" />
<MudIconButton Class="rounded-button" OnClick="ToggleFilter" Icon="@Icons.Material.Rounded.FilterList" Variant="Variant.Filled" Color="Color.Primary" Size="Size.Small" />
</div>
<MudChipSet Class="mt-2" T="string" @bind-SelectedValue="TypeUser" @bind-SelectedValue:after="FilterUsers" SelectionMode="SelectionMode.SingleSelection">
<MudChip Color="Color.Secondary" Variant="Variant.Text" Value="@("all")">Tutti</MudChip>
<MudChip Color="Color.Secondary" Variant="Variant.Text" Value="@("contact")">Contatti</MudChip>
<MudChip Color="Color.Secondary" Variant="Variant.Text" Value="@("prospect")">Prospect</MudChip>
<MudChip Color="Color.Primary" Variant="Variant.Text" Value="@("all")">Tutti</MudChip>
<MudChip Color="Color.Primary" Variant="Variant.Text" Value="@("contact")">Contatti</MudChip>
<MudChip Color="Color.Primary" Variant="Variant.Text" Value="@("prospect")">Prospect</MudChip>
</MudChipSet>
</div>
@@ -37,7 +37,7 @@
}
else if (GroupedUserList?.Count > 0)
{
<Virtualize Items="FilteredGroupedUserList" Context="item">
<Virtualize OverscanCount="20" Items="FilteredGroupedUserList" Context="item">
@if (item.ShowHeader)
{
<div class="letter-header">@item.HeaderLetter</div>

View File

@@ -1,8 +1,9 @@
@using salesbook.Shared.Core.Entity
@using salesbook.Shared.Core.Dto
@inject IDialogService Dialog
<div class="contact-card">
<div class="contact-card" @onclick="OpenPersRifForm">
<div class="contact-left-section">
<MudIcon Color="Color.Default" Icon="@Icons.Material.Filled.PersonOutline" Size="Size.Large" />
<MudIcon Color="Color.Default" Icon="@Icons.Material.Filled.PersonOutline" Size="Size.Large"/>
<div class="contact-body-section">
<div class="title-section">
@@ -18,16 +19,25 @@
<div class="contact-right-section">
@if (!Contact.NumCellulare.IsNullOrEmpty())
{
<MudIconButton Href="@($"tel:{Contact.NumCellulare}")" Color="Color.Success" Size="Size.Large" Icon="@Icons.Material.Outlined.Phone" />
<a href="@($"tel:{Contact.NumCellulare}")">
<MudIcon Color="Color.Success" Size="Size.Large" Icon="@Icons.Material.Outlined.Phone"/>
</a>
}
@if (!Contact.EMail.IsNullOrEmpty())
{
<MudIconButton Href="@($"mailto:{Contact.EMail}")" Color="Color.Info" Size="Size.Large" Icon="@Icons.Material.Filled.MailOutline" />
<a href="@($"mailto:{Contact.EMail}")">
<MudIcon Color="Color.Info" Size="Size.Large" Icon="@Icons.Material.Filled.MailOutline"/>
</a>
}
</div>
</div>
@code {
[Parameter] public VtbCliePersRif Contact { get; set; } = new();
[Parameter] public PersRifDTO Contact { get; set; } = new();
private async Task OpenPersRifForm()
{
var result = await ModalHelpers.OpenPersRifForm(Dialog, Contact);
}
}

View File

@@ -7,7 +7,7 @@
<div class="user-card-left-section">
<div class="user-card-body-section">
<div class="title-section">
<MudIcon @onclick="OpenUser" Color="@(User.IsContact? Color.Primary: Color.Secondary)" Icon="@(User.IsContact? Icons.Material.Filled.Person : Icons.Material.Filled.PersonOutline)" Size="Size.Large" />
<MudIcon @onclick="OpenUser" Color="Color.Primary" Icon="@(User.IsContact? Icons.Material.Filled.Person : Icons.Material.Filled.PersonOutline)" Size="Size.Large" />
<div class="user-card-right-section">
<div class="user-card-title">
@@ -55,7 +55,7 @@
private bool ShowSectionCommesse { get; set; }
private void OpenUser() =>
NavigationManager.NavigateTo($"/User/{User.CodContact}");
NavigationManager.NavigateTo($"/User/{User.CodContact}/{User.IsContact}");
private async Task ShowCommesse()
{

View File

@@ -37,71 +37,76 @@
<div class="input-card">
<div class="form-container">
<span class="disable-full-width">Indirizzo</span>
<MudTextField ReadOnly="IsView"
T="string?"
Placeholder="Indirizzo"
Variant="Variant.Text"
Lines="1"
@bind-Value="ContactModel.Indirizzo"
@bind-Value:after="OnAfterChangeValue"
DebounceInterval="500"
OnDebounceIntervalElapsed="OnAfterChangeValue" />
OnDebounceIntervalElapsed="OnAfterChangeValue"/>
</div>
<div class="divider"></div>
<div class="form-container">
<span class="disable-full-width">CAP</span>
<MudTextField ReadOnly="IsView"
T="string?"
Placeholder="CAP"
Variant="Variant.Text"
Lines="1"
@bind-Value="ContactModel.Cap"
@bind-Value:after="OnAfterChangeValue"
DebounceInterval="500"
OnDebounceIntervalElapsed="OnAfterChangeValue" />
OnDebounceIntervalElapsed="OnAfterChangeValue"/>
</div>
<div class="divider"></div>
<div class="form-container">
<span class="disable-full-width">Città</span>
<MudTextField ReadOnly="IsView"
T="string?"
Placeholder="Città"
Variant="Variant.Text"
Lines="1"
@bind-Value="ContactModel.Citta"
@bind-Value:after="OnAfterChangeValue"
DebounceInterval="500"
OnDebounceIntervalElapsed="OnAfterChangeValue" />
OnDebounceIntervalElapsed="OnAfterChangeValue"/>
</div>
<div class="divider"></div>
<div class="form-container">
<span class="disable-full-width">Provincia</span>
<MudTextField ReadOnly="IsView"
T="string?"
Placeholder="Provincia"
Variant="Variant.Text"
Lines="1"
@bind-Value="ContactModel.Prov"
@bind-Value:after="OnAfterChangeValue"
DebounceInterval="500"
OnDebounceIntervalElapsed="OnAfterChangeValue" />
OnDebounceIntervalElapsed="OnAfterChangeValue"/>
</div>
<div class="divider"></div>
<div class="form-container">
<span class="disable-full-width">Nazione</span>
<MudTextField ReadOnly="IsView"
T="string?"
Placeholder="Nazione"
Variant="Variant.Text"
Lines="1"
@bind-Value="ContactModel.Nazione"
@bind-Value:after="OnAfterChangeValue"
DebounceInterval="500"
OnDebounceIntervalElapsed="OnAfterChangeValue" />
OnDebounceIntervalElapsed="OnAfterChangeValue"/>
</div>
</div>
@@ -147,13 +152,10 @@
@code {
[CascadingParameter] private IMudDialogInstance MudDialog { get; set; }
[Parameter] public string? CodAnag { get; set; }
[Parameter] public string? UserType { get; set; }
private ContactDTO OriginalModel { get; set; } = new();
[Parameter] public ContactDTO? OriginalModel { get; set; }
private ContactDTO ContactModel { get; set; } = new();
private bool IsNew => CodAnag.IsNullOrEmpty();
private bool IsNew => OriginalModel is null;
private bool IsView => !NetworkService.IsNetworkAvailable();
private string? LabelSave { get; set; }
@@ -183,7 +185,8 @@
private async Task LoadData()
{
if (!IsNew)
ContactModel = OriginalModel!.Clone();
}
private void OnAfterChangeValue()

View File

@@ -0,0 +1,155 @@
@using salesbook.Shared.Core.Dto
@using salesbook.Shared.Components.Layout
@using salesbook.Shared.Core.Interface
@using salesbook.Shared.Components.Layout.Overlay
@inject IManageDataService ManageData
@inject INetworkService NetworkService
@inject IIntegryApiService IntegryApiService
<MudDialog Class="customDialog-form">
<DialogContent>
<HeaderLayout ShowProfile="false" Cancel="true" OnCancel="() => MudDialog.Cancel()" LabelSave="@LabelSave" OnSave="Save" Title="@(IsNew ? "Nuovo" : $"{PersRifModel.CodPersRif}")" />
<div class="content">
<div class="input-card">
<MudTextField ReadOnly="IsView"
T="string?"
Placeholder="Persona di riferimento"
Variant="Variant.Text"
Lines="1"
@bind-Value="PersRifModel.PersonaRif"
@bind-Value:after="OnAfterChangeValue"
DebounceInterval="500"
OnDebounceIntervalElapsed="OnAfterChangeValue"/>
</div>
<div class="input-card">
<MudTextField ReadOnly="IsView"
T="string?"
Placeholder="Mansione"
Variant="Variant.Text"
Lines="1"
@bind-Value="PersRifModel.Mansione"
@bind-Value:after="OnAfterChangeValue"
DebounceInterval="500"
OnDebounceIntervalElapsed="OnAfterChangeValue" />
</div>
<div class="input-card">
<div class="form-container">
<span class="disable-full-width">Email</span>
<MudTextField ReadOnly="IsView"
T="string?"
Variant="Variant.Text"
Lines="1"
@bind-Value="PersRifModel.EMail"
@bind-Value:after="OnAfterChangeValue"
DebounceInterval="500"
OnDebounceIntervalElapsed="OnAfterChangeValue"/>
</div>
<div class="divider"></div>
<div class="form-container">
<span class="disable-full-width">Fax</span>
<MudTextField ReadOnly="IsView"
T="string?"
Variant="Variant.Text"
Lines="1"
@bind-Value="PersRifModel.Fax"
@bind-Value:after="OnAfterChangeValue"
DebounceInterval="500"
OnDebounceIntervalElapsed="OnAfterChangeValue"/>
</div>
<div class="divider"></div>
<div class="form-container">
<span class="disable-full-width">Cellulare</span>
<MudTextField ReadOnly="IsView"
T="string?"
Variant="Variant.Text"
Lines="1"
@bind-Value="PersRifModel.NumCellulare"
@bind-Value:after="OnAfterChangeValue"
DebounceInterval="500"
OnDebounceIntervalElapsed="OnAfterChangeValue"/>
</div>
<div class="divider"></div>
<div class="form-container">
<span class="disable-full-width">Telefono</span>
<MudTextField ReadOnly="IsView"
T="string?"
Variant="Variant.Text"
Lines="1"
@bind-Value="PersRifModel.Telefono"
@bind-Value:after="OnAfterChangeValue"
DebounceInterval="500"
OnDebounceIntervalElapsed="OnAfterChangeValue" />
</div>
</div>
</div>
</DialogContent>
</MudDialog>
<SaveOverlay VisibleOverlay="VisibleOverlay" SuccessAnimation="SuccessAnimation"/>
@code {
[CascadingParameter] private IMudDialogInstance MudDialog { get; set; }
[Parameter] public PersRifDTO? OriginalModel { get; set; }
private PersRifDTO PersRifModel { get; set; } = new();
private bool IsNew => OriginalModel is null;
private bool IsView => !NetworkService.IsNetworkAvailable();
private string? LabelSave { get; set; }
//Overlay for save
private bool VisibleOverlay { get; set; }
private bool SuccessAnimation { get; set; }
protected override async Task OnInitializedAsync()
{
Snackbar.Configuration.PositionClass = Defaults.Classes.Position.TopCenter;
_ = LoadData();
LabelSave = IsNew ? "Aggiungi" : null;
}
private async Task Save()
{
SuccessAnimation = true;
StateHasChanged();
await Task.Delay(1250);
MudDialog.Close();
}
private async Task LoadData()
{
if (!IsNew)
PersRifModel = OriginalModel!.Clone();
}
private void OnAfterChangeValue()
{
if (!IsNew)
{
LabelSave = !OriginalModel.Equals(PersRifModel) ? "Aggiorna" : null;
}
}
private void NewPersRif()
{
}
}

View File

@@ -0,0 +1,4 @@
.container-button {
background: var(--mud-palette-background-gray) !important;
box-shadow: unset;
}

View File

@@ -57,4 +57,9 @@ public class ContactDTO
[JsonPropertyName("eMailPec")]
public string EMailPec { get; set; }
public ContactDTO Clone()
{
return (ContactDTO)MemberwiseClone();
}
}

View File

@@ -0,0 +1,35 @@
using System.Text.Json.Serialization;
namespace salesbook.Shared.Core.Dto;
public class PersRifDTO
{
[JsonPropertyName("codPersRif")]
public string CodPersRif { get; set; }
[JsonPropertyName("idPersRif")]
public int IdPersRif { get; set; }
[JsonPropertyName("personaRif")]
public string PersonaRif { get; set; }
[JsonPropertyName("eMail")]
public string EMail { get; set; }
[JsonPropertyName("fax")]
public string Fax { get; set; }
[JsonPropertyName("mansione")]
public string? Mansione { get; set; }
[JsonPropertyName("numCellulare")]
public string NumCellulare { get; set; }
[JsonPropertyName("telefono")]
public string Telefono { get; set; }
public PersRifDTO Clone()
{
return (PersRifDTO)MemberwiseClone();
}
}

View File

@@ -19,5 +19,13 @@ public class MappingProfile : Profile
CreateMap<PtbPros, ContactDTO>()
.ForMember(dest => dest.CodContact, opt => opt.MapFrom(src => src.CodPpro))
.ForMember(dest => dest.IsContact, opt => opt.MapFrom(src => false));
//Mapping da VtbCliePersRif a PersRifDTO
CreateMap<VtbCliePersRif, PersRifDTO>()
.ForMember(x => x.CodPersRif, y => y.MapFrom(z => z.CodAnag));
//Mapping da PtbProsRif a PersRifDTO
CreateMap<PtbProsRif, PersRifDTO>()
.ForMember(x => x.CodPersRif, y => y.MapFrom(z => z.CodPpro));
}
}

View File

@@ -26,13 +26,32 @@ public class ModalHelpers
return await modal.Result;
}
public static async Task<DialogResult?> OpenUserForm(IDialogService dialog, string? codAnag)
public static async Task<DialogResult?> OpenUserForm(IDialogService dialog, ContactDTO? anag)
{
var modal = await dialog.ShowAsync<ContactForm>(
"User form",
new DialogParameters<ContactForm>
{
{ x => x.CodAnag, codAnag }
{ x => x.OriginalModel, anag }
},
new DialogOptions
{
FullScreen = true,
CloseButton = false,
NoHeader = true
}
);
return await modal.Result;
}
public static async Task<DialogResult?> OpenPersRifForm(IDialogService dialog, PersRifDTO? persRif)
{
var modal = await dialog.ShowAsync<PersRifForm>(
"Pers rif form",
new DialogParameters<PersRifForm>
{
{ x => x.OriginalModel, persRif }
},
new DialogOptions
{

View File

@@ -6,6 +6,16 @@
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<IsAotCompatible>True</IsAotCompatible>
<RunAOTCompilation>true</RunAOTCompilation>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<IsAotCompatible>True</IsAotCompatible>
<RunAOTCompilation>true</RunAOTCompilation>
</PropertyGroup>
<ItemGroup>
<SupportedPlatform Include="browser" />
</ItemGroup>