[mod] widget:weekview:outsourced backend calls

This commit is contained in:
Fenris Wolf 2024-10-01 22:11:08 +02:00
parent 17e920a2fa
commit 6d0103b721
2 changed files with 42 additions and 14 deletions

View file

@ -65,6 +65,13 @@ namespace _zeitbild.frontend_web.pages.overview
// weekview // weekview
{ {
const widget_weekview = new _zeitbild.frontend_web.widgets.weekview.class_widget_weekview( const widget_weekview = new _zeitbild.frontend_web.widgets.weekview.class_widget_weekview(
(from_pit, to_pit, calendar_ids) => _zeitbild.frontend_web.backend.events(
from_pit,
to_pit,
{
"calendar_ids": calendar_ids,
}
),
{ {
"action_select_day": (date) => { "action_select_day": (date) => {
lib_plankton.zoo_page.set( lib_plankton.zoo_page.set(

View file

@ -1,11 +1,40 @@
namespace _zeitbild.frontend_web.widgets.weekview namespace _zeitbild.frontend_web.widgets.weekview
{ {
/**
*/
type type_entry = {
calendar_id : _zeitbild.frontend_web.type.calendar_id;
calendar_name : string;
access_level : _zeitbild.frontend_web.type.enum_access_level;
event_id : (null | _zeitbild.frontend_web.type.local_resource_event_id);
event_object : _zeitbild.frontend_web.type.event_object;
};
/**
*/
type type_get_entries = (
(
from_pit : lib_plankton.pit.type_pit,
to_pit : lib_plankton.pit.type_pit,
calendar_ids : Array<_zeitbild.frontend_web.type.calendar_id>
)
=>
Promise<Array<type_entry>>
);
/** /**
*/ */
export class class_widget_weekview extends _zeitbild.class_widget export class class_widget_weekview extends _zeitbild.class_widget
{ {
/**
*/
private get_entries : type_get_entries;
/** /**
*/ */
private container : (null | Element); private container : (null | Element);
@ -38,6 +67,7 @@ namespace _zeitbild.frontend_web.widgets.weekview
/** /**
*/ */
public constructor( public constructor(
get_entries : type_get_entries,
options : { options : {
action_select_day ?: ( action_select_day ?: (
( (
@ -66,6 +96,7 @@ namespace _zeitbild.frontend_web.widgets.weekview
options options
); );
super(); super();
this.get_entries = get_entries;
this.container = null; this.container = null;
this.action_select_day = options.action_select_day; this.action_select_day = options.action_select_day;
this.action_select_event = options.action_select_event; this.action_select_event = options.action_select_event;
@ -203,7 +234,7 @@ namespace _zeitbild.frontend_web.widgets.weekview
/** /**
* @todo kein "while" * @todo kein "while"
*/ */
private static async calendar_view_table_data( private async calendar_view_table_data(
calendar_ids : ( calendar_ids : (
null null
| |
@ -271,20 +302,10 @@ namespace _zeitbild.frontend_web.widgets.weekview
); );
// prepare // prepare
const entries : Array< const entries : Array<type_entry> = await this.get_entries(
{
calendar_id : _zeitbild.frontend_web.type.calendar_id;
calendar_name : string;
access_level : _zeitbild.frontend_web.type.enum_access_level;
event_id : (null | _zeitbild.frontend_web.type.local_resource_event_id);
event_object : _zeitbild.frontend_web.type.event_object;
}
> = await _zeitbild.frontend_web.backend.events(
from_pit, from_pit,
to_pit, to_pit,
{ calendar_ids
"calendar_ids": calendar_ids,
}
); );
let result : { let result : {
sources : lib_plankton.map.type_map< sources : lib_plankton.map.type_map<
@ -523,7 +544,7 @@ namespace _zeitbild.frontend_web.widgets.weekview
>; >;
} }
>; >;
} = await class_widget_weekview.calendar_view_table_data( } = await this.calendar_view_table_data(
options.calendar_ids, options.calendar_ids,
options.from, options.from,
options.to, options.to,