From 5bf07d00f541667fc4dff97dbec8e03d46e8d6b8 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Fri, 17 Jan 2025 11:17:50 +0100 Subject: [PATCH] Fix ordering in pareto detail --- LiMan.UI/Components/InstAppPareto.razor | 11 +- LiMan.UI/Components/InstAppPareto.razor.cs | 142 +++++++++++++++++---- LiMan.UI/LiMan.UI.csproj | 2 +- LiMan.UI/Resources/ChangeLog.html | 2 +- LiMan.UI/Resources/VersNum.txt | 2 +- LiMan.UI/Resources/manifest.xml | 2 +- 6 files changed, 128 insertions(+), 33 deletions(-) diff --git a/LiMan.UI/Components/InstAppPareto.razor b/LiMan.UI/Components/InstAppPareto.razor index 47f5f23..ad9853a 100644 --- a/LiMan.UI/Components/InstAppPareto.razor +++ b/LiMan.UI/Components/InstAppPareto.razor @@ -10,12 +10,19 @@ + + + + # Lic. + + + + Versione + - # Lic. - Versione diff --git a/LiMan.UI/Components/InstAppPareto.razor.cs b/LiMan.UI/Components/InstAppPareto.razor.cs index a68764d..563b855 100644 --- a/LiMan.UI/Components/InstAppPareto.razor.cs +++ b/LiMan.UI/Components/InstAppPareto.razor.cs @@ -6,6 +6,7 @@ using Org.BouncyCastle.Ocsp; using System; using System.Collections.Generic; using System.Linq; +using static EgwCoreLib.Razor.Sorter; namespace LiMan.UI.Components { @@ -14,10 +15,10 @@ namespace LiMan.UI.Components #region Public Properties [Parameter] - public AppStatusDTO CurrRecord { get; set; } = null!; + public List AppDetList { get; set; } = new List(); [Parameter] - public List AppDetList { get; set; } = new List(); + public AppStatusDTO CurrRecord { get; set; } = null!; #endregion Public Properties @@ -87,6 +88,13 @@ namespace LiMan.UI.Components MServ.UsrParamSet("PcInst", ""); // Richiedo azione x gestione dettaglio info MServ.ReportSelCodInst(); + // se era selezionato impianto lo deseleziona... + if (HasFlitImp) + { + CodImpSel = ""; + HasFlitImp = false; + MServ.ReportSelCodImp(); + } } /// @@ -100,6 +108,12 @@ namespace LiMan.UI.Components AppInstList = AppDetList .Where(x => x.CodImp == currRec.CodImp) .ToList(); + // se era selezionato cliente lo riseleziono... + if (HasFlitCli) + { + CodInstSel = currRec.CodInst; + MServ.ReportSelCodInst(); + } // salvo nelle preferenze i valori CodImp e PcInst MServ.UsrParamSet("Cliente", currRec.Cliente); MServ.UsrParamSet("CodInst", currRec.CodInst); @@ -109,8 +123,6 @@ namespace LiMan.UI.Components MServ.ReportSelCodImp(); } - private List AppInstList = new List(); - protected void setNumPage(int newNum) { currPage = newNum; @@ -125,30 +137,34 @@ namespace LiMan.UI.Components isLoading = false; } + protected void SortRequested(SortCallBack e) + { + isLoading = true; + if (sortField == e.ParamName) + { + sortAsc = e.IsAscending; + } + sortField = e.ParamName; + ReloadData(); + isLoading = false; + } + #endregion Protected Methods #region Private Fields + private List AppInstList = new List(); private List ChartColor = new List(); - private double[] ChartData = new double[1]; - private string[] ChartLabels = new string[1]; - private string CodImpSel = ""; - private string CodInstSel = ""; - private int currPage = 1; - private bool HasFlitCli = false; - private bool HasFlitImp = false; - private bool isLoading = false; - - private int numRecord = 25; - + private int numRecord = 10; + private string sKey = "InstAppPareto"; private int totalCount = 0; #endregion Private Fields @@ -175,22 +191,40 @@ namespace LiMan.UI.Components get => HasFlitImp ? "" : "disabled"; } - - - private string CssBtnInst(string CodInst) + private bool sortAsc { - return HasFlitCli && CodInstSel == CodInst ? "btn-dark" : "btn-outline-dark"; + get + { + bool answ = false; + var sVal = MServ.UsrParamGet($"{sKey}_sort"); + if (!string.IsNullOrEmpty(sVal)) + { + bool.TryParse(sVal, out answ); + } + return answ; + } + set => MServ.UsrParamSet($"{sKey}_sort", $"{value}"); } + private string sortField + { + get => MServ.UsrParamGet($"{sKey}_field"); + set => MServ.UsrParamSet($"{sKey}_field", $"{value}"); + } + + #endregion Private Properties + + #region Private Methods + private string CssBtnImp(string CodImp) { return HasFlitImp && CodImpSel == CodImp ? "btn-primary" : "btn-outline-primary"; } - - #endregion Private Properties - - #region Private Methods + private string CssBtnInst(string CodInst) + { + return HasFlitCli && CodInstSel == CodInst ? "btn-dark" : "btn-outline-dark"; + } private string cssVers(AppRelStatusDTO rec) { @@ -280,13 +314,67 @@ namespace LiMan.UI.Components } } + private void ReloadData() { - SearchRecord = CurrRecord.DetailInstalled - .OrderByDescending(x => x.VersNumInstall) - .ToList(); + SearchRecord = CurrRecord.DetailInstalled; totalCount = SearchRecord.Count; - // sistemo tabella + switch (sortField) + { + + case "NumImp": + if (sortAsc) + { + SearchRecord = SearchRecord.OrderBy(x => x.NumImp).ThenByDescending(x => x.VersNumInstall).ToList(); + } + else + { + SearchRecord = SearchRecord.OrderByDescending(x => x.NumImp).ThenByDescending(x => x.VersNumInstall).ToList(); + } + break; + + case "VersNumInstall": + if (sortAsc) + { + SearchRecord = SearchRecord.OrderBy(x => x.VersNumInstall).ThenBy(x => x.PcInst).ToList(); + } + else + { + SearchRecord = SearchRecord.OrderByDescending(x => x.VersNumInstall).ThenBy(x => x.PcInst).ToList(); + } + break; + + case "PcInst": + if (sortAsc) + { + SearchRecord = SearchRecord.OrderBy(x => x.PcInst).ThenByDescending(x => x.VersNumInstall).ToList(); + } + else + { + SearchRecord = SearchRecord.OrderByDescending(x => x.PcInst).ThenByDescending(x => x.VersNumInstall).ToList(); + } + break; + + case "CodInst": + if (sortAsc) + { + SearchRecord = SearchRecord.OrderBy(x => x.CodInst).ThenByDescending(x => x.VersNumInstall).ToList(); + } + else + { + SearchRecord = SearchRecord.OrderByDescending(x => x.CodInst).ThenByDescending(x => x.VersNumInstall).ToList(); + } + break; + + default: + SearchRecord = SearchRecord + .OrderByDescending(x => x.VersNumInstall) + .ThenBy(x => x.PcInst) + .ToList(); + break; + } + + // paginazione ListRecord = SearchRecord .Skip((currPage - 1) * numRecord) .Take(numRecord) diff --git a/LiMan.UI/LiMan.UI.csproj b/LiMan.UI/LiMan.UI.csproj index 25dfbc5..876eb68 100644 --- a/LiMan.UI/LiMan.UI.csproj +++ b/LiMan.UI/LiMan.UI.csproj @@ -2,7 +2,7 @@ net6.0 - 2.1.2501.1710 + 2.1.2501.1711 LiMan.UI LiMan.UI diff --git a/LiMan.UI/Resources/ChangeLog.html b/LiMan.UI/Resources/ChangeLog.html index 363394a..e5d0424 100644 --- a/LiMan.UI/Resources/ChangeLog.html +++ b/LiMan.UI/Resources/ChangeLog.html @@ -1,6 +1,6 @@ License Manager -

Versione: 2.1.2501.1710

+

Versione: 2.1.2501.1711


Note di rilascio:
  • diff --git a/LiMan.UI/Resources/VersNum.txt b/LiMan.UI/Resources/VersNum.txt index 9d242fd..43b37a4 100644 --- a/LiMan.UI/Resources/VersNum.txt +++ b/LiMan.UI/Resources/VersNum.txt @@ -1 +1 @@ -2.1.2501.1710 +2.1.2501.1711 diff --git a/LiMan.UI/Resources/manifest.xml b/LiMan.UI/Resources/manifest.xml index 8e74bf5..7ca3d4d 100644 --- a/LiMan.UI/Resources/manifest.xml +++ b/LiMan.UI/Resources/manifest.xml @@ -1,6 +1,6 @@ - 2.1.2501.1710 + 2.1.2501.1711 https://nexus.steamware.net/repository/SWS/LiMan/stable/LAST/LiMan.UI.zip https://nexus.steamware.net/repository/SWS/LiMan/stable/LAST/ChangeLog.html false