Migliorie form inserimento
This commit is contained in:
@@ -174,10 +174,10 @@
|
||||
|
||||
// Cache per rendering
|
||||
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 Dictionary<DateTime, List<ActivityDTO>> _eventsCache = new();
|
||||
private Dictionary<DateTime, CategoryData[]> _categoriesCache = new();
|
||||
private readonly Dictionary<DateTime, List<ActivityDTO>> _eventsCache = new();
|
||||
private readonly Dictionary<DateTime, CategoryData[]> _categoriesCache = new();
|
||||
private bool _isInitialized = false;
|
||||
|
||||
// Stato UI
|
||||
@@ -325,7 +325,7 @@
|
||||
private CategoryData[] GetFilteredCategoriesForDay(DateTime date)
|
||||
{
|
||||
if (!_categoriesCache.TryGetValue(date, out var categories))
|
||||
return Array.Empty<CategoryData>();
|
||||
return [];
|
||||
|
||||
if (Filter.ClearFilter)
|
||||
return categories;
|
||||
@@ -333,7 +333,7 @@
|
||||
// Applica i filtri alle categorie
|
||||
var filteredActivities = GetFilteredActivitiesForDay(date);
|
||||
if (!filteredActivities.Any())
|
||||
return Array.Empty<CategoryData>();
|
||||
return [];
|
||||
|
||||
return filteredActivities
|
||||
.Select(x => x.Category)
|
||||
@@ -345,7 +345,7 @@
|
||||
private List<ActivityDTO> GetFilteredActivitiesForDay(DateTime date)
|
||||
{
|
||||
if (!_eventsCache.TryGetValue(date, out var activities))
|
||||
return new List<ActivityDTO>();
|
||||
return [];
|
||||
|
||||
if (Filter.ClearFilter)
|
||||
return activities;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
@using System.Globalization
|
||||
@using Microsoft.VisualBasic
|
||||
@using Template.Shared.Core.Dto
|
||||
@using Template.Shared.Components.Layout
|
||||
@using Template.Shared.Core.Entity
|
||||
@@ -21,13 +20,22 @@
|
||||
|
||||
<div class="input-card">
|
||||
<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 class="divider"></div>
|
||||
|
||||
<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>
|
||||
|
||||
@@ -116,9 +124,12 @@
|
||||
private List<StbActivityResult> ActivityResult { get; set; } = [];
|
||||
private List<StbActivityType> ActivityType { 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 IsView => !IsNew && !NetworkService.IsNetworkAvailable();
|
||||
private bool IsView => !NetworkService.IsNetworkAvailable();
|
||||
|
||||
private string? LabelSave { get; set; }
|
||||
|
||||
@@ -173,9 +184,66 @@
|
||||
{
|
||||
Users = await ManageData.GetTable<StbUser>();
|
||||
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"));
|
||||
}
|
||||
|
||||
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()
|
||||
{
|
||||
LabelSave = !OriginalModel.Equals(ActivityModel) ? "Aggiorna" : null;
|
||||
|
||||
@@ -37,7 +37,7 @@ public class JtbComt
|
||||
public string Note { get; set; }
|
||||
|
||||
[Column("cod_anag"), JsonPropertyName("codAnag")]
|
||||
public string CodAnag { get; set; }
|
||||
public string? CodAnag { get; set; }
|
||||
|
||||
[Column("cod_divi"), JsonPropertyName("codDivi")]
|
||||
public string CodDivi { get; set; } = "EURO";
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
.bottom-sheet-container {
|
||||
position: fixed;
|
||||
bottom: -100%;
|
||||
bottom: -200%;
|
||||
left: 0;
|
||||
right: 0;
|
||||
transition: bottom 0.3s ease;
|
||||
|
||||
Reference in New Issue
Block a user