From 70b221cedff0b08c3ef2725f037997a8c904d515 Mon Sep 17 00:00:00 2001 From: Dan Garner Date: Fri, 9 Feb 2024 16:06:00 +0000 Subject: [PATCH 1/2] PlayerJS: make sure we pass dataItems into both data load methods and hook those up on the back end. Fix v3 players isDataReady. Modules: remove old onDataError. relates to xibosignageltd/xibo-private#611 --- lib/Entity/Module.php | 8 +-- lib/Entity/ModuleTemplate.php | 8 ++- lib/Factory/ModuleFactory.php | 7 +-- lib/Factory/ModuleTemplateFactory.php | 8 ++- lib/Widget/Render/WidgetHtmlRenderer.php | 9 +-- modules/calendar.xml | 13 +--- modules/src/xibo-player.js | 80 ++++++++++++++++-------- modules/widget-html-render.twig | 12 ++-- 8 files changed, 82 insertions(+), 63 deletions(-) diff --git a/lib/Entity/Module.php b/lib/Entity/Module.php index 7710adcb82..9b75b0e6e5 100644 --- a/lib/Entity/Module.php +++ b/lib/Entity/Module.php @@ -1,6 +1,6 @@ onDataLoad = trim($module->onDataLoad); } - $module->onDataError = $this->getFirstValueOrDefaultFromXmlNode($xml, 'onDataError'); - if (!empty($module->onDataError)) { - $module->onDataError = trim($module->onDataError); - } - $module->onRender = $this->getFirstValueOrDefaultFromXmlNode($xml, 'onRender'); if (!empty($module->onRender)) { $module->onRender = trim($module->onRender); diff --git a/lib/Factory/ModuleTemplateFactory.php b/lib/Factory/ModuleTemplateFactory.php index 35b6fb453e..233b16afc9 100644 --- a/lib/Factory/ModuleTemplateFactory.php +++ b/lib/Factory/ModuleTemplateFactory.php @@ -1,6 +1,6 @@ startHeight = intval($this->getFirstValueOrDefaultFromXmlNode($xml, 'startHeight')); $template->hasDimensions = $this->getFirstValueOrDefaultFromXmlNode($xml, 'hasDimensions', 'true') === 'true'; $template->canRotate = $this->getFirstValueOrDefaultFromXmlNode($xml, 'canRotate', 'false') === 'true'; + $template->onTemplateDataLoad = $this->getFirstValueOrDefaultFromXmlNode($xml, 'onTemplateDataLoad'); $template->onTemplateRender = $this->getFirstValueOrDefaultFromXmlNode($xml, 'onTemplateRender'); $template->onTemplateVisible = $this->getFirstValueOrDefaultFromXmlNode($xml, 'onTemplateVisible'); $template->onElementParseData = $this->getFirstValueOrDefaultFromXmlNode($xml, 'onElementParseData'); $template->showIn = $this->getFirstValueOrDefaultFromXmlNode($xml, 'showIn') ?? 'both'; + + if (!empty($template->onTemplateDataLoad)) { + $template->onTemplateDataLoad = trim($template->onTemplateDataLoad); + } + if (!empty($template->onTemplateRender)) { $template->onTemplateRender = trim($template->onTemplateRender); } diff --git a/lib/Widget/Render/WidgetHtmlRenderer.php b/lib/Widget/Render/WidgetHtmlRenderer.php index f384475889..0fefe53145 100644 --- a/lib/Widget/Render/WidgetHtmlRenderer.php +++ b/lib/Widget/Render/WidgetHtmlRenderer.php @@ -397,8 +397,8 @@ private function render( $twig['onRender'] = []; $twig['onParseData'] = []; $twig['onDataLoad'] = []; - $twig['onDataError'] = []; $twig['onElementParseData'] = []; + $twig['onTemplateDataLoad'] = []; $twig['onTemplateRender'] = []; $twig['onTemplateVisible'] = []; $twig['onInitialize'] = []; @@ -522,9 +522,6 @@ private function render( if (!empty($module->onDataLoad)) { $twig['onDataLoad'][$widget->widgetId] = $module->onDataLoad; } - if (!empty($module->onDataError)) { - $twig['onDataError'][$widget->widgetId] = $module->onDataError; - } if (!empty($module->onRender)) { $twig['onRender'][$widget->widgetId] = $module->onRender; } @@ -733,6 +730,10 @@ private function render( $twig['style'][] = $moduleTemplate->stencil->style; } + if ($moduleTemplate->onTemplateDataLoad !== null) { + $twig['onTemplateDataLoad'][$moduleTemplate->templateId] = $moduleTemplate->onTemplateDataLoad; + } + if ($moduleTemplate->onTemplateRender !== null) { $twig['onTemplateRender'][$moduleTemplate->templateId] = $moduleTemplate->onTemplateRender; } diff --git a/modules/calendar.xml b/modules/calendar.xml index 35ddd17016..65da8d1f38 100644 --- a/modules/calendar.xml +++ b/modules/calendar.xml @@ -1,5 +1,5 @@