189 lines
5.1 KiB
C#
189 lines
5.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.AspNetCore.Components;
|
|
using System.Net.Http;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Components.Authorization;
|
|
using Microsoft.AspNetCore.Components.Forms;
|
|
using Microsoft.AspNetCore.Components.Routing;
|
|
using Microsoft.AspNetCore.Components.Web;
|
|
using Microsoft.AspNetCore.Components.Web.Virtualization;
|
|
using Microsoft.JSInterop;
|
|
using GPW.CORE.UI;
|
|
using GPW.CORE.UI.Shared;
|
|
using GPW.CORE.Data.DbModels;
|
|
using GPW.CORE.UI.Data;
|
|
|
|
namespace GPW.CORE.UI.Components
|
|
{
|
|
public partial class RegAtt
|
|
{
|
|
|
|
[Parameter]
|
|
public bool IsClipboard { get; set; } = false;
|
|
[Parameter]
|
|
public RegAttivitaModel CurrData { get; set; } = null!;
|
|
[Parameter]
|
|
public double Periodo { get; set; } = 1;
|
|
[Parameter]
|
|
public int IdxDipSel { get; set; } = 0;
|
|
[Parameter]
|
|
public List<AnagFasiModel> ListFasi { get; set; } = null!;
|
|
[Parameter]
|
|
public EventCallback<RegAttivitaModel> ItemCloned { get; set; }
|
|
|
|
[Parameter]
|
|
public EventCallback<RegAttivitaModel> ItemSelected { get; set; }
|
|
|
|
[Parameter]
|
|
public EventCallback<RegAttivitaModel> ItemUpdated { get; set; }
|
|
|
|
private bool _isEnd = true;
|
|
|
|
public bool IsEnd
|
|
{
|
|
get
|
|
{
|
|
return _isEnd;
|
|
}
|
|
set
|
|
{
|
|
_isEnd = value;
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Trim linea di testo secondo regole
|
|
/// </summary>
|
|
/// <param name = "stringOrig">Stringa origiale</param>
|
|
/// <param name = "multFact">Fattore di moltiplicazione (std: 130)</param>
|
|
/// <returns></returns>
|
|
protected string trimLine(object stringOrig, int multFact = 130)
|
|
{
|
|
double num = 1;
|
|
if (CurrData.OreTot != null)
|
|
{
|
|
num = (double)CurrData.OreTot;
|
|
}
|
|
|
|
double perc = num / Periodo;
|
|
int maxLenght = (int)(perc * multFact);
|
|
string answ = $"{stringOrig}";
|
|
if (answ.Length > maxLenght)
|
|
{
|
|
answ = $"{answ.Substring(0, maxLenght)}...";
|
|
}
|
|
|
|
return answ;
|
|
}
|
|
|
|
private string widthPerc
|
|
{
|
|
get
|
|
{
|
|
string answ = "1%";
|
|
if (CurrData != null)
|
|
{
|
|
double num = CurrData.OreTot != null ? (double)CurrData.OreTot : 0;
|
|
answ = $"{num / Periodo:P2}".Replace(",", ".");
|
|
}
|
|
|
|
return answ;
|
|
}
|
|
}
|
|
|
|
private string blockCss
|
|
{
|
|
get
|
|
{
|
|
string answ = CurrData.IdxFase == 0 ? "" : " border border-info rounded";
|
|
return answ;
|
|
}
|
|
}
|
|
|
|
protected bool isSelected = false;
|
|
protected string cssSelected {
|
|
get => isSelected ? "table-info" : "";
|
|
}
|
|
|
|
protected string buttonCss {
|
|
get => !IsClipboard ? "dropbtn" : "";
|
|
}
|
|
|
|
protected override void OnInitialized()
|
|
{
|
|
isSelected = false;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Indico item selezionato
|
|
/// </summary>
|
|
protected async void Edit()
|
|
{
|
|
// SOLO SE non è una copia clipboard...
|
|
//if (!IsClipboard)
|
|
//{
|
|
isSelected = true;
|
|
await ItemSelected.InvokeAsync(CurrData);
|
|
//}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Indico item selezionato
|
|
/// </summary>
|
|
protected async void Clone()
|
|
{
|
|
AppMServ.clonedRA = CurrData;
|
|
await ItemCloned.InvokeAsync(CurrData);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Indico item selezionato
|
|
/// </summary>
|
|
protected async void Delete()
|
|
{
|
|
// chiedo verifica
|
|
if (!await JSRuntime.InvokeAsync<bool>("confirm", "Sicuro di voler eliminare il record selezionato??"))
|
|
return;
|
|
|
|
// aggiorno
|
|
await GDataServ.RegAttDelete(CurrData);
|
|
// registro fatto
|
|
await ItemUpdated.InvokeAsync(null);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Indico item selezionato
|
|
/// </summary>
|
|
protected async void ReportSelect(RegAttivitaModel selRecord)
|
|
{
|
|
await ItemSelected.InvokeAsync(selRecord);
|
|
}
|
|
|
|
protected async void AddTime(int deltaMin)
|
|
{
|
|
// verifico checkbox IsEnd
|
|
if (IsEnd)
|
|
{
|
|
// modifico fine...
|
|
CurrData.Fine = CurrData.Fine.AddMinutes(deltaMin);
|
|
}
|
|
else
|
|
{
|
|
// modifico inizio...
|
|
CurrData.Inizio = CurrData.Inizio.AddMinutes(deltaMin);
|
|
}
|
|
// salvo
|
|
await GDataServ.RegAttUpdate(CurrData);
|
|
await ItemUpdated.InvokeAsync(CurrData);
|
|
}
|
|
|
|
public string txtModDurata
|
|
{
|
|
get => IsEnd ? "Fine" : "Inizio";
|
|
}
|
|
}
|
|
} |