Skip to content

Commit

Permalink
Widget: weather upgrade/import should clear saved defaults for weathe…
Browse files Browse the repository at this point in the history
…r background images. fixes xibosignage/xibo#3218
  • Loading branch information
dasgarner committed Nov 4, 2023
1 parent 1826565 commit 66e21db
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions lib/Widget/Compatibility/WeatherWidgetCompatibility.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,27 @@ public function upgradeWidget(Widget $widget, int $fromSchema, int $toSchema): b
$widget->changeOption('widgetOriginalHeight', 'widgetDesignHeight');
}

// Process the background image properties so that they are removed if empty
$this->removeOptionIfEquals($widget, 'cloudy-image');
$this->removeOptionIfEquals($widget, 'day-cloudy-image');
$this->removeOptionIfEquals($widget, 'day-sunny-image');
$this->removeOptionIfEquals($widget, 'fog-image');
$this->removeOptionIfEquals($widget, 'hail-image');
$this->removeOptionIfEquals($widget, 'night-clear-image');
$this->removeOptionIfEquals($widget, 'night-partly-cloudy-image');
$this->removeOptionIfEquals($widget, 'rain-image');
$this->removeOptionIfEquals($widget, 'snow-image');
$this->removeOptionIfEquals($widget, 'windy-image');
return true;
}

private function removeOptionIfEquals(Widget $widget, string $option): void
{
if ($widget->getOptionValue($option, null) === $option) {
$widget->removeOption($option);
}
}

public function saveTemplate(string $template, string $fileName): bool
{
return false;
Expand Down

0 comments on commit 66e21db

Please sign in to comment.