Skip to content

Commit

Permalink
Fixed hook update, visibility and default values on landing page and …
Browse files Browse the repository at this point in the history
…publication
  • Loading branch information
yeniatencio committed Dec 18, 2024
1 parent a89cd26 commit 8f1be43
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <a href="https://ripple.sdp.vic.gov.au/design-system/components/header">Ripple header page to understand the header </a>component design.'
required: true
translatable: false
default_value: { }
default_value:
-
value: light
default_value_callback: ''
settings: { }
field_type: list_string
9 changes: 4 additions & 5 deletions modules/tide_landing_page/tide_landing_page.install
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: ''
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: ''
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ required: true
translatable: true
default_value:
-
value: default
value: light
default_value_callback: ''
settings: { }
field_type: list_string
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ required: true
translatable: true
default_value:
-
value: default
value: light
default_value_callback: ''
settings: { }
field_type: list_string
13 changes: 7 additions & 6 deletions modules/tide_publication/tide_publication.module
Original file line number Diff line number Diff line change
Expand Up @@ -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'] = [
Expand Down Expand Up @@ -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'] = [
Expand Down

0 comments on commit 8f1be43

Please sign in to comment.