From 8f1be434202cea855e88c88791fc43f521286333 Mon Sep 17 00:00:00 2001 From: Yeni Atencio Date: Thu, 19 Dec 2024 00:51:54 +1100 Subject: [PATCH] Fixed hook update, visibility and default values on landing page and publication --- ...ntity_form_display.node.landing_page.default.yml | 2 +- ...e.landing_page.field_landing_page_hero_theme.yml | 4 +++- modules/tide_landing_page/tide_landing_page.install | 9 ++++----- ...entity_form_display.node.publication.default.yml | 2 +- ...y_form_display.node.publication_page.default.yml | 2 +- ...de.publication.field_landing_page_hero_theme.yml | 2 +- ...blication_page.field_landing_page_hero_theme.yml | 2 +- modules/tide_publication/tide_publication.module | 13 +++++++------ 8 files changed, 19 insertions(+), 17 deletions(-) diff --git a/modules/tide_landing_page/config/install/core.entity_form_display.node.landing_page.default.yml b/modules/tide_landing_page/config/install/core.entity_form_display.node.landing_page.default.yml index 257d59f0c..a088b7375 100644 --- a/modules/tide_landing_page/config/install/core.entity_form_display.node.landing_page.default.yml +++ b/modules/tide_landing_page/config/install/core.entity_form_display.node.landing_page.default.yml @@ -223,8 +223,8 @@ third_party_settings: label: 'Customised Header' parent_name: group_section_header children: - - field_landing_page_hero_image - field_landing_page_hero_theme + - field_landing_page_hero_image - field_landing_page_hero_logo - field_graphical_image - field_bottom_graphical_image diff --git a/modules/tide_landing_page/config/install/field.field.node.landing_page.field_landing_page_hero_theme.yml b/modules/tide_landing_page/config/install/field.field.node.landing_page.field_landing_page_hero_theme.yml index 4dc077950..e79189c12 100644 --- a/modules/tide_landing_page/config/install/field.field.node.landing_page.field_landing_page_hero_theme.yml +++ b/modules/tide_landing_page/config/install/field.field.node.landing_page.field_landing_page_hero_theme.yml @@ -14,7 +14,9 @@ label: Page title display style description: 'By default the page title will display in the site’s primary colour. If you choose ‘Reverse blocked text’ the heading and introduction text will be white with a coloured block behind the text (the site’s ‘accent contrast’ and ‘accent alternate’ colours). See Ripple header page to understand the header component design.' required: true translatable: false -default_value: { } +default_value: + - + value: light default_value_callback: '' settings: { } field_type: list_string diff --git a/modules/tide_landing_page/tide_landing_page.install b/modules/tide_landing_page/tide_landing_page.install index 56907dec3..9a49ef16b 100644 --- a/modules/tide_landing_page/tide_landing_page.install +++ b/modules/tide_landing_page/tide_landing_page.install @@ -232,12 +232,11 @@ function tide_landing_page_update_10108() { function tide_landing_page_update_10109() { $config = \Drupal::configFactory()->getEditable('field.storage.node.field_landing_page_hero_theme'); $allowed_values = $config->get('settings.allowed_values'); - foreach ($allowed_values as $allowed_value) { + foreach ($allowed_values as $key => $allowed_value) { if ($allowed_value['label'] === 'Dark') { - $allowed_value['label'] = 'Reverse blocked text'; - } - elseif ($allowed_value['label'] === 'Light') { - $allowed_value['label'] = 'Default'; + $allowed_values[$key]['label'] = 'Reverse blocked text'; + } elseif ($allowed_value['label'] === 'Light') { + $allowed_values[$key]['label'] = 'Default'; } } $config->set('settings.allowed_values', $allowed_values); diff --git a/modules/tide_publication/config/install/core.entity_form_display.node.publication.default.yml b/modules/tide_publication/config/install/core.entity_form_display.node.publication.default.yml index 76843c195..019d29b8d 100644 --- a/modules/tide_publication/config/install/core.entity_form_display.node.publication.default.yml +++ b/modules/tide_publication/config/install/core.entity_form_display.node.publication.default.yml @@ -133,8 +133,8 @@ third_party_settings: label: 'Customised Header' parent_name: group_section_header children: - - field_landing_page_hero_image - field_landing_page_hero_theme + - field_landing_page_hero_image format_type: tab format_settings: description: '' diff --git a/modules/tide_publication/config/install/core.entity_form_display.node.publication_page.default.yml b/modules/tide_publication/config/install/core.entity_form_display.node.publication_page.default.yml index a1a808a0c..6d99612e6 100644 --- a/modules/tide_publication/config/install/core.entity_form_display.node.publication_page.default.yml +++ b/modules/tide_publication/config/install/core.entity_form_display.node.publication_page.default.yml @@ -126,8 +126,8 @@ third_party_settings: label: 'Customised Header' parent_name: group_section_header children: - - field_landing_page_hero_image - field_landing_page_hero_theme + - field_landing_page_hero_image format_type: tab format_settings: description: '' diff --git a/modules/tide_publication/config/install/field.field.node.publication.field_landing_page_hero_theme.yml b/modules/tide_publication/config/install/field.field.node.publication.field_landing_page_hero_theme.yml index 7f2dbc7c5..24c69d439 100644 --- a/modules/tide_publication/config/install/field.field.node.publication.field_landing_page_hero_theme.yml +++ b/modules/tide_publication/config/install/field.field.node.publication.field_landing_page_hero_theme.yml @@ -16,7 +16,7 @@ required: true translatable: true default_value: - - value: default + value: light default_value_callback: '' settings: { } field_type: list_string diff --git a/modules/tide_publication/config/install/field.field.node.publication_page.field_landing_page_hero_theme.yml b/modules/tide_publication/config/install/field.field.node.publication_page.field_landing_page_hero_theme.yml index 64847289f..6c4fc2800 100644 --- a/modules/tide_publication/config/install/field.field.node.publication_page.field_landing_page_hero_theme.yml +++ b/modules/tide_publication/config/install/field.field.node.publication_page.field_landing_page_hero_theme.yml @@ -16,7 +16,7 @@ required: true translatable: true default_value: - - value: default + value: light default_value_callback: '' settings: { } field_type: list_string diff --git a/modules/tide_publication/tide_publication.module b/modules/tide_publication/tide_publication.module index 7dd65b6e5..322d63e7d 100644 --- a/modules/tide_publication/tide_publication.module +++ b/modules/tide_publication/tide_publication.module @@ -72,12 +72,6 @@ function tide_publication_form_node_form_alter(&$form, FormStateInterface $form_ $form['#process'][] = '_tide_publication_form_node_form_process'; - // Move Hero Image theme to Hero Image field group. - if (isset($form['field_landing_page_hero_theme']) && isset($form['field_landing_page_hero_image']['widget'])) { - $form['field_landing_page_hero_image']['widget']['field_landing_page_hero_theme'] = $form['field_landing_page_hero_theme']; - unset($form['field_landing_page_hero_theme']); - } - // Add conditional field for show table of content. if (isset($form['field_node_display_headings'])) { $form['field_node_display_headings']['#states'] = [ @@ -126,6 +120,13 @@ function _tide_publication_form_node_form_process(array $form, FormStateInterfac 'default' => t('Default appearance'), 'fullwidth' => t('Full-width background image'), ], + '#ajax' => [ + 'callback' => 'tide_landing_page_set_value_hero_image_theme', + ], + ]; + + $form['field_landing_page_hero_theme']['#states']['enabled'] = [ + ':input[name="_header_style_options"]' => ['value' => 'corner'], ]; $form['field_landing_page_hero_image']['#states']['visible'] = [