From b42c23fe61d66710c635b1a030872c517860946f Mon Sep 17 00:00:00 2001 From: Ruben Pingol Date: Fri, 20 Oct 2023 16:04:54 +0800 Subject: [PATCH] Elements: Text appears once and disappears when added with weather widget relates to xibosignage/xibo#3195 --- modules/src/player.js | 29 +++++++++++++------------ modules/templates/forecast-elements.xml | 3 ++- ui/src/helpers/player-helper.js | 9 +++----- 3 files changed, 20 insertions(+), 21 deletions(-) diff --git a/modules/src/player.js b/modules/src/player.js index b02317479d..1fc6e4a1d6 100644 --- a/modules/src/player.js +++ b/modules/src/player.js @@ -268,6 +268,7 @@ $(function() { templateId, widgetId, url, + meta, } = widget; if (Object.keys(elements.groups).length > 0 || @@ -485,7 +486,7 @@ $(function() { $itemContainer.find(`.${itemID}--item`), $content.find(`.${itemID}--item`), {item, ...item.templateData, data: dataItem}, - widget?.meta, + meta, ); } else { if ($groupContent && @@ -746,21 +747,21 @@ $(function() { const $content = $('#content'); - initStaticTemplates( - $template, - $content, - moduleTemplate, - hbs, - widget, - widget.data, - widget.showError, - widget.data, - ); - - // Get widget with templateId = elements - if ((widget.templateId === 'elements' || + if (widget.templateId !== 'elements' && widget.templateId !== null) { + initStaticTemplates( + $template, + $content, + moduleTemplate, + hbs, + widget, + widget.data, + widget.showError, + widget.data, + ); + } else if ((widget.templateId === 'elements' || widget.templateId === null) && typeof widget.elements !== 'undefined') { + // Get widget with templateId = elements initPlayerElements(widget); } }); diff --git a/modules/templates/forecast-elements.xml b/modules/templates/forecast-elements.xml index dc08a86458..af9d0c46dd 100644 --- a/modules/templates/forecast-elements.xml +++ b/modules/templates/forecast-elements.xml @@ -231,7 +231,8 @@ return value + '%'; 100 div:first-child').html(meta.Attribution); + var $childElem = $(target).is('.' + id + '--item') ? '> div:first-child' : '.global-elements-text > div:first-child'; + $(target).find($childElem).html(meta.Attribution); } ]]> diff --git a/ui/src/helpers/player-helper.js b/ui/src/helpers/player-helper.js index d168ec1b99..7dc7282051 100644 --- a/ui/src/helpers/player-helper.js +++ b/ui/src/helpers/player-helper.js @@ -7,13 +7,10 @@ const PlayerHelper = function() { this.init = (widgetData, elements) => new Promise((resolve) => { if (Array.isArray(widgetData)) { const _widgetData = [...widgetData]; - const _widgetPromises = []; - _widgetData.forEach((widget) => { - _widgetPromises.push(this.getWidgetData(widget)); - }); - - Promise.all(_widgetPromises).then((values) => { + Promise.all(_widgetData.map(function(widget) { + return _self.getWidgetData(widget); + })).then((values) => { const widgets = {}; values.forEach((value, widgetIndex) => { let _elements = {standalone: {}, groups: {}};