From 3b896e091993f9656bce79526407cd4bc265c1d4 Mon Sep 17 00:00:00 2001 From: ralf Date: Sat, 5 Mar 2022 15:22:45 +0200 Subject: [PATCH] deprecated and replace attributes: needed-->required, blur-->placeholder in preprocessor remove client-side code for them and enable translation of placeholder --- api/js/etemplate/Et2InputWidget/Et2InputWidget.ts | 14 ++++++++++++++ api/js/etemplate/Et2Widget/Et2Widget.ts | 15 +-------------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/api/js/etemplate/Et2InputWidget/Et2InputWidget.ts b/api/js/etemplate/Et2InputWidget/Et2InputWidget.ts index 11edb9ed60..bb73ec7d95 100644 --- a/api/js/etemplate/Et2InputWidget/Et2InputWidget.ts +++ b/api/js/etemplate/Et2InputWidget/Et2InputWidget.ts @@ -82,6 +82,20 @@ const Et2InputWidgetMixin = (superclass) => }; } + /** + * List of properties that get translated + * Done separately to not interfere with properties - if we re-define label property, + * labels go missing. + * @returns object + */ + static get translate() + { + return { + ...super.translate, + placeholder: true, + } + } + /** * Compatibility for deprecated name "needed" * diff --git a/api/js/etemplate/Et2Widget/Et2Widget.ts b/api/js/etemplate/Et2Widget/Et2Widget.ts index 47201ba564..679a270226 100644 --- a/api/js/etemplate/Et2Widget/Et2Widget.ts +++ b/api/js/etemplate/Et2Widget/Et2Widget.ts @@ -1243,7 +1243,6 @@ export function loadWebComponent(_nodeName : string, _template_node, parent : Et */ function transformAttributes(widget, mgr : et2_arrayMgr, attributes) { - const widget_class = window.customElements.get(widget.localName); // Apply any set attributes - widget will do its own coercion @@ -1251,24 +1250,12 @@ function transformAttributes(widget, mgr : et2_arrayMgr, attributes) { let attrValue = attributes[attribute]; - // If there is not attribute set, ignore it. Widget sets its own default. + // If there is no attribute set, ignore it. Widget sets its own default. if(typeof attrValue === "undefined") { continue; } - // "needed" is deprecated, use "required" - if(attribute == "needed") - { - attribute = "required"; - } - // Skip these ones - // options is legacy / read-only - if(["options"].indexOf(attribute) > -1) - { - continue; - } - const property = widget_class.getPropertyOptions(attribute); switch(typeof property === "object" ? property.type : property)