Skip to content

Commit

Permalink
Remove durationIsPerPage from currencies ans stocks (xibosignage#2359)
Browse files Browse the repository at this point in the history
  • Loading branch information
maurofmferrao authored Feb 8, 2024
1 parent ba96c20 commit a91cbaa
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 10 deletions.
3 changes: 3 additions & 0 deletions lib/Widget/Compatibility/CurrenciesWidgetCompatibility.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
3 changes: 3 additions & 0 deletions lib/Widget/Compatibility/StocksWidgetCompatibility.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
4 changes: 2 additions & 2 deletions modules/currencies.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@
<helpText>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.</helpText>
<default>0</default>
</property>
<property id="durationIsPerPage" type="checkbox">
<title>Duration is per page</title>
<property id="durationIsPerItem" type="checkbox">
<title>Duration is per item</title>
<helpText>The duration specified is per page/item otherwise the widget duration is divided between the number of pages/items.</helpText>
<default>0</default>
</property>
Expand Down
4 changes: 2 additions & 2 deletions modules/src/xibo-finance-render.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jQuery.fn.extend({
pauseEffectOnStart: true,
speed: '2',
duration: '30',
durationIsPerPage: false,
durationIsPerItem: false,
numItems: items.length,
maxItemsPerPage: 5,
previewWidth: 0,
Expand Down Expand Up @@ -108,7 +108,7 @@ jQuery.fn.extend({
$mainContainer.append($mainHTML);

const duration =
(options.durationIsPerPage) ?
(options.durationIsPerItem) ?
options.duration :
options.duration / numberOfPages;

Expand Down
4 changes: 2 additions & 2 deletions modules/stocks.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@
</test>
</rule>
</property>
<property id="durationIsPerPage" type="checkbox">
<title>Duration is per page</title>
<property id="durationIsPerItem" type="checkbox">
<title>Duration is per item</title>
<helpText>The duration specified is per page/item otherwise the widget duration is divided between the number of pages/items.</helpText>
<default>0</default>
</property>
Expand Down
6 changes: 3 additions & 3 deletions tests/integration/Widget/CurrenciesWidgetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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, [
Expand All @@ -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());
Expand Down
2 changes: 1 addition & 1 deletion ui/src/preview/html-preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,7 @@ function media(parent, id, xml, options, preload) {
self.checkIframeStatus = true;
self.iframe = $('<iframe scrolling="no" id="' + self.iframeName + '" src="' + tmpUrl + '&width=' + self.divWidth + '&height=' + self.divHeight + '" width="' + self.divWidth + 'px" height="' + self.divHeight + 'px" style="border:0; visibility: hidden;"></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("<!-- NUMITEMS=(.*?) -->");
jQuery.ajax({
url: tmpUrl + '&width=' + self.divWidth + '&height=' + self.divHeight,
Expand Down

0 comments on commit a91cbaa

Please sign in to comment.