164 lines
4.3 KiB
TypeScript
164 lines
4.3 KiB
TypeScript
![]() |
namespace _zeitbild.frontend_web.pages
|
||
|
{
|
||
|
|
||
|
/**
|
||
|
*/
|
||
|
lib_plankton.zoo_page.register(
|
||
|
"event_add",
|
||
|
async (parameters, target_element) => {
|
||
|
const calendar_id : int = parseInt(parameters["calendar_id"]);
|
||
|
target_element.innerHTML = await _zeitbild.frontend_web.helpers.template_coin(
|
||
|
"event_add",
|
||
|
{
|
||
|
"label": lib_plankton.translate.get("page.event_add.title")
|
||
|
}
|
||
|
);
|
||
|
const form : lib_plankton.zoo_form.class_form<
|
||
|
{
|
||
|
calendar_id : _zeitbild.frontend_web.type.calendar_id;
|
||
|
event_object : _zeitbild.frontend_web.type.event_object;
|
||
|
},
|
||
|
{
|
||
|
calendar_id : string;
|
||
|
name : string;
|
||
|
begin : lib_plankton.pit.type_datetime;
|
||
|
end : (null | lib_plankton.pit.type_datetime);
|
||
|
location : (null | string);
|
||
|
description : (null | string);
|
||
|
}
|
||
|
> = new lib_plankton.zoo_form.class_form<
|
||
|
{
|
||
|
calendar_id : _zeitbild.frontend_web.type.calendar_id;
|
||
|
event_object : _zeitbild.frontend_web.type.event_object;
|
||
|
},
|
||
|
{
|
||
|
calendar_id : string;
|
||
|
name : string;
|
||
|
begin : lib_plankton.pit.type_datetime;
|
||
|
end : (null | lib_plankton.pit.type_datetime);
|
||
|
location : (null | string);
|
||
|
description : (null | string);
|
||
|
}
|
||
|
>(
|
||
|
(value) => ({
|
||
|
"calendar_id": value.calendar_id.toFixed(0),
|
||
|
"name": value.event_object.name,
|
||
|
"begin": value.event_object.begin,
|
||
|
"end": value.event_object.end,
|
||
|
"location": value.event_object.location,
|
||
|
"description": value.event_object.description,
|
||
|
}),
|
||
|
(representation) => ({
|
||
|
"calendar_id": parseInt(representation.calendar_id),
|
||
|
"event_object": {
|
||
|
"name": representation.name,
|
||
|
"begin": representation.begin,
|
||
|
"end": representation.end,
|
||
|
"location": representation.location,
|
||
|
"description": representation.description,
|
||
|
}
|
||
|
}),
|
||
|
new lib_plankton.zoo_input.class_input_group<any>(
|
||
|
[
|
||
|
{
|
||
|
"name": "calendar_id",
|
||
|
"input": new lib_plankton.zoo_input.class_input_selection(
|
||
|
(await _zeitbild.frontend_web.backend.calendar_list())
|
||
|
.filter(
|
||
|
(entry) => (["edit","admin"].includes(entry.access_level))
|
||
|
)
|
||
|
.map(
|
||
|
(entry) => ({
|
||
|
"value": entry.id.toFixed(0),
|
||
|
"label": entry.name,
|
||
|
})
|
||
|
)
|
||
|
),
|
||
|
"label": lib_plankton.translate.get("calendar.calendar")
|
||
|
},
|
||
|
{
|
||
|
"name": "name",
|
||
|
"input": new lib_plankton.zoo_input.class_input_text(
|
||
|
),
|
||
|
"label": lib_plankton.translate.get("event.name")
|
||
|
},
|
||
|
{
|
||
|
"name": "begin",
|
||
|
"input": new lib_plankton.zoo_input.class_input_datetime(
|
||
|
),
|
||
|
"label": lib_plankton.translate.get("event.begin")
|
||
|
},
|
||
|
{
|
||
|
"name": "end",
|
||
|
"input": new lib_plankton.zoo_input.class_input_soft<lib_plankton.pit.type_datetime>(
|
||
|
new lib_plankton.zoo_input.class_input_datetime(
|
||
|
)
|
||
|
),
|
||
|
"label": lib_plankton.translate.get("event.end")
|
||
|
},
|
||
|
{
|
||
|
"name": "location",
|
||
|
"input": new lib_plankton.zoo_input.class_input_soft<string>(
|
||
|
new lib_plankton.zoo_input.class_input_text(
|
||
|
)
|
||
|
),
|
||
|
"label": lib_plankton.translate.get("event.location")
|
||
|
},
|
||
|
{
|
||
|
"name": "description",
|
||
|
"input": new lib_plankton.zoo_input.class_input_soft<string>(
|
||
|
new lib_plankton.zoo_input.class_input_text(
|
||
|
)
|
||
|
),
|
||
|
"label": lib_plankton.translate.get("event.description")
|
||
|
},
|
||
|
]
|
||
|
),
|
||
|
[
|
||
|
{
|
||
|
"label": lib_plankton.translate.get("page.event_add.actions.do"),
|
||
|
"target": "submit",
|
||
|
"procedure": async (get_value, get_representation) => {
|
||
|
const value : any = await get_value();
|
||
|
try {
|
||
|
await _zeitbild.frontend_web.backend.calendar_event_add(
|
||
|
value.calendar_id,
|
||
|
value.event_object
|
||
|
);
|
||
|
lib_plankton.zoo_page.set(
|
||
|
{
|
||
|
"name": "events",
|
||
|
"parameters": {}
|
||
|
}
|
||
|
);
|
||
|
}
|
||
|
catch (error) {
|
||
|
// do nothing
|
||
|
/*
|
||
|
lib_plankton.zoo_page.set(
|
||
|
{
|
||
|
"name": "event_add",
|
||
|
"parameters": {
|
||
|
}
|
||
|
}
|
||
|
);
|
||
|
*/
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
]
|
||
|
);
|
||
|
/*
|
||
|
await form.write(
|
||
|
{
|
||
|
"calendar_id": parameters["calendar_id"],
|
||
|
}
|
||
|
);
|
||
|
*/
|
||
|
await form.setup(document.querySelector("#event_add_form"));
|
||
|
return Promise.resolve<void>(undefined);
|
||
|
}
|
||
|
);
|
||
|
|
||
|
}
|