Skip to content

Commit

Permalink
Merge branch 'develop' into feature/SD-623-change-settings-iframe-embed
Browse files Browse the repository at this point in the history
  • Loading branch information
yeniatencio authored Jan 12, 2025
2 parents 730ab5c + f3a0ee4 commit 2a7586c
Show file tree
Hide file tree
Showing 11 changed files with 160 additions and 28 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 @@ -10,11 +10,13 @@ id: node.landing_page.field_landing_page_hero_theme
field_name: field_landing_page_hero_theme
entity_type: node
bundle: landing_page
label: Here image theme
description: 'If your hero image is mostly dark, apply the dark theme. This changes how the page title is displayed.'
required: false
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
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ settings:
allowed_values:
-
value: dark
label: Dark
label: Reverse blocked text
-
value: light
label: Light
label: Default
allowed_values_function: ''
module: options
locked: false
Expand Down
49 changes: 49 additions & 0 deletions modules/tide_landing_page/tests/behat/features/fields.feature
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ Feature: Fields for Landing Page content type
And the "#edit-field-bottom-graphical-image" element should contain "Bottom Corner Graphic"
And I should see an "input#edit-field-bottom-graphical-image-entity-browser-target" element

And I should see a "select#edit-field-landing-page-hero-theme" element

And I click on the horizontal tab "Header extras"
And I should see text matching "Header components"
And I press the "edit-field-landing-page-header-add-more-add-modal-form-area-add-more" button
Expand Down Expand Up @@ -164,6 +166,8 @@ Feature: Fields for Landing Page content type
And the "#edit-field-bottom-graphical-image" element should contain "Bottom Corner Graphic"
And I should see an "input#edit-field-bottom-graphical-image-entity-browser-target" element

And I should see a "select#edit-field-landing-page-hero-theme" element

And I click on the horizontal tab "Header extras"
And I should see text matching "Header components"
And I press the "edit-field-landing-page-header-add-more-add-modal-form-area-add-more" button
Expand Down Expand Up @@ -300,3 +304,48 @@ Feature: Fields for Landing Page content type
# This field can be "seen" but not visible.
And I see field "field_landing_page_component[0][subform][field_customise][value]"
And save screenshot


@api @javascript
Scenario: Selecting Corner graphics value from header style.
Given I am logged in as a user with the "editor" role
When I visit "node/add/landing_page"
And I click on the horizontal tab "Customised Header"
Then I should see an "#edit-header-style-options-corner" element
And I select "corner" from "edit-header-style-options-corner"
Then I should see an "#edit-field-landing-page-hero-theme" element
And I should see text matching "Default"
And save screenshot

@api @javascript
Scenario: Selecting Default appearance value from header style.
Given I am logged in as a user with the "editor" role
When I visit "node/add/landing_page"
And I click on the horizontal tab "Customised Header"
Then I should see an "#edit-header-style-options-default" element
And I select "corner" from "edit-header-style-options-default"
Then I should see an "#edit-field-landing-page-hero-theme" element
And I should see text matching "Default"
And save screenshot

@api @javascript
Scenario: Selecting Full-width background image value from header style.
Given I am logged in as a user with the "editor" role
When I visit "node/add/landing_page"
And I click on the horizontal tab "Customised Header"
Then I should see an "#edit-header-style-options-fullwidtht" element
And I select "corner" from "edit-header-style-options-fullwidth"
Then I should see an "#edit-field-landing-page-hero-theme" element
And I should see text matching "Reverse blocked text"
And save screenshot

@api @javascript
Scenario: Selecting Call to action banner value from header style.
Given I am logged in as a user with the "editor" role
When I visit "node/add/landing_page"
And I click on the horizontal tab "Customised Header"
Then I should see an "#edit-header-style-options-cta" element
And I select "corner" from "edit-header-style-options-cta"
Then I should see an "#edit-field-landing-page-hero-theme" element
And I should see text matching "Default"
And save screenshot
40 changes: 40 additions & 0 deletions modules/tide_landing_page/tide_landing_page.install
Original file line number Diff line number Diff line change
Expand Up @@ -203,3 +203,43 @@ function tide_landing_page_update_10107() {
$tide_update_helper = \Drupal::service('tide_core.entity_update_helper');
$tide_update_helper->revert('field_config', 'paragraph.key_journeys.field_paragraph_title');
}

/**
* Set field `field_landing_page_hero_theme` to mandatory, description, label.
*/
function tide_landing_page_update_10108() {
$bundles = [
'landing_page',
'publication',
'publication_page',
];

foreach ($bundles as $bundle) {
$field = FieldConfig::loadByName('node', $bundle, 'field_landing_page_hero_theme');
if (!empty($field)) {
$field->setLabel('Page title display style');
$field->setRequired(TRUE);
$field->setDefaultValue('light');
$field->setDescription('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.');
$field->save();
}
}
}

/**
* Set label options for `field_landing_page_hero_theme`.
*/
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 $key => $allowed_value) {
if ($allowed_value['label'] === 'Dark') {
$allowed_values[$key]['label'] = 'Reverse blocked text';
}
elseif ($allowed_value['label'] === 'Light') {
$allowed_values[$key]['label'] = 'Default';
}
}
$config->set('settings.allowed_values', $allowed_values);
$config->save();
}
46 changes: 41 additions & 5 deletions modules/tide_landing_page/tide_landing_page.module
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* Tide Landing Page module functionality.
*/

use Drupal\Core\Ajax\AjaxResponse;
use Drupal\Core\Ajax\InvokeCommand;
use Drupal\Core\Cache\Cache;
use Drupal\Core\Field\WidgetBase;
use Drupal\Core\Form\FormStateInterface;
Expand Down Expand Up @@ -117,11 +119,6 @@ function tide_landing_page_form_node_form_alter(&$form, FormStateInterface $form
$form['field_landing_page_hero_image']['widget']['field_show_hero_image_caption'] = $form['field_show_hero_image_caption'];
unset($form['field_show_hero_image_caption']);
}
// 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']);
}

// @todo the below block needs to be in a proper widget alter.
if (isset($form['field_landing_page_component']['widget'][0])) {
Expand Down Expand Up @@ -371,6 +368,34 @@ function tide_landing_page_field_widget_single_element_paragraphs_form_alter(&$e
}
}

/**
* Function to set value to Hero image theme.
*
* @param array $form
* The form.
* @param Drupal\Core\Form\FormStateInterface $form_state
* The form state.
*
* @return Drupal\Core\Ajax\AjaxResponse
* The response.
*/
function tide_landing_page_set_value_hero_image_theme(array $form, FormStateInterface $form_state): AjaxResponse {
$response = new AjaxResponse();
$value = $form_state->getValue('_header_style_options');
if ($value === 'fullwidth') {
return $response->addCommand(new InvokeCommand(
'#edit-field-landing-page-hero-theme',
'val',
['dark']
));
}
return $response->addCommand(new InvokeCommand(
'#edit-field-landing-page-hero-theme',
'val',
['light']
));
}

/**
* Node form #process callback.
*
Expand Down Expand Up @@ -405,6 +430,16 @@ function _tide_landing_page_form_node_form_process(array $form, FormStateInterfa
'corner' => t('Corner graphics'),
'cta' => t('Call to action banner'),
],
'#ajax' => [
'callback' => 'tide_landing_page_set_value_hero_image_theme',
],
];

$form['field_landing_page_hero_theme']['#states']['disabled'] = [
':input[name="_header_style_options"]' => [
['value' => 'fullwidth'],
['value' => 'cta'],
],
];

$form['field_landing_page_hero_image']['#states']['visible'] = [
Expand All @@ -413,6 +448,7 @@ function _tide_landing_page_form_node_form_process(array $form, FormStateInterfa
['value' => 'cta'],
],
];

$form['field_graphical_image']['#states']['visible'] = [
':input[name="_header_style_options"]' => ['value' => 'corner'],
];
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 @@ -10,11 +10,13 @@ id: node.publication.field_landing_page_hero_theme
field_name: field_landing_page_hero_theme
entity_type: node
bundle: publication
label: 'Hero image theme'
description: 'If your hero image is mostly dark, apply the dark theme. This changes how the page title is displayed.'
required: false
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: true
default_value: { }
default_value:
-
value: light
default_value_callback: ''
settings: { }
field_type: list_string
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ id: node.publication_page.field_landing_page_hero_theme
field_name: field_landing_page_hero_theme
entity_type: node
bundle: publication_page
label: 'Hero image theme'
description: 'If your hero image is mostly dark, apply the dark theme. This changes how the page title is displayed.'
required: false
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: true
default_value: { }
default_value:
-
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 2a7586c

Please sign in to comment.