generated from Integry/Template_NetMauiBlazorHybrid
Aggiunta pagination nella tab Commesse
This commit is contained in:
@@ -6,6 +6,7 @@ public class NetworkService : INetworkService
|
||||
{
|
||||
public bool IsNetworkAvailable()
|
||||
{
|
||||
return false;
|
||||
return Connectivity.Current.NetworkAccess == NetworkAccess.Internet;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,21 +9,28 @@
|
||||
@using salesbook.Shared.Components.SingleElements
|
||||
@using salesbook.Shared.Core.Dto.JobProgress
|
||||
@using salesbook.Shared.Core.Dto.PageState
|
||||
@implements IAsyncDisposable
|
||||
@inject IManageDataService ManageData
|
||||
@inject IMapper Mapper
|
||||
@inject IDialogService Dialog
|
||||
@inject IIntegryApiService IntegryApiService
|
||||
@inject UserPageState UserState
|
||||
|
||||
<HeaderLayout BackTo="Indietro" LabelSave="Modifica" OnSave="() => OpenUserForm(Anag)" Back="true" BackOnTop="true" Title="" ShowProfile="false"/>
|
||||
<HeaderLayout BackTo="Indietro"
|
||||
LabelSave="Modifica"
|
||||
OnSave="() => OpenUserForm(Anag)"
|
||||
Back="true"
|
||||
BackOnTop="true"
|
||||
Title=""
|
||||
ShowProfile="false" />
|
||||
|
||||
@if (IsLoading)
|
||||
{
|
||||
<SpinnerLayout FullScreen="true"/>
|
||||
<SpinnerLayout FullScreen="true" />
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="container content">
|
||||
<div class="container content" style="overflow: auto;" id="topPage">
|
||||
<div class="container-primary-info">
|
||||
<div class="section-primary-info">
|
||||
<MudAvatar Style="height: 70px; width: 70px; font-size: 2rem; font-weight: bold" Color="Color.Secondary">
|
||||
@@ -32,11 +39,11 @@ else
|
||||
|
||||
<div class="personal-info">
|
||||
<span class="info-nome">@Anag.RagSoc</span>
|
||||
@if (Anag.Indirizzo != null)
|
||||
@if (!string.IsNullOrEmpty(Anag.Indirizzo))
|
||||
{
|
||||
<span class="info-section">@Anag.Indirizzo</span>
|
||||
}
|
||||
@if (Anag is { Citta: not null, Cap: not null, Prov: not null })
|
||||
@if (!string.IsNullOrEmpty(Anag.Cap) && !string.IsNullOrEmpty(Anag.Citta) && !string.IsNullOrEmpty(Anag.Prov))
|
||||
{
|
||||
<span class="info-section">@($"{Anag.Cap} - {Anag.Citta} ({Anag.Prov})")</span>
|
||||
}
|
||||
@@ -51,9 +58,7 @@ else
|
||||
{
|
||||
<div>
|
||||
<span class="info-title">Telefono</span>
|
||||
<span class="info-text">
|
||||
@Anag.Telefono
|
||||
</span>
|
||||
<span class="info-text">@Anag.Telefono</span>
|
||||
</div>
|
||||
}
|
||||
|
||||
@@ -61,9 +66,7 @@ else
|
||||
{
|
||||
<div>
|
||||
<span class="info-title">P. IVA</span>
|
||||
<span class="info-text">
|
||||
@Anag.PartIva
|
||||
</span>
|
||||
<span class="info-text">@Anag.PartIva</span>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
@@ -73,9 +76,7 @@ else
|
||||
{
|
||||
<div>
|
||||
<span class="info-title">E-mail</span>
|
||||
<span class="info-text">
|
||||
@Anag.EMail
|
||||
</span>
|
||||
<span class="info-text">@Anag.EMail</span>
|
||||
</div>
|
||||
}
|
||||
|
||||
@@ -83,47 +84,41 @@ else
|
||||
{
|
||||
<div>
|
||||
<span class="info-title">Agente</span>
|
||||
<span class="info-text">
|
||||
@Agente.FullName
|
||||
</span>
|
||||
<span class="info-text">@Agente.FullName</span>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<input type="radio" class="tab-toggle" name="tab-toggle" id="tab1" checked>
|
||||
<input type="radio" class="tab-toggle" name="tab-toggle" id="tab2">
|
||||
<input type="radio" class="tab-toggle" name="tab-toggle" id="tab1" checked="@(ActiveTab == 0)">
|
||||
<input type="radio" class="tab-toggle" name="tab-toggle" id="tab2" checked="@(ActiveTab == 1)">
|
||||
|
||||
<div class="box">
|
||||
<ul class="tab-list">
|
||||
<li class="tab-item">
|
||||
<label class="tab-trigger" for="tab1">Contatti</label>
|
||||
<label class="tab-trigger" for="tab1" @onclick="() => SwitchTab(0)">Contatti</label>
|
||||
</li>
|
||||
<li class="tab-item">
|
||||
<label class="tab-trigger" for="tab2">Commesse</label>
|
||||
<label class="tab-trigger" for="tab2" @onclick="() => SwitchTab(1)">Commesse</label>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<!-- contenuti -->
|
||||
<div class="tab-container">
|
||||
<div class="tab-content">
|
||||
<!-- Contatti -->
|
||||
@if (PersRif is { Count: > 0 })
|
||||
<!-- Tab Contatti -->
|
||||
<div class="tab-content" style="display: @(ActiveTab == 0 ? "block" : "none")">
|
||||
@if (PersRif?.Count > 0)
|
||||
{
|
||||
<div class="container-pers-rif">
|
||||
<Virtualize Items="PersRif" Context="person">
|
||||
@{
|
||||
var index = PersRif.IndexOf(person);
|
||||
var isLast = index == PersRif.Count - 1;
|
||||
}
|
||||
<ContactCard Contact="person"/>
|
||||
@if (!isLast)
|
||||
@foreach (var person in PersRif)
|
||||
{
|
||||
<ContactCard Contact="person" />
|
||||
@if (person != PersRif.Last())
|
||||
{
|
||||
<div class="divider"></div>
|
||||
}
|
||||
</Virtualize>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
|
||||
@@ -137,26 +132,90 @@ else
|
||||
</MudButton>
|
||||
</div>
|
||||
</div>
|
||||
<div class="tab-content">
|
||||
<!-- Commesse -->
|
||||
@if (LoadCommessa)
|
||||
|
||||
<!-- Tab Commesse -->
|
||||
<div class="tab-content" style="display: @(ActiveTab == 1 ? "block" : "none")">
|
||||
@if (IsLoadingCommesse)
|
||||
{
|
||||
<MudProgressLinear Color="Color.Primary" Indeterminate="true" Class="my-7"/>
|
||||
<MudProgressLinear Color="Color.Primary" Indeterminate="true" Class="my-7" />
|
||||
}
|
||||
else
|
||||
else if (Commesse?.Count == 0)
|
||||
{
|
||||
@if (Commesse.IsNullOrEmpty())
|
||||
{
|
||||
<NoDataAvailable Text="Nessuna commessa presente"/>
|
||||
<NoDataAvailable Text="Nessuna commessa presente" />
|
||||
}
|
||||
else
|
||||
else if (Commesse != null)
|
||||
{
|
||||
<!-- Filtri e ricerca -->
|
||||
<div class="input-card clearButton">
|
||||
<MudTextField T="string?"
|
||||
Placeholder="Cerca..."
|
||||
Variant="Variant.Text"
|
||||
@bind-Value="SearchTerm"
|
||||
OnDebounceIntervalElapsed="() => ApplyFilters()"
|
||||
DebounceInterval="500" />
|
||||
</div>
|
||||
|
||||
<div class="commesse-container">
|
||||
<Virtualize Items="Commesse" Context="commessa">
|
||||
<CommessaCard Steps="@Steps[commessa.CodJcom]" RagSoc="@Anag.RagSoc" Commessa="commessa"/>
|
||||
</Virtualize>
|
||||
@if (IsLoadingSteps)
|
||||
{
|
||||
<MudProgressLinear Color="Color.Primary" Indeterminate="true" Class="my-3" />
|
||||
}
|
||||
|
||||
@foreach (var commessa in CurrentPageCommesse)
|
||||
{
|
||||
<div class="commessa-wrapper" style="@(IsLoadingStep(commessa.CodJcom) ? "opacity: 0.7;" : "")">
|
||||
@if (Steps.TryGetValue(commessa.CodJcom, out var steps))
|
||||
{
|
||||
<CommessaCard Steps="@steps" RagSoc="@Anag.RagSoc" Commessa="commessa" />
|
||||
}
|
||||
else
|
||||
{
|
||||
<CommessaCard Steps="null" RagSoc="@Anag.RagSoc" Commessa="commessa" />
|
||||
@if (IsLoadingStep(commessa.CodJcom))
|
||||
{
|
||||
<MudProgressLinear Indeterminate="true" Color="Color.Primary" Class="my-1" Style="height: 2px;" />
|
||||
}
|
||||
}
|
||||
</div>
|
||||
}
|
||||
|
||||
@if (TotalPages > 1)
|
||||
{
|
||||
<div class="custom-pagination">
|
||||
<MudPagination BoundaryCount="1" MiddleCount="1" Count="@TotalPages"
|
||||
@bind-Selected="CurrentPage"
|
||||
Color="Color.Primary"/>
|
||||
</div>
|
||||
|
||||
<div class="SelectedPageSize">
|
||||
<MudSelect @bind-Value="SelectedPageSize"
|
||||
Variant="Variant.Text"
|
||||
Label="Elementi per pagina"
|
||||
Dense="true"
|
||||
Style="width: 100%;">
|
||||
<MudSelectItem Value="5">5</MudSelectItem>
|
||||
<MudSelectItem Value="10">10</MudSelectItem>
|
||||
<MudSelectItem Value="20">15</MudSelectItem>
|
||||
</MudSelect>
|
||||
</div>
|
||||
|
||||
<MudScrollToTop Selector="#topPage" VisibleCssClass="visible absolute" TopOffset="100" HiddenCssClass="invisible">
|
||||
<MudFab Size="Size.Small" Color="Color.Primary" StartIcon="@Icons.Material.Rounded.KeyboardArrowUp" />
|
||||
</MudScrollToTop>
|
||||
}
|
||||
|
||||
@* <div class="commesse-stats mt-4">
|
||||
<MudChip T="string" Size="Size.Small" Color="Color.Info">
|
||||
Visualizzate: @CurrentPageCommesse.Count() / @FilteredCommesse.Count()
|
||||
</MudChip>
|
||||
@if (!string.IsNullOrEmpty(SearchTerm))
|
||||
{
|
||||
<MudChip T="string" Size="Size.Small" Color="Color.Warning" OnClose="ClearSearch">
|
||||
Filtro: "@SearchTerm"
|
||||
</MudChip>
|
||||
}
|
||||
</div> *@
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
@@ -164,34 +223,173 @@ else
|
||||
}
|
||||
|
||||
@code {
|
||||
[Parameter] public string CodContact { get; set; }
|
||||
[Parameter] public string CodContact { get; set; } = string.Empty;
|
||||
[Parameter] public bool IsContact { get; set; }
|
||||
|
||||
// Dati principali
|
||||
private ContactDTO Anag { get; set; } = new();
|
||||
private List<PersRifDTO>? PersRif { get; set; }
|
||||
private List<JtbComt>? Commesse { get; set; }
|
||||
private StbUser? Agente { get; set; }
|
||||
private Dictionary<string, List<CRMJobStepDTO>?> Steps { get; set; } = [];
|
||||
private Dictionary<string, List<CRMJobStepDTO>?> Steps { get; set; } = new();
|
||||
|
||||
// Stati di caricamento
|
||||
private bool IsLoading { get; set; } = true;
|
||||
private bool LoadCommessa { get; set; } = true;
|
||||
private bool IsLoadingCommesse { get; set; } = true;
|
||||
private bool IsLoadingSteps { get; set; } = false;
|
||||
private readonly HashSet<string> _loadingSteps = new();
|
||||
|
||||
// Gestione tab
|
||||
private int ActiveTab { get; set; } = 0;
|
||||
|
||||
// Paginazione e filtri
|
||||
private int _currentPage = 1;
|
||||
private int _selectedPageSize = 5;
|
||||
private string _searchTerm = string.Empty;
|
||||
private List<JtbComt> _filteredCommesse = new();
|
||||
|
||||
// Cancellation tokens per gestire le richieste asincrone
|
||||
private CancellationTokenSource? _loadingCts;
|
||||
private CancellationTokenSource? _stepsCts;
|
||||
|
||||
// Timer per il debounce della ricerca
|
||||
private Timer? _searchTimer;
|
||||
private const int SearchDelayMs = 300;
|
||||
|
||||
#region Properties
|
||||
|
||||
private int CurrentPage
|
||||
{
|
||||
get => _currentPage;
|
||||
set
|
||||
{
|
||||
if (_currentPage != value)
|
||||
{
|
||||
_currentPage = value;
|
||||
_ = LoadStepsForCurrentPageAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int SelectedPageSize
|
||||
{
|
||||
get => _selectedPageSize;
|
||||
set
|
||||
{
|
||||
if (_selectedPageSize != value)
|
||||
{
|
||||
_selectedPageSize = value;
|
||||
_currentPage = 1;
|
||||
ApplyFilters();
|
||||
_ = LoadStepsForCurrentPageAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private string SearchTerm
|
||||
{
|
||||
get => _searchTerm;
|
||||
set
|
||||
{
|
||||
if (_searchTerm != value)
|
||||
{
|
||||
_searchTerm = value;
|
||||
|
||||
// Debounce della ricerca
|
||||
_searchTimer?.Dispose();
|
||||
_searchTimer = new Timer(async _ => await InvokeAsync(ApplyFilters), null, SearchDelayMs, Timeout.Infinite);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private List<JtbComt> FilteredCommesse
|
||||
{
|
||||
get => _filteredCommesse;
|
||||
set
|
||||
{
|
||||
_filteredCommesse = value;
|
||||
StateHasChanged();
|
||||
}
|
||||
}
|
||||
|
||||
private int TotalPages =>
|
||||
FilteredCommesse.Count == 0 ? 1 : (int)Math.Ceiling(FilteredCommesse.Count / (double)SelectedPageSize);
|
||||
|
||||
private IEnumerable<JtbComt> CurrentPageCommesse =>
|
||||
FilteredCommesse.Skip((CurrentPage - 1) * SelectedPageSize).Take(SelectedPageSize);
|
||||
|
||||
#endregion
|
||||
|
||||
#region Lifecycle Methods
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
if (UserState.CodUser != null && UserState.CodUser.Equals(CodContact))
|
||||
try
|
||||
{
|
||||
_loadingCts = new CancellationTokenSource();
|
||||
|
||||
if (UserState.CodUser?.Equals(CodContact) == true)
|
||||
{
|
||||
LoadDataFromSession();
|
||||
}
|
||||
else
|
||||
{
|
||||
await LoadData();
|
||||
await LoadDataAsync();
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// Log dell'errore
|
||||
Console.WriteLine($"Errore in OnInitializedAsync: {ex.Message}");
|
||||
}
|
||||
finally
|
||||
{
|
||||
IsLoading = false;
|
||||
StateHasChanged();
|
||||
}
|
||||
}
|
||||
|
||||
private async Task LoadData()
|
||||
public async ValueTask DisposeAsync()
|
||||
{
|
||||
_loadingCts?.Cancel();
|
||||
_loadingCts?.Dispose();
|
||||
_stepsCts?.Cancel();
|
||||
_stepsCts?.Dispose();
|
||||
_searchTimer?.Dispose();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Data Loading Methods
|
||||
|
||||
private async Task LoadDataAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
// Caricamento dati principali
|
||||
await LoadAnagAsync();
|
||||
await LoadPersRifAsync();
|
||||
|
||||
// Caricamento agente
|
||||
if (!string.IsNullOrEmpty(Anag.CodVage))
|
||||
{
|
||||
Agente = (await ManageData.GetTable<StbUser>(x => x.UserCode != null && x.UserCode.Equals(Anag.CodVage)))
|
||||
.LastOrDefault();
|
||||
}
|
||||
|
||||
// Salvataggio in sessione
|
||||
SaveDataToSession();
|
||||
|
||||
// Caricamento commesse in background
|
||||
_ = Task.Run(async () => await LoadCommesseAsync());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"Errore nel caricamento dati: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
private async Task LoadAnagAsync()
|
||||
{
|
||||
if (IsContact)
|
||||
{
|
||||
@@ -203,67 +401,9 @@ else
|
||||
var pros = (await ManageData.GetTable<PtbPros>(x => x.CodPpro.Equals(CodContact))).Last();
|
||||
Anag = Mapper.Map<ContactDTO>(pros);
|
||||
}
|
||||
|
||||
await LoadPersRif();
|
||||
_ = LoadCommesse();
|
||||
|
||||
if (Anag.CodVage != null)
|
||||
{
|
||||
Agente = (await ManageData.GetTable<StbUser>(x => x.UserCode != null && x.UserCode.Equals(Anag.CodVage))).LastOrDefault();
|
||||
}
|
||||
|
||||
SetDataSession();
|
||||
}
|
||||
|
||||
private void LoadDataFromSession()
|
||||
{
|
||||
Anag = UserState.Anag;
|
||||
PersRif = UserState.PersRif;
|
||||
Commesse = UserState.Commesse;
|
||||
Agente = UserState.Agente;
|
||||
Steps = UserState.Steps;
|
||||
|
||||
SortCommesse();
|
||||
|
||||
LoadCommessa = false;
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
private void SetDataSession()
|
||||
{
|
||||
UserState.CodUser = CodContact;
|
||||
UserState.Anag = Anag;
|
||||
UserState.PersRif = PersRif;
|
||||
UserState.Agente = Agente;
|
||||
UserState.Steps = Steps;
|
||||
}
|
||||
|
||||
private async Task LoadCommesse()
|
||||
{
|
||||
await Task.Run(async () =>
|
||||
{
|
||||
Commesse = await ManageData.GetTable<JtbComt>(x => x.CodAnag != null && x.CodAnag.Equals(CodContact));
|
||||
UserState.Commesse = Commesse;
|
||||
|
||||
foreach (var commessa in Commesse)
|
||||
{
|
||||
var steps = (await IntegryApiService.RetrieveJobProgress(commessa.CodJcom)).Steps;
|
||||
Steps.Add(commessa.CodJcom, steps);
|
||||
}
|
||||
|
||||
LoadCommessa = false;
|
||||
});
|
||||
|
||||
SortCommesse();
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
private void SortCommesse()
|
||||
{
|
||||
Commesse = Commesse?.OrderBy(x => x.LastUpd.HasValue).ThenBy(x => x.LastUpd).ToList();
|
||||
}
|
||||
|
||||
private async Task LoadPersRif()
|
||||
private async Task LoadPersRifAsync()
|
||||
{
|
||||
if (IsContact)
|
||||
{
|
||||
@@ -277,19 +417,224 @@ else
|
||||
}
|
||||
}
|
||||
|
||||
private async Task LoadCommesseAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
IsLoadingCommesse = true;
|
||||
|
||||
Commesse = await ManageData.GetTable<JtbComt>(x => x.CodAnag != null && x.CodAnag.Equals(CodContact));
|
||||
|
||||
// Ordinamento ottimizzato
|
||||
Commesse = Commesse?
|
||||
.OrderByDescending(x => x.LastUpd ?? DateTime.MinValue)
|
||||
.ThenByDescending(x => x.CodJcom)
|
||||
.ToList();
|
||||
|
||||
UserState.Commesse = Commesse;
|
||||
|
||||
ApplyFilters();
|
||||
|
||||
// Caricamento steps per la prima pagina
|
||||
await LoadStepsForCurrentPageAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"Errore nel caricamento commesse: {ex.Message}");
|
||||
}
|
||||
finally
|
||||
{
|
||||
IsLoadingCommesse = false;
|
||||
await InvokeAsync(StateHasChanged);
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadDataFromSession()
|
||||
{
|
||||
Anag = UserState.Anag;
|
||||
PersRif = UserState.PersRif;
|
||||
Commesse = UserState.Commesse;
|
||||
Agente = UserState.Agente;
|
||||
Steps = UserState.Steps ?? new Dictionary<string, List<CRMJobStepDTO>?>();
|
||||
|
||||
ApplyFilters();
|
||||
|
||||
IsLoadingCommesse = false;
|
||||
}
|
||||
|
||||
private void SaveDataToSession()
|
||||
{
|
||||
UserState.CodUser = CodContact;
|
||||
UserState.Anag = Anag;
|
||||
UserState.PersRif = PersRif;
|
||||
UserState.Agente = Agente;
|
||||
UserState.Steps = Steps;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Steps Loading Methods
|
||||
|
||||
private async Task LoadStepsForCurrentPageAsync()
|
||||
{
|
||||
if (CurrentPageCommesse?.Any() != true) return;
|
||||
|
||||
try
|
||||
{
|
||||
_stepsCts?.Cancel();
|
||||
_stepsCts = new CancellationTokenSource();
|
||||
var token = _stepsCts.Token;
|
||||
|
||||
IsLoadingSteps = true;
|
||||
|
||||
var tasksToLoad = new List<Task>();
|
||||
var semaphore = new SemaphoreSlim(3); // Limita a 3 richieste simultanee
|
||||
|
||||
foreach (var commessa in CurrentPageCommesse.Where(c => !Steps.ContainsKey(c.CodJcom)))
|
||||
{
|
||||
if (token.IsCancellationRequested) break;
|
||||
|
||||
tasksToLoad.Add(LoadStepForCommessaAsync(commessa.CodJcom, semaphore, token));
|
||||
}
|
||||
|
||||
if (tasksToLoad.Any())
|
||||
{
|
||||
await Task.WhenAll(tasksToLoad);
|
||||
UserState.Steps = Steps;
|
||||
}
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
// Operazione annullata, non fare nulla
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"Errore nel caricamento steps: {ex.Message}");
|
||||
}
|
||||
finally
|
||||
{
|
||||
IsLoadingSteps = false;
|
||||
await InvokeAsync(StateHasChanged);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task LoadStepForCommessaAsync(string codJcom, SemaphoreSlim semaphore, CancellationToken token)
|
||||
{
|
||||
await semaphore.WaitAsync(token);
|
||||
|
||||
try
|
||||
{
|
||||
_loadingSteps.Add(codJcom);
|
||||
await InvokeAsync(StateHasChanged);
|
||||
|
||||
var jobProgress = await IntegryApiService.RetrieveJobProgress(codJcom);
|
||||
|
||||
if (!token.IsCancellationRequested)
|
||||
{
|
||||
Steps[codJcom] = jobProgress.Steps;
|
||||
await InvokeAsync(StateHasChanged);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"Errore nel caricamento step per {codJcom}: {ex.Message}");
|
||||
if (!token.IsCancellationRequested)
|
||||
{
|
||||
Steps[codJcom] = null;
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
_loadingSteps.Remove(codJcom);
|
||||
semaphore.Release();
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsLoadingStep(string codJcom) => _loadingSteps.Contains(codJcom);
|
||||
|
||||
#endregion
|
||||
|
||||
#region UI Methods
|
||||
|
||||
private void SwitchTab(int tabIndex)
|
||||
{
|
||||
ActiveTab = tabIndex;
|
||||
|
||||
// Se si passa alle commesse e non sono ancora state caricate
|
||||
if (tabIndex == 1 && Commesse == null)
|
||||
{
|
||||
_ = Task.Run(async () => await LoadCommesseAsync());
|
||||
} else if (tabIndex == 1 && Steps.IsNullOrEmpty())
|
||||
{
|
||||
_ = Task.Run(async () => await LoadStepsForCurrentPageAsync());
|
||||
}
|
||||
}
|
||||
|
||||
private void ApplyFilters()
|
||||
{
|
||||
if (Commesse == null)
|
||||
{
|
||||
FilteredCommesse = new List<JtbComt>();
|
||||
return;
|
||||
}
|
||||
|
||||
var filtered = Commesse.AsEnumerable();
|
||||
|
||||
// Filtro per testo di ricerca
|
||||
if (!string.IsNullOrWhiteSpace(SearchTerm))
|
||||
{
|
||||
var searchLower = SearchTerm.ToLowerInvariant();
|
||||
filtered = filtered.Where(c =>
|
||||
c.CodJcom?.ToLowerInvariant().Contains(searchLower) == true ||
|
||||
c.Descrizione?.ToLowerInvariant().Contains(searchLower) == true ||
|
||||
c.CodAnag?.ToLowerInvariant().Contains(searchLower) == true);
|
||||
}
|
||||
|
||||
FilteredCommesse = filtered.ToList();
|
||||
|
||||
// Reset della pagina se necessario
|
||||
if (CurrentPage > TotalPages && TotalPages > 0)
|
||||
{
|
||||
_currentPage = 1;
|
||||
}
|
||||
|
||||
// Carica gli steps per la pagina corrente
|
||||
_ = LoadStepsForCurrentPageAsync();
|
||||
}
|
||||
|
||||
private void ClearSearch()
|
||||
{
|
||||
SearchTerm = string.Empty;
|
||||
ApplyFilters();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Modal Methods
|
||||
|
||||
private async Task OpenPersRifForm()
|
||||
{
|
||||
var result = await ModalHelpers.OpenPersRifForm(Dialog, null, Anag, PersRif);
|
||||
|
||||
if (result is { Canceled: false, Data: not null } && result.Data.GetType() == typeof(PersRifDTO))
|
||||
{
|
||||
await LoadPersRif();
|
||||
await LoadPersRifAsync();
|
||||
UserState.PersRif = PersRif;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task OpenUserForm(ContactDTO anag)
|
||||
{
|
||||
var result = await ModalHelpers.OpenUserForm(Dialog, anag);
|
||||
|
||||
if (result is { Canceled: false })
|
||||
{
|
||||
// Aggiorna i dati se necessario
|
||||
await LoadAnagAsync();
|
||||
SaveDataToSession();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
@@ -165,10 +165,6 @@
|
||||
gap: 1.25rem;
|
||||
}
|
||||
|
||||
.commesse-container ::deep > div:first-child:not(.activity-card) {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/*--------------
|
||||
TabPanel
|
||||
----------------*/
|
||||
@@ -242,14 +238,13 @@
|
||||
.tab-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
width: -webkit-fill-available;
|
||||
}
|
||||
|
||||
.tab-content {
|
||||
display: none;
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
overflow-y: hidden;
|
||||
animation: fade .3s ease;
|
||||
padding: .5rem;
|
||||
}
|
||||
@@ -275,3 +270,13 @@
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
|
||||
.custom-pagination ::deep ul { padding-left: 0 !important; }
|
||||
|
||||
.SelectedPageSize {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.FilterSection {
|
||||
display: flex;
|
||||
}
|
||||
@@ -38,6 +38,13 @@ a, .btn-link {
|
||||
height: 90vh;
|
||||
}
|
||||
|
||||
.content::-webkit-scrollbar { width: 3px; }
|
||||
|
||||
.content::-webkit-scrollbar-thumb {
|
||||
background: #bbb;
|
||||
border-radius: 2px;
|
||||
}
|
||||
|
||||
h1:focus { outline: none; }
|
||||
|
||||
.valid.modified:not([type=checkbox]) { outline: 1px solid #26b050; }
|
||||
@@ -97,9 +104,7 @@ h1:focus { outline: none; }
|
||||
color: var(--mud-palette-text-primary) !important;
|
||||
}
|
||||
|
||||
.custom_popover .mud-divider {
|
||||
border-color: var(--mud-palette-text-primary) !important;
|
||||
}
|
||||
.custom_popover .mud-divider { border-color: var(--mud-palette-text-primary) !important; }
|
||||
|
||||
.custom_popover .mud-list-padding { padding: 3px 0px 3px 0px !important; }
|
||||
|
||||
@@ -196,9 +201,7 @@ h1:focus { outline: none; }
|
||||
padding-left: calc(var(--m-page-x) * 0.5) !important;
|
||||
}
|
||||
|
||||
.mud-message-box > .mud-dialog-title > h6 {
|
||||
font-weight: 800 !important;
|
||||
}
|
||||
.mud-message-box > .mud-dialog-title > h6 { font-weight: 800 !important; }
|
||||
|
||||
.mud-dialog-actions button {
|
||||
margin-left: .5rem !important;
|
||||
|
||||
Reference in New Issue
Block a user