diff --git a/source/widgets/weekview/logic.ts b/source/widgets/weekview/logic.ts index f9660cf..a717941 100644 --- a/source/widgets/weekview/logic.ts +++ b/source/widgets/weekview/logic.ts @@ -591,8 +591,8 @@ namespace _dali.widgets { type type_row_data = Array< { - week : int; - day_pits : Array; + head : int; + pits : Array; } >; @@ -612,14 +612,23 @@ namespace _dali.widgets lib_plankton.translate.get("common.weekday.saturday"), lib_plankton.translate.get("common.weekday.sunday"), ]; - const row_data_original : type_row_data = ( + const row_data_horizontal : type_row_data = ( lib_plankton.list.sequence(this.count) .map( offset => { const week : int = (this.week + offset); + const week_adjusted : int = lib_plankton.call.convey( + this.week, + [ + x => lib_plankton.pit.from_ywd({"year": this.year, "week": x, "day": 2}), + x => lib_plankton.pit.shift_week(x, offset), + lib_plankton.pit.to_ywd, + x => x.week + ] + ); return { - "week": week, - "day_pits": ( + "head": week_adjusted, + "pits": ( lib_plankton.list.sequence(7) .map( day => lib_plankton.pit.from_ywd( @@ -638,13 +647,13 @@ namespace _dali.widgets } ) ); - const row_data_alternative : type_row_data = ( + const row_data_vertical : type_row_data = ( lib_plankton.list.sequence(7) .map( day_of_week => { return { - /*"day_of_week"*/"week": day_of_week, - /*"week_pits"*/"day_pits": ( + "head": day_of_week, + "pits": ( lib_plankton.list.sequence(this.count) .map( offset => { @@ -669,9 +678,9 @@ namespace _dali.widgets const row_data : type_row_data = ( (! this.vertical) ? - row_data_original + row_data_horizontal : - row_data_alternative + row_data_vertical ); // head { @@ -713,7 +722,6 @@ namespace _dali.widgets const dom_th = document.createElement("th"); dom_th.classList.add("weekview-cell"); dom_th.classList.add("weekview-cell-day"); - // const week : int = (this.week + offset); const week : int = lib_plankton.call.convey( this.week, [ @@ -722,7 +730,7 @@ namespace _dali.widgets lib_plankton.pit.to_ywd, x => x.week ] - ) + ); dom_th.textContent = week.toFixed(0).padStart(2, "0"); dom_tr.appendChild(dom_th); } @@ -746,13 +754,13 @@ namespace _dali.widgets "week": ( (! this.vertical) ? - row.week.toFixed(0).padStart(2, "0") + row.head.toFixed(0).padStart(2, "0") : day_names[index] ), "cells": ( await _dali.helpers.promise_row( - row.day_pits + row.pits .map( (day_pit) => async () => { const is_today : boolean = lib_plankton.pit.is_between(