From b2064ad71e3e151978bbd5e466a8a58813399144 Mon Sep 17 00:00:00 2001 From: MarcoE Date: Wed, 16 Jul 2025 17:24:41 +0200 Subject: [PATCH] Migliorati form Cliente e PersonaRif --- .../Platforms/Android/MainApplication.cs | 2 +- salesbook.Shared/Components/Pages/User.razor | 107 +++++++----- .../Components/Pages/User.razor.css | 7 + salesbook.Shared/Components/Pages/Users.razor | 10 +- .../SingleElements/Card/ContactCard.razor | 22 ++- .../SingleElements/Card/UserCard.razor | 4 +- .../SingleElements/Modal/ContactForm.razor | 35 ++-- .../SingleElements/Modal/PersRifForm.razor | 155 ++++++++++++++++++ .../Modal/PersRifForm.razor.css | 4 + salesbook.Shared/Core/Dto/ContactDTO.cs | 5 + salesbook.Shared/Core/Dto/PersRifDTO.cs | 35 ++++ .../Core/Helpers/MappingProfile.cs | 8 + salesbook.Shared/Core/Helpers/ModalHelpers.cs | 23 ++- salesbook.Shared/salesbook.Shared.csproj | 58 ++++--- 14 files changed, 381 insertions(+), 94 deletions(-) create mode 100644 salesbook.Shared/Components/SingleElements/Modal/PersRifForm.razor create mode 100644 salesbook.Shared/Components/SingleElements/Modal/PersRifForm.razor.css create mode 100644 salesbook.Shared/Core/Dto/PersRifDTO.cs diff --git a/salesbook.Maui/Platforms/Android/MainApplication.cs b/salesbook.Maui/Platforms/Android/MainApplication.cs index b8939c1..2820e44 100644 --- a/salesbook.Maui/Platforms/Android/MainApplication.cs +++ b/salesbook.Maui/Platforms/Android/MainApplication.cs @@ -3,7 +3,7 @@ using Android.Runtime; namespace salesbook.Maui { - [Application] + [Application(HardwareAccelerated = true)] public class MainApplication : MauiApplication { public MainApplication(IntPtr handle, JniHandleOwnership ownership) diff --git a/salesbook.Shared/Components/Pages/User.razor b/salesbook.Shared/Components/Pages/User.razor index 0201904..88d73b5 100644 --- a/salesbook.Shared/Components/Pages/User.razor +++ b/salesbook.Shared/Components/Pages/User.razor @@ -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 - + @if (IsLoading) { @@ -45,50 +50,42 @@ else } -
- P. IVA - - @if (string.IsNullOrEmpty(Anag.PartIva)) - { - @("Nessuna partita iva configurata") - } - else - { + @if (!string.IsNullOrEmpty(Anag.PartIva)) + { +
+ P. IVA + @Anag.PartIva - } - -
+
+
+ }
-
- E-mail - - @if (string.IsNullOrEmpty(Anag.EMail)) - { - @("Nessuna mail configurata") - } - else - { + @if (!string.IsNullOrEmpty(Anag.EMail)) + { +
+ E-mail + @Anag.EMail - } - -
+
+
+ }
- + @if (PersRif is { Count: > 0 }) { -
+
@{ var index = PersRif.IndexOf(person); var isLast = index == PersRif.Count - 1; } - + @if (!isLast) {
@@ -101,25 +98,34 @@ else Aggiungi contatto
- - - + @if (Commesse.IsNullOrEmpty()) + { + + } + else + { + + + + }
} @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? PersRif { get; set; } + private ContactDTO Anag { get; set; } = new(); + private List? PersRif { get; set; } private List Commesse { get; set; } private bool IsLoading { get; set; } = true; @@ -131,12 +137,37 @@ else private async Task LoadData() { - Anag = (await ManageData.GetTable(x => x.CodAnag.Equals(CodAnag))).Last(); - PersRif = await ManageData.GetTable(x => x.CodAnag.Equals(Anag.CodAnag)); - Commesse = await ManageData.GetTable(x => x.CodAnag != null && x.CodAnag.Equals(CodAnag)); + if (IsContact) + { + var clie = (await ManageData.GetTable(x => x.CodAnag.Equals(CodContact))).Last(); + Anag = Mapper.Map(clie); + + var pers = await ManageData.GetTable(x => x.CodAnag.Equals(Anag.CodContact)); + PersRif = Mapper.Map>(pers); + } + else + { + var pros = (await ManageData.GetTable(x => x.CodPpro.Equals(CodContact))).Last(); + Anag = Mapper.Map(pros); + + var pers = await ManageData.GetTable(x => x.CodPpro.Equals(Anag.CodContact)); + PersRif = Mapper.Map>(pers); + } + + Commesse = await ManageData.GetTable(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); + } + } \ No newline at end of file diff --git a/salesbook.Shared/Components/Pages/User.razor.css b/salesbook.Shared/Components/Pages/User.razor.css index f472205..fd088e5 100644 --- a/salesbook.Shared/Components/Pages/User.razor.css +++ b/salesbook.Shared/Components/Pages/User.razor.css @@ -144,4 +144,11 @@ .container-pers-rif .divider { margin: 0 0 0 3.5rem; width: unset; +} + +.custom-tab-panel { + width: 100%; + display: flex; + gap: 1rem; + flex-direction: column; } \ No newline at end of file diff --git a/salesbook.Shared/Components/Pages/Users.razor b/salesbook.Shared/Components/Pages/Users.razor index 1e3c576..eb6500a 100644 --- a/salesbook.Shared/Components/Pages/Users.razor +++ b/salesbook.Shared/Components/Pages/Users.razor @@ -20,13 +20,13 @@ } - + - Tutti - Contatti - Prospect + Tutti + Contatti + Prospect @@ -37,7 +37,7 @@ } else if (GroupedUserList?.Count > 0) { - + @if (item.ShowHeader) {
@item.HeaderLetter
diff --git a/salesbook.Shared/Components/SingleElements/Card/ContactCard.razor b/salesbook.Shared/Components/SingleElements/Card/ContactCard.razor index e09194f..7a0b4cb 100644 --- a/salesbook.Shared/Components/SingleElements/Card/ContactCard.razor +++ b/salesbook.Shared/Components/SingleElements/Card/ContactCard.razor @@ -1,8 +1,9 @@ -@using salesbook.Shared.Core.Entity +@using salesbook.Shared.Core.Dto +@inject IDialogService Dialog -
+
- +
@@ -18,16 +19,25 @@
@if (!Contact.NumCellulare.IsNullOrEmpty()) { - + + + } @if (!Contact.EMail.IsNullOrEmpty()) { - + + + }
@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); + } } \ No newline at end of file diff --git a/salesbook.Shared/Components/SingleElements/Card/UserCard.razor b/salesbook.Shared/Components/SingleElements/Card/UserCard.razor index 6531cb6..ec53244 100644 --- a/salesbook.Shared/Components/SingleElements/Card/UserCard.razor +++ b/salesbook.Shared/Components/SingleElements/Card/UserCard.razor @@ -7,7 +7,7 @@
- +
@@ -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() { diff --git a/salesbook.Shared/Components/SingleElements/Modal/ContactForm.razor b/salesbook.Shared/Components/SingleElements/Modal/ContactForm.razor index f1487aa..e663947 100644 --- a/salesbook.Shared/Components/SingleElements/Modal/ContactForm.razor +++ b/salesbook.Shared/Components/SingleElements/Modal/ContactForm.razor @@ -37,71 +37,76 @@
+ Indirizzo + + OnDebounceIntervalElapsed="OnAfterChangeValue"/>
+ CAP + + OnDebounceIntervalElapsed="OnAfterChangeValue"/>
+ Città + + OnDebounceIntervalElapsed="OnAfterChangeValue"/>
+ Provincia + + OnDebounceIntervalElapsed="OnAfterChangeValue"/>
+ Nazione + + OnDebounceIntervalElapsed="OnAfterChangeValue"/>
@@ -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() diff --git a/salesbook.Shared/Components/SingleElements/Modal/PersRifForm.razor b/salesbook.Shared/Components/SingleElements/Modal/PersRifForm.razor new file mode 100644 index 0000000..0998dca --- /dev/null +++ b/salesbook.Shared/Components/SingleElements/Modal/PersRifForm.razor @@ -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 + + + + + +
+
+ +
+ +
+ +
+ +
+
+ Email + + +
+ +
+ +
+ Fax + + +
+ +
+ +
+ Cellulare + + +
+ +
+ +
+ Telefono + + +
+
+
+
+
+ + + +@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() + { + + } +} \ No newline at end of file diff --git a/salesbook.Shared/Components/SingleElements/Modal/PersRifForm.razor.css b/salesbook.Shared/Components/SingleElements/Modal/PersRifForm.razor.css new file mode 100644 index 0000000..cb50e2e --- /dev/null +++ b/salesbook.Shared/Components/SingleElements/Modal/PersRifForm.razor.css @@ -0,0 +1,4 @@ +.container-button { + background: var(--mud-palette-background-gray) !important; + box-shadow: unset; +} diff --git a/salesbook.Shared/Core/Dto/ContactDTO.cs b/salesbook.Shared/Core/Dto/ContactDTO.cs index a025ecb..4d7d272 100644 --- a/salesbook.Shared/Core/Dto/ContactDTO.cs +++ b/salesbook.Shared/Core/Dto/ContactDTO.cs @@ -57,4 +57,9 @@ public class ContactDTO [JsonPropertyName("eMailPec")] public string EMailPec { get; set; } + + public ContactDTO Clone() + { + return (ContactDTO)MemberwiseClone(); + } } \ No newline at end of file diff --git a/salesbook.Shared/Core/Dto/PersRifDTO.cs b/salesbook.Shared/Core/Dto/PersRifDTO.cs new file mode 100644 index 0000000..10ec7cc --- /dev/null +++ b/salesbook.Shared/Core/Dto/PersRifDTO.cs @@ -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(); + } +} diff --git a/salesbook.Shared/Core/Helpers/MappingProfile.cs b/salesbook.Shared/Core/Helpers/MappingProfile.cs index ffe14ab..8ac3142 100644 --- a/salesbook.Shared/Core/Helpers/MappingProfile.cs +++ b/salesbook.Shared/Core/Helpers/MappingProfile.cs @@ -19,5 +19,13 @@ public class MappingProfile : Profile CreateMap() .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() + .ForMember(x => x.CodPersRif, y => y.MapFrom(z => z.CodAnag)); + + //Mapping da PtbProsRif a PersRifDTO + CreateMap() + .ForMember(x => x.CodPersRif, y => y.MapFrom(z => z.CodPpro)); } } diff --git a/salesbook.Shared/Core/Helpers/ModalHelpers.cs b/salesbook.Shared/Core/Helpers/ModalHelpers.cs index e7be287..0a619ea 100644 --- a/salesbook.Shared/Core/Helpers/ModalHelpers.cs +++ b/salesbook.Shared/Core/Helpers/ModalHelpers.cs @@ -26,13 +26,32 @@ public class ModalHelpers return await modal.Result; } - public static async Task OpenUserForm(IDialogService dialog, string? codAnag) + public static async Task OpenUserForm(IDialogService dialog, ContactDTO? anag) { var modal = await dialog.ShowAsync( "User form", new DialogParameters { - { x => x.CodAnag, codAnag } + { x => x.OriginalModel, anag } + }, + new DialogOptions + { + FullScreen = true, + CloseButton = false, + NoHeader = true + } + ); + + return await modal.Result; + } + + public static async Task OpenPersRifForm(IDialogService dialog, PersRifDTO? persRif) + { + var modal = await dialog.ShowAsync( + "Pers rif form", + new DialogParameters + { + { x => x.OriginalModel, persRif } }, new DialogOptions { diff --git a/salesbook.Shared/salesbook.Shared.csproj b/salesbook.Shared/salesbook.Shared.csproj index 7cf8a8b..39e5af9 100644 --- a/salesbook.Shared/salesbook.Shared.csproj +++ b/salesbook.Shared/salesbook.Shared.csproj @@ -1,31 +1,41 @@ - - net9.0 - enable - enable - + + net9.0 + enable + enable + - - - + + True + true + - - - - - - - - - - - - + + True + true + - - - - + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file