diff --git a/lib/plankton/plankton.d.ts b/lib/plankton/plankton.d.ts index b105772..1d88d33 100644 --- a/lib/plankton/plankton.d.ts +++ b/lib/plankton/plankton.d.ts @@ -2689,6 +2689,41 @@ declare namespace lib_plankton.zoo_input { } export {}; } +declare namespace lib_plankton.zoo_input { + /** + */ + class class_input_set implements lib_plankton.zoo_input.interface_input> { + /** + */ + private options; + /** + */ + private show_element; + /** + */ + private read_only; + /** + */ + private checkboxes; + /** + */ + constructor(options: Array, show_element: ((element: string) => string), { "read_only": read_only, }?: { + read_only?: boolean; + }); + /** + * [implementation] + */ + setup(parent: HTMLElement): Promise; + /** + * [implementation] + */ + read(): Promise>; + /** + * [implementation] + */ + write(value: Set): Promise; + } +} declare namespace lib_plankton.zoo_input { /** * @author fenris diff --git a/lib/plankton/plankton.js b/lib/plankton/plankton.js index 90f16cf..bab9870 100644 --- a/lib/plankton/plankton.js +++ b/lib/plankton/plankton.js @@ -7450,6 +7450,94 @@ 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 +along with »bacterio-plankton:zoo-input«. If not, see . + */ +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' + + +»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 along with »bacterio-plankton:zoo-input«. If not, see . */ diff --git a/source/logic/helpers.ts b/source/helpers.ts similarity index 100% rename from source/logic/helpers.ts rename to source/helpers.ts diff --git a/source/structure/index.html.tpl b/source/index.html.tpl similarity index 100% rename from source/structure/index.html.tpl rename to source/index.html.tpl diff --git a/source/logic/logic.ts b/source/logic.ts similarity index 100% rename from source/logic/logic.ts rename to source/logic.ts diff --git a/source/logic/input_set.ts b/source/logic/input_set.ts deleted file mode 100644 index 8ac9f98..0000000 --- a/source/logic/input_set.ts +++ /dev/null @@ -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 -. - */ - -namespace _espe -{ - - /** - * @todo outsource to plankton - */ - export class class_input_set implements lib_plankton.zoo_input.interface_input> - { - - /** - */ - private options : Array; - - - /** - */ - private show_element : ((element : string) => string); - - - /** - */ - private read_only : boolean; - - - /** - */ - private checkboxes : Map; - - - /** - */ - public constructor( - options : Array, - 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(); - } - - - /** - * [implementation] - */ - public setup( - parent : HTMLElement - ) : Promise - { - 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(undefined); - } - - - /** - * [implementation] - */ - public read( - ) : Promise> - { - const result : Set = new Set(); - for (const option of this.options) - { - const element_checkbox : HTMLInputElement = this.checkboxes.get(option); - if (element_checkbox.checked) { - result.add(option); - } - } - return Promise.resolve>(result); - } - - - /** - * [implementation] - */ - public write( - value : Set - ) : Promise - { - for (const option of this.options) - { - const element_checkbox : HTMLInputElement = this.checkboxes.get(option); - element_checkbox.checked = value.has(option); - } - return Promise.resolve(undefined); - } - - } - -} diff --git a/source/logic/main.ts b/source/main.ts similarity index 100% rename from source/logic/main.ts rename to source/main.ts diff --git a/source/pages/invitation_create/logic.ts b/source/pages/invitation_create/logic.ts index 2882d05..83d4ada 100644 --- a/source/pages/invitation_create/logic.ts +++ b/source/pages/invitation_create/logic.ts @@ -177,7 +177,7 @@ lib_plankton.zoo_page.register( ), */ "input": new lib_plankton.zoo_input.class_input_wrapped, Array>( - new _espe.class_input_set( + new lib_plankton.zoo_input.class_input_set( group_data.order.map( group_id => group_id.toFixed(0) ), diff --git a/source/pages/invitation_handle/logic.ts b/source/pages/invitation_handle/logic.ts index 77bae6d..b423377 100644 --- a/source/pages/invitation_handle/logic.ts +++ b/source/pages/invitation_handle/logic.ts @@ -161,7 +161,7 @@ lib_plankton.zoo_page.register( ), */ "input": new lib_plankton.zoo_input.class_input_wrapped, Array>( - new _espe.class_input_set( + new lib_plankton.zoo_input.class_input_set( group_data.order.map( group_id => group_id.toFixed(0) ), diff --git a/source/pages/invitation_view/logic.ts b/source/pages/invitation_view/logic.ts index 443bdf8..af4c1c2 100644 --- a/source/pages/invitation_view/logic.ts +++ b/source/pages/invitation_view/logic.ts @@ -236,7 +236,7 @@ lib_plankton.zoo_page.register( ), */ "input": new lib_plankton.zoo_input.class_input_wrapped, Array>( - new _espe.class_input_set( + new lib_plankton.zoo_input.class_input_set( groups_as_array.map( group_thingy => group_thingy.id.toFixed(0) ), diff --git a/source/pages/member_view/logic.ts b/source/pages/member_view/logic.ts index 6f43dc0..c7021dd 100644 --- a/source/pages/member_view/logic.ts +++ b/source/pages/member_view/logic.ts @@ -95,7 +95,7 @@ lib_plankton.zoo_page.register( ), */ "input": new lib_plankton.zoo_input.class_input_wrapped, Array>( - new _espe.class_input_set( + new lib_plankton.zoo_input.class_input_set( group_data.order.map( group_id => group_id.toFixed(0) ), diff --git a/source/style/style.css b/source/style/main.css similarity index 100% rename from source/style/style.css rename to source/style/main.css diff --git a/tools/makefile b/tools/makefile index e1ffd30..3cb8dce 100644 --- a/tools/makefile +++ b/tools/makefile @@ -35,11 +35,10 @@ _default: ${dir_build}/logic.js ${dir_build}/style.css ${dir_build}/index.html d ${dir_temp}/logic-unlinked.js: \ ${dir_lib}/plankton/plankton.d.ts \ - ${dir_source}/logic/helpers.ts \ - ${dir_source}/logic/input_set.ts \ + ${dir_source}/helpers.ts \ ${dir_source}/resources/backend.ts \ ${dir_source}/resources/conf.ts \ - ${dir_source}/logic/logic.ts \ + ${dir_source}/logic.ts \ ${dir_source}/pages/index/logic.ts \ ${dir_source}/pages/login/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_create/logic.ts \ ${dir_source}/pages/invitation_handle/logic.ts \ - ${dir_source}/logic/main.ts + ${dir_source}/main.ts @ ${cmd_log} "logic | compile …" @ ${cmd_mkdir} $(dir $@) @ ${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} $^ > $@ ${dir_build}/style.css: \ - ${dir_source}/style/style.css \ + ${dir_source}/style/main.css \ ${dir_source}/pages/index/style.css \ ${dir_source}/pages/login/style.css \ ${dir_source}/pages/logout/style.css \ @@ -85,7 +84,7 @@ ${dir_build}/style.css: \ @ ${cmd_cat} $^ > $@ ${dir_build}/index.html: \ - ${dir_source}/structure/index.html.tpl \ + ${dir_source}/index.html.tpl \ ${dir_source}/pages/index/structure.html \ ${dir_source}/pages/login/structure.html \ ${dir_source}/pages/logout/structure.html \