Sistemati filtri
This commit is contained in:
@@ -8,6 +8,7 @@ using MudBlazor.Services;
|
|||||||
using MudExtensions.Services;
|
using MudExtensions.Services;
|
||||||
using salesbook.Maui.Core.Services;
|
using salesbook.Maui.Core.Services;
|
||||||
using salesbook.Shared;
|
using salesbook.Shared;
|
||||||
|
using salesbook.Shared.Core.Dto;
|
||||||
using salesbook.Shared.Core.Helpers;
|
using salesbook.Shared.Core.Helpers;
|
||||||
using salesbook.Shared.Core.Interface;
|
using salesbook.Shared.Core.Interface;
|
||||||
using salesbook.Shared.Core.Messages.Activity.Copy;
|
using salesbook.Shared.Core.Messages.Activity.Copy;
|
||||||
@@ -72,6 +73,7 @@ namespace salesbook.Maui
|
|||||||
builder.Services.AddSingleton<IFormFactor, FormFactor>();
|
builder.Services.AddSingleton<IFormFactor, FormFactor>();
|
||||||
builder.Services.AddSingleton<IAttachedService, AttachedService>();
|
builder.Services.AddSingleton<IAttachedService, AttachedService>();
|
||||||
builder.Services.AddSingleton<LocalDbService>();
|
builder.Services.AddSingleton<LocalDbService>();
|
||||||
|
builder.Services.AddSingleton<FilterUserDTO>();
|
||||||
|
|
||||||
return builder.Build();
|
return builder.Build();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,22 +1,24 @@
|
|||||||
@page "/"
|
@page "/"
|
||||||
@using salesbook.Shared.Core.Interface
|
|
||||||
@attribute [Authorize]
|
@attribute [Authorize]
|
||||||
|
@using salesbook.Shared.Core.Interface
|
||||||
|
@using salesbook.Shared.Components.Layout.Spinner
|
||||||
@inject IFormFactor FormFactor
|
@inject IFormFactor FormFactor
|
||||||
@inject INetworkService NetworkService
|
@inject INetworkService NetworkService
|
||||||
|
|
||||||
|
<SpinnerLayout FullScreen="true" />
|
||||||
|
|
||||||
@code
|
@code
|
||||||
{
|
{
|
||||||
protected override Task OnInitializedAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
{
|
{
|
||||||
var lastSyncDate = LocalStorage.Get<DateTime>("last-sync");
|
var lastSyncDate = LocalStorage.Get<DateTime>("last-sync");
|
||||||
|
|
||||||
if (!FormFactor.IsWeb() && NetworkService.IsNetworkAvailable() && lastSyncDate.Equals(DateTime.MinValue))
|
if (!FormFactor.IsWeb() && NetworkService.IsNetworkAvailable() && lastSyncDate.Equals(DateTime.MinValue))
|
||||||
{
|
{
|
||||||
NavigationManager.NavigateTo("/sync");
|
NavigationManager.NavigateTo("/sync");
|
||||||
return base.OnInitializedAsync();
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
NavigationManager.NavigateTo("/Calendar");
|
NavigationManager.NavigateTo("/Calendar");
|
||||||
return base.OnInitializedAsync();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,9 +29,12 @@ else
|
|||||||
|
|
||||||
<div class="personal-info">
|
<div class="personal-info">
|
||||||
<span class="info-nome">@Anag.RagSoc</span>
|
<span class="info-nome">@Anag.RagSoc</span>
|
||||||
@if (UserSession.User.KeyGroup is not null)
|
@if (Anag.Indirizzo != null)
|
||||||
{
|
{
|
||||||
<span class="info-section">@Anag.Indirizzo</span>
|
<span class="info-section">@Anag.Indirizzo</span>
|
||||||
|
}
|
||||||
|
@if (Anag is { Citta: not null, Cap: not null, Prov: not null })
|
||||||
|
{
|
||||||
<span class="info-section">@($"{Anag.Cap} - {Anag.Citta} ({Anag.Prov})")</span>
|
<span class="info-section">@($"{Anag.Cap} - {Anag.Citta} ({Anag.Prov})")</span>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
@using salesbook.Shared.Core.Messages.Contact
|
@using salesbook.Shared.Core.Messages.Contact
|
||||||
@inject IManageDataService ManageData
|
@inject IManageDataService ManageData
|
||||||
@inject NewContactService NewContact
|
@inject NewContactService NewContact
|
||||||
|
@inject FilterUserDTO Filter
|
||||||
|
|
||||||
<HeaderLayout Title="Contatti"/>
|
<HeaderLayout Title="Contatti"/>
|
||||||
|
|
||||||
@@ -27,7 +28,7 @@
|
|||||||
|
|
||||||
<MudChipSet Class="mt-2" T="string" @bind-SelectedValue="TypeUser" @bind-SelectedValue:after="FilterUsers" SelectionMode="SelectionMode.SingleSelection">
|
<MudChipSet Class="mt-2" T="string" @bind-SelectedValue="TypeUser" @bind-SelectedValue:after="FilterUsers" SelectionMode="SelectionMode.SingleSelection">
|
||||||
<MudChip Color="Color.Primary" Variant="Variant.Text" Value="@("all")">Tutti</MudChip>
|
<MudChip Color="Color.Primary" Variant="Variant.Text" Value="@("all")">Tutti</MudChip>
|
||||||
<MudChip Color="Color.Primary" Variant="Variant.Text" Value="@("contact")">Contatti</MudChip>
|
<MudChip Color="Color.Primary" Variant="Variant.Text" Value="@("contact")">Clienti</MudChip>
|
||||||
<MudChip Color="Color.Primary" Variant="Variant.Text" Value="@("prospect")">Prospect</MudChip>
|
<MudChip Color="Color.Primary" Variant="Variant.Text" Value="@("prospect")">Prospect</MudChip>
|
||||||
</MudChipSet>
|
</MudChipSet>
|
||||||
</div>
|
</div>
|
||||||
@@ -64,12 +65,12 @@
|
|||||||
//Filtri
|
//Filtri
|
||||||
private string? TextToFilter { get; set; }
|
private string? TextToFilter { get; set; }
|
||||||
private bool OpenFilter { get; set; }
|
private bool OpenFilter { get; set; }
|
||||||
private FilterUserDTO Filter { get; set; } = new();
|
|
||||||
private string TypeUser { get; set; } = "all";
|
private string TypeUser { get; set; } = "all";
|
||||||
|
|
||||||
protected override void OnInitialized()
|
protected override void OnInitialized()
|
||||||
{
|
{
|
||||||
NewContact.OnContactCreated += async activityId => await OnActivityCreated(activityId);
|
NewContact.OnContactCreated += async response => await OnUserCreated(response);
|
||||||
|
Console.WriteLine($"Filter HashCode: {Filter.GetHashCode()} - IsInitialized: {Filter.IsInitialized}");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||||
@@ -85,10 +86,15 @@
|
|||||||
IsLoading = true;
|
IsLoading = true;
|
||||||
StateHasChanged();
|
StateHasChanged();
|
||||||
|
|
||||||
var loggedUser = (await ManageData.GetTable<StbUser>(x => x.UserName.Equals(UserSession.User.Username))).Last();
|
if (!Filter.IsInitialized)
|
||||||
|
{
|
||||||
|
var loggedUser = (await ManageData.GetTable<StbUser>(x => x.UserName.Equals(UserSession.User.Username))).Last();
|
||||||
|
|
||||||
if (loggedUser.UserCode != null)
|
if (loggedUser.UserCode != null)
|
||||||
Filter.Agenti = [loggedUser.UserCode];
|
Filter.Agenti = [loggedUser.UserCode];
|
||||||
|
|
||||||
|
Filter.IsInitialized = true;
|
||||||
|
}
|
||||||
|
|
||||||
var users = await ManageData.GetContact();
|
var users = await ManageData.GetContact();
|
||||||
|
|
||||||
@@ -105,7 +111,6 @@
|
|||||||
GroupedUserList = [];
|
GroupedUserList = [];
|
||||||
|
|
||||||
string? lastHeader = null;
|
string? lastHeader = null;
|
||||||
|
|
||||||
foreach (var user in sortedUsers)
|
foreach (var user in sortedUsers)
|
||||||
{
|
{
|
||||||
var firstChar = char.ToUpper(user.RagSoc[0]);
|
var firstChar = char.ToUpper(user.RagSoc[0]);
|
||||||
@@ -128,6 +133,7 @@
|
|||||||
StateHasChanged();
|
StateHasChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private class UserDisplayItem
|
private class UserDisplayItem
|
||||||
{
|
{
|
||||||
public required ContactDTO User { get; set; }
|
public required ContactDTO User { get; set; }
|
||||||
@@ -158,10 +164,18 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
var matchesFilter =
|
var matchesFilter =
|
||||||
(Filter.Prov.IsNullOrEmpty() || user.Prov.Equals(Filter.Prov, StringComparison.OrdinalIgnoreCase)) &&
|
(Filter.Prov.IsNullOrEmpty() ||
|
||||||
(Filter.Citta.IsNullOrEmpty() || user.Citta.Contains(Filter.Citta!, StringComparison.OrdinalIgnoreCase)) &&
|
(!string.IsNullOrEmpty(user.Prov) &&
|
||||||
(Filter.Nazione.IsNullOrEmpty() || user.Nazione.Contains(Filter.Nazione!, StringComparison.OrdinalIgnoreCase)) &&
|
user.Prov.Trim().Contains(Filter.Prov!.Trim(), StringComparison.OrdinalIgnoreCase))) &&
|
||||||
(Filter.Indirizzo.IsNullOrEmpty() || user.Indirizzo.Contains(Filter.Indirizzo!, StringComparison.OrdinalIgnoreCase)) &&
|
(Filter.Citta.IsNullOrEmpty() ||
|
||||||
|
(!string.IsNullOrEmpty(user.Citta) &&
|
||||||
|
user.Citta.Trim().Contains(Filter.Citta!.Trim(), StringComparison.OrdinalIgnoreCase))) &&
|
||||||
|
(Filter.Nazione.IsNullOrEmpty() ||
|
||||||
|
(!string.IsNullOrEmpty(user.Nazione) &&
|
||||||
|
user.Nazione.Trim().Contains(Filter.Nazione!.Trim(), StringComparison.OrdinalIgnoreCase))) &&
|
||||||
|
(Filter.Indirizzo.IsNullOrEmpty() ||
|
||||||
|
(!string.IsNullOrEmpty(user.Indirizzo) &&
|
||||||
|
user.Indirizzo.Trim().Contains(Filter.Indirizzo!.Trim(), StringComparison.OrdinalIgnoreCase))) &&
|
||||||
(!Filter.ConAgente || user.CodVage is not null) &&
|
(!Filter.ConAgente || user.CodVage is not null) &&
|
||||||
(!Filter.SenzaAgente || user.CodVage is null) &&
|
(!Filter.SenzaAgente || user.CodVage is null) &&
|
||||||
(Filter.Agenti.IsNullOrEmpty() || (user.CodVage != null && Filter.Agenti!.Contains(user.CodVage)));
|
(Filter.Agenti.IsNullOrEmpty() || (user.CodVage != null && Filter.Agenti!.Contains(user.CodVage)));
|
||||||
@@ -193,7 +207,7 @@
|
|||||||
FilteredGroupedUserList = result;
|
FilteredGroupedUserList = result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task OnActivityCreated(CRMCreateContactResponseDTO response)
|
private async Task OnUserCreated(CRMCreateContactResponseDTO response)
|
||||||
{
|
{
|
||||||
IsLoading = true;
|
IsLoading = true;
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
@using salesbook.Shared.Components.Pages
|
@using salesbook.Shared.Core.Dto
|
||||||
@using salesbook.Shared.Core.Dto
|
|
||||||
@using salesbook.Shared.Core.Entity
|
@using salesbook.Shared.Core.Entity
|
||||||
@using salesbook.Shared.Core.Interface
|
@using salesbook.Shared.Core.Interface
|
||||||
@inject IManageDataService manageData
|
@inject IManageDataService manageData
|
||||||
@@ -19,7 +18,7 @@
|
|||||||
<div class="form-container">
|
<div class="form-container">
|
||||||
<span class="disable-full-width">Con agente</span>
|
<span class="disable-full-width">Con agente</span>
|
||||||
|
|
||||||
<MudCheckBox @bind-Value="Filter.ConAgente" Color="Color.Primary" @bind-Value:after="OnAfterChangeAgente"/>
|
<MudCheckBox @bind-Value="Filter.ConAgente" Color="Color.Primary" @bind-Value:after="OnAfterChangeConAgente"/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="divider"></div>
|
<div class="divider"></div>
|
||||||
@@ -27,7 +26,7 @@
|
|||||||
<div class="form-container">
|
<div class="form-container">
|
||||||
<span class="disable-full-width">Senza agente</span>
|
<span class="disable-full-width">Senza agente</span>
|
||||||
|
|
||||||
<MudCheckBox @bind-Value="Filter.SenzaAgente" Color="Color.Primary" @bind-Value:after="OnAfterChangeAgente"/>
|
<MudCheckBox @bind-Value="Filter.SenzaAgente" Color="Color.Primary" @bind-Value:after="OnAfterChangeSenzaAgente"/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="divider"></div>
|
<div class="divider"></div>
|
||||||
@@ -89,7 +88,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="button-section">
|
<div class="button-section">
|
||||||
<MudButton OnClick="() => Filter = new FilterUserDTO()" Variant="Variant.Outlined" Color="Color.Error">Pulisci</MudButton>
|
<MudButton OnClick="ClearFilters" Variant="Variant.Outlined" Color="Color.Error">Pulisci</MudButton>
|
||||||
<MudButton Variant="Variant.Filled" Color="Color.Primary" OnClick="OnFilterButton">Filtra</MudButton>
|
<MudButton Variant="Variant.Filled" Color="Color.Primary" OnClick="OnFilterButton">Filtra</MudButton>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -140,16 +139,19 @@
|
|||||||
Filter.SenzaAgente = false;
|
Filter.SenzaAgente = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnAfterChangeAgente()
|
private void ClearFilters()
|
||||||
{
|
{
|
||||||
if (Filter.SenzaAgente)
|
Filter.ConAgente = false;
|
||||||
{
|
Filter.SenzaAgente = false;
|
||||||
Filter.ConAgente = false;
|
Filter.Agenti = [];
|
||||||
}
|
Filter.Indirizzo = null;
|
||||||
else if (Filter.ConAgente)
|
Filter.Citta = null;
|
||||||
{
|
Filter.Nazione = null;
|
||||||
Filter.SenzaAgente = false;
|
Filter.Prov = null;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnAfterChangeConAgente() => Filter.SenzaAgente = false;
|
||||||
|
|
||||||
|
private void OnAfterChangeSenzaAgente() => Filter.ConAgente = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -10,4 +10,6 @@ public class FilterUserDTO
|
|||||||
public string? Citta { get; set; }
|
public string? Citta { get; set; }
|
||||||
public string? Nazione { get; set; }
|
public string? Nazione { get; set; }
|
||||||
public string? Prov { get; set; }
|
public string? Prov { get; set; }
|
||||||
|
|
||||||
|
public bool IsInitialized { get; set; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ using salesbook.Shared.Core.Dto;
|
|||||||
using salesbook.Shared.Core.Entity;
|
using salesbook.Shared.Core.Entity;
|
||||||
using salesbook.Shared.Core.Interface;
|
using salesbook.Shared.Core.Interface;
|
||||||
using System.Net.Http.Headers;
|
using System.Net.Http.Headers;
|
||||||
using System.Reflection.Metadata.Ecma335;
|
|
||||||
|
|
||||||
namespace salesbook.Shared.Core.Services;
|
namespace salesbook.Shared.Core.Services;
|
||||||
|
|
||||||
|
|||||||
@@ -26,6 +26,7 @@
|
|||||||
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.0" />
|
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.0" />
|
||||||
<PackageReference Include="IntegryApiClient.Core" Version="1.1.6" />
|
<PackageReference Include="IntegryApiClient.Core" Version="1.1.6" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Components.Authorization" Version="9.0.6" />
|
<PackageReference Include="Microsoft.AspNetCore.Components.Authorization" Version="9.0.6" />
|
||||||
|
<PackageReference Include="Microsoft.Maui.Essentials" Version="9.0.81" />
|
||||||
<PackageReference Include="sqlite-net-pcl" Version="1.9.172" />
|
<PackageReference Include="sqlite-net-pcl" Version="1.9.172" />
|
||||||
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="8.12.1" />
|
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="8.12.1" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="9.0.6" />
|
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="9.0.6" />
|
||||||
@@ -38,4 +39,10 @@
|
|||||||
<Folder Include="wwwroot\js\bootstrap\" />
|
<Folder Include="wwwroot\js\bootstrap\" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="Mono.Android">
|
||||||
|
<HintPath>..\..\..\..\Program Files\dotnet\packs\Microsoft.Android.Ref.35\35.0.78\ref\net9.0\Mono.Android.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
Reference in New Issue
Block a user