Merge branch 'main' of pv-svartalfheim-git:zeitbild/frontend-dali
This commit is contained in:
commit
81a8c6e52b
11
lib/plankton/plankton.d.ts
vendored
11
lib/plankton/plankton.d.ts
vendored
|
|
@ -1,11 +1,11 @@
|
|||
/**
|
||||
* @author fenris
|
||||
*/
|
||||
type int = number;
|
||||
declare type int = number;
|
||||
/**
|
||||
* @author fenris
|
||||
*/
|
||||
type float = number;
|
||||
declare type float = number;
|
||||
declare class Buffer {
|
||||
constructor(x: string, modifier?: string);
|
||||
toString(modifier?: string): string;
|
||||
|
|
@ -19,7 +19,7 @@ declare namespace lib_plankton.base {
|
|||
/**
|
||||
* @author fenris
|
||||
*/
|
||||
type type_pseudopointer<type_value> = {
|
||||
declare type type_pseudopointer<type_value> = {
|
||||
value: type_value;
|
||||
};
|
||||
/**
|
||||
|
|
@ -2002,7 +2002,7 @@ declare namespace lib_plankton.storage.memory {
|
|||
clear(): Promise<void>;
|
||||
write(key: any, value: any): Promise<boolean>;
|
||||
delete(key: any): Promise<void>;
|
||||
read(key: any): Promise<Awaited<type_item>>;
|
||||
read(key: any): Promise<type_item>;
|
||||
search(term: any): Promise<{
|
||||
key: string;
|
||||
preview: string;
|
||||
|
|
@ -3861,6 +3861,9 @@ declare namespace lib_plankton.pit {
|
|||
function to_ywd(pit: type_pit, { "timezone_shift": option_timezone_shift, }?: {
|
||||
timezone_shift?: int;
|
||||
}): type_ywd;
|
||||
/**
|
||||
*/
|
||||
function number_of_weeks(year: int): int;
|
||||
/**
|
||||
* computes the point in time for switching to central european summer time
|
||||
*
|
||||
|
|
|
|||
|
|
@ -2241,7 +2241,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|||
function verb(n) { return function (v) { return step([n, v]); }; }
|
||||
function step(op) {
|
||||
if (f) throw new TypeError("Generator is already executing.");
|
||||
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
||||
while (_) try {
|
||||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
||||
if (y = 0, t) op = [op[0] & 2, t.value];
|
||||
switch (op[0]) {
|
||||
|
|
@ -9970,12 +9970,6 @@ var lib_plankton;
|
|||
* @author fenris
|
||||
*/
|
||||
class class_relation {
|
||||
/**
|
||||
* @author fenris
|
||||
*/
|
||||
check(value, reference) {
|
||||
return this.predicate(value, reference);
|
||||
}
|
||||
/**
|
||||
* @author fenris
|
||||
*/
|
||||
|
|
@ -9985,6 +9979,12 @@ var lib_plankton;
|
|||
this.name = name;
|
||||
this.predicate = predicate;
|
||||
}
|
||||
/**
|
||||
* @author fenris
|
||||
*/
|
||||
check(value, reference) {
|
||||
return this.predicate(value, reference);
|
||||
}
|
||||
/**
|
||||
* @author fenris
|
||||
*/
|
||||
|
|
@ -11654,6 +11654,17 @@ var lib_plankton;
|
|||
]);
|
||||
}
|
||||
pit_1.to_ywd = to_ywd;
|
||||
/**
|
||||
*/
|
||||
function number_of_weeks(year) {
|
||||
return lib_plankton.call.convey(year, [
|
||||
x => from_ywd({ "year": (x + 1), "week": 1, "day": 6 }),
|
||||
x => shift_week(x, -1),
|
||||
to_ywd,
|
||||
x => x.week,
|
||||
]);
|
||||
}
|
||||
pit_1.number_of_weeks = number_of_weeks;
|
||||
/**
|
||||
* computes the point in time for switching to central european summer time
|
||||
*
|
||||
|
|
@ -11740,7 +11751,8 @@ var lib_plankton;
|
|||
"time": ((datetime.time === null)
|
||||
?
|
||||
null
|
||||
: datetime_shifted.time)
|
||||
:
|
||||
datetime_shifted.time)
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -145,4 +145,37 @@ namespace _dali
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
export var general_cache : lib_plankton.cache.type_subject<unknown> = lib_plankton.cache.make<unknown>(
|
||||
/*
|
||||
lib_plankton.storage.memory.implementation_chest(
|
||||
{
|
||||
}
|
||||
)
|
||||
*/
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
export async function number_of_weeks(
|
||||
year : int
|
||||
) : Promise<int>
|
||||
{
|
||||
const value_raw : unknown = await lib_plankton.cache.get<unknown>(
|
||||
_dali.general_cache,
|
||||
lib_plankton.string.coin(
|
||||
"number_of_weeks_{{year}}",
|
||||
{
|
||||
"year": year.toFixed(0),
|
||||
}
|
||||
),
|
||||
null,
|
||||
() => Promise.resolve<int>(lib_plankton.pit.number_of_weeks(year))
|
||||
);
|
||||
return (value_raw as int);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -80,6 +80,8 @@ namespace _dali
|
|||
await _dali.backend.initialize(
|
||||
_dali.conf.get()["backend"]
|
||||
);
|
||||
// init:general cache
|
||||
lib_plankton.cache.init(_dali.general_cache);
|
||||
// init:model
|
||||
await _dali.model.initialize(
|
||||
);
|
||||
|
|
|
|||
|
|
@ -52,6 +52,11 @@ namespace _dali.widgets
|
|||
private value : int;
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
private dom_root : (null | HTMLElement);
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
public constructor(
|
||||
|
|
@ -80,6 +85,19 @@ namespace _dali.widgets
|
|||
this.maximum = maximum;
|
||||
this.value = initial_value;
|
||||
this.action_change = action_change;
|
||||
this.dom_root = null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
public set_value(
|
||||
value : int
|
||||
) : void
|
||||
{
|
||||
this.value = value;
|
||||
const dom_input : HTMLInputElement = (this.dom_root.querySelector(".widget-special_number_input-input") as HTMLInputElement);
|
||||
dom_input.value = value.toFixed(0);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -160,6 +178,7 @@ namespace _dali.widgets
|
|||
}
|
||||
|
||||
target_element.appendChild(dom_root);
|
||||
this.dom_root = dom_root;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -627,8 +627,8 @@ namespace _dali.widgets
|
|||
{
|
||||
type type_row_data = Array<
|
||||
{
|
||||
week : int;
|
||||
day_pits : Array<lib_plankton.pit.type_pit>;
|
||||
head : int;
|
||||
pits : Array<lib_plankton.pit.type_pit>;
|
||||
}
|
||||
>;
|
||||
|
||||
|
|
@ -648,14 +648,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(
|
||||
|
|
@ -674,13 +683,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 => {
|
||||
|
|
@ -705,9 +714,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
|
||||
{
|
||||
|
|
@ -749,7 +758,16 @@ namespace _dali.widgets
|
|||
const dom_th = document.createElement("th");
|
||||
dom_th.classList.add("weekview-cell");
|
||||
dom_th.classList.add("weekview-cell-day");
|
||||
dom_th.textContent = (this.week + offset).toFixed(0).padStart(2, "0");
|
||||
const week : 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
|
||||
]
|
||||
);
|
||||
dom_th.textContent = week.toFixed(0).padStart(2, "0");
|
||||
dom_tr.appendChild(dom_th);
|
||||
}
|
||||
);
|
||||
|
|
@ -772,13 +790,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<string>(
|
||||
row.day_pits
|
||||
row.pits
|
||||
.map(
|
||||
(day_pit) => async () => {
|
||||
const is_today : boolean = lib_plankton.pit.is_between(
|
||||
|
|
@ -914,42 +932,75 @@ namespace _dali.widgets
|
|||
{
|
||||
}
|
||||
);
|
||||
let input_year : _dali.widgets.class_widget_special_number_input;
|
||||
let input_week : _dali.widgets.class_widget_special_number_input;
|
||||
// control:year
|
||||
{
|
||||
const widget : lib_plankton.zoo_widget.interface_widget = new _dali.widgets.class_widget_special_number_input(
|
||||
input_year = new _dali.widgets.class_widget_special_number_input(
|
||||
{
|
||||
"label": lib_plankton.translate.get("widget.weekview.controls.year"),
|
||||
"minimum": 1900,
|
||||
"maximum": 2500,
|
||||
"initial_value": this.year,
|
||||
"action_change": async (value) => {
|
||||
this.year = value;
|
||||
"action_change": async (year_raw) => {
|
||||
// model
|
||||
const number_of_weeks : int = await _dali.number_of_weeks(year_raw);
|
||||
if (this.week > number_of_weeks)
|
||||
{
|
||||
this.year = year_raw;
|
||||
this.week = number_of_weeks;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.year = year_raw;
|
||||
// this.week = this.week;
|
||||
}
|
||||
|
||||
// view
|
||||
input_week.set_value(this.week);
|
||||
await this.update_table();
|
||||
await this.update_entries();
|
||||
},
|
||||
}
|
||||
);
|
||||
await widget.load(target_element.querySelector(".weekview-controls"));
|
||||
await input_year.load(target_element.querySelector(".weekview-controls"));
|
||||
}
|
||||
// control:week
|
||||
{
|
||||
const widget : lib_plankton.zoo_widget.interface_widget = new _dali.widgets.class_widget_special_number_input(
|
||||
input_week = new _dali.widgets.class_widget_special_number_input(
|
||||
{
|
||||
"label": lib_plankton.translate.get("widget.weekview.controls.week"),
|
||||
"minimum": 1,
|
||||
/**
|
||||
* @todo correct
|
||||
*/
|
||||
"maximum": 53,
|
||||
"initial_value": this.week,
|
||||
"action_change": async (value) => {
|
||||
this.week = value;
|
||||
"action_change": async (week_raw) => {
|
||||
// model
|
||||
if (week_raw < 1)
|
||||
{
|
||||
this.year = (this.year - 1);
|
||||
this.week = await _dali.number_of_weeks(this.year);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (week_raw > await _dali.number_of_weeks(this.year))
|
||||
{
|
||||
this.year = (this.year + 1);
|
||||
this.week = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
// this.year = this.year;
|
||||
this.week = week_raw;
|
||||
}
|
||||
}
|
||||
|
||||
// view
|
||||
input_year.set_value(this.year);
|
||||
input_week.set_value(this.week);
|
||||
await this.update_table();
|
||||
await this.update_entries();
|
||||
},
|
||||
}
|
||||
);
|
||||
await widget.load(target_element.querySelector(".weekview-controls"));
|
||||
await input_week.load(target_element.querySelector(".weekview-controls"));
|
||||
}
|
||||
// control:count
|
||||
/*
|
||||
|
|
|
|||
Loading…
Reference in a new issue