Update gestione calendario settimanale
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
|
||||
<div class="row bg-dark py-3">
|
||||
<div class="col">
|
||||
<CalendarWeek DateList="@ListDate" EventList="@EventListWeek" PercY="60" backToCalendar="ForceReloadWeek" EC_HeadDateSel="SetDayDetail"></CalendarWeek>
|
||||
<CalendarWeek DateList="@ListDate" EventList="@EventListWeek" PercX="150" PercY="0" backToCalendar="ForceReloadWeek" EC_HeadDateSel="SetDayDetail"></CalendarWeek>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -45,30 +45,9 @@ namespace EgwCoreLib.BlazorTest.Pages
|
||||
|
||||
protected void SetDayDetail(DateTime selDate)
|
||||
{
|
||||
var tmpDays = new List<DateTime>();
|
||||
var tmpEv = new List<CalendarEvent>();
|
||||
|
||||
tmpDays.Add(selDate);
|
||||
// genero qualche evento da 0 a 6...
|
||||
int numEv = rnd.Next(0, 8);
|
||||
if (numEv > 0)
|
||||
{
|
||||
for (int e = 0; e < numEv; e++)
|
||||
{
|
||||
double duration = 9 + 8 * rnd.NextDouble();
|
||||
CalendarEvent newEv = new CalendarEvent()
|
||||
{
|
||||
CssClass = "bg-success opacity-25",
|
||||
Description = $"Permesso #{e}",
|
||||
Type = "PERM",
|
||||
Inizio = selDate.AddHours(8),
|
||||
Fine = selDate.AddHours(duration),
|
||||
Title = "O.S.",
|
||||
ToolTip = $"O.S. {selDate.AddHours(8)} - {selDate.AddHours(duration)}"
|
||||
};
|
||||
tmpEv.Add(newEv);
|
||||
}
|
||||
}
|
||||
var tmpDays = ListDate.Where(x => x.Equals(selDate)).ToList();
|
||||
var tmpEv = EventListWeek.Where(x => x.Inizio.Date.Equals(selDate)).ToList();
|
||||
// salvo valori simulati
|
||||
ListDate = tmpDays;
|
||||
EventListWeek = tmpEv;
|
||||
@@ -89,15 +68,17 @@ namespace EgwCoreLib.BlazorTest.Pages
|
||||
{
|
||||
for (int e = 0; e < numEv; e++)
|
||||
{
|
||||
int inizio = rnd.Next(8, 12);
|
||||
int fine = inizio + rnd.Next(2,8);
|
||||
CalendarEvent newEv = new CalendarEvent()
|
||||
{
|
||||
CssClass = "bg-success opacity-25",
|
||||
Description = $"Permesso #{e}",
|
||||
Type = "PERM",
|
||||
Inizio = oggi.AddDays(i).AddHours(8),
|
||||
Fine = oggi.AddDays(i).AddHours(9 + 8 * rnd.NextDouble()),
|
||||
Inizio = oggi.AddDays(i).AddHours(inizio),
|
||||
Fine = oggi.AddDays(i).AddHours(fine),
|
||||
Title = "O.S.",
|
||||
ToolTip = $"O.S. {oggi.AddDays(i).AddHours(8)} - {oggi.AddDays(i).AddHours(17)}"
|
||||
ToolTip = $"O.S. {oggi.AddDays(i).AddHours(inizio)} - {oggi.AddDays(i).AddHours(fine)}"
|
||||
};
|
||||
tmpEv.Add(newEv);
|
||||
}
|
||||
|
||||
@@ -42,6 +42,14 @@ namespace EgwCoreLib.Razor
|
||||
[Parameter]
|
||||
public ColType ItemMode { get; set; } = ColType.dataContainer;
|
||||
|
||||
/// <summary>
|
||||
/// Fattore di shift in X, se 0 = nessuno shift, se > 0 è percentuale moltiplica il
|
||||
/// gradino calcolato
|
||||
/// Default: 100 (poi riportato a intero, quindi 100/100 = 1.0)
|
||||
/// </summary>
|
||||
[Parameter]
|
||||
public int PercX { get; set; } = 100;
|
||||
|
||||
/// <summary>
|
||||
/// Fattore di shift in Y, se 0 = nessuno shift, se > 0 è percentuale moltiplica il
|
||||
/// gradino calcolato
|
||||
@@ -102,19 +110,20 @@ namespace EgwCoreLib.Razor
|
||||
List<boxData> answ = new List<boxData>();
|
||||
int step = vBox.Height / (ValMax - ValMin);
|
||||
int numEv = EventList.Count;
|
||||
int evWidth = numEv > 1 ? (int)(0.7 * vBox.Width) : (int)(0.9 * vBox.Width);
|
||||
int evWidth = numEv > 1 ? (int)(0.5 * vBox.Width) : (int)(0.9 * vBox.Width);
|
||||
//int evWidth = numEv > 1 ? (int)(1.5 * vBox.Width / numEv) : (int)(0.9 * vBox.Width);
|
||||
int offsetX = 1;
|
||||
int offsetY = 0;// step / 2;
|
||||
if (numEv > 0)
|
||||
{
|
||||
int xStep = evWidth / (EventList.Count + 1);
|
||||
int xStep = evWidth / (EventList.Count + 1) * PercX / 100;
|
||||
int yStep = evWidth * PercY / 100;
|
||||
//int yStep = xStep * 5;
|
||||
//int yStep = xStep * (EventList.Count + 50) / (EventList.Count + 6);
|
||||
int deltaX = 0;
|
||||
answ = EventList
|
||||
.OrderBy(x => x.Inizio)
|
||||
.ThenByDescending(x => x.Durata)
|
||||
.Select(x => new boxData()
|
||||
{
|
||||
pX = offsetX + xStep * (deltaX),
|
||||
|
||||
@@ -6,7 +6,7 @@ else
|
||||
{
|
||||
<table class="cssTable" style="@HeadStyle">
|
||||
<thead>
|
||||
<tr class="">
|
||||
<tr>
|
||||
<th class="text-center text-light" @onclick="()=>OpenCalendarMonth()" style="width: @lblWidth;"><i class="fa-regular fa-circle-xmark"></i></th>
|
||||
@foreach (var item in DateList)
|
||||
{
|
||||
@@ -29,7 +29,7 @@ else
|
||||
@foreach (var item in DateList)
|
||||
{
|
||||
<td>
|
||||
<CalWeekColumn ItemMode="CalWeekColumn.ColType.dataContainer" vBox="vBoxCont" EventList="@DayEvent(item)" ValMin="8" ValMax="20" PercY="@PercY"></CalWeekColumn>
|
||||
<CalWeekColumn ItemMode="CalWeekColumn.ColType.dataContainer" vBox="vBoxCont" EventList="@DayEvent(item)" ValMin="8" ValMax="20" PercX="@PercX" PercY="@PercY"></CalWeekColumn>
|
||||
</td>
|
||||
}
|
||||
</tr>
|
||||
|
||||
@@ -8,40 +8,24 @@ namespace EgwCoreLib.Razor
|
||||
{
|
||||
#region Public Properties
|
||||
|
||||
/// <summary>
|
||||
/// Evento x ritorno click
|
||||
/// </summary>
|
||||
[Parameter]
|
||||
public EventCallback<bool> backToCalendar { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Periodo da mostrare (tipicamente 1 settimana)
|
||||
/// </summary>
|
||||
[Parameter]
|
||||
public List<DateTime> DateList { get; set; } = new List<DateTime>();
|
||||
|
||||
/// <summary>
|
||||
/// Eventi da inserire
|
||||
/// </summary>
|
||||
[Parameter]
|
||||
public List<CalendarEvent> EventList { get; set; } = new List<CalendarEvent>();
|
||||
|
||||
/// <summary>
|
||||
/// Evento selezione data valida (= entro il periodo selezionato)
|
||||
/// </summary>
|
||||
[Parameter]
|
||||
public EventCallback<DateTime> DateSelected { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Fattore di shift in Y, se 0 = nessuno shift, se > 0 è percentuale moltiplica il
|
||||
/// gradino calcolato
|
||||
/// Default: 90 (poi riportato a intero, quindi 90/100 = 0.9)
|
||||
/// </summary>
|
||||
[Parameter]
|
||||
public int PercY { get; set; } = 90;
|
||||
|
||||
/// <summary>
|
||||
/// Evento x ritorno click
|
||||
/// </summary>
|
||||
[Parameter]
|
||||
public EventCallback<bool> backToCalendar{ get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Evento selezione data singola giornata da header
|
||||
/// </summary>
|
||||
@@ -54,6 +38,12 @@ namespace EgwCoreLib.Razor
|
||||
[Parameter]
|
||||
public int EndHour { get; set; } = 20;
|
||||
|
||||
/// <summary>
|
||||
/// Eventi da inserire
|
||||
/// </summary>
|
||||
[Parameter]
|
||||
public List<CalendarEvent> EventList { get; set; } = new List<CalendarEvent>();
|
||||
|
||||
/// <summary>
|
||||
/// Css titolo
|
||||
/// default: color: red
|
||||
@@ -73,6 +63,22 @@ namespace EgwCoreLib.Razor
|
||||
[Parameter]
|
||||
public int labelWidth { get; set; } = 15;
|
||||
|
||||
/// <summary>
|
||||
/// Fattore di shift in X, se 0 = nessuno shift, se > 0 è percentuale moltiplica il
|
||||
/// gradino calcolato
|
||||
/// Default: 100 (poi riportato a intero, quindi 100/100 = 1.0)
|
||||
/// </summary>
|
||||
[Parameter]
|
||||
public int PercX { get; set; } = 100;
|
||||
|
||||
/// <summary>
|
||||
/// Fattore di shift in Y, se 0 = nessuno shift, se > 0 è percentuale moltiplica il
|
||||
/// gradino calcolato
|
||||
/// Default: 90 (poi riportato a intero, quindi 90/100 = 0.9)
|
||||
/// </summary>
|
||||
[Parameter]
|
||||
public int PercY { get; set; } = 90;
|
||||
|
||||
[Parameter]
|
||||
public int StartHour { get; set; } = 8;
|
||||
|
||||
@@ -103,6 +109,12 @@ namespace EgwCoreLib.Razor
|
||||
get => numDays + 1;
|
||||
}
|
||||
|
||||
protected int contWidth
|
||||
{
|
||||
get => (vBox.Width * 2) / (2 * numDays + 1);
|
||||
//get => numDays > 1 ? (vBox.Width * 2) / (2 * numDays + 1) : vBox.Width * 90 / 100;
|
||||
}
|
||||
|
||||
protected DateTime DtRif
|
||||
{
|
||||
get
|
||||
@@ -121,48 +133,26 @@ namespace EgwCoreLib.Razor
|
||||
get => DateList.Count;
|
||||
}
|
||||
|
||||
protected int contWidth
|
||||
protected Size vBoxCont
|
||||
{
|
||||
get => (vBox.Width * 2) / (2 * numDays + 1);
|
||||
}
|
||||
|
||||
private string lblWidth
|
||||
{
|
||||
get => $"{(double)(vBox.Width - (contWidth * numDays)) / vBox.Width:P2}".Replace(",", ".");
|
||||
}
|
||||
private string dataWidth
|
||||
{
|
||||
get => $"{(double)contWidth / vBox.Width:P2}".Replace(",", ".");
|
||||
get
|
||||
{
|
||||
// label e' MENO di 1/tot columns
|
||||
Size answ = new Size(contWidth, vBox.Height);
|
||||
return answ;
|
||||
}
|
||||
}
|
||||
|
||||
protected Size vBoxLabel
|
||||
{
|
||||
get
|
||||
{
|
||||
// label � MENO di 1/tot columns
|
||||
// label e' MENO di 1/tot columns
|
||||
Size answ = new Size(contWidth / 2, vBox.Height);
|
||||
//Size answ = new Size(labelWidth, vBox.Height);
|
||||
return answ;
|
||||
}
|
||||
}
|
||||
protected Size vBoxCont
|
||||
{
|
||||
get
|
||||
{
|
||||
// label � MENO di 1/tot columns
|
||||
Size answ = new Size(contWidth, vBox.Height);
|
||||
return answ;
|
||||
}
|
||||
}
|
||||
|
||||
//protected Size vBoxLabel
|
||||
//{
|
||||
// get
|
||||
// {
|
||||
// // label � MENO di 1/tot columns
|
||||
// Size answ = new Size(labelWidth, vBox.Height);
|
||||
// return answ;
|
||||
// }
|
||||
//}
|
||||
|
||||
#endregion Protected Properties
|
||||
|
||||
@@ -178,27 +168,6 @@ namespace EgwCoreLib.Razor
|
||||
await WeekChanged.InvokeAsync(delta);
|
||||
}
|
||||
|
||||
protected override async Task OnParametersSetAsync()
|
||||
{
|
||||
HourSlot = new List<int>();
|
||||
for (int i = StartHour; i <= EndHour; i++)
|
||||
{
|
||||
HourSlot.Add(i);
|
||||
}
|
||||
await InvokeAsync(StateHasChanged);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// GetIso8601WeekOfYear
|
||||
/// </summary>
|
||||
/// <param name="DtReq"></param>
|
||||
/// <returns></returns>
|
||||
protected int weekNum(DateTime DtReq)
|
||||
{
|
||||
int wNum = WeekData.GetIso8601WeekOfYear(DtReq);
|
||||
return wNum;
|
||||
}
|
||||
|
||||
protected List<CalendarEvent> DayEvent(DateTime DtReq)
|
||||
{
|
||||
List<CalendarEvent> answ = new List<CalendarEvent>();
|
||||
@@ -228,17 +197,51 @@ namespace EgwCoreLib.Razor
|
||||
return answ;
|
||||
}
|
||||
|
||||
protected override async Task OnParametersSetAsync()
|
||||
{
|
||||
HourSlot = new List<int>();
|
||||
for (int i = StartHour; i <= EndHour; i++)
|
||||
{
|
||||
HourSlot.Add(i);
|
||||
}
|
||||
await InvokeAsync(StateHasChanged);
|
||||
}
|
||||
|
||||
protected async Task OpenCalendarMonth()
|
||||
{
|
||||
await backToCalendar.InvokeAsync(true);
|
||||
}
|
||||
|
||||
protected async Task SelectDate( DateTime selDate)
|
||||
protected async Task SelectDate(DateTime selDate)
|
||||
{
|
||||
await EC_HeadDateSel.InvokeAsync(selDate);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// GetIso8601WeekOfYear
|
||||
/// </summary>
|
||||
/// <param name="DtReq"></param>
|
||||
/// <returns></returns>
|
||||
protected int weekNum(DateTime DtReq)
|
||||
{
|
||||
int wNum = WeekData.GetIso8601WeekOfYear(DtReq);
|
||||
return wNum;
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
#region Private Properties
|
||||
|
||||
private string dataWidth
|
||||
{
|
||||
get => $"{(double)contWidth / vBox.Width:P2}".Replace(",", ".");
|
||||
}
|
||||
|
||||
private string lblWidth
|
||||
{
|
||||
get => $"{(double)(vBox.Width - (contWidth * numDays)) / vBox.Width:P2}".Replace(",", ".");
|
||||
}
|
||||
|
||||
#endregion Private Properties
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
@@ -11,6 +12,11 @@ namespace EgwCoreLib.Razor.Data
|
||||
public int id { get; set; } = 0;
|
||||
public DateTime Inizio { get; set; } = DateTime.Today.AddHours(8);
|
||||
public DateTime Fine { get; set; } = DateTime.Today.AddHours(10);
|
||||
[NotMapped]
|
||||
public double Durata
|
||||
{
|
||||
get => Fine.Subtract(Inizio).TotalMinutes;
|
||||
}
|
||||
public string CssClass { get; set; } = "";
|
||||
public string Title { get; set; } = "";
|
||||
public string Description { get; set; } = "";
|
||||
|
||||
Reference in New Issue
Block a user