From b3f3a0826d2cd962a6cb8ba7509b14db4e086be6 Mon Sep 17 00:00:00 2001 From: David Blankenship Date: Wed, 18 Sep 2024 17:18:51 -0400 Subject: [PATCH] fix(thumbnail-view-defaults): Capture field_options not existing There are three states we're targeting here: 1. A new view where the default should be that show_thumbnail is on 2. A previously saved view where they might have enabled or disabled show_thumbnail 3. An existing view that was there before these options were presented (no config options set) We want to make sure that the default behavior is that where appropriate cards display thumbnails by default until they opt out. This attempt to determine if there's no config at all (existing view before update) and sets the thumbnail option accordingly. --- .../modules/custom/ys_views_basic/src/ViewsBasicManager.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/web/profiles/custom/yalesites_profile/modules/custom/ys_views_basic/src/ViewsBasicManager.php b/web/profiles/custom/yalesites_profile/modules/custom/ys_views_basic/src/ViewsBasicManager.php index 31ac117e6..759d00ecf 100644 --- a/web/profiles/custom/yalesites_profile/modules/custom/ys_views_basic/src/ViewsBasicManager.php +++ b/web/profiles/custom/yalesites_profile/modules/custom/ys_views_basic/src/ViewsBasicManager.php @@ -399,10 +399,13 @@ public function getView($type, $params) { $eventTimePeriod = $paramsDecoded['filters']['event_time_period'] ?? NULL; + // Determine if we are in a state where field_options doesn't yet exist (pre-existing view) + $no_field_display_options_saved = !key_exists('field_options', $paramsDecoded) || !is_array($paramsDecoded['field_options']); + $field_display_options = [ 'show_categories' => (int) !empty($paramsDecoded['field_options']['show_categories']), 'show_tags' => (int) !empty($paramsDecoded['field_options']['show_tags']), - 'show_thumbnail' => (int) !empty($paramsDecoded['field_options']['show_thumbnail']), + 'show_thumbnail' => (int) $no_field_display_options_saved || !empty($paramsDecoded['field_options']['show_thumbnail']), ]; $view->setArguments(