From de7ac4ba313e7ff596ae1fbc7ae81aadde6edb9a Mon Sep 17 00:00:00 2001 From: Pierre Goiffon Date: Fri, 19 Mar 2021 11:20:03 +0100 Subject: [PATCH] =?UTF-8?q?N=C2=B03833=20Fix=20DashletBadge=20in=20Ajax=20?= =?UTF-8?q?causing=20JS=20error=20*=20switch=20dashlet=5Fbadge=20widget=20?= =?UTF-8?q?init=20from=20js=5Ftemplate=20to=20js=5Fon=5Fready=5Ftemplate?= =?UTF-8?q?=20*=20add=20phpdoc=20on=20UIBlock::DEFAULT=5FJS=5FFILES=5FREL?= =?UTF-8?q?=5FPATH=20*=20remove=20old=20code=20in=20\AjaxPage::output=20(a?= =?UTF-8?q?fter=20the=20return=20statement)=20that=20is=20already=20handle?= =?UTF-8?q?d=20with=20the=20new=20Twig=20rendering?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Base/Component/Dashlet/DashletBadge.php | 2 +- sources/application/UI/Base/UIBlock.php | 6 +++++- sources/application/WebPage/AjaxPage.php | 21 ------------------- ...ge.js.twig => dashlet-badge.ready.js.twig} | 0 4 files changed, 6 insertions(+), 23 deletions(-) rename templates/base/components/dashlet/{dashlet-badge.js.twig => dashlet-badge.ready.js.twig} (100%) diff --git a/sources/application/UI/Base/Component/Dashlet/DashletBadge.php b/sources/application/UI/Base/Component/Dashlet/DashletBadge.php index 736895f2d..34024450c 100644 --- a/sources/application/UI/Base/Component/Dashlet/DashletBadge.php +++ b/sources/application/UI/Base/Component/Dashlet/DashletBadge.php @@ -16,7 +16,7 @@ class DashletBadge extends DashletContainer public const BLOCK_CODE = 'ibo-dashlet-badge'; public const DEFAULT_HTML_TEMPLATE_REL_PATH = 'base/components/dashlet/dashlet-badge'; - public const DEFAULT_JS_TEMPLATE_REL_PATH = 'base/components/dashlet/dashlet-badge'; + public const DEFAULT_JS_ON_READY_TEMPLATE_REL_PATH = 'base/components/dashlet/dashlet-badge'; public const DEFAULT_JS_FILES_REL_PATH = [ 'js/components/dashlet/dashlet-badge.js', ]; diff --git a/sources/application/UI/Base/UIBlock.php b/sources/application/UI/Base/UIBlock.php index 7d565e3f3..eeb2316e4 100644 --- a/sources/application/UI/Base/UIBlock.php +++ b/sources/application/UI/Base/UIBlock.php @@ -43,7 +43,11 @@ abstract class UIBlock implements iUIBlock public const DEFAULT_GLOBAL_TEMPLATE_REL_PATH = null; /** @var string|null */ public const DEFAULT_HTML_TEMPLATE_REL_PATH = null; - /** @var array */ + /** + * @var array list of external JS file paths to include in the page. Paths are relative to APPROOT + * **Warning** : if you need to call a JS var defined in one of this file, then this calling code MUST be in {@see DEFAULT_JS_ON_READY_TEMPLATE_REL_PATH} + * and not in {@see DEFAULT_JS_TEMPLATE_REL_PATH} ! Indeed the later is output before external files loading. + */ public const DEFAULT_JS_FILES_REL_PATH = []; /** @var string|null */ public const DEFAULT_JS_TEMPLATE_REL_PATH = null; diff --git a/sources/application/WebPage/AjaxPage.php b/sources/application/WebPage/AjaxPage.php index bbc2272d0..3bcee0fc4 100644 --- a/sources/application/WebPage/AjaxPage.php +++ b/sources/application/WebPage/AjaxPage.php @@ -237,19 +237,6 @@ EOF echo "\n\n"; } - //echo $this->s_deferred_content; - if (count($this->a_scripts) > 0) { - echo "\n"; - } - if (count($this->a_linked_scripts) > 0) { - echo "\n"; - } if (!empty($this->s_deferred_content)) { echo "\n"; } - if (count($this->a_linked_stylesheets) > 0) { - echo "\n"; - } if (trim($s_captured_output) != "") { echo self::FilterXSS($s_captured_output); diff --git a/templates/base/components/dashlet/dashlet-badge.js.twig b/templates/base/components/dashlet/dashlet-badge.ready.js.twig similarity index 100% rename from templates/base/components/dashlet/dashlet-badge.js.twig rename to templates/base/components/dashlet/dashlet-badge.ready.js.twig