Files
mapo-core/MP.SPEC/Components/Reparti/ModalOperAdd.razor
T
Samuele Locatelli 4d43230a0b SPEC:
- ok preliminare add/remove macchine/reparti
2025-04-16 11:17:31 +02:00

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.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;
private int totalCount = 0;
private int currPage = 1;
private bool isLoading = false;
private List<AnagOperatoriModel>? 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(AnagOperatoriModel currRec)
{
// sollevo evento richiesta aggiunta ...
await EC_ReqAdd.InvokeAsync(currRec);
}
}