131 lines
3.4 KiB
C#
131 lines
3.4 KiB
C#
using EgwCoreLib.Lux.Data.DbModel.Admin;
|
|
|
|
namespace Lux.UI.Components.Compo.Admin
|
|
{
|
|
public partial class VocabMan
|
|
{
|
|
#region Public Properties
|
|
|
|
[Parameter]
|
|
public List<VocabolarioModel> AllRecord { get; set; } = null!;
|
|
|
|
[Parameter]
|
|
public EventCallback<VocabolarioModel> EC_Updated { get; set; }
|
|
|
|
[Parameter]
|
|
public EventCallback<string> EC_ReqClone { get; set; }
|
|
|
|
[Parameter]
|
|
public List<LinguaModel> ListLingue { get; set; } = null!;
|
|
|
|
[Parameter]
|
|
public string SearchVal { get; set; } = string.Empty;
|
|
|
|
[Parameter]
|
|
public string SelLingua { get; set; } = "";
|
|
|
|
#endregion Public Properties
|
|
|
|
#region Protected Methods
|
|
|
|
protected override void OnParametersSet()
|
|
{
|
|
if (AllRecord != null && AllRecord.Count > 0)
|
|
{
|
|
isLoading = true;
|
|
UpdateTable();
|
|
}
|
|
}
|
|
|
|
private async Task DoClone()
|
|
{
|
|
if (!string.IsNullOrEmpty(SelLingua))
|
|
await EC_ReqClone.InvokeAsync(SelLingua);
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Private Fields
|
|
|
|
private int currPage = 1;
|
|
private VocabolarioModel? editRec = null;
|
|
private VocabolarioModel? currRec = null;
|
|
private bool isLoading = false;
|
|
private List<VocabolarioModel> ListPaged = new();
|
|
private int numRecord = 10;
|
|
|
|
private int totalCount = 0;
|
|
|
|
#endregion Private Fields
|
|
|
|
#region Private Methods
|
|
|
|
private void DoCancel()
|
|
{
|
|
currRec = null;
|
|
editRec = null;
|
|
}
|
|
|
|
private void DoEdit(VocabolarioModel selRec)
|
|
{
|
|
editRec = editRec == null || editRec.Lemma != selRec.Lemma ? selRec : null;
|
|
}
|
|
private void DoSelect(VocabolarioModel selRec)
|
|
{
|
|
currRec = selRec;
|
|
}
|
|
|
|
private async Task DoSave()
|
|
{
|
|
await EC_Updated.InvokeAsync(editRec);
|
|
editRec = null;
|
|
}
|
|
|
|
private void FiltLingua()
|
|
{
|
|
UpdateTable();
|
|
}
|
|
|
|
private void SaveNumRec(int newNum)
|
|
{
|
|
numRecord = newNum;
|
|
currPage = 1;
|
|
UpdateTable();
|
|
}
|
|
|
|
private void SavePage(int newNum)
|
|
{
|
|
currPage = newNum;
|
|
UpdateTable();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Filtro e paginazione
|
|
/// </summary>
|
|
private void UpdateTable()
|
|
{
|
|
ListPaged.Clear();
|
|
if (!string.IsNullOrEmpty(SelLingua))
|
|
{
|
|
var rawList = AllRecord.Where(x => x.Lingua == SelLingua).ToList();
|
|
if (!string.IsNullOrEmpty(SearchVal))
|
|
{
|
|
rawList = rawList.Where(x =>
|
|
x.Lemma.Contains(SearchVal, StringComparison.InvariantCultureIgnoreCase) ||
|
|
x.Traduzione.Contains(SearchVal, StringComparison.InvariantCultureIgnoreCase)
|
|
).ToList();
|
|
}
|
|
|
|
totalCount = rawList.Count;
|
|
// fix paginazione
|
|
ListPaged = rawList
|
|
.Skip(numRecord * (currPage - 1))
|
|
.Take(numRecord)
|
|
.ToList();
|
|
}
|
|
isLoading = false;
|
|
}
|
|
|
|
#endregion Private Methods
|
|
}
|
|
} |