This commit is contained in:
roydfalk 2025-08-22 16:57:14 +02:00
parent 17f432ab10
commit 9d1a0c856c
13 changed files with 63 additions and 57 deletions

View file

@ -14,14 +14,30 @@ You should have received a copy of the GNU General Public License along with thi
*/ */
/** namespace _espe.helpers
* @todo outsource
*/
function template_request(
id : string
) : DocumentFragment
{ {
let dom_template = document.querySelector("template#" + id);
// return template["content"].cloneNode(true); /**
return (document.importNode(dom_template["content"], true) as DocumentFragment) * @todo outsource
*/
export function template_request(
id : string
) : DocumentFragment
{
let dom_template = document.querySelector("template#" + id);
// return template["content"].cloneNode(true);
return (document.importNode(dom_template["content"], true) as DocumentFragment)
}
/**
* @todo outsource
*/
export function null_when_empty(
str : (null | string)
) : (null | string)
{
return (((str === null) || (str === "")) ? null : str);
}
} }

View file

@ -16,7 +16,7 @@ You should have received a copy of the GNU General Public License along with thi
lib_plankton.zoo_page.register( lib_plankton.zoo_page.register(
"group_create", "group_create",
(parameters, target_element) => { (parameters, target_element) => {
target_element.appendChild(template_request("group_create")); target_element.appendChild(_espe.helpers.template_request("group_create"));
target_element.querySelector(".group_create-title").textContent = lib_plankton.translate.get("page.group_create.title"); target_element.querySelector(".group_create-title").textContent = lib_plankton.translate.get("page.group_create.title");

View file

@ -25,7 +25,7 @@ lib_plankton.zoo_page.register(
}; };
const term : (null | string) = (parameters["term"] ?? ""); const term : (null | string) = (parameters["term"] ?? "");
target_element.appendChild(template_request("group_list")); target_element.appendChild(_espe.helpers.template_request("group_list"));
target_element.querySelector(".group_list-title").textContent = lib_plankton.translate.get("page.group_list.title"); target_element.querySelector(".group_list-title").textContent = lib_plankton.translate.get("page.group_list.title");

View file

@ -18,7 +18,7 @@ lib_plankton.zoo_page.register(
async (parameters, target_element) => { async (parameters, target_element) => {
const id : int = parseInt(parameters["id"]); const id : int = parseInt(parameters["id"]);
let dom_fragment : DocumentFragment = template_request("group_view"); let dom_fragment : DocumentFragment = _espe.helpers.template_request("group_view");
dom_fragment.querySelector(".group_view-title").textContent = lib_plankton.translate.get("page.group_view.title"); dom_fragment.querySelector(".group_view-title").textContent = lib_plankton.translate.get("page.group_view.title");

View file

@ -16,17 +16,12 @@ You should have received a copy of the GNU General Public License along with thi
lib_plankton.zoo_page.register( lib_plankton.zoo_page.register(
"invite_create", "invite_create",
async (parameters, target_element) => { async (parameters, target_element) => {
target_element.appendChild(template_request("invite_create")); target_element.appendChild(_espe.helpers.template_request("invite_create"));
target_element.querySelector(".invite_create-title").textContent = lib_plankton.translate.get("page.invite_create.title"); target_element.querySelector(".invite_create-title").textContent = lib_plankton.translate.get("page.invite_create.title");
const indent = str => (/*"... " + */str); const indent = str => (/*"... " + */str);
/**
* @todo outsource
*/
const null_when_empty = (str) => (((str === null) || (str === "")) ? null : str);
/** /**
* @todo cache * @todo cache
*/ */
@ -131,11 +126,11 @@ lib_plankton.zoo_page.register(
representation => ({ representation => ({
"data": { "data": {
"name_changeable": representation.name.changeable, "name_changeable": representation.name.changeable,
"name_value": null_when_empty(representation.name.value), "name_value": _espe.helpers.null_when_empty(representation.name.value),
"label_changeable": representation.label.changeable, "label_changeable": representation.label.changeable,
"label_value": null_when_empty(representation.label.value), "label_value": _espe.helpers.null_when_empty(representation.label.value),
"email_address_changeable": representation.email_address.changeable, "email_address_changeable": representation.email_address.changeable,
"email_address_value": null_when_empty(representation.email_address.value), "email_address_value": _espe.helpers.null_when_empty(representation.email_address.value),
"groups_changeable": representation.groups.changeable, "groups_changeable": representation.groups.changeable,
"groups_value": representation.groups.value, "groups_value": representation.groups.value,
"expiry": ( "expiry": (
@ -220,7 +215,7 @@ lib_plankton.zoo_page.register(
groups_as_array.map( groups_as_array.map(
group_thingy => group_thingy.id.toFixed(0) group_thingy => group_thingy.id.toFixed(0)
), ),
group_id_encoded => groups_as_map.get(parseInt(group_id_encoded)).name group_id_encoded => groups_as_map.get(parseInt(group_id_encoded)).label
), ),
(value_inner) => { (value_inner) => {
const array : Array<int> = []; const array : Array<int> = [];

View file

@ -38,7 +38,7 @@ lib_plankton.zoo_page.register(
const key : string = parameters["key"]; const key : string = parameters["key"];
update_nav({"mode": null}); update_nav({"mode": null});
target_element.appendChild(template_request("invite_handle")); target_element.appendChild(_espe.helpers.template_request("invite_handle"));
set_state( set_state(
"load", "load",
[ [

View file

@ -31,7 +31,7 @@ lib_plankton.zoo_page.register(
const term : (null | string) = (parameters["term"] ?? ""); const term : (null | string) = (parameters["term"] ?? "");
// exec // exec
target_element.appendChild(template_request("invite_list")); target_element.appendChild(_espe.helpers.template_request("invite_list"));
target_element.querySelector(".invite_list-title").textContent = lib_plankton.translate.get("page.invite_list.title"); target_element.querySelector(".invite_list-title").textContent = lib_plankton.translate.get("page.invite_list.title");

View file

@ -31,17 +31,12 @@ lib_plankton.zoo_page.register(
// parameters // parameters
const id : int = parseInt(parameters["id"]); const id : int = parseInt(parameters["id"]);
target_element.appendChild(template_request("invite_view")); target_element.appendChild(_espe.helpers.template_request("invite_view"));
target_element.querySelector(".invite_view-title").textContent = lib_plankton.translate.get("page.invite_view.title"); target_element.querySelector(".invite_view-title").textContent = lib_plankton.translate.get("page.invite_view.title");
const indent = str => (/*"... " + */str); const indent = str => (/*"... " + */str);
/**
* @todo outsource
*/
const null_when_empty = (str) => (((str === null) || (str === "")) ? null : str);
/** /**
* @todo cache * @todo cache
*/ */
@ -157,7 +152,7 @@ lib_plankton.zoo_page.register(
"label_changeable": representation.label.changeable, "label_changeable": representation.label.changeable,
"label_value": representation.label.value, "label_value": representation.label.value,
"email_address_changeable": representation.email_address.changeable, "email_address_changeable": representation.email_address.changeable,
"email_address_value": null_when_empty(representation.email_address.value), "email_address_value": _espe.helpers.null_when_empty(representation.email_address.value),
"groups_changeable": representation.groups.changeable, "groups_changeable": representation.groups.changeable,
"groups_value": representation.groups.value, "groups_value": representation.groups.value,
"url": "", "url": "",
@ -210,6 +205,24 @@ lib_plankton.zoo_page.register(
), ),
"label": lib_plankton.translate.get("domain.member.label.label"), "label": lib_plankton.translate.get("domain.member.label.label"),
}, },
{
"name": "email_address",
"input": new lib_plankton.zoo_input.class_input_group(
[
{
"name": "value",
"input": new lib_plankton.zoo_input.class_input_text({"read_only": true}),
"label": indent(lib_plankton.translate.get("common.initial_value")),
},
{
"name": "changeable",
"input": new lib_plankton.zoo_input.class_input_checkbox({"read_only": true}),
"label": indent(lib_plankton.translate.get("common.changeable")),
},
]
),
"label": lib_plankton.translate.get("domain.member.email_address.label"),
},
{ {
"name": "groups", "name": "groups",
"input": new lib_plankton.zoo_input.class_input_group( "input": new lib_plankton.zoo_input.class_input_group(
@ -227,7 +240,7 @@ lib_plankton.zoo_page.register(
groups_as_array.map( groups_as_array.map(
group_thingy => group_thingy.id.toFixed(0) group_thingy => group_thingy.id.toFixed(0)
), ),
group_id_encoded => groups_as_map.get(parseInt(group_id_encoded)).name group_id_encoded => groups_as_map.get(parseInt(group_id_encoded)).label
), ),
(value_inner) => { (value_inner) => {
const array : Array<int> = []; const array : Array<int> = [];
@ -250,24 +263,6 @@ lib_plankton.zoo_page.register(
), ),
"label": lib_plankton.translate.get("domain.member.groups.label"), "label": lib_plankton.translate.get("domain.member.groups.label"),
}, },
{
"name": "email_address",
"input": new lib_plankton.zoo_input.class_input_group(
[
{
"name": "value",
"input": new lib_plankton.zoo_input.class_input_text({"read_only": true}),
"label": indent(lib_plankton.translate.get("common.initial_value")),
},
{
"name": "changeable",
"input": new lib_plankton.zoo_input.class_input_checkbox({"read_only": true}),
"label": indent(lib_plankton.translate.get("common.changeable")),
},
]
),
"label": lib_plankton.translate.get("domain.member.email_address.label"),
},
{ {
"name": "expiry", "name": "expiry",
"input": new lib_plankton.zoo_input.class_input_soft( "input": new lib_plankton.zoo_input.class_input_soft(

View file

@ -16,7 +16,7 @@ You should have received a copy of the GNU General Public License along with thi
lib_plankton.zoo_page.register( lib_plankton.zoo_page.register(
"login", "login",
(parameters, target_element) => { (parameters, target_element) => {
target_element.appendChild(template_request("login")); target_element.appendChild(_espe.helpers.template_request("login"));
target_element.querySelector(".login-title").textContent = lib_plankton.translate.get("page.login.title"); target_element.querySelector(".login-title").textContent = lib_plankton.translate.get("page.login.title");

View file

@ -25,7 +25,7 @@ lib_plankton.zoo_page.register(
}; };
const term : (null | string) = (parameters["term"] ?? ""); const term : (null | string) = (parameters["term"] ?? "");
target_element.appendChild(template_request("member_list")); target_element.appendChild(_espe.helpers.template_request("member_list"));
target_element.querySelector(".member_list-title").textContent = lib_plankton.translate.get("page.member_list.title"); target_element.querySelector(".member_list-title").textContent = lib_plankton.translate.get("page.member_list.title");

View file

@ -18,7 +18,7 @@ lib_plankton.zoo_page.register(
async (parameters, target_element) => { async (parameters, target_element) => {
const id : int = parseInt(parameters["id"]); const id : int = parseInt(parameters["id"]);
let dom_fragment : DocumentFragment = template_request("member_view"); let dom_fragment : DocumentFragment = _espe.helpers.template_request("member_view");
dom_fragment.querySelector(".member_view-title").textContent = lib_plankton.translate.get("page.member_view.title"); dom_fragment.querySelector(".member_view-title").textContent = lib_plankton.translate.get("page.member_view.title");
@ -133,7 +133,7 @@ lib_plankton.zoo_page.register(
groups_as_array.map( groups_as_array.map(
group_thingy => group_thingy.id.toFixed(0) group_thingy => group_thingy.id.toFixed(0)
), ),
group_id_encoded => groups_as_map.get(parseInt(group_id_encoded)).name group_id_encoded => groups_as_map.get(parseInt(group_id_encoded)).label
), ),
(value_inner) => { (value_inner) => {
const array : Array<int> = []; const array : Array<int> = [];

View file

@ -38,7 +38,7 @@ lib_plankton.zoo_page.register(
const token : string = parameters.token; const token : string = parameters.token;
update_nav({"mode": null}); update_nav({"mode": null});
target_element.appendChild(template_request("password_change_exec")); target_element.appendChild(_espe.helpers.template_request("password_change_exec"));
target_element.querySelector(".password_change_exec-title").textContent = lib_plankton.translate.get("page.password_change_exec.title"); target_element.querySelector(".password_change_exec-title").textContent = lib_plankton.translate.get("page.password_change_exec.title");
set_state( set_state(
"load", "load",

View file

@ -16,7 +16,7 @@ You should have received a copy of the GNU General Public License along with thi
lib_plankton.zoo_page.register( lib_plankton.zoo_page.register(
"password_change_init", "password_change_init",
(parameters, target_element) => { (parameters, target_element) => {
target_element.appendChild(template_request("password_change_init")); target_element.appendChild(_espe.helpers.template_request("password_change_init"));
target_element.querySelector(".password_change_init-title").textContent = lib_plankton.translate.get("page.password_change_init.title"); target_element.querySelector(".password_change_init-title").textContent = lib_plankton.translate.get("page.password_change_init.title");
target_element.querySelector(".password_change_init-info").textContent = lib_plankton.translate.get("page.password_change_init.info"); target_element.querySelector(".password_change_init-info").textContent = lib_plankton.translate.get("page.password_change_init.info");