70d3e50baf
- ok Insert/delete amcchina - manca refresh
119 lines
3.5 KiB
Plaintext
119 lines
3.5 KiB
Plaintext
@using MP.SPEC.Data
|
|
<div class="modal-dialog">
|
|
<div class="modal-content p-2">
|
|
<div class="modal-title d-flex justify-content-between">
|
|
<div class="px-0">
|
|
<h5>Selezione Macchine</h5>
|
|
</div>
|
|
<div class="px-0">
|
|
<button class="btn btn-outline-dark" @onclick="() => DoClose()"><i class="fa-solid fa-xmark"></i></button>
|
|
</div>
|
|
</div>
|
|
<div class="modal-body p-1">
|
|
@if (ListRecords == null || ListRecords.Count == 0)
|
|
{
|
|
<div class="alert alert-warning text-center display-6">
|
|
Nessuna macchina 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.CodMacchina</div>
|
|
</td>
|
|
<td>
|
|
<div>@record.Descrizione</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<Macchine>? AllRecords { get; set; } = null;
|
|
|
|
[Parameter]
|
|
public EventCallback<bool> EC_Close { get; set; }
|
|
[Parameter]
|
|
public EventCallback<Macchine> EC_ReqAdd { get; set; }
|
|
|
|
|
|
private int numRecord = 5;
|
|
|
|
private int totalCount = 0;
|
|
private int currPage = 1;
|
|
private bool isLoading = false;
|
|
|
|
private List<Macchine>? ListRecords;
|
|
protected override void OnParametersSet()
|
|
{
|
|
numRecord = 10;
|
|
UpdateTable();
|
|
}
|
|
|
|
private void UpdateTable()
|
|
{
|
|
ListRecords?.Clear();
|
|
totalCount = 0;
|
|
if (AllRecords != null)
|
|
{
|
|
ListRecords = AllRecords
|
|
.Skip(numRecord * (currPage - 1))
|
|
.Take(numRecord)
|
|
.ToList();
|
|
totalCount = AllRecords.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(Macchine currRec)
|
|
{
|
|
// sollevo evento richiesta aggiunta ...
|
|
await EC_ReqAdd.InvokeAsync(currRec);
|
|
}
|
|
}
|