From a91cbaa367e3f92299e9776546367eed1b76edce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mauro=20Ferr=C3=A3o?= Date: Thu, 8 Feb 2024 16:44:49 +0000 Subject: [PATCH] Remove durationIsPerPage from currencies ans stocks (#2359) relates to xibosignageltd/xibo-private#615 --- lib/Widget/Compatibility/CurrenciesWidgetCompatibility.php | 3 +++ lib/Widget/Compatibility/StocksWidgetCompatibility.php | 3 +++ modules/currencies.xml | 4 ++-- modules/src/xibo-finance-render.js | 4 ++-- modules/stocks.xml | 4 ++-- tests/integration/Widget/CurrenciesWidgetTest.php | 6 +++--- ui/src/preview/html-preview.js | 2 +- 7 files changed, 16 insertions(+), 10 deletions(-) diff --git a/lib/Widget/Compatibility/CurrenciesWidgetCompatibility.php b/lib/Widget/Compatibility/CurrenciesWidgetCompatibility.php index 305490825b..6eba473d6b 100644 --- a/lib/Widget/Compatibility/CurrenciesWidgetCompatibility.php +++ b/lib/Widget/Compatibility/CurrenciesWidgetCompatibility.php @@ -52,6 +52,9 @@ public function upgradeWidget(Widget $widget, int $fromSchema, int $toSchema): b $widget->changeOption('widgetOriginalHeight', 'widgetDesignHeight'); } + // We need to change duration per page to duration per item + $widget->changeOption('durationIsPerPage', 'durationIsPerItem'); + return $upgraded; } diff --git a/lib/Widget/Compatibility/StocksWidgetCompatibility.php b/lib/Widget/Compatibility/StocksWidgetCompatibility.php index db3192e8aa..b9b5ec3af9 100644 --- a/lib/Widget/Compatibility/StocksWidgetCompatibility.php +++ b/lib/Widget/Compatibility/StocksWidgetCompatibility.php @@ -52,6 +52,9 @@ public function upgradeWidget(Widget $widget, int $fromSchema, int $toSchema): b $widget->changeOption('widgetOriginalHeight', 'widgetDesignHeight'); } + // We need to change duration per page to duration per item + $widget->changeOption('durationIsPerPage', 'durationIsPerItem'); + return $upgraded; } diff --git a/modules/currencies.xml b/modules/currencies.xml index 5f98fe6123..02abe80b1a 100755 --- a/modules/currencies.xml +++ b/modules/currencies.xml @@ -62,8 +62,8 @@ Tick if you would like your base currency to be used as the comparison currency for each currency you've entered. For example base/compare becomes compare/base - USD/GBP becomes GBP/USD. 0 - - Duration is per page + + Duration is per item The duration specified is per page/item otherwise the widget duration is divided between the number of pages/items. 0 diff --git a/modules/src/xibo-finance-render.js b/modules/src/xibo-finance-render.js index b51fb3c536..60d95df6e4 100644 --- a/modules/src/xibo-finance-render.js +++ b/modules/src/xibo-finance-render.js @@ -26,7 +26,7 @@ jQuery.fn.extend({ pauseEffectOnStart: true, speed: '2', duration: '30', - durationIsPerPage: false, + durationIsPerItem: false, numItems: items.length, maxItemsPerPage: 5, previewWidth: 0, @@ -108,7 +108,7 @@ jQuery.fn.extend({ $mainContainer.append($mainHTML); const duration = - (options.durationIsPerPage) ? + (options.durationIsPerItem) ? options.duration : options.duration / numberOfPages; diff --git a/modules/stocks.xml b/modules/stocks.xml index 49e20d6716..6661c7fd0a 100755 --- a/modules/stocks.xml +++ b/modules/stocks.xml @@ -49,8 +49,8 @@ - - Duration is per page + + Duration is per item The duration specified is per page/item otherwise the widget duration is divided between the number of pages/items. 0 diff --git a/tests/integration/Widget/CurrenciesWidgetTest.php b/tests/integration/Widget/CurrenciesWidgetTest.php index 483e47b4ff..300e743019 100644 --- a/tests/integration/Widget/CurrenciesWidgetTest.php +++ b/tests/integration/Widget/CurrenciesWidgetTest.php @@ -78,7 +78,7 @@ public function tearDown() /** * Each array is a test run - * Format ($overrideTemplate, $templateId, $name, $duration, $useDuration, $base, $items, $reverseConversion, $effect, $speed, $backgroundColor, $noRecordsMessage, $dateFormat, $updateInterval, $durationIsPerPage, $widgetOriginalWidth, $widgetOriginalHeight, $maxItemsPerPage, $mainTemplate, $itemTemplate, $styleSheet, $javaScript) + * Format ($overrideTemplate, $templateId, $name, $duration, $useDuration, $base, $items, $reverseConversion, $effect, $speed, $backgroundColor, $noRecordsMessage, $dateFormat, $updateInterval, $durationIsPerItem, $widgetOriginalWidth, $widgetOriginalHeight, $maxItemsPerPage, $mainTemplate, $itemTemplate, $styleSheet, $javaScript) * @return array */ public function provideSuccessCases() @@ -96,7 +96,7 @@ public function provideSuccessCases() * @group broken * @dataProvider provideSuccessCases */ - public function testEdit($isOverride, $templateId, $name, $duration, $useDuration, $base, $items, $reverseConversion, $effect, $speed, $backgroundColor, $noRecordsMessage, $dateFormat, $updateInterval, $durationIsPerPage, $widgetOriginalWidth, $widgetOriginalHeight, $maxItemsPerPage, $mainTemplate, $itemTemplate, $styleSheet, $javaScript) + public function testEdit($isOverride, $templateId, $name, $duration, $useDuration, $base, $items, $reverseConversion, $effect, $speed, $backgroundColor, $noRecordsMessage, $dateFormat, $updateInterval, $durationIsPerItem, $widgetOriginalWidth, $widgetOriginalHeight, $maxItemsPerPage, $mainTemplate, $itemTemplate, $styleSheet, $javaScript) { # Edit currency widget and change name, duration, template, reverseConversion and items $response = $this->sendRequest('PUT','/playlist/widget/' . $this->widgetId, [ @@ -113,7 +113,7 @@ public function testEdit($isOverride, $templateId, $name, $duration, $useDuratio 'noRecordsMessage' => $noRecordsMessage, 'dateFormat' => $dateFormat, 'updateInterval' => $updateInterval, - 'durationIsPerPage' => $durationIsPerPage, + 'durationIsPerItem' => $durationIsPerItem, ], ['CONTENT_TYPE' => 'application/x-www-form-urlencoded']); $this->assertSame(200, $response->getStatusCode()); diff --git a/ui/src/preview/html-preview.js b/ui/src/preview/html-preview.js index 77b356f316..af9c2e21c5 100644 --- a/ui/src/preview/html-preview.js +++ b/ui/src/preview/html-preview.js @@ -787,7 +787,7 @@ function media(parent, id, xml, options, preload) { self.checkIframeStatus = true; self.iframe = $(''); /* Check if the ticker duration is based on the number of items in the feed */ - if(self.options['durationisperitem'] == '1' || self.options['durationisperpage'] == '1') { + if(self.options['durationisperitem'] == '1') { var regex = new RegExp(""); jQuery.ajax({ url: tmpUrl + '&width=' + self.divWidth + '&height=' + self.divHeight,