From f97c33de1e5b16bd0b1ebf37491f3bbede1ca246 Mon Sep 17 00:00:00 2001 From: Fenris Wolf Date: Wed, 22 Oct 2025 00:41:22 +0200 Subject: [PATCH] [int] --- lib/plankton/plankton.d.ts | 353 ++++++++---- lib/plankton/plankton.js | 771 +++++++++++++++++--------- source/pages/overview/logic.ts | 181 +++--- source/widgets/calendar_edit/logic.ts | 38 +- source/widgets/event_edit/logic.ts | 4 +- source/widgets/sources/logic.ts | 30 +- 6 files changed, 860 insertions(+), 517 deletions(-) diff --git a/lib/plankton/plankton.d.ts b/lib/plankton/plankton.d.ts index 09b58dd..30c6b9f 100644 --- a/lib/plankton/plankton.d.ts +++ b/lib/plankton/plankton.d.ts @@ -226,9 +226,10 @@ declare namespace lib_plankton.base { function object_merge(core: Record, mantle: Record): Record; /** */ - function buffer_show(buffer: Buffer, { "block_size": option_block_size, "break_char": option_break_char, }?: { + function buffer_show(buffer: Buffer, { "block_size": option_block_size, "break_char": option_break_char, "render_readable_characters": render_readable_characters, }?: { block_size?: int; break_char?: string; + render_readable_characters?: boolean; }): string; } declare module lib_plankton.pod { @@ -4224,6 +4225,59 @@ declare namespace lib_plankton.zoo_input { /** */ write(value: type_value): Promise; + /** + */ + lock(mode: boolean): Promise; + /** + */ + hook_change(action: (() => void)): Promise; + } +} +declare namespace lib_plankton.zoo_input { + /** + * @author fenris + */ + abstract class class_input_simple implements interface_input { + /** + */ + private dom_input; + /** + */ + private type; + /** + */ + private decode; + /** + */ + private encode; + /** + */ + private additional_attributes?; + /** + */ + constructor(type: string, decode: ((representation: string) => type_value), encode: ((value: type_value) => string), { "additional_attributes": additional_attributes, }?: { + additional_attributes?: Record; + }); + /** + * [implementation] + */ + setup(parent: HTMLElement): Promise; + /** + * [implementation] + */ + read(): Promise; + /** + * [implementation] + */ + write(value: type_value): Promise; + /** + * [implementation] + */ + lock(mode: boolean): Promise; + /** + * [implementation] + */ + hook_change(action: (() => void)): Promise; } } declare namespace lib_plankton.zoo_input { @@ -4255,6 +4309,14 @@ declare namespace lib_plankton.zoo_input { * [implementation] */ write(value: type_value_outer): Promise; + /** + * [implementation] + */ + lock(mode: boolean): Promise; + /** + * [implementation] + */ + hook_change(action: (() => void)): Promise; } } declare namespace lib_plankton.zoo_input { @@ -4262,6 +4324,9 @@ declare namespace lib_plankton.zoo_input { * @author fenris */ class class_input_soft implements interface_input<(null | type_value_core)> { + /** + */ + private read_only; /** */ private core; @@ -4273,7 +4338,9 @@ declare namespace lib_plankton.zoo_input { private dom_wrapper; /** */ - constructor(core: interface_input, options?: {}); + constructor(core: interface_input, { "read_only": read_only, }?: { + read_only?: boolean; + }); /** */ private toggle; @@ -4289,6 +4356,14 @@ declare namespace lib_plankton.zoo_input { * [implementation] */ write(value: (null | type_value_core)): Promise; + /** + * [implementation] + */ + lock(mode: boolean): Promise; + /** + * [implementation] + */ + hook_change(action: (() => void)): Promise; } } declare namespace lib_plankton.zoo_input { @@ -4304,7 +4379,7 @@ declare namespace lib_plankton.zoo_input { private value; /** */ - constructor(options?: { + constructor({ "initial_value": initial_value, }?: { initial_value?: any; }); /** @@ -4319,6 +4394,14 @@ declare namespace lib_plankton.zoo_input { * [implementation] */ write(value: any): Promise; + /** + * [implementation] + */ + lock(mode: boolean): Promise; + /** + * [implementation] + */ + hook_change(action: (() => void)): Promise; } } declare namespace lib_plankton.zoo_input { @@ -4326,61 +4409,22 @@ declare namespace lib_plankton.zoo_input { * @author fenris * @todo abstract */ - class class_input_text implements interface_input { + class class_input_text extends class_input_simple implements interface_input { /** */ - private read_only; - /** - */ - private pattern; - /** - */ - /** - */ - private dom_input; - /** - */ - constructor(options?: { - read_only?: boolean; + constructor({ "pattern": pattern, }?: { pattern?: (null | string); }); - /** - * [implementation] - */ - setup(parent: HTMLElement): Promise; - /** - * [implementation] - */ - read(): Promise; - /** - * [implementation] - */ - write(value: string): Promise; } } declare namespace lib_plankton.zoo_input { /** * @author fenris */ - class class_input_email implements interface_input { - /** - */ - private dom_input; + class class_input_email extends class_input_simple implements interface_input { /** */ constructor(); - /** - * [implementation] - */ - setup(parent: HTMLElement): Promise; - /** - * [implementation] - */ - read(): Promise; - /** - * [implementation] - */ - write(value: string): Promise; } } declare namespace lib_plankton.zoo_input { @@ -4406,6 +4450,14 @@ declare namespace lib_plankton.zoo_input { * [implementation] */ write(value: string): Promise; + /** + * [implementation] + */ + lock(mode: boolean): Promise; + /** + * [implementation] + */ + hook_change(action: (() => void)): Promise; } } declare namespace lib_plankton.zoo_input { @@ -4421,7 +4473,7 @@ declare namespace lib_plankton.zoo_input { private dom_input; /** */ - constructor(options?: { + constructor({ "required": required, }?: { required?: boolean; }); /** @@ -4436,6 +4488,14 @@ declare namespace lib_plankton.zoo_input { * [implementation] */ write(value: (null | lib_plankton.pit.type_date)): Promise; + /** + * [implementation] + */ + lock(mode: boolean): Promise; + /** + * [implementation] + */ + hook_change(action: (() => void)): Promise; } } declare namespace lib_plankton.zoo_input { @@ -4443,34 +4503,12 @@ declare namespace lib_plankton.zoo_input { * @author fenris * @todo abstract */ - class class_input_number implements interface_input { + class class_input_number extends class_input_simple implements interface_input { /** */ - private read_only; - /** - */ - private step; - /** - */ - private dom_input; - /** - */ - constructor(options?: { - read_only?: boolean; + constructor({ "step": step, }?: { step?: (null | float); }); - /** - * [implementation] - */ - setup(parent: HTMLElement): Promise; - /** - * [implementation] - */ - read(): Promise; - /** - * [implementation] - */ - write(value: number): Promise; } } declare namespace lib_plankton.zoo_input { @@ -4478,21 +4516,12 @@ declare namespace lib_plankton.zoo_input { * @author fenris */ class class_input_checkbox implements interface_input { - /** - */ - private read_only; /** */ private dom_input; /** */ - private hooks_change; - /** - */ - constructor(options?: { - read_only?: boolean; - hooks_change?: Array<((value: boolean) => void)>; - }); + constructor(); /** * [implementation] */ @@ -4505,6 +4534,14 @@ declare namespace lib_plankton.zoo_input { * [implementation] */ write(value: boolean): Promise; + /** + * [implementation] + */ + lock(mode: boolean): Promise; + /** + * [implementation] + */ + hook_change(action: (() => void)): Promise; } } declare namespace lib_plankton.zoo_input { @@ -4536,13 +4573,27 @@ declare namespace lib_plankton.zoo_input { * [implementation] */ write(value: string): Promise; + /** + * [implementation] + */ + lock(mode: boolean): Promise; + /** + * [implementation] + */ + hook_change(action: (() => void)): Promise; } } declare namespace lib_plankton.zoo_input { /** * @author fenris */ - class class_input_enumeration implements interface_input { + class class_input_enumeration implements interface_input { + /** + */ + private encode_value; + /** + */ + private decode_value; /** */ private options; @@ -4551,8 +4602,8 @@ declare namespace lib_plankton.zoo_input { private dom_inputs; /** */ - constructor(options: Array<{ - value: string; + constructor(encode_value: ((value: type_value) => string), decode_value: ((representation: string) => type_value), options: Array<{ + value: type_value; label: string; }>); /** @@ -4563,11 +4614,19 @@ declare namespace lib_plankton.zoo_input { /** * [implementation] */ - read(): Promise; + read(): Promise; /** * [implementation] */ - write(value: string): Promise; + write(value: type_value): Promise; + /** + * [implementation] + */ + lock(mode: boolean): Promise; + /** + * [implementation] + */ + hook_change(action: (() => void)): Promise; } } declare namespace lib_plankton.zoo_input { @@ -4598,7 +4657,10 @@ declare namespace lib_plankton.zoo_input { private translations; /** */ - constructor(element_input_factory: (() => interface_input), options?: { + private locked; + /** + */ + constructor(element_input_factory: (() => interface_input), { "read_only": read_only, "translations": translations, }?: { read_only?: boolean; translations?: type_translations; }); @@ -4620,6 +4682,14 @@ declare namespace lib_plankton.zoo_input { * [implementation] */ write(value: Array): Promise; + /** + * [implementation] + */ + lock(mode: boolean): Promise; + /** + * [implementation] + */ + hook_change(action: (() => void)): Promise; } export {}; } @@ -4656,6 +4726,14 @@ declare namespace lib_plankton.zoo_input { * [implementation] */ write(value: Set): Promise; + /** + * [implementation] + */ + lock(mode: boolean): Promise; + /** + * [implementation] + */ + hook_change(action: (() => void)): Promise; } } declare namespace lib_plankton.zoo_input { @@ -4700,6 +4778,14 @@ declare namespace lib_plankton.zoo_input { * [implementation] */ write(value: string): Promise; + /** + * [implementation] + */ + lock(mode: boolean): Promise; + /** + * [implementation] + */ + hook_change(action: (() => void)): Promise; } } declare namespace lib_plankton.zoo_input { @@ -4715,7 +4801,15 @@ declare namespace lib_plankton.zoo_input { private value; /** */ - constructor(); + private symbols; + /** + */ + constructor({ "symbols": symbols, }?: { + symbols?: { + yes: string; + no: string; + }; + }); /** * [implementation] */ @@ -4728,31 +4822,24 @@ declare namespace lib_plankton.zoo_input { * [implementation] */ write(value: boolean): Promise; + /** + * [implementation] + */ + lock(mode: boolean): Promise; + /** + * [implementation] + */ + hook_change(action: (() => void)): Promise; } } declare namespace lib_plankton.zoo_input { /** * @author fenris */ - class class_input_time implements interface_input<(null | lib_plankton.pit.type_time)> { - /** - */ - private dom_input; + class class_input_time extends class_input_simple<(null | lib_plankton.pit.type_time)> implements interface_input<(null | lib_plankton.pit.type_time)> { /** */ constructor(); - /** - * [implementation] - */ - setup(parent: HTMLElement): Promise; - /** - * [implementation] - */ - read(): Promise<(null | lib_plankton.pit.type_time)>; - /** - * [implementation] - */ - write(value: (null | lib_plankton.pit.type_time)): Promise; } } declare namespace lib_plankton.zoo_input { @@ -4783,12 +4870,20 @@ declare namespace lib_plankton.zoo_input { * [implementation] */ write(value: type_record): Promise; + /** + * [implementation] + */ + lock(mode: boolean): Promise; + /** + * [implementation] + */ + hook_change(action: (() => void)): Promise; } } declare namespace lib_plankton.zoo_input { /** */ - class class_input_hashmap implements lib_plankton.zoo_input.interface_input> { + class class_input_hashmap implements interface_input> { /** */ private hash_key; @@ -4797,7 +4892,7 @@ declare namespace lib_plankton.zoo_input { private core; /** */ - constructor(hash_key: ((key: type_key) => string), key_input_factory: (() => lib_plankton.zoo_input.interface_input), value_input_factory: (() => lib_plankton.zoo_input.interface_input)); + constructor(hash_key: ((key: type_key) => string), key_input_factory: (() => interface_input), value_input_factory: (() => interface_input)); /** * [implementation] */ @@ -4810,6 +4905,14 @@ declare namespace lib_plankton.zoo_input { * [implementation] */ write(map: lib_plankton.map.type_map): Promise; + /** + * [implementation] + */ + lock(mode: boolean): Promise; + /** + * [implementation] + */ + hook_change(action: (() => void)): Promise; } } declare namespace lib_plankton.zoo_input { @@ -4835,6 +4938,14 @@ declare namespace lib_plankton.zoo_input { /** */ write(value: lib_plankton.pit.type_datetime): Promise; + /** + * [implementation] + */ + lock(mode: boolean): Promise; + /** + * [implementation] + */ + hook_change(action: (() => void)): Promise; } } declare namespace lib_plankton.zoo_input { @@ -4847,7 +4958,7 @@ declare namespace lib_plankton.zoo_input { private core; /** */ - constructor(options?: { + constructor({ "label_date": label_date, "label_time": label_time, }?: { label_date?: string; label_time?: string; }); @@ -4860,30 +4971,23 @@ declare namespace lib_plankton.zoo_input { /** */ write(value: lib_plankton.pit.type_datetime): Promise; + /** + * [implementation] + */ + lock(mode: boolean): Promise; + /** + * [implementation] + */ + hook_change(action: (() => void)): Promise; } } declare namespace lib_plankton.zoo_input { /** */ - class class_input_color implements interface_input<(null | lib_plankton.color.type_color)> { - /** - */ - private dom_input; + class class_input_color extends class_input_simple<(null | lib_plankton.color.type_color)> implements interface_input<(null | lib_plankton.color.type_color)> { /** */ constructor(); - /** - * [implementation] - */ - setup(parent: HTMLElement): Promise; - /** - * [implementation] - */ - read(): Promise<(null | lib_plankton.color.type_color)>; - /** - * [implementation] - */ - write(value: (null | lib_plankton.color.type_color)): Promise; } } declare namespace lib_plankton.zoo_input { @@ -4919,7 +5023,7 @@ declare namespace lib_plankton.zoo_form { name: string; type: string; label?: (null | string); - }>, encode: ((value: type_value) => Record), decode: ((raw: Record) => type_value), options?: { + }>, encode: ((value: type_value) => Record), decode: ((raw: Record) => type_value), { "class_prefix": class_prefix, }?: { class_prefix?: string; }): type_form; /** @@ -4984,6 +5088,9 @@ declare namespace lib_plankton.zoo_form { /** */ input_write(value: type_value): Promise; + /** + */ + input_lock(mode: boolean): Promise; } export {}; } diff --git a/lib/plankton/plankton.js b/lib/plankton/plankton.js index 4cd8cd9..8509b96 100644 --- a/lib/plankton/plankton.js +++ b/lib/plankton/plankton.js @@ -436,18 +436,32 @@ var lib_plankton; base.object_merge = object_merge; /** */ - function buffer_show(buffer, { "block_size": option_block_size = 20, "break_char": option_break_char = "\n", } = {}) { + function buffer_show(buffer, { "block_size": option_block_size = 20, "break_char": option_break_char = "\n", "render_readable_characters": render_readable_characters = true, } = {}) { + function is_readable(code) { + return ((code > 0x20) + && + (code <= 0x7E)); + } let output = ""; let count = 0; // @ts-ignore for (const entry of buffer) { count = ((count + 1) % option_block_size); - output += ((typeof (entry) === "string") + /* + */ + const code = ((typeof (entry) === "string") ? entry.charCodeAt(0) : - entry).toString(16).toUpperCase().padStart(2, "0"); - output += ((count === 0) ? option_break_char : " "); + entry); + output += ((render_readable_characters + && + is_readable(code)) + ? + String.fromCharCode(code) + : + ("[" + code.toString(16).toUpperCase().padStart(2, "0") + "]")); + output += ((count === 0) ? option_break_char : ""); } return output; } @@ -12967,6 +12981,98 @@ 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) { + /** + * @author fenris + */ + class class_input_simple { + /** + */ + constructor(type, decode, encode, { "additional_attributes": additional_attributes = {}, } = {}) { + this.type = type; + this.decode = decode; + this.encode = encode; + this.additional_attributes = additional_attributes; + this.dom_input = null; + } + /** + * [implementation] + */ + setup(parent) { + this.dom_input = document.createElement("input"); + this.dom_input.setAttribute("type", this.type); + Object.entries(this.additional_attributes).forEach(([key, value]) => { + if (value === null) { + // do nothing + } + else { + this.dom_input.setAttribute(key, value); + } + }); + parent.appendChild(this.dom_input); + return Promise.resolve(undefined); + } + /** + * [implementation] + */ + read() { + const value = this.decode(this.dom_input.value); + return Promise.resolve(value); + } + /** + * [implementation] + */ + write(value) { + this.dom_input.value = this.encode(value); + return Promise.resolve(undefined); + } + /** + * [implementation] + */ + lock(mode) { + if (mode) { + this.dom_input.setAttribute("disabled", "disabled"); + } + else { + this.dom_input.removeAttribute("disabled"); + } + return Promise.resolve(undefined); + } + /** + * [implementation] + */ + hook_change(action) { + this.dom_input.addEventListener("change", () => { + action(); + }); + return Promise.resolve(undefined); + } + } + zoo_input.class_input_simple = class_input_simple; + })(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 . */ @@ -13005,6 +13111,18 @@ var lib_plankton; write(value) { return this.core.write(this.unwrap(value)); } + /** + * [implementation] + */ + lock(mode) { + return this.core.lock(mode); + } + /** + * [implementation] + */ + hook_change(action) { + return this.core.hook_change(action); + } } zoo_input.class_input_wrapped = class_input_wrapped; })(zoo_input = lib_plankton.zoo_input || (lib_plankton.zoo_input = {})); @@ -13038,8 +13156,7 @@ var lib_plankton; class class_input_soft { /** */ - constructor(core, options = {}) { - options = Object.assign({}, options); + constructor(core, { "read_only": read_only = false, } = {}) { this.core = core; this.dom_set = null; this.dom_wrapper = null; @@ -13108,6 +13225,27 @@ var lib_plankton; return this.core.write(value); } } + /** + * [implementation] + */ + async lock(mode) { + if (mode) { + this.dom_set.setAttribute("disabled", "disabled"); + } + else { + this.dom_set.removeAttribute("disabled"); + } + await this.core.lock(mode); + } + /** + * [implementation] + */ + async hook_change(action) { + this.dom_set.addEventListener("change", () => { + action(); + }); + await this.core.hook_change(action); + } } zoo_input.class_input_soft = class_input_soft; })(zoo_input = lib_plankton.zoo_input || (lib_plankton.zoo_input = {})); @@ -13141,12 +13279,9 @@ var lib_plankton; class class_input_hidden { /** */ - constructor(options = {}) { - options = Object.assign({ - "initial_value": null, - }, options); + constructor({ "initial_value": initial_value = null, } = {}) { this.dom_input = null; - this.value = options.initial_value; + this.value = initial_value; } /** * [implementation] @@ -13161,7 +13296,8 @@ var lib_plankton; * [implementation] */ read() { - return Promise.resolve(this.value); + const value = this.value; + return Promise.resolve(value); } /** * [implementation] @@ -13170,6 +13306,18 @@ var lib_plankton; this.value = value; return Promise.resolve(undefined); } + /** + * [implementation] + */ + lock(mode) { + return Promise.resolve(undefined); + } + /** + * [implementation] + */ + hook_change(action) { + return Promise.resolve(undefined); + } } zoo_input.class_input_hidden = class_input_hidden; })(zoo_input = lib_plankton.zoo_input || (lib_plankton.zoo_input = {})); @@ -13201,71 +13349,17 @@ var lib_plankton; * @author fenris * @todo abstract */ - class class_input_text { + class class_input_text extends zoo_input.class_input_simple { /** */ - constructor(options = {}) { - options = Object.assign({ - "read_only": false, - "pattern": null, - // "autocompletion_list": null, - }, options); - this.read_only = options.read_only; - this.pattern = options.pattern; - // this.autocompletion_list = options.autocompletion_list; - this.dom_input = null; - } - /** - * [implementation] - */ - setup(parent) { - this.dom_input = document.createElement("input"); - this.dom_input.setAttribute("type", "text"); - { - if (!this.read_only) { - // do nothing + constructor({ "pattern": pattern = null, + // "autocompletion_list": autocompletion_list = null, + } = {}) { + super("text", representation => representation, value => value, { + "additional_attributes": { + "pattern": pattern, } - else { - this.dom_input.setAttribute("disabled", "disabled"); - } - } - { - if (this.pattern === null) { - // do nothing - } - else { - this.dom_input.setAttribute("pattern", this.pattern); - } - } - { - /* - if (this.autocompletion_list === null) { - // do nothing - } - else { - const autocomplete : class_autocomplete = new class_autocomplete( - this.dom_input, - this.autocompletion_list - ); - autocomplete.init(); - } - */ - } - parent.appendChild(this.dom_input); - return Promise.resolve(undefined); - } - /** - * [implementation] - */ - read() { - return Promise.resolve(this.dom_input.value); - } - /** - * [implementation] - */ - write(value) { - this.dom_input.value = value; - return Promise.resolve(undefined); + }); } } zoo_input.class_input_text = class_input_text; @@ -13297,33 +13391,11 @@ var lib_plankton; /** * @author fenris */ - class class_input_email { + class class_input_email extends zoo_input.class_input_simple { /** */ constructor() { - this.dom_input = null; - } - /** - * [implementation] - */ - setup(parent) { - this.dom_input = document.createElement("input"); - this.dom_input.setAttribute("type", "email"); - parent.appendChild(this.dom_input); - return Promise.resolve(undefined); - } - /** - * [implementation] - */ - read() { - return Promise.resolve(this.dom_input.value); - } - /** - * [implementation] - */ - write(value) { - this.dom_input.value = value; - return Promise.resolve(undefined); + super("email", representation => representation, value => value); } } zoo_input.class_input_email = class_input_email; @@ -13382,6 +13454,27 @@ var lib_plankton; this.dom_textarea.value = value; return Promise.resolve(undefined); } + /** + * [implementation] + */ + lock(mode) { + if (mode) { + this.dom_textarea.setAttribute("disabled", "disabled"); + } + else { + this.dom_textarea.removeAttribute("disabled"); + } + return Promise.resolve(undefined); + } + /** + * [implementation] + */ + hook_change(action) { + this.dom_textarea.addEventListener("change", () => { + action(); + }); + return Promise.resolve(undefined); + } } zoo_input.class_input_textarea = class_input_textarea; })(zoo_input = lib_plankton.zoo_input || (lib_plankton.zoo_input = {})); @@ -13434,11 +13527,8 @@ var lib_plankton; class class_input_date { /** */ - constructor(options = {}) { - options = Object.assign({ - "required": false, - }, options); - this.required = options.required; + constructor({ "required": required = false, } = {}) { + this.required = required; this.dom_input = null; } /** @@ -13447,12 +13537,10 @@ var lib_plankton; setup(parent) { this.dom_input = document.createElement("input"); this.dom_input.setAttribute("type", "date"); - if (!this.required) { - // do nothing - } - else { + if (this.required) { this.dom_input.setAttribute("required", "required"); } + else { /*do nothing*/ } parent.appendChild(this.dom_input); return Promise.resolve(undefined); } @@ -13478,6 +13566,27 @@ var lib_plankton; : value_encode(value)); return Promise.resolve(undefined); } + /** + * [implementation] + */ + lock(mode) { + if (mode) { + this.dom_input.setAttribute("disabled", "disabled"); + } + else { + this.dom_input.removeAttribute("disabled"); + } + return Promise.resolve(undefined); + } + /** + * [implementation] + */ + hook_change(action) { + this.dom_input.addEventListener("change", () => { + action(); + }); + return Promise.resolve(undefined); + } } zoo_input.class_input_date = class_input_date; })(zoo_input = lib_plankton.zoo_input || (lib_plankton.zoo_input = {})); @@ -13509,57 +13618,15 @@ var lib_plankton; * @author fenris * @todo abstract */ - class class_input_number { + class class_input_number extends zoo_input.class_input_simple { /** */ - constructor(options = {}) { - options = Object.assign({ - "read_only": false, - "step": null, - }, options); - this.read_only = options.read_only; - this.step = options.step; - this.dom_input = null; - } - /** - * [implementation] - */ - setup(parent) { - this.dom_input = document.createElement("input"); - this.dom_input.setAttribute("type", "number"); - // readonly - { - if (!this.read_only) { - // do nothing + constructor({ "step": step = null, } = {}) { + super("number", representation => Number(representation), value => value.toString(), { + "additional_attributes": { + "step": step.toString(), } - else { - this.dom_input.setAttribute("disabled", "disabled"); - } - } - // step - { - if (this.step === null) { - // do nothing - } - else { - this.dom_input.setAttribute("step", this.step.toString()); - } - } - parent.appendChild(this.dom_input); - return Promise.resolve(undefined); - } - /** - * [implementation] - */ - read() { - return Promise.resolve(Number(this.dom_input.value)); - } - /** - * [implementation] - */ - write(value) { - this.dom_input.value = value.toString(); - return Promise.resolve(undefined); + }); } } zoo_input.class_input_number = class_input_number; @@ -13594,14 +13661,8 @@ var lib_plankton; class class_input_checkbox { /** */ - constructor(options = {}) { - options = Object.assign({ - "read_only": false, - "hooks_change": [], - }, options); - this.read_only = options.read_only; + constructor() { this.dom_input = null; - this.hooks_change = options.hooks_change; } /** * [implementation] @@ -13609,21 +13670,6 @@ var lib_plankton; setup(parent) { this.dom_input = document.createElement("input"); this.dom_input.setAttribute("type", "checkbox"); - { - if (this.read_only) { - this.dom_input.setAttribute("disabled", "disabled"); - } - else { - // do nothing - } - } - this.dom_input.addEventListener("change", (event) => { - const value = event.target.checked; - this.hooks_change.forEach(procedure => { - procedure(value); - }); - }); - // this.dom_input.style.display = "initial"; // n3o!!! parent.appendChild(this.dom_input); return Promise.resolve(undefined); } @@ -13631,7 +13677,8 @@ var lib_plankton; * [implementation] */ read() { - return Promise.resolve(this.dom_input.checked); + const value = this.dom_input.checked; + return Promise.resolve(value); } /** * [implementation] @@ -13640,6 +13687,27 @@ var lib_plankton; this.dom_input.checked = value; return Promise.resolve(undefined); } + /** + * [implementation] + */ + lock(mode) { + if (mode) { + this.dom_input.setAttribute("disabled", "disabled"); + } + else { + this.dom_input.removeAttribute("disabled"); + } + return Promise.resolve(undefined); + } + /** + * [implementation] + */ + hook_change(action) { + this.dom_input.addEventListener("change", () => { + action(); + }); + return Promise.resolve(undefined); + } } zoo_input.class_input_checkbox = class_input_checkbox; })(zoo_input = lib_plankton.zoo_input || (lib_plankton.zoo_input = {})); @@ -13704,6 +13772,27 @@ var lib_plankton; this.dom_select.value = value; return Promise.resolve(undefined); } + /** + * [implementation] + */ + lock(mode) { + if (mode) { + this.dom_select.setAttribute("disabled", "disabled"); + } + else { + this.dom_select.removeAttribute("disabled"); + } + return Promise.resolve(undefined); + } + /** + * [implementation] + */ + hook_change(action) { + this.dom_select.addEventListener("change", () => { + action(); + }); + return Promise.resolve(undefined); + } } zoo_input.class_input_selection = class_input_selection; })(zoo_input = lib_plankton.zoo_input || (lib_plankton.zoo_input = {})); @@ -13737,7 +13826,9 @@ var lib_plankton; class class_input_enumeration { /** */ - constructor(options) { + constructor(encode_value, decode_value, options) { + this.encode_value = encode_value; + this.decode_value = decode_value; this.options = options; this.dom_inputs = []; } @@ -13754,7 +13845,7 @@ var lib_plankton; let dom_input = document.createElement("input"); dom_input.setAttribute("type", "radio"); dom_input.setAttribute("name", name); - dom_input.setAttribute("value", option.value); + dom_input.setAttribute("value", this.encode_value(option.value)); dom_label.appendChild(dom_input); let dom_span = document.createElement("span"); dom_span.textContent = option.label; @@ -13769,22 +13860,49 @@ var lib_plankton; * [implementation] */ read() { - const active = (this.dom_inputs + const active_representations = (this.dom_inputs .filter(dom_input => dom_input.checked) .map(dom_input => dom_input.value)); - if (active.length != 1) { - return Promise.reject("nothing picked"); + if (active_representations.length != 1) { + return Promise.reject(new Error("nothing picked")); } else { - return Promise.resolve(active[0]); + const value = this.decode_value(active_representations[0]); + return Promise.resolve(value); } } /** * [implementation] */ write(value) { + const representation = this.encode_value(value); this.dom_inputs.forEach(dom_input => { - dom_input.checked = (value === dom_input.value); + dom_input.checked = (representation === dom_input.value); + }); + return Promise.resolve(undefined); + } + /** + * [implementation] + */ + lock(mode) { + this.dom_inputs.forEach(dom_input => { + if (mode) { + dom_input.setAttribute("disabled", "disabled"); + } + else { + dom_input.removeAttribute("disabled"); + } + }); + return Promise.resolve(undefined); + } + /** + * [implementation] + */ + hook_change(action) { + this.dom_inputs.forEach(dom_input => { + dom_input.addEventListener("change", () => { + action(); + }); }); return Promise.resolve(undefined); } @@ -13821,19 +13939,16 @@ var lib_plankton; class class_input_list { /** */ - constructor(element_input_factory, options = {}) { - options = Object.assign({ - "read_only": false, - "translations": { - "add": "add", - "remove": "remove", - }, - }, options); + constructor(element_input_factory, { "read_only": read_only = false, "translations": translations = { + "add": "add", + "remove": "remove", + }, } = {}) { this.element_input_factory = element_input_factory; this.elements = []; this.elements_container_dom = null; - this.read_only = options.read_only; - this.translations = options.translations; + this.read_only = read_only; + this.translations = translations; + this.locked = false; } /** */ @@ -13863,11 +13978,16 @@ var lib_plankton; } remover_dom.textContent = "x"; remover_dom.addEventListener("click", (event) => { - event.preventDefault(); - const index = this.elements.findIndex(element => (element.input === input)); - const element = this.elements[index]; - this.elements_container_dom.removeChild(element.dom); - this.elements.splice(index, 1); + if (this.locked) { + // do nothing + } + else { + event.preventDefault(); + const index = this.elements.findIndex(element => (element.input === input)); + const element = this.elements[index]; + this.elements_container_dom.removeChild(element.dom); + this.elements.splice(index, 1); + } }); element_dom.appendChild(remover_dom); } @@ -13909,8 +14029,13 @@ var lib_plankton; } adder_dom.textContent = "+"; adder_dom.addEventListener("click", (event) => { - event.preventDefault(); - this.add(); + if (this.locked) { + // do nothing + } + else { + event.preventDefault(); + this.add(); + } }); footer_dom.appendChild(adder_dom); } @@ -13943,6 +14068,24 @@ var lib_plankton; .then(element_input => element_input.write(element_value)))))) .then(() => Promise.resolve(undefined))); } + /** + * [implementation] + */ + async lock(mode) { + this.locked = mode; + for (const element of this.elements) { + await element.input.lock(mode); + } + return Promise.resolve(undefined); + } + /** + * [implementation] + */ + async hook_change(action) { + for (const element of this.elements) { + await element.input.hook_change(action); + } + } } zoo_input.class_input_list = class_input_list; })(zoo_input = lib_plankton.zoo_input || (lib_plankton.zoo_input = {})); @@ -13994,7 +14137,6 @@ var lib_plankton; { 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); } @@ -14031,6 +14173,31 @@ var lib_plankton; } return Promise.resolve(undefined); } + /** + * [implementation] + */ + lock(mode) { + this.checkboxes.forEach(dom_checkbox => { + if (mode) { + dom_checkbox.setAttribute("disabled", "disabled"); + } + else { + dom_checkbox.removeAttribute("disabled"); + } + }); + return Promise.resolve(undefined); + } + /** + * [implementation] + */ + hook_change(action) { + this.checkboxes.forEach(dom_checkbox => { + dom_checkbox.addEventListener("change", () => { + action(); + }); + }); + return Promise.resolve(undefined); + } } zoo_input.class_input_set = class_input_set; })(zoo_input = lib_plankton.zoo_input || (lib_plankton.zoo_input = {})); @@ -14129,6 +14296,27 @@ var lib_plankton; this.dom_input.value = value; return Promise.resolve(undefined); } + /** + * [implementation] + */ + lock(mode) { + if (mode) { + this.dom_input.setAttribute("disabled", "disabled"); + } + else { + this.dom_input.removeAttribute("disabled"); + } + return Promise.resolve(undefined); + } + /** + * [implementation] + */ + hook_change(action) { + this.dom_input.addEventListener("change", () => { + action(); + }); + return Promise.resolve(undefined); + } } zoo_input.class_input_password = class_input_password; })(zoo_input = lib_plankton.zoo_input || (lib_plankton.zoo_input = {})); @@ -14162,9 +14350,13 @@ var lib_plankton; class class_input_switch { /** */ - constructor() { + constructor({ "symbols": symbols = { + "yes": "✔", + "no": " " + }, } = {}) { this.dom_element = null; this.value = false; + this.symbols = symbols; } /** * [implementation] @@ -14191,13 +14383,34 @@ var lib_plankton; write(value) { this.value = value; if (value) { - this.dom_element.value = "✔"; + this.dom_element.value = this.symbols.yes; } else { - this.dom_element.value = " "; + this.dom_element.value = this.symbols.no; } return Promise.resolve(undefined); } + /** + * [implementation] + */ + lock(mode) { + if (mode) { + this.dom_element.setAttribute("disabled", "disabled"); + } + else { + this.dom_element.removeAttribute("disabled"); + } + return Promise.resolve(undefined); + } + /** + * [implementation] + */ + hook_change(action) { + this.dom_element.addEventListener("change", () => { + action(); + }); + return Promise.resolve(undefined); + } } zoo_input.class_input_switch = class_input_switch; })(zoo_input = lib_plankton.zoo_input || (lib_plankton.zoo_input = {})); @@ -14246,37 +14459,19 @@ var lib_plankton; /** * @author fenris */ - class class_input_time { + class class_input_time extends zoo_input.class_input_simple { /** */ constructor() { - this.dom_input = null; - } - /** - * [implementation] - */ - setup(parent) { - this.dom_input = document.createElement("input"); - this.dom_input.setAttribute("type", "time"); - parent.appendChild(this.dom_input); - return Promise.resolve(undefined); - } - /** - * [implementation] - */ - read() { - return Promise.resolve((this.dom_input.value === "") - ? null - : value_decode(this.dom_input.value)); - } - /** - * [implementation] - */ - write(value) { - this.dom_input.value = ((value === null) - ? "" - : value_encode(value)); - return Promise.resolve(undefined); + super("time", representation => ((representation === "") + ? + null + : + value_decode(representation)), value => ((value === null) + ? + "" + : + value_encode(value))); } } zoo_input.class_input_time = class_input_time; @@ -14382,6 +14577,24 @@ var lib_plankton; .then(() => Promise.resolve(undefined)))))) .then(() => Promise.resolve(undefined))); } + /** + * [implementation] + */ + lock(mode) { + this.fields.forEach(field => { + field.input.lock(mode); + }); + return Promise.resolve(undefined); + } + /** + * [implementation] + */ + hook_change(action) { + this.fields.forEach(field => { + field.input.hook_change(action); + }); + return Promise.resolve(undefined); + } } zoo_input.class_input_group = class_input_group; })(zoo_input = lib_plankton.zoo_input || (lib_plankton.zoo_input = {})); @@ -14416,7 +14629,7 @@ var lib_plankton; */ constructor(hash_key, key_input_factory, value_input_factory) { this.hash_key = hash_key; - this.core = new lib_plankton.zoo_input.class_input_list(() => new lib_plankton.zoo_input.class_input_group([ + this.core = new zoo_input.class_input_list(() => new zoo_input.class_input_group([ { "name": "key", "input": key_input_factory(), @@ -14451,6 +14664,18 @@ var lib_plankton; await this.core.write(pairs); return Promise.resolve(undefined); } + /** + * [implementation] + */ + lock(mode) { + return this.core.lock(mode); + } + /** + * [implementation] + */ + hook_change(action) { + return this.core.hook_change(action); + } } zoo_input.class_input_hashmap = class_input_hashmap; })(zoo_input = lib_plankton.zoo_input || (lib_plankton.zoo_input = {})); @@ -14527,6 +14752,18 @@ var lib_plankton; write(value) { return this.core.write(value); } + /** + * [implementation] + */ + lock(mode) { + return this.core.lock(mode); + } + /** + * [implementation] + */ + hook_change(action) { + return this.core.hook_change(action); + } } zoo_input.class_input_datetime = class_input_datetime; })(zoo_input = lib_plankton.zoo_input || (lib_plankton.zoo_input = {})); @@ -14560,21 +14797,17 @@ var lib_plankton; class class_input_datetime_central_europe { /** */ - constructor(options = {}) { - options = Object.assign({ - "label_date": "", - "label_time": "", - }, options); + constructor({ "label_date": label_date = "", "label_time": label_time = "", } = {}) { this.core = new zoo_input.class_input_group([ { "name": "date", "input": new zoo_input.class_input_date(), - "label": options.label_date, + "label": label_date, }, { "name": "time", "input": new zoo_input.class_input_soft(new zoo_input.class_input_time()), - "label": options.label_time, + "label": label_time, }, ]); } @@ -14630,6 +14863,18 @@ var lib_plankton; }; return this.core.write(datetime_easy); } + /** + * [implementation] + */ + lock(mode) { + return this.core.lock(mode); + } + /** + * [implementation] + */ + hook_change(action) { + return this.core.hook_change(action); + } } zoo_input.class_input_datetime_central_europe = class_input_datetime_central_europe; })(zoo_input = lib_plankton.zoo_input || (lib_plankton.zoo_input = {})); @@ -14659,37 +14904,15 @@ var lib_plankton; (function (zoo_input) { /** */ - class class_input_color { + class class_input_color extends zoo_input.class_input_simple { /** */ constructor() { - this.dom_input = null; - } - /** - * [implementation] - */ - setup(parent) { - this.dom_input = document.createElement("input"); - this.dom_input.setAttribute("type", "color"); - parent.appendChild(this.dom_input); - return Promise.resolve(undefined); - } - /** - * [implementation] - */ - read() { - return Promise.resolve((this.dom_input.value === "") + super("color", (representation) => ((representation === "") ? null - : lib_plankton.color.from_hex(this.dom_input.value)); - } - /** - * [implementation] - */ - write(value) { - this.dom_input.value = ((value === null) + : lib_plankton.color.from_hex(representation)), (value) => ((value === null) ? "" - : lib_plankton.color.output_hex(value)); - return Promise.resolve(undefined); + : lib_plankton.color.output_hex(value))); } } zoo_input.class_input_color = class_input_color; @@ -14773,10 +14996,7 @@ var lib_plankton; (function (zoo_form) { /** */ - function make(method, fields, encode, decode, options = {}) { - options = Object.assign({ - "class_prefix": "plankton_form_", - }, options); + function make(method, fields, encode, decode, { "class_prefix": class_prefix = "plankton_form_", } = {}) { return { "method": method, "fields": fields.map(field_raw => ({ @@ -14786,7 +15006,7 @@ var lib_plankton; })), "encode": encode, "decode": decode, - "class_prefix": options.class_prefix, + "class_prefix": class_prefix, "root_element": null, }; } @@ -15001,6 +15221,11 @@ var lib_plankton; input_write(value) { return this.input.write(this.encode(value)); } + /** + */ + input_lock(mode) { + return this.input.lock(mode); + } } zoo_form.class_form = class_form; })(zoo_form = lib_plankton.zoo_form || (lib_plankton.zoo_form = {})); diff --git a/source/pages/overview/logic.ts b/source/pages/overview/logic.ts index 39656aa..374caab 100644 --- a/source/pages/overview/logic.ts +++ b/source/pages/overview/logic.ts @@ -137,6 +137,29 @@ namespace _dali.pages.overview { const widget = new _dali.widgets.calendar_edit.class_widget_calendar_edit( await _dali.model.user_list(), + { + "name": "", + "hue": lib_plankton.random.generate_unit(), + "access": { + "public": false, + "default_level": _dali.enum_access_level.view, + "attributed": lib_plankton.map.hashmap.implementation_map< + _dali.type_user_id, + _dali.enum_access_level + >( + lib_plankton.map.hashmap.make< + _dali.type_user_id, + _dali.enum_access_level + >( + user_id => user_id.toFixed(0), + ) + ), + }, + /** + * @todo + */ + "resource_id": 0, + }, { "read_only": false, "action_cancel": () => { @@ -161,7 +184,6 @@ namespace _dali.pages.overview } ); }, - "initial_value": null, } ); _dali.overlay.clear(); @@ -169,6 +191,88 @@ namespace _dali.pages.overview await widget.load(_dali.overlay.get_content_element()); } + /** + */ + async function action_edit_calendar( + calendar_object_reduced_with_id : type_calendar_object_reduced_with_id + ) + : Promise + { + const read_only : boolean = (() => { + switch (calendar_object_reduced_with_id.access_level) + { + case _dali.enum_access_level.none: + { + throw (new Error("this event should not be visible")); + break; + } + case _dali.enum_access_level.edit: + case _dali.enum_access_level.view: + { + return true; + break; + } + case _dali.enum_access_level.admin: + { + return false; + break; + } + } + }) (); + if (read_only) + { + lib_plankton.log.notice( + "dali.overview.may_not_edit_calendar", + { + "calendar_id": calendar_object_reduced_with_id.id, + } + ); + } + else + { + const calendar_id : _dali.type_calendar_id = calendar_object_reduced_with_id.id; + const calendar_object : _dali.type_calendar_object = await _dali.model.calendar_get( + calendar_id + ); + const widget = new _dali.widgets.calendar_edit.class_widget_calendar_edit( + await _dali.model.user_list(), + calendar_object, + { + "read_only": read_only, + "action_cancel": () => { + _dali.overlay.toggle({"mode": false}); + }, + "action_change": (data) => { + _dali.model.calendar_change( + calendar_id, + data + ) + .then( + () => { + update_sources_and_entries(); + _dali.overlay.toggle({"mode": false}); + } + ); + }, + "action_remove": (data) => { + _dali.model.calendar_remove( + calendar_id + ) + .then( + () => { + update_sources_and_entries(); + _dali.overlay.toggle({"mode": false}); + } + ); + }, + } + ); + _dali.overlay.clear(); + _dali.overlay.toggle({"mode": true}); + await widget.load(_dali.overlay.get_content_element()); + } + } + /** * @todo unterschiedliches Verhalten bei Anmeldung? */ @@ -259,7 +363,7 @@ namespace _dali.pages.overview /** */ - async function action_select_event + async function action_edit_event ( event_key : _dali.type_event_key ) @@ -402,72 +506,9 @@ namespace _dali.pages.overview _dali.model.calendar_list, { "initial_priviliged": _dali.is_logged_in(), - "action_create": action_create_calendar, - "action_open": (entry) => { - let read_only : boolean; - switch (entry.access_level) - { - case _dali.enum_access_level.none: - { - throw (new Error("this event should not be visible")); - break; - } - case _dali.enum_access_level.edit: - case _dali.enum_access_level.view: - { - read_only = true; - break; - } - case _dali.enum_access_level.admin: - { - read_only = false; - break; - } - } - (async () => { - const calendar_id : _dali.type_calendar_id = entry.id; - const calendar_object : _dali.type_calendar_object = await _dali.model.calendar_get( - calendar_id - ); - const widget = new _dali.widgets.calendar_edit.class_widget_calendar_edit( - await _dali.model.user_list(), - { - "read_only": read_only, - "action_cancel": () => { - _dali.overlay.toggle({"mode": false}); - }, - "action_change": (data) => { - _dali.model.calendar_change( - calendar_id, - data - ) - .then( - () => { - update_sources_and_entries(); - _dali.overlay.toggle({"mode": false}); - } - ); - }, - "action_remove": (data) => { - _dali.model.calendar_remove( - calendar_id - ) - .then( - () => { - update_sources_and_entries(); - _dali.overlay.toggle({"mode": false}); - } - ); - }, - "initial_value": calendar_object, - } - ); - _dali.overlay.clear(); - _dali.overlay.toggle({"mode": true}); - await widget.load(_dali.overlay.get_content_element()); - }) (); - }, - "action_toggle_visibility": (entry, mode) => { + "action_add": action_create_calendar, + "action_select": (entry) => action_edit_calendar(entry), + "action_toggle": (entry, mode) => { widget_weekview.toggle_visibility(entry.id, {"mode": mode}); widget_listview.toggle_visibility(entry.id, {"mode": mode}); }, @@ -482,7 +523,7 @@ namespace _dali.pages.overview new _dali.widgets.weekview.class_widget_weekview( get_entries, { - "action_select_event": (event_key) => action_select_event(event_key), + "action_select_event": (event_key) => action_edit_event(event_key), "action_select_day": (date) => action_create_event({"date": date}), } ) @@ -496,7 +537,7 @@ namespace _dali.pages.overview new _dali.widgets.listview.class_widget_listview( get_entries, { - "action_select": (event_key) => action_select_event(event_key), + "action_select": (event_key) => action_edit_event(event_key), "action_add": () => action_create_event(), } ) diff --git a/source/widgets/calendar_edit/logic.ts b/source/widgets/calendar_edit/logic.ts index 290525b..a5b54e4 100644 --- a/source/widgets/calendar_edit/logic.ts +++ b/source/widgets/calendar_edit/logic.ts @@ -39,20 +39,20 @@ namespace _dali.widgets.calendar_edit /** */ - private initial_value : (null | _dali.type_calendar_object); + private initial_value : _dali.type_calendar_object; /** */ public constructor( users : Array<{id : _dali.type_user_id; name : string;}>, + initial_value : _dali.type_calendar_object, { "read_only": read_only = false, "action_cancel": action_cancel = null, "action_add": action_add = null, "action_change": action_change = null, "action_remove": action_remove = null, - "initial_value": initial_value = null, } : { @@ -61,7 +61,6 @@ namespace _dali.widgets.calendar_edit action_add ?: (null | ((value : _dali.type_calendar_object) => void)) action_change ?: (null | ((value : _dali.type_calendar_object) => void)); action_remove ?: (null | ((value : _dali.type_calendar_object) => void)); - initial_value ?: (null | _dali.type_calendar_object); } = { @@ -69,12 +68,12 @@ namespace _dali.widgets.calendar_edit ) { this.users = users; + this.initial_value = initial_value; this.read_only = read_only; this.action_cancel = action_cancel; this.action_add = action_add; this.action_change = action_change; this.action_remove = action_remove; - this.initial_value = initial_value; } @@ -213,35 +212,8 @@ namespace _dali.widgets.calendar_edit ) ); await form.setup(target_element); - await form.input_write( - (! (this.initial_value === null)) - ? - this.initial_value - : - { - "name": "", - "hue": lib_plankton.random.generate_unit(), - "access": { - "public": false, - "default_level": _dali.enum_access_level.view, - "attributed": lib_plankton.map.hashmap.implementation_map< - _dali.type_user_id, - _dali.enum_access_level - >( - lib_plankton.map.hashmap.make< - _dali.type_user_id, - _dali.enum_access_level - >( - user_id => user_id.toFixed(0), - ) - ), - }, - /** - * @todo - */ - "resource_id": 0, - } - ); + await form.input_lock(this.read_only); + await form.input_write(this.initial_value); } } diff --git a/source/widgets/event_edit/logic.ts b/source/widgets/event_edit/logic.ts index 14c07d4..4be6d35 100644 --- a/source/widgets/event_edit/logic.ts +++ b/source/widgets/event_edit/logic.ts @@ -179,9 +179,6 @@ namespace _dali.widgets.event_edit { "name": "event_name", "input": new lib_plankton.zoo_input.class_input_text( - { - "read_only": this.read_only, - } ), "label": lib_plankton.translate.get("event.name") }, @@ -300,6 +297,7 @@ namespace _dali.widgets.event_edit ) ); await form.setup(target_element); + await form.input_lock(this.read_only); await form.input_write(this.initial_value); } diff --git a/source/widgets/sources/logic.ts b/source/widgets/sources/logic.ts index f090b1d..82a8db8 100644 --- a/source/widgets/sources/logic.ts +++ b/source/widgets/sources/logic.ts @@ -25,19 +25,19 @@ namespace _dali.widgets.sources /** * [hook] */ - private action_open : ((entry : type_entry) => void); + private action_toggle : ((entry : type_entry, mode : boolean) => void); /** * [hook] */ - private action_toggle_visibility : ((entry : type_entry, mode : boolean) => void); + private action_select : ((entry : type_entry) => void); /** * [hook] */ - private action_create : (() => void); + private action_add : (() => void); /** @@ -57,16 +57,16 @@ namespace _dali.widgets.sources public constructor( get_entries : (() => Promise>), { - "action_open": action_open = ((calendar_id) => {}), - "action_toggle_visibility": action_toggle_visibility = ((calendar_id, mode) => {}), - "action_create": action_create = (() => {}), + "action_select": action_select = ((calendar_id) => {}), + "action_toggle": action_toggle = ((calendar_id, mode) => {}), + "action_add": action_add = (() => {}), "initial_priviliged": initial_priviliged = false, } : { - action_open ?: ((entry : type_entry) => void); - action_toggle_visibility ?: ((entry : type_entry, mode : boolean) => void); - action_create ?: (() => void); + action_select ?: ((entry : type_entry) => void); + action_toggle ?: ((entry : type_entry, mode : boolean) => void); + action_add ?: (() => void); initial_priviliged ?: boolean; } = @@ -78,9 +78,9 @@ namespace _dali.widgets.sources this.get_entries = get_entries; // hooks - this.action_open = action_open; - this.action_toggle_visibility = action_toggle_visibility; - this.action_create = action_create; + this.action_select = action_select; + this.action_toggle = action_toggle; + this.action_add = action_add; // state this.priviliged = initial_priviliged; @@ -191,7 +191,7 @@ namespace _dali.widgets.sources "click", (event) => { event.preventDefault(); - this.action_create(); + this.action_add(); } ); this.container.querySelectorAll(".sources-entry-visibility").forEach( @@ -204,7 +204,7 @@ namespace _dali.widgets.sources const calendar_id : _dali.type_calendar_id = class_widget_sources.id_decode(key_encoded); const entry : type_entry = data.get(calendar_id); element.parentElement.classList.toggle("sources-entry-hidden", (! mode)); - this.action_toggle_visibility(entry, mode); + this.action_toggle(entry, mode); } ); } @@ -223,7 +223,7 @@ namespace _dali.widgets.sources const key_encoded : string = element.getAttribute("rel"); const calendar_id : _dali.type_calendar_id = class_widget_sources.id_decode(key_encoded); const entry : type_entry = data.get(calendar_id); - this.action_open(entry); + this.action_select(entry); } } );