From b7522fb1165d14e9eee63e613361bc120707352f Mon Sep 17 00:00:00 2001 From: MarcoE Date: Thu, 30 Oct 2025 10:12:10 +0100 Subject: [PATCH] =?UTF-8?q?Aggiunto=20tasto=20per=20il=20suggerimento=20de?= =?UTF-8?q?lla=20descrizione=20attvit=C3=A0=20in=20base=20al=20tipo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SingleElements/Modal/ActivityForm.razor | 38 ++++++++++++++++++- .../Modal/ModalSuggestDescription.razor | 32 ++++++++++++++++ .../Modal/ModalSuggestDescription.razor.css | 1 + salesbook.Shared/Core/Helpers/ModalHelpers.cs | 28 ++++++++++++-- .../IntegryApi/IIntegryApiService.cs | 2 + .../Core/Services/IntegryApiService.cs | 15 ++++++-- 6 files changed, 108 insertions(+), 8 deletions(-) create mode 100644 salesbook.Shared/Components/SingleElements/Modal/ModalSuggestDescription.razor create mode 100644 salesbook.Shared/Components/SingleElements/Modal/ModalSuggestDescription.razor.css diff --git a/salesbook.Shared/Components/SingleElements/Modal/ActivityForm.razor b/salesbook.Shared/Components/SingleElements/Modal/ActivityForm.razor index 41188ea..3efb438 100644 --- a/salesbook.Shared/Components/SingleElements/Modal/ActivityForm.razor +++ b/salesbook.Shared/Components/SingleElements/Modal/ActivityForm.razor @@ -30,6 +30,17 @@ DebounceInterval="500" OnDebounceIntervalElapsed="OnAfterChangeValue"/> +
+ + Suggerisci descrizione + +
+
(x => @@ -783,4 +794,29 @@ private static string AdjustCoordinate(double coordinate) => coordinate.ToString(CultureInfo.InvariantCulture).Replace(",", "."); + private async Task SuggestActivityDescription() + { + if (ActivityModel.ActivityTypeId == null) + { + Snackbar.Add("Indicare prima il tipo attività", Severity.Error); + return; + } + + VisibleOverlay = true; + StateHasChanged(); + + _ = Task.Run(async () => + { + var activityDescriptions = await IntegryApiService.SuggestActivityDescription(ActivityModel.ActivityTypeId); + + var modal = ModalHelpers.OpenSuggestActivityDescription(Dialog, activityDescriptions); + + if (modal is { IsCanceled: false, Result: not null }) + ActivityModel.ActivityDescription = modal.Result.Data!.ToString(); + + VisibleOverlay = false; + await InvokeAsync(StateHasChanged); + }); + } + } \ No newline at end of file diff --git a/salesbook.Shared/Components/SingleElements/Modal/ModalSuggestDescription.razor b/salesbook.Shared/Components/SingleElements/Modal/ModalSuggestDescription.razor new file mode 100644 index 0000000..a284799 --- /dev/null +++ b/salesbook.Shared/Components/SingleElements/Modal/ModalSuggestDescription.razor @@ -0,0 +1,32 @@ +@using salesbook.Shared.Core.Entity + + + + @if (!ActivityTypers.IsNullOrEmpty()) + { + + @foreach (var item in ActivityTypers!) + { + + } + + } + else + { +
+ + Nessuna descrizione consigliata +
+ } +
+
+ +@code { + [CascadingParameter] private IMudDialogInstance MudDialog { get; set; } + [Parameter] public List? ActivityTypers { get; set; } + + private void Cancel() => MudDialog.Cancel(); + + private void OnClickItem(string? selectedValue) => + MudDialog.Close(DialogResult.Ok(selectedValue)); +} \ No newline at end of file diff --git a/salesbook.Shared/Components/SingleElements/Modal/ModalSuggestDescription.razor.css b/salesbook.Shared/Components/SingleElements/Modal/ModalSuggestDescription.razor.css new file mode 100644 index 0000000..5f28270 --- /dev/null +++ b/salesbook.Shared/Components/SingleElements/Modal/ModalSuggestDescription.razor.css @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/salesbook.Shared/Core/Helpers/ModalHelpers.cs b/salesbook.Shared/Core/Helpers/ModalHelpers.cs index 74da67e..1d39135 100644 --- a/salesbook.Shared/Core/Helpers/ModalHelpers.cs +++ b/salesbook.Shared/Core/Helpers/ModalHelpers.cs @@ -2,6 +2,7 @@ using salesbook.Shared.Components.SingleElements.Modal; using salesbook.Shared.Core.Dto; using salesbook.Shared.Core.Dto.Activity; +using salesbook.Shared.Core.Entity; namespace salesbook.Shared.Core.Helpers; @@ -46,7 +47,7 @@ public class ModalHelpers return await modal.Result; } - public static async Task OpenPersRifForm(IDialogService dialog, PersRifDTO? persRif, + public static async Task OpenPersRifForm(IDialogService dialog, PersRifDTO? persRif, ContactDTO? contactModel = null, List? persRifList = null) { var modal = await dialog.ShowAsync( @@ -54,7 +55,7 @@ public class ModalHelpers new DialogParameters { { x => x.OriginalModel, persRif }, - { x => x.ContactModel, contactModel}, + { x => x.ContactModel, contactModel }, { x => x.PersRifList, persRifList } }, new DialogOptions @@ -74,7 +75,7 @@ public class ModalHelpers "Add attached", new DialogParameters { - { x => x.CanAddPosition, canAddPosition} + { x => x.CanAddPosition, canAddPosition } }, new DialogOptions { @@ -87,4 +88,25 @@ public class ModalHelpers return await modal.Result; } + + public static async Task OpenSuggestActivityDescription(IDialogService dialog, + List? activityTypers) + { + var modal = await dialog.ShowAsync( + "Suggest activity description", + new DialogParameters + { + { x => x.ActivityTypers, activityTypers } + }, + new DialogOptions + { + FullScreen = false, + CloseButton = false, + NoHeader = true, + BackdropClick = false + } + ); + + return await modal.Result; + } } \ No newline at end of file diff --git a/salesbook.Shared/Core/Interface/IntegryApi/IIntegryApiService.cs b/salesbook.Shared/Core/Interface/IntegryApi/IIntegryApiService.cs index ea44154..72a70a0 100644 --- a/salesbook.Shared/Core/Interface/IntegryApi/IIntegryApiService.cs +++ b/salesbook.Shared/Core/Interface/IntegryApi/IIntegryApiService.cs @@ -31,6 +31,8 @@ public interface IIntegryApiService Task DownloadFileFromRefUuid(string refUuid, string fileName); Task RetrieveJobProgress(string codJcom); + + Task?> SuggestActivityDescription(string activityType); //Position Task SavePosition(PositionDTO position); diff --git a/salesbook.Shared/Core/Services/IntegryApiService.cs b/salesbook.Shared/Core/Services/IntegryApiService.cs index fe92db0..30718b3 100644 --- a/salesbook.Shared/Core/Services/IntegryApiService.cs +++ b/salesbook.Shared/Core/Services/IntegryApiService.cs @@ -26,7 +26,7 @@ public class IntegryApiService(IIntegryApiRestClient integryApiRestClient, IUser return false; } } - + public Task?> RetrieveActivity(CRMRetrieveActivityRequestDTO activityRequest) => integryApiRestClient.AuthorizedPost?>("crm/retrieveActivity", activityRequest); @@ -42,10 +42,10 @@ public class IntegryApiService(IIntegryApiRestClient integryApiRestClient, IUser return integryApiRestClient.AuthorizedGet?>("crm/retrieveCommesse", queryParams); } - public Task RetrieveAnagClie(CRMAnagRequestDTO request) => + public Task RetrieveAnagClie(CRMAnagRequestDTO request) => integryApiRestClient.AuthorizedPost("crm/retrieveClienti", request)!; - public Task RetrieveProspect(CRMProspectRequestDTO request) => + public Task RetrieveProspect(CRMProspectRequestDTO request) => integryApiRestClient.AuthorizedPost("crm/retrieveProspect", request)!; public Task RetrieveSettings() => @@ -74,7 +74,8 @@ public class IntegryApiService(IIntegryApiRestClient integryApiRestClient, IUser public Task?> SaveActivity(ActivityDTO activity) { - if (activity.CodJcom is null && userSession.ProfileDb != null && userSession.ProfileDb.Equals("smetar", StringComparison.OrdinalIgnoreCase)) + if (activity.CodJcom is null && userSession.ProfileDb != null && + userSession.ProfileDb.Equals("smetar", StringComparison.OrdinalIgnoreCase)) { activity.CodJcom = "0000"; } @@ -188,4 +189,10 @@ public class IntegryApiService(IIntegryApiRestClient integryApiRestClient, IUser return integryApiRestClient.Get("crm/retrieveJobProgress", queryParams)!; } + + public Task?> SuggestActivityDescription(string activityType) => + integryApiRestClient.Get>( + "activity/suggestActivityDescription", + new Dictionary { { "activityType", activityType } } + ); } \ No newline at end of file