From d725ba3d84cdec5e6458db0c4126eb26290c2cda Mon Sep 17 00:00:00 2001 From: Pierre Goiffon Date: Fri, 10 Nov 2023 15:10:37 +0100 Subject: [PATCH] =?UTF-8?q?N=C2=B06765=20Avoid=20behat=20scenario=20loadin?= =?UTF-8?q?g=20issues=20on=20portal=20modal=20(#569)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - New CombodoJsActivity API - Replace existing calls in NiceWebPage (ready scripts) - Add calls in ready block in portal object create template (used in both create and edit) --- .../bricks/object/mode_create.html.twig | 4 +++ js/utils.js | 28 +++++++++++++++++++ sources/application/WebPage/NiceWebPage.php | 4 +-- 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/datamodels/2.x/itop-portal-base/portal/templates/bricks/object/mode_create.html.twig b/datamodels/2.x/itop-portal-base/portal/templates/bricks/object/mode_create.html.twig index edd26d5a0..bdad93978 100644 --- a/datamodels/2.x/itop-portal-base/portal/templates/bricks/object/mode_create.html.twig +++ b/datamodels/2.x/itop-portal-base/portal/templates/bricks/object/mode_create.html.twig @@ -67,6 +67,8 @@ \ No newline at end of file diff --git a/js/utils.js b/js/utils.js index 04fad01b2..ad062fe75 100644 --- a/js/utils.js +++ b/js/utils.js @@ -994,6 +994,34 @@ const CombodoJSConsole = { } } +/** + * Helper to reflect ongoing JS activity to other processes like BeHat + * @api + * @since 3.0.4 3.1.1 3.2.0 N°6765 + */ +const CombodoJsActivity = { + BODY_DATA_ATTR_NAME_READY: "data-ready-scripts", + + /** + * Counter so that we set the flag as done only on the last call + * @type number + */ + iOngoingScriptsCount: 0, + + AddOngoingScript: function() { + this.iOngoingScriptsCount++; + $("body").attr(this.BODY_DATA_ATTR_NAME_READY, "start"); + }, + + RemoveOngoingScript: function() { + this.iOngoingScriptsCount--; + + if (this.iOngoingScriptsCount < 1) { + $("body").attr(this.BODY_DATA_ATTR_NAME_READY, "done"); + } + } +} + /** * Helper to Sanitize string * diff --git a/sources/application/WebPage/NiceWebPage.php b/sources/application/WebPage/NiceWebPage.php index de11f57d1..30606a0f0 100644 --- a/sources/application/WebPage/NiceWebPage.php +++ b/sources/application/WebPage/NiceWebPage.php @@ -255,14 +255,14 @@ EOF protected function GetReadyScriptsStartedTrigger(): ?string { return <<