From 6a00fe0c25b84d13520822c9e920f07c5fd54861 Mon Sep 17 00:00:00 2001 From: Yeni Atencio Date: Mon, 25 Nov 2024 20:02:40 +1100 Subject: [PATCH] removed js --- .../tide_landing_page/js/hero_image_theme.js | 40 ------------------- .../tests/behat/features/fields.feature | 9 +++++ .../tide_landing_page.install | 1 + .../tide_landing_page.libraries.yml | 1 - .../tide_landing_page.module | 4 +- 5 files changed, 12 insertions(+), 43 deletions(-) delete mode 100644 modules/tide_landing_page/js/hero_image_theme.js diff --git a/modules/tide_landing_page/js/hero_image_theme.js b/modules/tide_landing_page/js/hero_image_theme.js deleted file mode 100644 index a4f9a82d0..000000000 --- a/modules/tide_landing_page/js/hero_image_theme.js +++ /dev/null @@ -1,40 +0,0 @@ -(function (Drupal) { - 'use strict'; - - Drupal.behaviors.heroImageTheme = { - attach: function (context) { - const imageTheme = context.querySelector( - 'select[data-drupal-selector^="edit-field-landing-page-hero-theme"]' - ); - - if (imageTheme !== null) { - setImageTheme(); - - const headerStyles = context.querySelectorAll( - 'input[data-drupal-selector^="edit-header-style-options"]' - ); - - if (headerStyles.length > 0) { - headerStyles.forEach((style) => { - style.addEventListener('change', setImageTheme); - }); - } - } - - function setImageTheme() { - const selectedHeaderStyle = context.querySelector( - 'input[data-drupal-selector^="edit-header-style-options"]:checked' - ); - - if (!selectedHeaderStyle) { - return; // Exit if no style option is selected. - } - - let defaultHeaderStyle = selectedHeaderStyle.value; - imageTheme.disabled = defaultHeaderStyle === 'corner' ? false : true; - imageTheme.value = - defaultHeaderStyle === 'fullwidth' ? 'dark' : 'light'; - } - }, - }; -})(Drupal); diff --git a/modules/tide_landing_page/tests/behat/features/fields.feature b/modules/tide_landing_page/tests/behat/features/fields.feature index c9b09dd63..280d5de7a 100644 --- a/modules/tide_landing_page/tests/behat/features/fields.feature +++ b/modules/tide_landing_page/tests/behat/features/fields.feature @@ -304,3 +304,12 @@ 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 a value from the field Hero image theme. + Given I am logged in as a user with the "create landing_page content" permission + When I visit "node/add/landing_page" + And I click "Customised Header" + Then I select "Corner graphics" from "edit-header-style-options-corner" + Then I select "Hero image theme" from "edit-field-landing-page-hero-theme" + And save screenshot diff --git a/modules/tide_landing_page/tide_landing_page.install b/modules/tide_landing_page/tide_landing_page.install index b2869d956..126dc781c 100644 --- a/modules/tide_landing_page/tide_landing_page.install +++ b/modules/tide_landing_page/tide_landing_page.install @@ -210,6 +210,7 @@ function tide_landing_page_update_10107() { if (!empty($field)) { $field->setLabel('Hero image theme'); $field->setRequired(TRUE); + $field->setDefaultValue('light'); $field->save(); } } diff --git a/modules/tide_landing_page/tide_landing_page.libraries.yml b/modules/tide_landing_page/tide_landing_page.libraries.yml index a0928ca57..9f056fcd9 100644 --- a/modules/tide_landing_page/tide_landing_page.libraries.yml +++ b/modules/tide_landing_page/tide_landing_page.libraries.yml @@ -5,6 +5,5 @@ landing_page_form: js: js/hide_elements.js: {} js/statistics_grid.js: {} - js/hero_image_theme.js: {} dependencies: - core/jquery diff --git a/modules/tide_landing_page/tide_landing_page.module b/modules/tide_landing_page/tide_landing_page.module index e78b8c140..d1934a6f7 100644 --- a/modules/tide_landing_page/tide_landing_page.module +++ b/modules/tide_landing_page/tide_landing_page.module @@ -376,7 +376,7 @@ function tide_landing_page_field_widget_single_element_paragraphs_form_alter(&$e } /** - * Function to change value. + * Function to set value to Hero image theme. * * @param array $form * The form. @@ -386,7 +386,7 @@ function tide_landing_page_field_widget_single_element_paragraphs_form_alter(&$e * @return Drupal\Core\Ajax\AjaxResponse * The response. */ -function tide_landing_page_change_the_value(array $form, FormStateInterface $form_state): AjaxResponse { +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') {