Migliorie form inserimento
This commit is contained in:
@@ -174,10 +174,10 @@
|
|||||||
|
|
||||||
// Cache per rendering
|
// Cache per rendering
|
||||||
private DayData[] _monthDaysData = Array.Empty<DayData>();
|
private DayData[] _monthDaysData = Array.Empty<DayData>();
|
||||||
private DayData[] _weekDaysData = new DayData[7];
|
private readonly DayData[] _weekDaysData = new DayData[7];
|
||||||
private string _headerTitle = string.Empty;
|
private string _headerTitle = string.Empty;
|
||||||
private Dictionary<DateTime, List<ActivityDTO>> _eventsCache = new();
|
private readonly Dictionary<DateTime, List<ActivityDTO>> _eventsCache = new();
|
||||||
private Dictionary<DateTime, CategoryData[]> _categoriesCache = new();
|
private readonly Dictionary<DateTime, CategoryData[]> _categoriesCache = new();
|
||||||
private bool _isInitialized = false;
|
private bool _isInitialized = false;
|
||||||
|
|
||||||
// Stato UI
|
// Stato UI
|
||||||
@@ -325,7 +325,7 @@
|
|||||||
private CategoryData[] GetFilteredCategoriesForDay(DateTime date)
|
private CategoryData[] GetFilteredCategoriesForDay(DateTime date)
|
||||||
{
|
{
|
||||||
if (!_categoriesCache.TryGetValue(date, out var categories))
|
if (!_categoriesCache.TryGetValue(date, out var categories))
|
||||||
return Array.Empty<CategoryData>();
|
return [];
|
||||||
|
|
||||||
if (Filter.ClearFilter)
|
if (Filter.ClearFilter)
|
||||||
return categories;
|
return categories;
|
||||||
@@ -333,7 +333,7 @@
|
|||||||
// Applica i filtri alle categorie
|
// Applica i filtri alle categorie
|
||||||
var filteredActivities = GetFilteredActivitiesForDay(date);
|
var filteredActivities = GetFilteredActivitiesForDay(date);
|
||||||
if (!filteredActivities.Any())
|
if (!filteredActivities.Any())
|
||||||
return Array.Empty<CategoryData>();
|
return [];
|
||||||
|
|
||||||
return filteredActivities
|
return filteredActivities
|
||||||
.Select(x => x.Category)
|
.Select(x => x.Category)
|
||||||
@@ -345,7 +345,7 @@
|
|||||||
private List<ActivityDTO> GetFilteredActivitiesForDay(DateTime date)
|
private List<ActivityDTO> GetFilteredActivitiesForDay(DateTime date)
|
||||||
{
|
{
|
||||||
if (!_eventsCache.TryGetValue(date, out var activities))
|
if (!_eventsCache.TryGetValue(date, out var activities))
|
||||||
return new List<ActivityDTO>();
|
return [];
|
||||||
|
|
||||||
if (Filter.ClearFilter)
|
if (Filter.ClearFilter)
|
||||||
return activities;
|
return activities;
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
@using System.Globalization
|
@using System.Globalization
|
||||||
@using Microsoft.VisualBasic
|
|
||||||
@using Template.Shared.Core.Dto
|
@using Template.Shared.Core.Dto
|
||||||
@using Template.Shared.Components.Layout
|
@using Template.Shared.Components.Layout
|
||||||
@using Template.Shared.Core.Entity
|
@using Template.Shared.Core.Entity
|
||||||
@@ -12,22 +11,31 @@
|
|||||||
|
|
||||||
<MudDialog Class="customDialog-form">
|
<MudDialog Class="customDialog-form">
|
||||||
<DialogContent>
|
<DialogContent>
|
||||||
<HeaderLayout ShowProfile="false" Cancel="true" OnCancel="() => MudDialog.Cancel()" LabelSave="@LabelSave" OnSave="Save" Title="@(IsNew ? "Nuova" : $"{ActivityModel.ActivityId}")" />
|
<HeaderLayout ShowProfile="false" Cancel="true" OnCancel="() => MudDialog.Cancel()" LabelSave="@LabelSave" OnSave="Save" Title="@(IsNew ? "Nuova" : $"{ActivityModel.ActivityId}")"/>
|
||||||
|
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<div class="input-card">
|
<div class="input-card">
|
||||||
<MudTextField ReadOnly="IsView" T="string?" Placeholder="Descrizione" Variant="Variant.Text" Lines="3" @bind-Value="ActivityModel.ActivityDescription" @bind-Value:after="OnAfterChangeValue" DebounceInterval="500" OnDebounceIntervalElapsed="OnAfterChangeValue" />
|
<MudTextField ReadOnly="IsView" T="string?" Placeholder="Descrizione" Variant="Variant.Text" Lines="3" @bind-Value="ActivityModel.ActivityDescription" @bind-Value:after="OnAfterChangeValue" DebounceInterval="500" OnDebounceIntervalElapsed="OnAfterChangeValue"/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="input-card">
|
<div class="input-card">
|
||||||
<div class="form-container">
|
<div class="form-container">
|
||||||
<MudInput ReadOnly="IsView" T="string?" Placeholder="Cliente" @bind-Value="ActivityModel.Cliente" @bind-Value:after="OnAfterChangeValue" />
|
<MudAutocomplete ReadOnly="IsView" T="string?" Placeholder="Cliente"
|
||||||
|
SearchFunc="@SearchCliente" @bind-Value="ActivityModel.Cliente" @bind-Value:after="OnClienteChanged"
|
||||||
|
CoerceValue="true"/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="divider"></div>
|
<div class="divider"></div>
|
||||||
|
|
||||||
<div class="form-container">
|
<div class="form-container">
|
||||||
<MudInput ReadOnly="IsView" T="string?" Placeholder="Commessa" @bind-Value="ActivityModel.Commessa" @bind-Value:after="OnAfterChangeValue" />
|
<span class="disable-full-width">Commessa</span>
|
||||||
|
|
||||||
|
<MudSelectExtended FullWidth="true" ReadOnly="@(IsView || Commesse.IsNullOrEmpty())" T="string?" Variant="Variant.Text" @bind-Value="ActivityModel.CodJcom" @bind-Value:after="OnCommessaChanged" Class="customIcon-select" AdornmentIcon="@Icons.Material.Filled.Code">
|
||||||
|
@foreach (var com in Commesse)
|
||||||
|
{
|
||||||
|
<MudSelectItemExtended Class="custom-item-select" Value="@com.CodJcom">@com.Descrizione</MudSelectItemExtended>
|
||||||
|
}
|
||||||
|
</MudSelectExtended>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -35,7 +43,7 @@
|
|||||||
<div class="form-container">
|
<div class="form-container">
|
||||||
<span>Inizio</span>
|
<span>Inizio</span>
|
||||||
|
|
||||||
<MudTextField ReadOnly="IsView" T="DateTime?" Format="s" Culture="CultureInfo.CurrentUICulture" InputType="InputType.DateTimeLocal" @bind-Value="ActivityModel.EstimatedTime" @bind-Value:after="OnAfterChangeValue" DebounceInterval="500" OnDebounceIntervalElapsed="OnAfterChangeValue" />
|
<MudTextField ReadOnly="IsView" T="DateTime?" Format="s" Culture="CultureInfo.CurrentUICulture" InputType="InputType.DateTimeLocal" @bind-Value="ActivityModel.EstimatedTime" @bind-Value:after="OnAfterChangeValue" DebounceInterval="500" OnDebounceIntervalElapsed="OnAfterChangeValue"/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="divider"></div>
|
<div class="divider"></div>
|
||||||
@@ -43,7 +51,7 @@
|
|||||||
<div class="form-container">
|
<div class="form-container">
|
||||||
<span>Fine</span>
|
<span>Fine</span>
|
||||||
|
|
||||||
<MudTextField ReadOnly="IsView" T="DateTime?" Format="s" Culture="CultureInfo.CurrentUICulture" InputType="InputType.DateTimeLocal" @bind-Value="ActivityModel.EstimatedEndtime" @bind-Value:after="OnAfterChangeValue" DebounceInterval="500" OnDebounceIntervalElapsed="OnAfterChangeValue" />
|
<MudTextField ReadOnly="IsView" T="DateTime?" Format="s" Culture="CultureInfo.CurrentUICulture" InputType="InputType.DateTimeLocal" @bind-Value="ActivityModel.EstimatedEndtime" @bind-Value:after="OnAfterChangeValue" DebounceInterval="500" OnDebounceIntervalElapsed="OnAfterChangeValue"/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="divider"></div>
|
<div class="divider"></div>
|
||||||
@@ -51,7 +59,7 @@
|
|||||||
<div class="form-container">
|
<div class="form-container">
|
||||||
<span>Avviso</span>
|
<span>Avviso</span>
|
||||||
|
|
||||||
<MudSwitch ReadOnly="IsView" T="bool" Disabled="true" Color="Color.Primary" />
|
<MudSwitch ReadOnly="IsView" T="bool" Disabled="true" Color="Color.Primary"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -95,15 +103,15 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="input-card">
|
<div class="input-card">
|
||||||
<MudTextField ReadOnly="IsView" T="string?" Placeholder="Note" Variant="Variant.Text" Lines="4" @bind-Value="ActivityModel.Note" @bind-Value:after="OnAfterChangeValue" DebounceInterval="500" OnDebounceIntervalElapsed="OnAfterChangeValue" />
|
<MudTextField ReadOnly="IsView" T="string?" Placeholder="Note" Variant="Variant.Text" Lines="4" @bind-Value="ActivityModel.Note" @bind-Value:after="OnAfterChangeValue" DebounceInterval="500" OnDebounceIntervalElapsed="OnAfterChangeValue"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
</MudDialog>
|
</MudDialog>
|
||||||
|
|
||||||
<SaveOverlay VisibleOverlay="VisibleOverlay" SuccessAnimation="SuccessAnimation" />
|
<SaveOverlay VisibleOverlay="VisibleOverlay" SuccessAnimation="SuccessAnimation"/>
|
||||||
|
|
||||||
<SelectEsito @bind-IsSheetVisible="OpenEsito" @bind-ActivityModel="ActivityModel" @bind-ActivityModel:after="OnAfterChangeValue" />
|
<SelectEsito @bind-IsSheetVisible="OpenEsito" @bind-ActivityModel="ActivityModel" @bind-ActivityModel:after="OnAfterChangeValue"/>
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
[CascadingParameter] private IMudDialogInstance MudDialog { get; set; }
|
[CascadingParameter] private IMudDialogInstance MudDialog { get; set; }
|
||||||
@@ -116,9 +124,12 @@
|
|||||||
private List<StbActivityResult> ActivityResult { get; set; } = [];
|
private List<StbActivityResult> ActivityResult { get; set; } = [];
|
||||||
private List<StbActivityType> ActivityType { get; set; } = [];
|
private List<StbActivityType> ActivityType { get; set; } = [];
|
||||||
private List<StbUser> Users { get; set; } = [];
|
private List<StbUser> Users { get; set; } = [];
|
||||||
|
private List<JtbComt> Commesse { get; set; } = [];
|
||||||
|
private List<AnagClie> Clienti { get; set; } = [];
|
||||||
|
private List<PtbPros> Pros { get; set; } = [];
|
||||||
|
|
||||||
private bool IsNew => Id.IsNullOrEmpty();
|
private bool IsNew => Id.IsNullOrEmpty();
|
||||||
private bool IsView => !IsNew && !NetworkService.IsNetworkAvailable();
|
private bool IsView => !NetworkService.IsNetworkAvailable();
|
||||||
|
|
||||||
private string? LabelSave { get; set; }
|
private string? LabelSave { get; set; }
|
||||||
|
|
||||||
@@ -173,9 +184,66 @@
|
|||||||
{
|
{
|
||||||
Users = await ManageData.GetTable<StbUser>();
|
Users = await ManageData.GetTable<StbUser>();
|
||||||
ActivityResult = await ManageData.GetTable<StbActivityResult>();
|
ActivityResult = await ManageData.GetTable<StbActivityResult>();
|
||||||
|
Clienti = await ManageData.GetTable<AnagClie>(x => x.FlagStato.Equals("A"));
|
||||||
|
Pros = await ManageData.GetTable<PtbPros>();
|
||||||
ActivityType = await ManageData.GetTable<StbActivityType>(x => x.FlagTipologia.Equals("A"));
|
ActivityType = await ManageData.GetTable<StbActivityType>(x => x.FlagTipologia.Equals("A"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task LoadCommesse() =>
|
||||||
|
Commesse = await ManageData.GetTable<JtbComt>(x => x.CodAnag != null && x.CodAnag.Equals(ActivityModel.CodAnag));
|
||||||
|
|
||||||
|
private async Task<IEnumerable<string>?> SearchCliente(string value, CancellationToken token)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(value))
|
||||||
|
return null;
|
||||||
|
|
||||||
|
var listToReturn = new List<string>();
|
||||||
|
|
||||||
|
listToReturn.AddRange(
|
||||||
|
Clienti.Where(x => x.RagSoc.Contains(value, StringComparison.OrdinalIgnoreCase)).Select(x => x.RagSoc)
|
||||||
|
);
|
||||||
|
|
||||||
|
listToReturn.AddRange(
|
||||||
|
Pros.Where(x => x.RagSoc.Contains(value, StringComparison.OrdinalIgnoreCase)).Select(x => x.RagSoc)
|
||||||
|
);
|
||||||
|
|
||||||
|
return listToReturn;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task OnClienteChanged()
|
||||||
|
{
|
||||||
|
string? codAnag = null;
|
||||||
|
|
||||||
|
var cliente = Clienti.LastOrDefault(x => ActivityModel.Cliente != null && x.RagSoc.Contains(ActivityModel.Cliente, StringComparison.OrdinalIgnoreCase));
|
||||||
|
if (cliente is null)
|
||||||
|
{
|
||||||
|
var pros = Pros.LastOrDefault(x => ActivityModel.Cliente != null && x.RagSoc.Contains(ActivityModel.Cliente, StringComparison.OrdinalIgnoreCase));
|
||||||
|
|
||||||
|
if (pros is not null)
|
||||||
|
{
|
||||||
|
codAnag = pros.CodAnag;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
codAnag = cliente.CodAnag;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (codAnag is not null)
|
||||||
|
{
|
||||||
|
ActivityModel.CodAnag = codAnag;
|
||||||
|
await LoadCommesse();
|
||||||
|
OnAfterChangeValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task OnCommessaChanged()
|
||||||
|
{
|
||||||
|
ActivityModel.Commessa = (await ManageData.GetTable<JtbComt>(x => x.CodJcom.Equals(ActivityModel.CodJcom))).Last().Descrizione;
|
||||||
|
OnAfterChangeValue();
|
||||||
|
}
|
||||||
|
|
||||||
private void OnAfterChangeValue()
|
private void OnAfterChangeValue()
|
||||||
{
|
{
|
||||||
LabelSave = !OriginalModel.Equals(ActivityModel) ? "Aggiorna" : null;
|
LabelSave = !OriginalModel.Equals(ActivityModel) ? "Aggiorna" : null;
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ public class JtbComt
|
|||||||
public string Note { get; set; }
|
public string Note { get; set; }
|
||||||
|
|
||||||
[Column("cod_anag"), JsonPropertyName("codAnag")]
|
[Column("cod_anag"), JsonPropertyName("codAnag")]
|
||||||
public string CodAnag { get; set; }
|
public string? CodAnag { get; set; }
|
||||||
|
|
||||||
[Column("cod_divi"), JsonPropertyName("codDivi")]
|
[Column("cod_divi"), JsonPropertyName("codDivi")]
|
||||||
public string CodDivi { get; set; } = "EURO";
|
public string CodDivi { get; set; } = "EURO";
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
.bottom-sheet-container {
|
.bottom-sheet-container {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
bottom: -100%;
|
bottom: -200%;
|
||||||
left: 0;
|
left: 0;
|
||||||
right: 0;
|
right: 0;
|
||||||
transition: bottom 0.3s ease;
|
transition: bottom 0.3s ease;
|
||||||
|
|||||||
Reference in New Issue
Block a user