72 lines
1.7 KiB
Plaintext
72 lines
1.7 KiB
Plaintext
@using CORE.Data.DbModels
|
|
@using UI.Data
|
|
@inject GpwDataService GDataServ
|
|
@inject MessageService AppMServ
|
|
|
|
@if (EnableAction)
|
|
{
|
|
<button @onclick="() => AddNew()" class="px-1 text-center btn btn-lg btn-outline-success">
|
|
@if (canPaste)
|
|
{
|
|
<i class="fas fa-clipboard"></i>
|
|
}
|
|
else
|
|
{
|
|
<i class="fas fa-plus-circle"></i>
|
|
}
|
|
</button>
|
|
}
|
|
else
|
|
{
|
|
<span> </span>
|
|
}
|
|
|
|
@code {
|
|
|
|
|
|
[Parameter]
|
|
public DateTime InizioPer { get; set; } = DateTime.Today.AddHours(8);
|
|
|
|
[Parameter]
|
|
public int IdxDip { get; set; } = 0;
|
|
|
|
[Parameter]
|
|
public EventCallback<RegAttivitaModel> NewItemCreated { get; set; }
|
|
|
|
[Parameter]
|
|
public bool EnableAction { get; set; } = true;
|
|
|
|
protected bool canPaste
|
|
{
|
|
get => AppMServ.clonedRA != null;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Indico item selezionato
|
|
/// </summary>
|
|
protected async void AddNew()
|
|
{
|
|
RegAttivitaModel newItem = new RegAttivitaModel();
|
|
TimeSpan durata = new TimeSpan(1, 0, 0);
|
|
// se ho un record clonato parto da quello...
|
|
if (AppMServ.clonedRA != null)
|
|
{
|
|
newItem = AppMServ.clonedRA;
|
|
}
|
|
else
|
|
{
|
|
// recupero ultima fase x utente...
|
|
newItem = await GDataServ.RegAttLastByDip(AppMServ.IdxDipendente);
|
|
}
|
|
// calcolo durata arrotondata ai 5 minuti...
|
|
durata = CORE.Data.Utils.TSpanRounded(newItem.Durata, 5, false);
|
|
newItem.IdxRa = 0;
|
|
newItem.Inizio = InizioPer;
|
|
newItem.Fine = InizioPer.AddMinutes(durata.TotalMinutes);
|
|
// salvo in AppMS
|
|
AppMServ.recordRA = newItem;
|
|
await NewItemCreated.InvokeAsync(newItem);
|
|
}
|
|
|
|
}
|