From ba89ff0726fb3108a9a8a89bf1fe3fad04580ae4 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Thu, 19 Jan 2023 12:59:48 +0100 Subject: [PATCH] ok cambio settimana calendario --- GPW.CORE.Comp/CalendarWeek.razor | 69 ++++++++++-------------- GPW.CORE.Comp/CalendarWeek.razor.cs | 68 +++++++++++++++++++++++ GPW.CORE.Comp/CalendarWeek.razor.css | 2 +- GPW.CORE.Comp/CalendarWeek.razor.less | 2 +- GPW.CORE.Comp/CalendarWeek.razor.min.css | 2 +- GPW.CORE.SMART/Pages/Scratch.razor | 2 +- GPW.CORE.SMART/Pages/Scratch.razor.cs | 22 ++++++-- 7 files changed, 119 insertions(+), 48 deletions(-) diff --git a/GPW.CORE.Comp/CalendarWeek.razor b/GPW.CORE.Comp/CalendarWeek.razor index 4263315..80ef279 100644 --- a/GPW.CORE.Comp/CalendarWeek.razor +++ b/GPW.CORE.Comp/CalendarWeek.razor @@ -7,60 +7,47 @@ else - @for (int i = 0; i < 7; i++) + + @foreach (var item in DateList) { } - @* - @if (SingleWeek) - { - - @foreach (var giorno in SingleWeekRow) - { - - } - - } - else - { - @foreach (var settim in WeekRows) - { - - @foreach (var giorno in settim) - { - - } - - } - }*@ + + @foreach (var ora in HourSlot) + { + + + @foreach (var item in DateList) + { + + } + + } - @* @if (!SingleWeek) - { - - - - }*@ + + +
- @($"{DateList[i]:ddd}".Substring(0, 1).ToUpper()) + @($"{item:ddd}".Substring(0, 1).ToUpper())
- @($"{DateList[i]:dd}") + @($"{item:dd}")
- - @($"{giorno:dd}") - -
- - @($"{giorno:dd}") - -
+ @($"{ora:00}:00") + .
- @($"{DtRif:MMMM yyyy}") -
+
+ +
+ @($"{DtRif: MMM yyyy}") | W@($"{weekNum(DtRif):00}") +
+ +
+
} diff --git a/GPW.CORE.Comp/CalendarWeek.razor.cs b/GPW.CORE.Comp/CalendarWeek.razor.cs index 8900a66..c116255 100644 --- a/GPW.CORE.Comp/CalendarWeek.razor.cs +++ b/GPW.CORE.Comp/CalendarWeek.razor.cs @@ -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 /// [Parameter] public EventCallback DateSelected { get; set; } + /// + /// Evento richiesta modifica settimana + /// + [Parameter] + public EventCallback WeekChanged { get; set; } /// /// Css titolo @@ -27,5 +33,67 @@ namespace GPW.CORE.Comp /// [Parameter] public List DateList { get; set; } = new List(); + + + [Parameter] + public int StartHour { get; set; } = 8; + + [Parameter] + public int EndHour { get; set; } = 20; + + /// + /// Altezza di ogni blocco ora da mostrare + /// + [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(); + for (int i = StartHour; i <= EndHour; i++) + { + HourSlot.Add(i); + } + await InvokeAsync(StateHasChanged); + } + + protected List HourSlot = new List(); + protected int calcColSpan + { + get => DateList.Count + 1; + } + /// + /// GetIso8601WeekOfYear + /// + /// + /// + protected int weekNum(DateTime DtReq) + { + int wNum = WeekData.GetIso8601WeekOfYear(DtReq); + return wNum; + } + + /// + /// Richiesta cambio sett di riferimento --> riporta evento + /// + /// + /// + protected async Task changeWeek(int delta) + { + await WeekChanged.InvokeAsync(delta); + } } } \ No newline at end of file diff --git a/GPW.CORE.Comp/CalendarWeek.razor.css b/GPW.CORE.Comp/CalendarWeek.razor.css index e41e55d..2485d20 100644 --- a/GPW.CORE.Comp/CalendarWeek.razor.css +++ b/GPW.CORE.Comp/CalendarWeek.razor.css @@ -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 { diff --git a/GPW.CORE.Comp/CalendarWeek.razor.less b/GPW.CORE.Comp/CalendarWeek.razor.less index ef7e4b7..296afb5 100644 --- a/GPW.CORE.Comp/CalendarWeek.razor.less +++ b/GPW.CORE.Comp/CalendarWeek.razor.less @@ -10,7 +10,7 @@ } .cssTable td { - padding: 0.6rem 0rem 0.4rem 0rem; + padding: 0.1rem 0rem 0.1rem 0rem; border: none; } diff --git a/GPW.CORE.Comp/CalendarWeek.razor.min.css b/GPW.CORE.Comp/CalendarWeek.razor.min.css index 4817159..15b6536 100644 --- a/GPW.CORE.Comp/CalendarWeek.razor.min.css +++ b/GPW.CORE.Comp/CalendarWeek.razor.min.css @@ -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;} \ No newline at end of file +.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;} \ No newline at end of file diff --git a/GPW.CORE.SMART/Pages/Scratch.razor b/GPW.CORE.SMART/Pages/Scratch.razor index c60a605..ceab53d 100644 --- a/GPW.CORE.SMART/Pages/Scratch.razor +++ b/GPW.CORE.SMART/Pages/Scratch.razor @@ -1,3 +1,3 @@ @page "/Scratch" - + diff --git a/GPW.CORE.SMART/Pages/Scratch.razor.cs b/GPW.CORE.SMART/Pages/Scratch.razor.cs index f9cbaba..039c377 100644 --- a/GPW.CORE.SMART/Pages/Scratch.razor.cs +++ b/GPW.CORE.SMART/Pages/Scratch.razor.cs @@ -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 ListDate = new List(); protected override async Task OnInitializedAsync() + { + await reloadData(); + } + + private async Task reloadData() { ListDate = new List(); - 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(); + await Task.Delay(1); + DtReq = DtReq.AddDays(7 * numWeek); + await reloadData(); + await Task.Delay(1); + + } } } \ No newline at end of file