179 lines
4.3 KiB
C#
179 lines
4.3 KiB
C#
using Microsoft.AspNetCore.Components;
|
|
using SHERPA.BBM.CORE.DbModels;
|
|
using SHERPA.BBM.UI.Data;
|
|
|
|
namespace SHERPA.BBM.UI.Components
|
|
{
|
|
public partial class DocMovList
|
|
{
|
|
#region Public Properties
|
|
|
|
[Parameter]
|
|
public int AnnoSel { get; set; } = 0;
|
|
|
|
[Parameter]
|
|
public EventCallback<int> docMoveRequested { get; set; }
|
|
|
|
[Parameter]
|
|
public int NegotIdSour
|
|
{
|
|
get
|
|
{
|
|
return _negotIdSour;
|
|
}
|
|
|
|
set
|
|
{
|
|
_negotIdSour = value;
|
|
// condiziono visualizzazione...
|
|
var pUpd = Task.Run(async () => await ReloadAllData());
|
|
pUpd.Wait();
|
|
}
|
|
}
|
|
|
|
#endregion Public Properties
|
|
|
|
#region Public Methods
|
|
|
|
public string btnFromState(bool isActive)
|
|
{
|
|
string answ = isActive ? "btn-success" : "btn-outline-warning";
|
|
return answ;
|
|
}
|
|
|
|
public string checkSelect(int DocId)
|
|
{
|
|
string answ = "";
|
|
if (currItem != null)
|
|
{
|
|
try
|
|
{
|
|
answ = (currItem.DocId == DocId) ? "table-info" : "";
|
|
}
|
|
catch
|
|
{ }
|
|
}
|
|
|
|
return answ;
|
|
}
|
|
|
|
public async void OnSeachUpdated()
|
|
{
|
|
await InvokeAsync(() =>
|
|
{
|
|
Task task = UpdateData();
|
|
StateHasChanged();
|
|
});
|
|
}
|
|
|
|
public string tooltipFromState(bool isActive)
|
|
{
|
|
string answ = isActive ? "Attivo" : "Imposta Attivo";
|
|
return answ;
|
|
}
|
|
|
|
#endregion Public Methods
|
|
|
|
#region Protected Fields
|
|
|
|
protected int totalCount = 0;
|
|
|
|
#endregion Protected Fields
|
|
|
|
#region Protected Properties
|
|
|
|
|
|
|
|
#endregion Protected Properties
|
|
|
|
#region Protected Methods
|
|
|
|
protected async Task ForceReload(int newNum)
|
|
{
|
|
numRecord = newNum;
|
|
await ReloadAllData();
|
|
}
|
|
|
|
protected async Task ForceReloadPage(int newNum)
|
|
{
|
|
currPage = newNum;
|
|
await ReloadAllData();
|
|
}
|
|
|
|
protected async Task Move(vDocsDataModel currRecord)
|
|
{
|
|
// riporto richiesta spostamento
|
|
await docMoveRequested.InvokeAsync(currRecord.DocId);
|
|
}
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
MessageService.ShowSearch = true;
|
|
MessageService.SearchVal = "";
|
|
MessageService.EA_SearchUpdated += OnSeachUpdated;
|
|
await ReloadAllData();
|
|
}
|
|
|
|
protected async Task ReloadAllData()
|
|
{
|
|
await updateTable();
|
|
}
|
|
|
|
protected void ResetData()
|
|
{
|
|
if (currItem != null)
|
|
{
|
|
BBMService.rollBackEdit(currItem);
|
|
}
|
|
currItem = null;
|
|
}
|
|
|
|
protected async Task UpdateData()
|
|
{
|
|
currItem = null;
|
|
await ReloadAllData();
|
|
}
|
|
|
|
protected async Task updateTable()
|
|
{
|
|
SearchRecords = await BBMService.DocsGetAsync(MessageService.SearchVal, AnnoSel, 1, NegotIdSour, ShowAllDoc);
|
|
totalCount = SearchRecords.Count();
|
|
ListRecords = SearchRecords.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList();
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Private Fields
|
|
|
|
private bool _showAllDoc = false;
|
|
private DocsModel? currItem = null;
|
|
private bool isLoading = false;
|
|
private List<vDocsDataModel> ListRecords = new List<vDocsDataModel>();
|
|
private List<vDocsDataModel> SearchRecords = new List<vDocsDataModel>();
|
|
|
|
#endregion Private Fields
|
|
|
|
#region Private Properties
|
|
|
|
private int _negotIdSour { get; set; } = 0;
|
|
private int currPage { get; set; } = 1;
|
|
|
|
private int numRecord { get; set; } = 10;
|
|
|
|
private bool ShowAllDoc
|
|
{
|
|
get
|
|
{
|
|
return _showAllDoc;
|
|
}
|
|
|
|
set
|
|
{
|
|
_showAllDoc = value;
|
|
updateTable().ConfigureAwait(false);
|
|
}
|
|
}
|
|
|
|
#endregion Private Properties
|
|
}
|
|
} |