[int]
This commit is contained in:
parent
cfdfb96d7d
commit
4b3c0beb93
13 changed files with 132 additions and 143 deletions
35
lib/plankton/plankton.d.ts
vendored
35
lib/plankton/plankton.d.ts
vendored
|
@ -2689,6 +2689,41 @@ declare namespace lib_plankton.zoo_input {
|
||||||
}
|
}
|
||||||
export {};
|
export {};
|
||||||
}
|
}
|
||||||
|
declare namespace lib_plankton.zoo_input {
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
class class_input_set implements lib_plankton.zoo_input.interface_input<Set<string>> {
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
private options;
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
private show_element;
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
private read_only;
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
private checkboxes;
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
constructor(options: Array<string>, show_element: ((element: string) => string), { "read_only": read_only, }?: {
|
||||||
|
read_only?: boolean;
|
||||||
|
});
|
||||||
|
/**
|
||||||
|
* [implementation]
|
||||||
|
*/
|
||||||
|
setup(parent: HTMLElement): Promise<void>;
|
||||||
|
/**
|
||||||
|
* [implementation]
|
||||||
|
*/
|
||||||
|
read(): Promise<Set<string>>;
|
||||||
|
/**
|
||||||
|
* [implementation]
|
||||||
|
*/
|
||||||
|
write(value: Set<string>): Promise<void>;
|
||||||
|
}
|
||||||
|
}
|
||||||
declare namespace lib_plankton.zoo_input {
|
declare namespace lib_plankton.zoo_input {
|
||||||
/**
|
/**
|
||||||
* @author fenris
|
* @author fenris
|
||||||
|
|
|
@ -7450,6 +7450,94 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU Lesser General Public License for more details.
|
GNU Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
|
along with »bacterio-plankton:zoo-input«. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
var lib_plankton;
|
||||||
|
(function (lib_plankton) {
|
||||||
|
var zoo_input;
|
||||||
|
(function (zoo_input) {
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
class class_input_set {
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
constructor(options, show_element, { "read_only": read_only = false, } = {}) {
|
||||||
|
this.show_element = show_element;
|
||||||
|
this.options = options;
|
||||||
|
this.read_only = read_only;
|
||||||
|
this.checkboxes = new Map();
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* [implementation]
|
||||||
|
*/
|
||||||
|
setup(parent) {
|
||||||
|
for (const option of this.options) {
|
||||||
|
// label
|
||||||
|
const element_container = document.createElement("label");
|
||||||
|
element_container.classList.add("plankton_input_set_option");
|
||||||
|
element_container.setAttribute("rel", option);
|
||||||
|
// checkbox
|
||||||
|
{
|
||||||
|
const element_checkbox = document.createElement("input");
|
||||||
|
element_checkbox.setAttribute("type", "checkbox");
|
||||||
|
(this.read_only && element_checkbox.setAttribute("disabled", "disabled"));
|
||||||
|
element_container.appendChild(element_checkbox);
|
||||||
|
this.checkboxes.set(option, element_checkbox);
|
||||||
|
}
|
||||||
|
// text
|
||||||
|
{
|
||||||
|
const element_text = document.createElement("span");
|
||||||
|
element_text.textContent = this.show_element(option);
|
||||||
|
element_container.appendChild(element_text);
|
||||||
|
}
|
||||||
|
parent.appendChild(element_container);
|
||||||
|
}
|
||||||
|
return Promise.resolve(undefined);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* [implementation]
|
||||||
|
*/
|
||||||
|
read() {
|
||||||
|
const result = new Set();
|
||||||
|
for (const option of this.options) {
|
||||||
|
const element_checkbox = this.checkboxes.get(option);
|
||||||
|
if (element_checkbox.checked) {
|
||||||
|
result.add(option);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Promise.resolve(result);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* [implementation]
|
||||||
|
*/
|
||||||
|
write(value) {
|
||||||
|
for (const option of this.options) {
|
||||||
|
const element_checkbox = this.checkboxes.get(option);
|
||||||
|
element_checkbox.checked = value.has(option);
|
||||||
|
}
|
||||||
|
return Promise.resolve(undefined);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
zoo_input.class_input_set = class_input_set;
|
||||||
|
})(zoo_input = lib_plankton.zoo_input || (lib_plankton.zoo_input = {}));
|
||||||
|
})(lib_plankton || (lib_plankton = {}));
|
||||||
|
/*
|
||||||
|
This file is part of »bacterio-plankton:zoo-input«.
|
||||||
|
|
||||||
|
Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR'
|
||||||
|
<info@greenscale.de>
|
||||||
|
|
||||||
|
»bacterio-plankton:zoo-input« is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
»bacterio-plankton:zoo-input« 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 Lesser General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public License
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
along with »bacterio-plankton:zoo-input«. If not, see <http://www.gnu.org/licenses/>.
|
along with »bacterio-plankton:zoo-input«. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,133 +0,0 @@
|
||||||
/*
|
|
||||||
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/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace _espe
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @todo outsource to plankton
|
|
||||||
*/
|
|
||||||
export class class_input_set implements lib_plankton.zoo_input.interface_input<Set<string>>
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
private options : Array<string>;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
private show_element : ((element : string) => string);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
private read_only : boolean;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
private checkboxes : Map<string, HTMLInputElement>;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
public constructor(
|
|
||||||
options : Array<string>,
|
|
||||||
show_element : ((element : string) => string),
|
|
||||||
{
|
|
||||||
"read_only": read_only = false,
|
|
||||||
} : {
|
|
||||||
read_only ?: boolean;
|
|
||||||
} = {
|
|
||||||
}
|
|
||||||
)
|
|
||||||
{
|
|
||||||
this.show_element = show_element;
|
|
||||||
this.options = options;
|
|
||||||
this.read_only = read_only;
|
|
||||||
this.checkboxes = new Map<string, HTMLInputElement>();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* [implementation]
|
|
||||||
*/
|
|
||||||
public setup(
|
|
||||||
parent : HTMLElement
|
|
||||||
) : Promise<void>
|
|
||||||
{
|
|
||||||
for (const option of this.options)
|
|
||||||
{
|
|
||||||
// label
|
|
||||||
const element_container : HTMLElement = document.createElement("label");
|
|
||||||
element_container.classList.add("plankton_input_set_option");
|
|
||||||
element_container.setAttribute("rel", option);
|
|
||||||
// checkbox
|
|
||||||
{
|
|
||||||
const element_checkbox : HTMLInputElement = document.createElement("input");
|
|
||||||
element_checkbox.setAttribute("type", "checkbox");
|
|
||||||
(this.read_only && element_checkbox.setAttribute("disabled", "disabled"));
|
|
||||||
element_container.appendChild(element_checkbox);
|
|
||||||
this.checkboxes.set(option, element_checkbox);
|
|
||||||
}
|
|
||||||
// text
|
|
||||||
{
|
|
||||||
const element_text : HTMLElement = document.createElement("span");
|
|
||||||
element_text.textContent = this.show_element(option);
|
|
||||||
element_container.appendChild(element_text);
|
|
||||||
}
|
|
||||||
parent.appendChild(element_container);
|
|
||||||
}
|
|
||||||
return Promise.resolve<void>(undefined);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* [implementation]
|
|
||||||
*/
|
|
||||||
public read(
|
|
||||||
) : Promise<Set<string>>
|
|
||||||
{
|
|
||||||
const result : Set<string> = new Set<string>();
|
|
||||||
for (const option of this.options)
|
|
||||||
{
|
|
||||||
const element_checkbox : HTMLInputElement = this.checkboxes.get(option);
|
|
||||||
if (element_checkbox.checked) {
|
|
||||||
result.add(option);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return Promise.resolve<Set<string>>(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* [implementation]
|
|
||||||
*/
|
|
||||||
public write(
|
|
||||||
value : Set<string>
|
|
||||||
) : Promise<void>
|
|
||||||
{
|
|
||||||
for (const option of this.options)
|
|
||||||
{
|
|
||||||
const element_checkbox : HTMLInputElement = this.checkboxes.get(option);
|
|
||||||
element_checkbox.checked = value.has(option);
|
|
||||||
}
|
|
||||||
return Promise.resolve<void>(undefined);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -177,7 +177,7 @@ lib_plankton.zoo_page.register(
|
||||||
),
|
),
|
||||||
*/
|
*/
|
||||||
"input": new lib_plankton.zoo_input.class_input_wrapped<Set<string>, Array<int>>(
|
"input": new lib_plankton.zoo_input.class_input_wrapped<Set<string>, Array<int>>(
|
||||||
new _espe.class_input_set(
|
new lib_plankton.zoo_input.class_input_set(
|
||||||
group_data.order.map(
|
group_data.order.map(
|
||||||
group_id => group_id.toFixed(0)
|
group_id => group_id.toFixed(0)
|
||||||
),
|
),
|
||||||
|
|
|
@ -161,7 +161,7 @@ lib_plankton.zoo_page.register(
|
||||||
),
|
),
|
||||||
*/
|
*/
|
||||||
"input": new lib_plankton.zoo_input.class_input_wrapped<Set<string>, Array<int>>(
|
"input": new lib_plankton.zoo_input.class_input_wrapped<Set<string>, Array<int>>(
|
||||||
new _espe.class_input_set(
|
new lib_plankton.zoo_input.class_input_set(
|
||||||
group_data.order.map(
|
group_data.order.map(
|
||||||
group_id => group_id.toFixed(0)
|
group_id => group_id.toFixed(0)
|
||||||
),
|
),
|
||||||
|
|
|
@ -236,7 +236,7 @@ lib_plankton.zoo_page.register(
|
||||||
),
|
),
|
||||||
*/
|
*/
|
||||||
"input": new lib_plankton.zoo_input.class_input_wrapped<Set<string>, Array<int>>(
|
"input": new lib_plankton.zoo_input.class_input_wrapped<Set<string>, Array<int>>(
|
||||||
new _espe.class_input_set(
|
new lib_plankton.zoo_input.class_input_set(
|
||||||
groups_as_array.map(
|
groups_as_array.map(
|
||||||
group_thingy => group_thingy.id.toFixed(0)
|
group_thingy => group_thingy.id.toFixed(0)
|
||||||
),
|
),
|
||||||
|
|
|
@ -95,7 +95,7 @@ lib_plankton.zoo_page.register(
|
||||||
),
|
),
|
||||||
*/
|
*/
|
||||||
"input": new lib_plankton.zoo_input.class_input_wrapped<Set<string>, Array<int>>(
|
"input": new lib_plankton.zoo_input.class_input_wrapped<Set<string>, Array<int>>(
|
||||||
new _espe.class_input_set(
|
new lib_plankton.zoo_input.class_input_set(
|
||||||
group_data.order.map(
|
group_data.order.map(
|
||||||
group_id => group_id.toFixed(0)
|
group_id => group_id.toFixed(0)
|
||||||
),
|
),
|
||||||
|
|
|
@ -35,11 +35,10 @@ _default: ${dir_build}/logic.js ${dir_build}/style.css ${dir_build}/index.html d
|
||||||
|
|
||||||
${dir_temp}/logic-unlinked.js: \
|
${dir_temp}/logic-unlinked.js: \
|
||||||
${dir_lib}/plankton/plankton.d.ts \
|
${dir_lib}/plankton/plankton.d.ts \
|
||||||
${dir_source}/logic/helpers.ts \
|
${dir_source}/helpers.ts \
|
||||||
${dir_source}/logic/input_set.ts \
|
|
||||||
${dir_source}/resources/backend.ts \
|
${dir_source}/resources/backend.ts \
|
||||||
${dir_source}/resources/conf.ts \
|
${dir_source}/resources/conf.ts \
|
||||||
${dir_source}/logic/logic.ts \
|
${dir_source}/logic.ts \
|
||||||
${dir_source}/pages/index/logic.ts \
|
${dir_source}/pages/index/logic.ts \
|
||||||
${dir_source}/pages/login/logic.ts \
|
${dir_source}/pages/login/logic.ts \
|
||||||
${dir_source}/pages/logout/logic.ts \
|
${dir_source}/pages/logout/logic.ts \
|
||||||
|
@ -54,7 +53,7 @@ ${dir_temp}/logic-unlinked.js: \
|
||||||
${dir_source}/pages/invitation_view/logic.ts \
|
${dir_source}/pages/invitation_view/logic.ts \
|
||||||
${dir_source}/pages/invitation_create/logic.ts \
|
${dir_source}/pages/invitation_create/logic.ts \
|
||||||
${dir_source}/pages/invitation_handle/logic.ts \
|
${dir_source}/pages/invitation_handle/logic.ts \
|
||||||
${dir_source}/logic/main.ts
|
${dir_source}/main.ts
|
||||||
@ ${cmd_log} "logic | compile …"
|
@ ${cmd_log} "logic | compile …"
|
||||||
@ ${cmd_mkdir} $(dir $@)
|
@ ${cmd_mkdir} $(dir $@)
|
||||||
@ ${cmd_tsc} --lib es2020,dom --target es2015 $^ --outFile $@
|
@ ${cmd_tsc} --lib es2020,dom --target es2015 $^ --outFile $@
|
||||||
|
@ -65,7 +64,7 @@ ${dir_build}/logic.js: ${dir_lib}/plankton/plankton.js ${dir_temp}/logic-unlinke
|
||||||
@ ${cmd_cat} $^ > $@
|
@ ${cmd_cat} $^ > $@
|
||||||
|
|
||||||
${dir_build}/style.css: \
|
${dir_build}/style.css: \
|
||||||
${dir_source}/style/style.css \
|
${dir_source}/style/main.css \
|
||||||
${dir_source}/pages/index/style.css \
|
${dir_source}/pages/index/style.css \
|
||||||
${dir_source}/pages/login/style.css \
|
${dir_source}/pages/login/style.css \
|
||||||
${dir_source}/pages/logout/style.css \
|
${dir_source}/pages/logout/style.css \
|
||||||
|
@ -85,7 +84,7 @@ ${dir_build}/style.css: \
|
||||||
@ ${cmd_cat} $^ > $@
|
@ ${cmd_cat} $^ > $@
|
||||||
|
|
||||||
${dir_build}/index.html: \
|
${dir_build}/index.html: \
|
||||||
${dir_source}/structure/index.html.tpl \
|
${dir_source}/index.html.tpl \
|
||||||
${dir_source}/pages/index/structure.html \
|
${dir_source}/pages/index/structure.html \
|
||||||
${dir_source}/pages/login/structure.html \
|
${dir_source}/pages/login/structure.html \
|
||||||
${dir_source}/pages/logout/structure.html \
|
${dir_source}/pages/logout/structure.html \
|
||||||
|
|
Loading…
Add table
Reference in a new issue