Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SD-22]Updated hero image theme according header style #516

Open
wants to merge 27 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
c7d45c8
added logic for landing page
yeniatencio Oct 1, 2024
30e903b
Added hook update
yeniatencio Oct 1, 2024
2c041b6
updated behat test
yeniatencio Oct 1, 2024
f3a0c31
remove patch as new released has been launched
yeniatencio Oct 2, 2024
9672fbc
Updated
yeniatencio Oct 8, 2024
af3eca9
resolving conflicts
yeniatencio Oct 23, 2024
0e68315
Replaced drupal state condition with JS due to bug in Drupal core #st…
yeniatencio Oct 28, 2024
79067b4
Merge branch 'develop' into feature/SD-22-customised-options
yeniatencio Nov 1, 2024
783369c
Merge branch 'develop' into feature/SD-22-customised-options
yeniatencio Nov 1, 2024
d6325e1
Merge branch 'develop' into feature/SD-22-customised-options
yeniatencio Nov 13, 2024
c25234d
Merge branch 'develop' into feature/SD-22-customised-options
yeniatencio Nov 17, 2024
ab1735a
Implement feedback
yeniatencio Nov 17, 2024
4d1de87
test
vincent-gao Nov 18, 2024
294b0c6
fixed lint
yeniatencio Nov 21, 2024
eb3f802
added function description
yeniatencio Nov 21, 2024
c2996c2
added function description
yeniatencio Nov 21, 2024
6a00fe0
removed js
yeniatencio Nov 25, 2024
704ba8d
Merge branch 'develop' into feature/SD-22-customised-options
yeniatencio Nov 25, 2024
950b3f8
Update tide_landing_page.module
yeniatencio Nov 25, 2024
4524117
upgrade search api version
yeniatencio Nov 25, 2024
ad83ea7
upgrade patch
yeniatencio Nov 25, 2024
df394a3
Merge branch 'develop' into feature/SD-22-customised-options
yeniatencio Nov 25, 2024
9289343
added behat test for hero theme scenarios
yeniatencio Nov 25, 2024
66d8688
fixed lint
yeniatencio Nov 25, 2024
186915c
Merge branch 'develop' into feature/SD-22-customised-options
yeniatencio Nov 25, 2024
0852f96
Merge branch 'develop' into feature/SD-22-customised-options
yeniatencio Nov 26, 2024
a40650e
Merge branch 'develop' into feature/SD-22-customised-options
yeniatencio Nov 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ 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
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
required: true
translatable: false
default_value: { }
default_value_callback: ''
Expand Down
48 changes: 48 additions & 0 deletions modules/tide_landing_page/tests/behat/features/fields.feature
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,15 @@ Feature: Fields for Landing Page content type
And I should see text matching "Call to action banner"
And I should see text matching "No Hero Banner with CTA added yet."
And I should see the button "Add Hero banner with CTA" in the "content" region
And I should see a "select#edit-field-landing-page-hero-theme" element

And the "#edit-field-landing-page-hero-logo" element should contain "Logo"
And I should see an "input#edit-field-landing-page-hero-logo-entity-browser-entity-browser-open-modal" element

And I select the radio button "Corner graphics"
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"
Expand Down Expand Up @@ -156,13 +158,15 @@ Feature: Fields for Landing Page content type
And I should see text matching "Call to action banner"
And I should see text matching "No Hero Banner with CTA added yet."
And I should see the button "Add Hero banner with CTA" in the "content" region
And I should see a "select#edit-field-landing-page-hero-theme" element

And the "#edit-field-landing-page-hero-logo" element should contain "Logo"
And I should see an "input#edit-field-landing-page-hero-logo-entity-browser-entity-browser-open-modal" element

And I select the radio button "Corner graphics"
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"
Expand Down Expand Up @@ -300,3 +304,47 @@ 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 "Light"
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 "Light"
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 "Dark"
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 "Light"
And save screenshot
21 changes: 21 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,24 @@ 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.
*/
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('Hero image theme');
$field->setRequired(TRUE);
$field->setDefaultValue('light');
$field->save();
}
}
}
38 changes: 36 additions & 2 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 @@ -371,6 +373,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,14 +435,18 @@ 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_image']['#states']['visible'] = [
$form['field_landing_page_hero_image']['widget']['field_landing_page_hero_theme']['#states']['disabled'] = [
':input[name="_header_style_options"]' => [
['value' => 'default'],
['value' => 'fullwidth'],
['value' => 'cta'],
],
];

$form['field_graphical_image']['#states']['visible'] = [
':input[name="_header_style_options"]' => ['value' => 'corner'],
];
Expand Down
7 changes: 2 additions & 5 deletions modules/tide_publication/tide_publication.module
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,8 @@ function _tide_publication_form_node_form_process(array $form, FormStateInterfac
],
];

$form['field_landing_page_hero_image']['#states']['visible'] = [
':input[name="_header_style_options"]' => [
['value' => 'fullwidth'],
['value' => 'cta'],
],
$form['field_landing_page_hero_image']['widget']['field_landing_page_hero_theme']['#states']['enabled'] = [
':input[name="_header_style_options"]' => ['value' => 'corner'],
];

// Determine the initial value of Header style.
Expand Down