From 587c4fd8fdf3e94a255c4a708ec24b47cb0c48e8 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Fri, 11 Jun 2021 14:50:37 +0200 Subject: [PATCH] fix not working add in calendar (et2_valueWidget not defined) instead of checking widget to be instance of valueWidget (which would create a circular dependency) we check for the interface/methods of valueWidget --- api/js/etemplate/et2_core_baseWidget.js | 4 +++- api/js/etemplate/et2_core_baseWidget.ts | 9 +++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/api/js/etemplate/et2_core_baseWidget.js b/api/js/etemplate/et2_core_baseWidget.js index d68538d596..5308683563 100644 --- a/api/js/etemplate/et2_core_baseWidget.js +++ b/api/js/etemplate/et2_core_baseWidget.js @@ -284,7 +284,9 @@ export class et2_container extends et2_baseWidget { */ getInputWidgetById(_id) { let widget = this.getWidgetById(_id); - if (widget && widget.instanceOf(et2_valueWidget)) { + // instead of checking widget to be instance of valueWidget (which would create a circular dependency) + // we check for the interface/methods of valueWidget + if (widget && typeof widget.get_value === 'function' && typeof widget.set_value === 'function') { return widget; } return null; diff --git a/api/js/etemplate/et2_core_baseWidget.ts b/api/js/etemplate/et2_core_baseWidget.ts index d8ac31bb84..7ceed52915 100644 --- a/api/js/etemplate/et2_core_baseWidget.ts +++ b/api/js/etemplate/et2_core_baseWidget.ts @@ -21,7 +21,6 @@ import {et2_register_widget, et2_widget, WidgetConfig} from "./et2_core_widget"; import {et2_no_init} from "./et2_core_common"; // fixing circular dependencies by only importing type import type {et2_inputWidget} from "./et2_core_inputWidget"; -import type {et2_valueWidget} from "./et2_core_valueWidget"; import {egwIsMobile} from "../egw_action/egw_action_common.js"; /** @@ -383,10 +382,12 @@ export class et2_container extends et2_baseWidget */ getInputWidgetById(_id) : et2_inputWidget | null { - let widget = this.getWidgetById(_id); - if(widget && widget.instanceOf(et2_valueWidget)) + let widget = this.getWidgetById(_id); + // instead of checking widget to be instance of valueWidget (which would create a circular dependency) + // we check for the interface/methods of valueWidget + if(widget && typeof widget.get_value === 'function' && typeof widget.set_value === 'function') { - return widget; + return widget; } return null }