167aa2d98a
- completato editing macchine/operatori
156 lines
4.9 KiB
Plaintext
156 lines
4.9 KiB
Plaintext
@using MP.SPEC.Data
|
|
<div class="modal-dialog shadow">
|
|
<div class="modal-content p-2">
|
|
<div class="modal-title border-bottom">
|
|
<div class="d-flex justify-content-between">
|
|
<div class="px-1">
|
|
<h5>Selezione Operatori</h5>
|
|
</div>
|
|
<div class="px-1">
|
|
<button class="btn btn-outline-dark" @onclick="() => DoClose()"><i class="fa-solid fa-xmark"></i></button>
|
|
</div>
|
|
</div>
|
|
<div class="px-0 mt-1 mb-2">
|
|
<div class="input-group">
|
|
<span class="input-group-text"><i class="fa fa-search"></i></span>
|
|
<input type="text" class="form-control" placeholder="Search Ctr-R" @bind="@SearchVal" accesskey="R">
|
|
<button class="btn @btnSearchCss" @onclick="ResetSearch"><i class="fa fa-ban"></i></button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="modal-body p-1">
|
|
@if (ListRecords == null || ListRecords.Count == 0)
|
|
{
|
|
<div class="alert alert-warning text-center display-6">
|
|
Nessun Operatore da aggiungere
|
|
</div>
|
|
}
|
|
else
|
|
{
|
|
<table class="table table-sm table-striped small">
|
|
<thead>
|
|
<tr>
|
|
<th></th>
|
|
<th><i class="fa-solid fa-key"></i> Cod.Macc</th>
|
|
<th><i class="fa-solid fa-object-group"></i> Descrizione</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
@foreach (var record in ListRecords)
|
|
{
|
|
<tr>
|
|
<td>
|
|
<button @onclick="() => DoAdd(record)" class="btn btn-primary btn-sm" title="Seleziona Record"><i class="bi bi-search"></i></button>
|
|
</td>
|
|
<td>
|
|
<div>@record.MatrOpr</div>
|
|
</td>
|
|
<td>
|
|
<div>@record.Cognome @record.Nome</div>
|
|
</td>
|
|
</tr>
|
|
}
|
|
</tbody>
|
|
</table>
|
|
}
|
|
@if (totalCount > numRecord)
|
|
{
|
|
<DataPager PageSize="numRecord" currPage="currPage" numRecordChanged="SetNumRec" numPageChanged="SetNumPage" totalCount="totalCount" showLoading="isLoading" />
|
|
}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
@code {
|
|
|
|
|
|
[Parameter]
|
|
public List<AnagOperatoriModel>? AllRecords { get; set; } = null;
|
|
|
|
[Parameter]
|
|
public EventCallback<bool> EC_Close { get; set; }
|
|
[Parameter]
|
|
public EventCallback<AnagOperatoriModel> EC_ReqAdd { get; set; }
|
|
|
|
|
|
private int numRecord = 5;
|
|
protected string SearchVal
|
|
{
|
|
get => searchVal;
|
|
set
|
|
{
|
|
if (searchVal != value)
|
|
{
|
|
searchVal = value;
|
|
UpdateTable();
|
|
}
|
|
}
|
|
}
|
|
private string searchVal = "";
|
|
private int totalCount = 0;
|
|
private int currPage = 1;
|
|
private bool isLoading = false;
|
|
private List<AnagOperatoriModel>? ListRecords;
|
|
|
|
|
|
private string btnSearchCss
|
|
{
|
|
get => string.IsNullOrWhiteSpace(SearchVal) ? "btn-secondary" : "btn-primary";
|
|
}
|
|
|
|
private void ResetSearch()
|
|
{
|
|
SearchVal = "";
|
|
}
|
|
|
|
protected override void OnParametersSet()
|
|
{
|
|
numRecord = 10;
|
|
UpdateTable();
|
|
}
|
|
|
|
private void UpdateTable()
|
|
{
|
|
ListRecords?.Clear();
|
|
totalCount = 0;
|
|
if (AllRecords != null)
|
|
{
|
|
List<AnagOperatoriModel> tmpList = new List<AnagOperatoriModel>(AllRecords);
|
|
// verifico ricerca
|
|
if (!string.IsNullOrEmpty(SearchVal))
|
|
{
|
|
tmpList = AllRecords.Where(x => x.Cognome.Contains(SearchVal, StringComparison.InvariantCultureIgnoreCase) || x.Nome.Contains(SearchVal, StringComparison.InvariantCultureIgnoreCase)).ToList();
|
|
}
|
|
ListRecords = tmpList
|
|
.Skip(numRecord * (currPage - 1))
|
|
.Take(numRecord)
|
|
.ToList();
|
|
totalCount = tmpList.Count;
|
|
}
|
|
}
|
|
|
|
protected void SetNumPage(int newNum)
|
|
{
|
|
currPage = newNum;
|
|
UpdateTable();
|
|
}
|
|
|
|
protected void SetNumRec(int newNum)
|
|
{
|
|
currPage = 1;
|
|
numRecord = newNum;
|
|
UpdateTable();
|
|
}
|
|
|
|
private async Task DoClose()
|
|
{
|
|
await EC_Close.InvokeAsync(true);
|
|
}
|
|
|
|
private async Task DoAdd(AnagOperatoriModel currRec)
|
|
{
|
|
// sollevo evento richiesta aggiunta ...
|
|
await EC_ReqAdd.InvokeAsync(currRec);
|
|
}
|
|
}
|