223 lines
9.5 KiB
Plaintext
223 lines
9.5 KiB
Plaintext
@using GWMS.UI.Components
|
|
@using GWMS.Data.DatabaseModels
|
|
@using System.Security.Claims
|
|
@using Microsoft.AspNetCore.Components.Authorization
|
|
@using GWMS.UI.Data
|
|
@using GWMS.Data.DTO
|
|
@using Microsoft.Extensions.Configuration
|
|
|
|
@inject MessageService AppMService
|
|
@inject GWMSDataService DataService
|
|
@inject IConfiguration Configuration
|
|
|
|
<div class="card">
|
|
<div class="card-header bg-info text-light">
|
|
<b>Modifica</b>
|
|
</div>
|
|
<div class="card-body small p-1">
|
|
<EditForm Model="@_currItem">
|
|
<DataAnnotationsValidator />
|
|
<div class="row">
|
|
<div class="col-9 col-lg-10">
|
|
<div class="row mb-2">
|
|
<div class="col-3">
|
|
<div class="input-group input-group-sm">
|
|
<div class="input-group-prepend">
|
|
<span class="input-group-text"><i class="fas fa-puzzle-piece"></i></span>
|
|
</div>
|
|
<InputText @bind-Value="_currItem.UserName" class="form-control" title="User Name" />
|
|
</div>
|
|
</div>
|
|
<div class="col-3">
|
|
<div class="input-group input-group-sm">
|
|
<div class="input-group-prepend">
|
|
<span class="input-group-text"><i class="fas fa-user"></i></span>
|
|
</div>
|
|
<InputText @bind-Value="_currItem.Lastname" class="form-control" title="Cognome" />
|
|
</div>
|
|
</div>
|
|
<div class="col-3">
|
|
<div class="input-group input-group-sm">
|
|
<div class="input-group-prepend">
|
|
<span class="input-group-text"><i class="far fa-user"></i></span>
|
|
</div>
|
|
<InputText @bind-Value="_currItem.Firstname" class="form-control" title="Nome" />
|
|
</div>
|
|
</div>
|
|
<div class="col-2">
|
|
<div class="input-group input-group-sm">
|
|
<div class="input-group-prepend">
|
|
<span class="input-group-text">
|
|
<i class="fas fa-user-shield"></i>
|
|
</span>
|
|
</div>
|
|
<select @bind="_currItem.Livello" class="form-control">
|
|
@foreach (var itemVal in Enum.GetValues(typeof(GWMS.Data.UserLevel)))
|
|
{
|
|
<option>@itemVal</option>
|
|
}
|
|
</select>
|
|
</div>
|
|
</div>
|
|
<div class="col-1">
|
|
<div class="custom-control custom-switch">
|
|
<input type="checkbox" class="custom-control-input" id="switchAtt" title="attivo" @bind="_currItem.IsActive">
|
|
<label class="custom-control-label" for="switchAtt">Att</label>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="row">
|
|
<div class="col-3">
|
|
<div class="input-group input-group-sm">
|
|
<div class="input-group-prepend">
|
|
<span class="input-group-text"><i class="fas fa-at"></i></span>
|
|
</div>
|
|
<InputText @bind-Value="_currItem.Email" class="form-control" title="Email" />
|
|
</div>
|
|
</div>
|
|
<div class="col-3">
|
|
<div class="input-group">
|
|
<div class="input-group-prepend">
|
|
<span class="input-group-text">
|
|
<span class="fas fa-gas-pump" aria-hidden="true"></span>
|
|
</span>
|
|
</div>
|
|
<select @bind="_currItem.MaskPlantId" class="form-control form-control-sm">
|
|
<option value="0">--- Tutti ---</option>
|
|
@if (PlantsList != null)
|
|
{
|
|
foreach (var item in PlantsList)
|
|
{
|
|
<option value="@item.PlantId">@item.PlantCode | @item.PlantDesc</option>
|
|
}
|
|
}
|
|
</select>
|
|
</div>
|
|
</div>
|
|
<div class="col-3">
|
|
<div class="input-group">
|
|
<div class="input-group-prepend">
|
|
<span class="input-group-text">
|
|
<span class="fas fa-industry" aria-hidden="true"></span>
|
|
</span>
|
|
</div>
|
|
<select @bind="_currItem.MaskSupplierId" class="form-control form-control-sm">
|
|
<option value="0">--- Tutti ---</option>
|
|
@if (SuppliersList != null)
|
|
{
|
|
foreach (var item in SuppliersList)
|
|
{
|
|
<option value="@item.SupplierId">@item.SupplierCode | @item.SupplierDesc</option>
|
|
}
|
|
}
|
|
</select>
|
|
</div>
|
|
</div>
|
|
<div class="col-3">
|
|
<div class="input-group">
|
|
<div class="input-group-prepend">
|
|
<span class="input-group-text">
|
|
<span class="fas fa-truck-moving" aria-hidden="true"></span>
|
|
</span>
|
|
</div>
|
|
<select @bind="_currItem.MaskTranspId" class="form-control form-control-sm" title="Trasportatore">
|
|
<option value="0">--- Tutti ---</option>
|
|
@if (TransportersList != null)
|
|
{
|
|
foreach (var item in TransportersList)
|
|
{
|
|
<option value="@item.TransporterId">@item.TransporterCode | @item.TransporterDesc</option>
|
|
}
|
|
}
|
|
</select>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="col-3 col-lg-2">
|
|
<div class="mb-2">
|
|
<button type="button" class="btn btn-sm btn-outline-success btn-block" value="Save" @onclick="saveUpdate">Save <i class="far fa-save"></i></button>
|
|
</div>
|
|
<div>
|
|
<button type="button" class="btn btn-sm btn-outline-warning btn-block" value="Cancel" @onclick="cancelUpdate">Cancel <i class="fas fa-ban"></i></button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</EditForm>
|
|
</div>
|
|
</div>
|
|
|
|
@code {
|
|
|
|
private List<PlantDTO> PlantsList;
|
|
private List<SupplierModel> SuppliersList;
|
|
private List<TransporterModel> TransportersList;
|
|
|
|
protected UserModel _currItem = new UserModel();
|
|
protected int _supplierId { get; set; } = 0;
|
|
|
|
[Parameter]
|
|
public UserModel currItem
|
|
{
|
|
get
|
|
{
|
|
return _currItem = null;
|
|
}
|
|
set
|
|
{
|
|
_currItem = value;
|
|
}
|
|
}
|
|
|
|
[Parameter]
|
|
public EventCallback<int> DataReset { get; set; }
|
|
[Parameter]
|
|
public EventCallback<int> DataUpdated { get; set; }
|
|
[Parameter]
|
|
public int SupplierId
|
|
{
|
|
get
|
|
{
|
|
return _supplierId;
|
|
}
|
|
set
|
|
{
|
|
_supplierId = value;
|
|
// condiziono visualizzazione...
|
|
var pUpd = Task.Run(async () => await ReloadAllData());
|
|
pUpd.Wait();
|
|
}
|
|
}
|
|
|
|
private async Task saveUpdate()
|
|
{
|
|
if (_currItem != null)
|
|
{
|
|
DataService.UserUpdate(_currItem);
|
|
await DataUpdated.InvokeAsync(1);
|
|
}
|
|
else
|
|
{
|
|
Console.WriteLine("User null!");
|
|
}
|
|
}
|
|
|
|
private async Task cancelUpdate()
|
|
{
|
|
await DataReset.InvokeAsync(0);
|
|
}
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
await ReloadAllData();
|
|
}
|
|
|
|
protected async Task ReloadAllData()
|
|
{
|
|
PlantsList = await DataService.PlantsGetAll();
|
|
SuppliersList = await DataService.SuppliersGetAll();
|
|
TransportersList = await DataService.TransportersGetAll();
|
|
}
|
|
|
|
} |