2024-05-20 22:04:23 +02:00
|
|
|
/*
|
|
|
|
Espe | Ein schlichtes Werkzeug zur Mitglieder-Verwaltung | Frontend
|
|
|
|
Copyright (C) 2024 Christian Fraß
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
|
|
|
|
License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later
|
|
|
|
version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
|
|
|
|
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License along with this program. If not, see
|
|
|
|
<https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2024-04-22 10:02:43 +02:00
|
|
|
lib_plankton.zoo_page.register(
|
|
|
|
"create",
|
|
|
|
(parameters, target_element) => {
|
2024-05-02 08:41:10 +02:00
|
|
|
target_element.appendChild(template_request("create"));
|
|
|
|
|
|
|
|
target_element.querySelector(".create-title").textContent = lib_plankton.translate.get("page.create.title");
|
|
|
|
|
2024-04-22 10:02:43 +02:00
|
|
|
const form = new lib_plankton.zoo_form.class_form<
|
|
|
|
{
|
|
|
|
membership_number : string;
|
|
|
|
name_real_value : string;
|
2024-04-30 01:32:40 +02:00
|
|
|
email_address_private : (null | string);
|
2024-04-22 10:02:43 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
membership_number : string;
|
|
|
|
name_real_value : string;
|
2024-04-30 01:32:40 +02:00
|
|
|
email_address_private : string;
|
2024-04-22 10:02:43 +02:00
|
|
|
}
|
|
|
|
>(
|
|
|
|
value => ({
|
|
|
|
"membership_number": value.membership_number,
|
|
|
|
"name_real_value": value.name_real_value,
|
2024-04-30 01:32:40 +02:00
|
|
|
"email_address_private": (value.email_address_private ?? ""),
|
2024-04-22 10:02:43 +02:00
|
|
|
}),
|
|
|
|
representation => ({
|
|
|
|
"membership_number": representation.membership_number,
|
|
|
|
"name_real_value": representation.name_real_value,
|
2024-04-30 01:32:40 +02:00
|
|
|
"email_address_private": representation.email_address_private,
|
2024-04-22 10:02:43 +02:00
|
|
|
}),
|
|
|
|
new lib_plankton.zoo_input.class_input_group(
|
|
|
|
[
|
|
|
|
{
|
2024-04-30 08:46:19 +02:00
|
|
|
"name": "name_real_value",
|
2024-04-22 10:02:43 +02:00
|
|
|
"input": new lib_plankton.zoo_input.class_input_text(),
|
2024-04-30 08:46:19 +02:00
|
|
|
"label": "Echter Name",
|
2024-04-22 10:02:43 +02:00
|
|
|
},
|
|
|
|
{
|
2024-04-30 08:46:19 +02:00
|
|
|
"name": "membership_number",
|
2024-04-22 10:02:43 +02:00
|
|
|
"input": new lib_plankton.zoo_input.class_input_text(),
|
2024-04-30 08:46:19 +02:00
|
|
|
"label": "Mitgliedsnummer",
|
2024-04-22 10:02:43 +02:00
|
|
|
},
|
|
|
|
{
|
2024-04-30 01:32:40 +02:00
|
|
|
"name": "email_address_private",
|
2024-04-22 10:02:43 +02:00
|
|
|
"input": new lib_plankton.zoo_input.class_input_text(),
|
|
|
|
"label": "Private E-Mail-Adresse",
|
|
|
|
},
|
|
|
|
]
|
|
|
|
),
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"label": "Senden",
|
|
|
|
"procedure": async (get_value, get_representation) => {
|
|
|
|
const value = await get_value();
|
2024-06-23 09:54:54 +02:00
|
|
|
const id : int = await _espe.backend.member_project(
|
|
|
|
value,
|
|
|
|
lib_plankton.zoo_page.encode(
|
|
|
|
{
|
|
|
|
"name": "view",
|
|
|
|
"parameters": {
|
|
|
|
"id": "{{id}}",
|
|
|
|
}
|
|
|
|
}
|
|
|
|
)
|
|
|
|
);
|
2024-04-23 23:01:49 +02:00
|
|
|
lib_plankton.zoo_page.set({"name": "view", "parameters": {"id": id}});
|
2024-04-22 10:02:43 +02:00
|
|
|
},
|
|
|
|
}
|
|
|
|
]
|
|
|
|
);
|
2024-05-02 08:41:10 +02:00
|
|
|
form.setup(target_element.querySelector(".create-form") as HTMLElement);
|
2024-04-22 10:02:43 +02:00
|
|
|
}
|
|
|
|
);
|