From 0945d9e68643ccf270c7b9a8626b455ca2f4a366 Mon Sep 17 00:00:00 2001 From: nathangray Date: Fri, 24 Jan 2020 02:12:14 -0700 Subject: [PATCH] Temporary work around for legacyOptions issue --- api/js/etemplate/et2_core_DOMWidget.ts | 2 +- api/js/etemplate/et2_core_widget.js | 16 ++++++++++------ api/js/etemplate/et2_core_widget.ts | 2 +- api/js/etemplate/et2_types.d.ts | 19 +++++++++++-------- api/js/etemplate/et2_widget_selectbox.js | 5 +++-- api/js/etemplate/et2_widget_selectbox.ts | 11 ++++++----- 6 files changed, 32 insertions(+), 23 deletions(-) diff --git a/api/js/etemplate/et2_core_DOMWidget.ts b/api/js/etemplate/et2_core_DOMWidget.ts index 4c51a002ab..b2b360b115 100644 --- a/api/js/etemplate/et2_core_DOMWidget.ts +++ b/api/js/etemplate/et2_core_DOMWidget.ts @@ -285,7 +285,7 @@ export abstract class et2_DOMWidget extends et2_widget implements et2_IDOMNode * * @returns {Object|null} Data for tab the widget is on */ - get_tab_info() : object | null + get_tab_info() : {id: string, label: string, widget: et2_widget, contentDiv: JQuery} | null { var parent : et2_widget = this; do { diff --git a/api/js/etemplate/et2_core_widget.js b/api/js/etemplate/et2_core_widget.js index 12219456af..c4c310692c 100644 --- a/api/js/etemplate/et2_core_widget.js +++ b/api/js/etemplate/et2_core_widget.js @@ -285,11 +285,15 @@ var et2_widget = /** @class */ (function (_super) { } _node._parent = this; this._children.splice(_idx, 0, _node); - if (_node.implements(et2_IDOMNode) && this.implements(et2_IDOMNode) && _node.parentNode) { - _node.detachFromDOM(); - _node.parentNode = this.getDOMNode(_node); - _node.attachToDOM(); - } + /* + Comment this out (for now) + if (_node.implements(et2_IDOMNode) && this.implements(et2_IDOMNode) && typeof _node.hasOwnProperty('parentNode') ) + { + _node.detachFromDOM(); + _node.parentNode = (this).getDOMNode(_node); + _node.attachToDOM(); + } + */ } else { this.egw().debug("error", "Widget " + _node._type + " is not supported by this widget class", this); @@ -404,7 +408,7 @@ var et2_widget = /** @class */ (function (_super) { var attrName = _attrsObj[i].name; var attrValue = _attrsObj[i].value; // Special handling for the legacy options - if (attrName == "options" && _proto.legacyOptions.length > 0) { + if (attrName == "options" && _proto.legacyOptions && _proto.legacyOptions.length > 0) { // Check for modifications on legacy options here. Normal modifications // are handled in widget constructor, but it's too late for legacy options then if (_target.id && this.getArrayMgr("modifications").getEntry(_target.id)) { diff --git a/api/js/etemplate/et2_core_widget.ts b/api/js/etemplate/et2_core_widget.ts index 669105ab27..fd3cd53d4c 100644 --- a/api/js/etemplate/et2_core_widget.ts +++ b/api/js/etemplate/et2_core_widget.ts @@ -535,7 +535,7 @@ Comment this out (for now) var attrValue = _attrsObj[i].value; // Special handling for the legacy options - if (attrName == "options" && _proto.legacyOptions.length > 0) { + if (attrName == "options" && _proto.legacyOptions && _proto.legacyOptions.length > 0) { // Check for modifications on legacy options here. Normal modifications // are handled in widget constructor, but it's too late for legacy options then if (_target.id && this.getArrayMgr("modifications").getEntry(_target.id)) { diff --git a/api/js/etemplate/et2_types.d.ts b/api/js/etemplate/et2_types.d.ts index ab9875853d..ad66ffbd44 100644 --- a/api/js/etemplate/et2_types.d.ts +++ b/api/js/etemplate/et2_types.d.ts @@ -56,12 +56,6 @@ declare var et2_nextmatch : any; declare var et2_nextmatch_header_bar : any; declare var et2_nextmatch_header : any; declare var et2_nextmatch_customfields : any; -declare var et2_nextmatch_sortheader : any; -declare var et2_nextmatch_filterheader : any; -declare var et2_nextmatch_accountfilterheader : any; -declare var et2_nextmatch_taglistheader : any; -declare var et2_nextmatch_entryheader : any; -declare var et2_nextmatch_customfilter : any; declare var et2_nextmatch_controller : any; declare var et2_dynheight : any; declare var et2_nextmatch_rowProvider : any; @@ -119,12 +113,15 @@ declare var et2_radioGroup : any; declare var et2_script : any; declare var et2_selectAccount : any; declare var et2_selectAccount_ro : any; -declare class et2_selectbox extends et2_inputWidget {} +declare class et2_selectbox extends et2_inputWidget { + protected options : any; + public createInputWidget(); +} declare var et2_selectbox_ro : any; declare var et2_menulist : any; declare var et2_split : any; declare var et2_styles : any; -declare var et2_taglist : any; +declare class et2_taglist extends et2_selectbox {} declare var et2_taglist_account : any; declare var et2_taglist_email : any; declare var et2_taglist_category : any; @@ -152,6 +149,12 @@ declare var et2_vfsUpload : any; declare var et2_vfsSelect : any; declare var et2_video : any; declare var et2_IExposable : any; +declare class et2_nextmatch_sortheader extends et2_nextmatch_header {} +declare class et2_nextmatch_filterheader extends et2_nextmatch_header {} +declare class et2_nextmatch_accountfilterheader extends et2_nextmatch_header {} +declare class et2_nextmatch_taglistheader extends et2_nextmatch_header {} +declare class et2_nextmatch_entryheader extends et2_nextmatch_header {} +declare class et2_nextmatch_customfilter extends et2_nextmatch_filterheader {} declare function et2_createWidget(type : string, params : {}, parent? : any) : any; declare function nm_action(_action : {}, _senders : [], _target : any, _ids? : any) : void; declare function et2_compileLegacyJS(_code : string, _widget : et2_widget, _context? : HTMLElement) : Function; diff --git a/api/js/etemplate/et2_widget_selectbox.js b/api/js/etemplate/et2_widget_selectbox.js index 54209eddbc..7feb59b7ef 100644 --- a/api/js/etemplate/et2_widget_selectbox.js +++ b/api/js/etemplate/et2_widget_selectbox.js @@ -30,12 +30,12 @@ Object.defineProperty(exports, "__esModule", { value: true }); et2_core_xml; et2_core_DOMWidget; et2_core_inputWidget; + et2_extension_nextmatch; */ require("./et2_core_common"); var et2_core_inheritance_1 = require("./et2_core_inheritance"); var et2_core_widget_1 = require("./et2_core_widget"); var et2_core_inputWidget_1 = require("./et2_core_inputWidget"); -require("./et2_types"); var et2_core_DOMWidget_1 = require("./et2_core_DOMWidget"); // all calls to Chosen jQuery plugin as jQuery.(un)chosen() give errors which are currently suppressed with @ts-ignore // adding npm package @types/chosen-js did NOT help :( @@ -816,7 +816,8 @@ var et2_selectbox = /** @class */ (function (_super) { var content_options = {}; // First check type, there may be static options. There's some special handling // for filterheaders, which have the wrong type. - var type = widget.instanceOf(et2_nextmatch_filterheader) ? attrs.widget_type || '' : widget._type; + // TODO: filterheader should always be defined, find out why it's not + var type = /* widget.instanceOf(et2_nextmatch_filterheader) ? attrs.widget_type || '' :*/ widget._type; var type_function = type.replace('select-', '').replace('taglist-', '').replace('_ro', '') + '_options'; if (typeof this[type_function] == 'function') { var old_type = widget._type; diff --git a/api/js/etemplate/et2_widget_selectbox.ts b/api/js/etemplate/et2_widget_selectbox.ts index 3f6655c1d3..5a8d4ed774 100644 --- a/api/js/etemplate/et2_widget_selectbox.ts +++ b/api/js/etemplate/et2_widget_selectbox.ts @@ -16,13 +16,13 @@ et2_core_xml; et2_core_DOMWidget; et2_core_inputWidget; + et2_extension_nextmatch; */ import './et2_core_common'; -import { ClassWithAttributes } from "./et2_core_inheritance"; -import { et2_widget, et2_createWidget, et2_register_widget, WidgetConfig } from "./et2_core_widget"; -import { et2_inputWidget } from './et2_core_inputWidget' -import './et2_types'; +import {ClassWithAttributes} from "./et2_core_inheritance"; +import {et2_register_widget, et2_widget, WidgetConfig} from "./et2_core_widget"; +import {et2_inputWidget} from './et2_core_inputWidget' import {et2_DOMWidget} from "./et2_core_DOMWidget"; // all calls to Chosen jQuery plugin as jQuery.(un)chosen() give errors which are currently suppressed with @ts-ignore @@ -1093,7 +1093,8 @@ export class et2_selectbox extends et2_inputWidget // First check type, there may be static options. There's some special handling // for filterheaders, which have the wrong type. - var type = widget.instanceOf(et2_nextmatch_filterheader) ? attrs.widget_type || '' : widget._type; + // TODO: filterheader should always be defined, find out why it's not + var type = /* widget.instanceOf(et2_nextmatch_filterheader) ? attrs.widget_type || '' :*/ widget._type; var type_function = type.replace('select-','').replace('taglist-','').replace('_ro','')+'_options'; if(typeof this[type_function] == 'function') {