ok cambio settimana calendario

This commit is contained in:
Samuele Locatelli
2023-01-19 12:59:48 +01:00
parent 8ff9385b67
commit ba89ff0726
7 changed files with 119 additions and 48 deletions
+28 -41
View File
@@ -7,60 +7,47 @@ else
<table class="text-center cssTable" style="@HeadStyle">
<thead>
<tr class="row">
@for (int i = 0; i < 7; i++)
<th class="col"></th>
@foreach (var item in DateList)
{
<th class="col">
<div>
@($"{DateList[i]:ddd}".Substring(0, 1).ToUpper())
@($"{item:ddd}".Substring(0, 1).ToUpper())
</div>
<div class="small">
<sup>@($"{DateList[i]:dd}")</sup>
<sup>@($"{item:dd}")</sup>
</div>
</th>
}
</tr>
</thead>
<tbody>
@*
@if (SingleWeek)
{
<tr class="row">
@foreach (var giorno in SingleWeekRow)
{
<td class="col @singleDayCss(giorno)">
<span @onclick="() => clickDay(giorno)" class="@singleDaySpanCss(giorno)">
@($"{giorno:dd}")
</span>
</td>
}
</tr>
}
else
{
@foreach (var settim in WeekRows)
{
<tr class="row">
@foreach (var giorno in settim)
{
<td class="col @dayCss(giorno)">
<span @onclick="() => clickDay(giorno)" class="@spanCss(giorno)">
@($"{giorno:dd}")
</span>
</td>
}
</tr>
}
}*@
@foreach (var ora in HourSlot)
{
<tr class="row">
<td class="col">
<small>@($"{ora:00}:00")</small>
</td>
@foreach (var item in DateList)
{
<td class="col">.</td>
}
</tr>
}
</tbody>
<tfoot>
@* @if (!SingleWeek)
{
<tr class="row">
<td colspan="7" class="col meseAnno">
@($"{DtRif:MMMM yyyy}")
</td>
</tr>
}*@
<tr class="row">
<td colspan="@calcColSpan" class="col meseAnno">
<div class="d-flex justify-content-around">
<button class="containerBtnTemp btn-sm btn-primary" @onclick="()=> changeWeek(-1)"><i class="fa-solid fa-caret-left"></i></button>
<div class="">
@($"{DtRif: MMM yyyy}") | <b>W@($"{weekNum(DtRif):00}")</b>
</div>
<button class="containerBtnTemp btn-sm btn-primary" @onclick="()=> changeWeek(1)"><i class="fa-solid fa-caret-right"></i></button>
</div>
</td>
</tr>
</tfoot>
</table>
}
+68
View File
@@ -2,6 +2,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using GPW.CORE.Data;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Web;
@@ -14,6 +15,11 @@ namespace GPW.CORE.Comp
/// </summary>
[Parameter]
public EventCallback<DateTime> DateSelected { get; set; }
/// <summary>
/// Evento richiesta modifica settimana
/// </summary>
[Parameter]
public EventCallback<int> WeekChanged { get; set; }
/// <summary>
/// Css titolo
@@ -27,5 +33,67 @@ namespace GPW.CORE.Comp
/// </summary>
[Parameter]
public List<DateTime> DateList { get; set; } = new List<DateTime>();
[Parameter]
public int StartHour { get; set; } = 8;
[Parameter]
public int EndHour { get; set; } = 20;
/// <summary>
/// Altezza di ogni blocco ora da mostrare
/// </summary>
[Parameter]
public int HeightHour { get; set; } = 20;
protected DateTime DtRif
{
get
{
DateTime answ = DateTime.Today;
if (DateList != null && DateList.Count > 0)
{
answ = DateList[0];
}
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 List<int> HourSlot = new List<int>();
protected int calcColSpan
{
get => DateList.Count + 1;
}
/// <summary>
/// GetIso8601WeekOfYear
/// </summary>
/// <param name="DtReq"></param>
/// <returns></returns>
protected int weekNum(DateTime DtReq)
{
int wNum = WeekData.GetIso8601WeekOfYear(DtReq);
return wNum;
}
/// <summary>
/// Richiesta cambio sett di riferimento --> riporta evento
/// </summary>
/// <param name="delta"></param>
/// <returns></returns>
protected async Task changeWeek(int delta)
{
await WeekChanged.InvokeAsync(delta);
}
}
}
+1 -1
View File
@@ -8,7 +8,7 @@
margin: 0 1rem 0 1rem;
}
.cssTable td {
padding: 0.6rem 0rem 0.4rem 0rem;
padding: 0.1rem 0rem 0.1rem 0rem;
border: none;
}
.cssTable thead tr {
+1 -1
View File
@@ -10,7 +10,7 @@
}
.cssTable td {
padding: 0.6rem 0rem 0.4rem 0rem;
padding: 0.1rem 0rem 0.1rem 0rem;
border: none;
}
+1 -1
View File
@@ -1 +1 @@
.cssTable{border-radius:12px;width:100%;height:100%;background-color:#34495e;}.cssTable tr{margin:0 1rem 0 1rem;}.cssTable td{padding:.6rem 0 .4rem 0;border:0;}.cssTable thead tr{margin-top:.625rem;}.meseAnno{text-transform:capitalize;color:#fff;}.containerBtnTemp{position:relative;align-items:center;display:flex;justify-content:center;}.selDate{background-color:#e67e22;color:#000;}
.cssTable{border-radius:12px;width:100%;height:100%;background-color:#34495e;}.cssTable tr{margin:0 1rem 0 1rem;}.cssTable td{padding:.1rem 0 .1rem 0;border:0;}.cssTable thead tr{margin-top:.625rem;}.meseAnno{text-transform:capitalize;color:#fff;}.containerBtnTemp{position:relative;align-items:center;display:flex;justify-content:center;}.selDate{background-color:#e67e22;color:#000;}
+1 -1
View File
@@ -1,3 +1,3 @@
@page "/Scratch"
<CalendarWeek DateList="@ListDate"></CalendarWeek>
<CalendarWeek DateList="@ListDate" WeekChanged="ChangeWeek"></CalendarWeek>
+19 -3
View File
@@ -16,22 +16,38 @@ using GPW.CORE.Data.DbModels;
using GPW.CORE.Smart;
using GPW.CORE.Smart.Components;
using GPW.CORE.Smart.Shared;
using Org.BouncyCastle.Ocsp;
namespace GPW.CORE.Smart.Pages
{
public partial class Scratch
{
protected DateTime DtReq { get; set; } = DateTime.Today;
protected List<DateTime> ListDate = new List<DateTime>();
protected override async Task OnInitializedAsync()
{
await reloadData();
}
private async Task reloadData()
{
ListDate = new List<DateTime>();
DateTime oggi = DateTime.Today;
int nWeek = oggi.DayOfWeek - DayOfWeek.Monday;
int nWeek = DtReq.DayOfWeek - DayOfWeek.Monday;
for (int i = 0; i < 7; i++)
{
ListDate.Add(oggi.AddDays(i - nWeek));
ListDate.Add(DtReq.AddDays(i - nWeek));
}
await Task.Delay(1);
}
protected async Task ChangeWeek(int numWeek)
{
ListDate = new List<DateTime>();
await Task.Delay(1);
DtReq = DtReq.AddDays(7 * numWeek);
await reloadData();
await Task.Delay(1);
}
}
}