[mod] weekview:Korrekter Jahresübergang
This commit is contained in:
parent
45f0135056
commit
f1a5e37feb
|
|
@ -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(
|
await _dali.backend.initialize(
|
||||||
_dali.conf.get()["backend"]
|
_dali.conf.get()["backend"]
|
||||||
);
|
);
|
||||||
|
// init:general cache
|
||||||
|
lib_plankton.cache.init(_dali.general_cache);
|
||||||
// init:model
|
// init:model
|
||||||
await _dali.model.initialize(
|
await _dali.model.initialize(
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -52,6 +52,11 @@ namespace _dali.widgets
|
||||||
private value : int;
|
private value : int;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
private dom_root : (null | HTMLElement);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
public constructor(
|
public constructor(
|
||||||
|
|
@ -80,6 +85,19 @@ namespace _dali.widgets
|
||||||
this.maximum = maximum;
|
this.maximum = maximum;
|
||||||
this.value = initial_value;
|
this.value = initial_value;
|
||||||
this.action_change = action_change;
|
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);
|
target_element.appendChild(dom_root);
|
||||||
|
this.dom_root = dom_root;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -713,7 +713,17 @@ namespace _dali.widgets
|
||||||
const dom_th = document.createElement("th");
|
const dom_th = document.createElement("th");
|
||||||
dom_th.classList.add("weekview-cell");
|
dom_th.classList.add("weekview-cell");
|
||||||
dom_th.classList.add("weekview-cell-day");
|
dom_th.classList.add("weekview-cell-day");
|
||||||
dom_th.textContent = (this.week + offset).toFixed(0).padStart(2, "0");
|
// const week : int = (this.week + offset);
|
||||||
|
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);
|
dom_tr.appendChild(dom_th);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
@ -878,42 +888,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
|
// 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"),
|
"label": lib_plankton.translate.get("widget.weekview.controls.year"),
|
||||||
"minimum": 1900,
|
"minimum": 1900,
|
||||||
"maximum": 2500,
|
"maximum": 2500,
|
||||||
"initial_value": this.year,
|
"initial_value": this.year,
|
||||||
"action_change": async (value) => {
|
"action_change": async (year_raw) => {
|
||||||
this.year = value;
|
// 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_table();
|
||||||
await this.update_entries();
|
await this.update_entries();
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
await widget.load(target_element.querySelector(".weekview-controls"));
|
await input_year.load(target_element.querySelector(".weekview-controls"));
|
||||||
}
|
}
|
||||||
// control:week
|
// 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"),
|
"label": lib_plankton.translate.get("widget.weekview.controls.week"),
|
||||||
"minimum": 1,
|
|
||||||
/**
|
|
||||||
* @todo correct
|
|
||||||
*/
|
|
||||||
"maximum": 53,
|
|
||||||
"initial_value": this.week,
|
"initial_value": this.week,
|
||||||
"action_change": async (value) => {
|
"action_change": async (week_raw) => {
|
||||||
this.week = value;
|
// 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_table();
|
||||||
await this.update_entries();
|
await this.update_entries();
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
await widget.load(target_element.querySelector(".weekview-controls"));
|
await input_week.load(target_element.querySelector(".weekview-controls"));
|
||||||
}
|
}
|
||||||
// control:count
|
// control:count
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue