From 5cbadaeea570938c4a56100dd3795ce0e2980537 Mon Sep 17 00:00:00 2001 From: Abel Santos <abel.santos.corral@gmail.com> Date: Mon, 14 Mar 2022 08:34:23 +0100 Subject: [PATCH 01/21] OEL-1280: Add modules at composer.json for oe_whitelabel_paragraphs. --- composer.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index c942170a..9ab60f54 100644 --- a/composer.json +++ b/composer.json @@ -10,7 +10,7 @@ "cweagans/composer-patches": "^1.7", "drupal/core": "^9.2", "drupal/twig_field_value": "^2.0", - "openeuropa/oe_bootstrap_theme": "^1.0.0-alpha7" + "openeuropa/oe_bootstrap_theme": "dev-OEL-1280" }, "require-dev": { "composer/installers": "^1.11", @@ -19,6 +19,7 @@ "drupal/core-composer-scaffold": "^9.2", "drupal/core-dev": "^9.2", "drupal/ctools": "^3.7", + "drupal/description_list_field": "^1.0@alpha", "drupal/drupal-extension": "~4.1", "drupal/file_link": "^2.0.4", "drupal/pathauto": "^1.8", @@ -34,7 +35,9 @@ "openeuropa/oe_contact_forms": "~1.1", "openeuropa/oe_content": "^2.8.0", "openeuropa/oe_corporate_blocks": "^4.4", + "openeuropa/oe_media": "^1.14", "openeuropa/oe_multilingual": "^1.9", + "openeuropa/oe_paragraphs": "^1.12", "openeuropa/oe_starter_content": "1.x-dev", "openeuropa/task-runner-drupal-project-symlink": "^1.0-beta5", "phpspec/prophecy-phpunit": "^1 || ^2" -- GitLab From 280d105f97e2e70e9b1cb06b157f7d3df3ffb473 Mon Sep 17 00:00:00 2001 From: Abel Santos <abel.santos.corral@gmail.com> Date: Mon, 14 Mar 2022 08:35:37 +0100 Subject: [PATCH 02/21] OEL-1280: Add oe_whitelabel_paragraphs by copying oe_bootstrap_theme_paragraphs. Rename strings where needed. --- ....oe_description_list.oe_bt_orientation.yml | 22 + ...graph.oe_facts_figures.oe_bt_n_columns.yml | 24 + ...nks_block.oe_bt_links_block_background.yml | 22 + ...ks_block.oe_bt_links_block_orientation.yml | 22 + ...ia_follow.oe_bt_links_block_background.yml | 22 + ...paragraph.oe_bt_links_block_background.yml | 26 + ...aragraph.oe_bt_links_block_orientation.yml | 26 + ...ield.storage.paragraph.oe_bt_n_columns.yml | 19 + ...ld.storage.paragraph.oe_bt_orientation.yml | 26 + ...ay.paragraph.oe_accordion_item.default.yml | 36 ++ ....paragraph.oe_description_list.default.yml | 38 ++ ...lay.paragraph.oe_facts_figures.default.yml | 61 ++ ...splay.paragraph.oe_links_block.default.yml | 48 ++ ...display.paragraph.oe_list_item.default.yml | 71 +++ ...y.paragraph.oe_list_item_block.default.yml | 67 +++ ...paragraph.oe_list_item_block.highlight.yml | 68 +++ ...ragraph.oe_social_media_follow.default.yml | 57 ++ ...ay.paragraph.oe_accordion_item.default.yml | 32 ++ ....paragraph.oe_description_list.default.yml | 32 ++ ...lay.paragraph.oe_facts_figures.default.yml | 48 ++ ...splay.paragraph.oe_links_block.default.yml | 39 ++ ...ragraph.oe_social_media_follow.default.yml | 53 ++ ...a_follow.field_oe_social_media_variant.yml | 22 + ....paragraph.oe_description_list.default.yml | 38 ++ ....paragraph.oe_description_list.default.yml | 32 ++ ....oe_description_list.oe_bt_orientation.yml | 22 + ...ld.storage.paragraph.oe_bt_orientation.yml | 26 + ...ay.paragraph.oe_accordion_item.default.yml | 36 ++ ...ay.paragraph.oe_accordion_item.default.yml | 32 ++ ...lay.paragraph.oe_facts_figures.default.yml | 61 ++ ...display.paragraph.oe_list_item.default.yml | 71 +++ ...y.paragraph.oe_list_item_block.default.yml | 67 +++ ...paragraph.oe_list_item_block.highlight.yml | 68 +++ ...lay.paragraph.oe_facts_figures.default.yml | 48 ++ ...graph.oe_facts_figures.oe_bt_n_columns.yml | 24 + ...ield.storage.paragraph.oe_bt_n_columns.yml | 19 + .../oe_whitelabel_paragraphs.info.yml | 23 + .../oe_whitelabel_paragraphs.install | 40 ++ .../oe_whitelabel_paragraphs.module | 535 ++++++++++++++++++ .../oe_whitelabel_paragraphs.post_update.php | 65 +++ .../oe_whitelabel_paragraphs.services.yml | 5 + .../EventSubscriber/IconOptionsSubscriber.php | 57 ++ 42 files changed, 2150 insertions(+) create mode 100644 modules/oe_whitelabel_paragraphs/config/install/field.field.paragraph.oe_description_list.oe_bt_orientation.yml create mode 100644 modules/oe_whitelabel_paragraphs/config/install/field.field.paragraph.oe_facts_figures.oe_bt_n_columns.yml create mode 100644 modules/oe_whitelabel_paragraphs/config/install/field.field.paragraph.oe_links_block.oe_bt_links_block_background.yml create mode 100644 modules/oe_whitelabel_paragraphs/config/install/field.field.paragraph.oe_links_block.oe_bt_links_block_orientation.yml create mode 100644 modules/oe_whitelabel_paragraphs/config/install/field.field.paragraph.oe_social_media_follow.oe_bt_links_block_background.yml create mode 100644 modules/oe_whitelabel_paragraphs/config/install/field.storage.paragraph.oe_bt_links_block_background.yml create mode 100644 modules/oe_whitelabel_paragraphs/config/install/field.storage.paragraph.oe_bt_links_block_orientation.yml create mode 100644 modules/oe_whitelabel_paragraphs/config/install/field.storage.paragraph.oe_bt_n_columns.yml create mode 100644 modules/oe_whitelabel_paragraphs/config/install/field.storage.paragraph.oe_bt_orientation.yml create mode 100644 modules/oe_whitelabel_paragraphs/config/overrides/core.entity_form_display.paragraph.oe_accordion_item.default.yml create mode 100644 modules/oe_whitelabel_paragraphs/config/overrides/core.entity_form_display.paragraph.oe_description_list.default.yml create mode 100644 modules/oe_whitelabel_paragraphs/config/overrides/core.entity_form_display.paragraph.oe_facts_figures.default.yml create mode 100644 modules/oe_whitelabel_paragraphs/config/overrides/core.entity_form_display.paragraph.oe_links_block.default.yml create mode 100644 modules/oe_whitelabel_paragraphs/config/overrides/core.entity_form_display.paragraph.oe_list_item.default.yml create mode 100644 modules/oe_whitelabel_paragraphs/config/overrides/core.entity_form_display.paragraph.oe_list_item_block.default.yml create mode 100644 modules/oe_whitelabel_paragraphs/config/overrides/core.entity_form_display.paragraph.oe_list_item_block.highlight.yml create mode 100644 modules/oe_whitelabel_paragraphs/config/overrides/core.entity_form_display.paragraph.oe_social_media_follow.default.yml create mode 100644 modules/oe_whitelabel_paragraphs/config/overrides/core.entity_view_display.paragraph.oe_accordion_item.default.yml create mode 100644 modules/oe_whitelabel_paragraphs/config/overrides/core.entity_view_display.paragraph.oe_description_list.default.yml create mode 100644 modules/oe_whitelabel_paragraphs/config/overrides/core.entity_view_display.paragraph.oe_facts_figures.default.yml create mode 100644 modules/oe_whitelabel_paragraphs/config/overrides/core.entity_view_display.paragraph.oe_links_block.default.yml create mode 100644 modules/oe_whitelabel_paragraphs/config/overrides/core.entity_view_display.paragraph.oe_social_media_follow.default.yml create mode 100755 modules/oe_whitelabel_paragraphs/config/overrides/field.field.paragraph.oe_social_media_follow.field_oe_social_media_variant.yml create mode 100644 modules/oe_whitelabel_paragraphs/config/post_updates/00001/core.entity_form_display.paragraph.oe_description_list.default.yml create mode 100644 modules/oe_whitelabel_paragraphs/config/post_updates/00001/core.entity_view_display.paragraph.oe_description_list.default.yml create mode 100644 modules/oe_whitelabel_paragraphs/config/post_updates/00001/field.field.paragraph.oe_description_list.oe_bt_orientation.yml create mode 100644 modules/oe_whitelabel_paragraphs/config/post_updates/00001/field.storage.paragraph.oe_bt_orientation.yml create mode 100644 modules/oe_whitelabel_paragraphs/config/post_updates/00002/core.entity_form_display.paragraph.oe_accordion_item.default.yml create mode 100644 modules/oe_whitelabel_paragraphs/config/post_updates/00002/core.entity_view_display.paragraph.oe_accordion_item.default.yml create mode 100644 modules/oe_whitelabel_paragraphs/config/post_updates/00003/core.entity_form_display.paragraph.oe_facts_figures.default.yml create mode 100644 modules/oe_whitelabel_paragraphs/config/post_updates/00003/core.entity_form_display.paragraph.oe_list_item.default.yml create mode 100644 modules/oe_whitelabel_paragraphs/config/post_updates/00003/core.entity_form_display.paragraph.oe_list_item_block.default.yml create mode 100644 modules/oe_whitelabel_paragraphs/config/post_updates/00003/core.entity_form_display.paragraph.oe_list_item_block.highlight.yml create mode 100644 modules/oe_whitelabel_paragraphs/config/post_updates/00003/core.entity_view_display.paragraph.oe_facts_figures.default.yml create mode 100644 modules/oe_whitelabel_paragraphs/config/post_updates/00003/field.field.paragraph.oe_facts_figures.oe_bt_n_columns.yml create mode 100644 modules/oe_whitelabel_paragraphs/config/post_updates/00003/field.storage.paragraph.oe_bt_n_columns.yml create mode 100644 modules/oe_whitelabel_paragraphs/oe_whitelabel_paragraphs.info.yml create mode 100644 modules/oe_whitelabel_paragraphs/oe_whitelabel_paragraphs.install create mode 100644 modules/oe_whitelabel_paragraphs/oe_whitelabel_paragraphs.module create mode 100644 modules/oe_whitelabel_paragraphs/oe_whitelabel_paragraphs.post_update.php create mode 100644 modules/oe_whitelabel_paragraphs/oe_whitelabel_paragraphs.services.yml create mode 100644 modules/oe_whitelabel_paragraphs/src/EventSubscriber/IconOptionsSubscriber.php diff --git a/modules/oe_whitelabel_paragraphs/config/install/field.field.paragraph.oe_description_list.oe_bt_orientation.yml b/modules/oe_whitelabel_paragraphs/config/install/field.field.paragraph.oe_description_list.oe_bt_orientation.yml new file mode 100644 index 00000000..73b09a47 --- /dev/null +++ b/modules/oe_whitelabel_paragraphs/config/install/field.field.paragraph.oe_description_list.oe_bt_orientation.yml @@ -0,0 +1,22 @@ +langcode: en +status: true +dependencies: + config: + - field.storage.paragraph.oe_bt_orientation + - paragraphs.paragraphs_type.oe_description_list + module: + - options +id: paragraph.oe_description_list.oe_bt_orientation +field_name: oe_bt_orientation +entity_type: paragraph +bundle: oe_description_list +label: Orientation +description: 'Sets the orientation (vertical|horizontal) for the paragraph.' +required: true +translatable: false +default_value: + - + value: horizontal +default_value_callback: '' +settings: { } +field_type: list_string diff --git a/modules/oe_whitelabel_paragraphs/config/install/field.field.paragraph.oe_facts_figures.oe_bt_n_columns.yml b/modules/oe_whitelabel_paragraphs/config/install/field.field.paragraph.oe_facts_figures.oe_bt_n_columns.yml new file mode 100644 index 00000000..eec70a14 --- /dev/null +++ b/modules/oe_whitelabel_paragraphs/config/install/field.field.paragraph.oe_facts_figures.oe_bt_n_columns.yml @@ -0,0 +1,24 @@ +langcode: en +status: true +dependencies: + config: + - field.storage.paragraph.oe_bt_n_columns + - paragraphs.paragraphs_type.oe_facts_figures +id: paragraph.oe_facts_figures.oe_bt_n_columns +field_name: oe_bt_n_columns +entity_type: paragraph +bundle: oe_facts_figures +label: 'Number of columns' +description: 'Sets the number of grid columns. Minimum number is 1 column and maximum is 3.' +required: false +translatable: false +default_value: + - + value: 1 +default_value_callback: '' +settings: + min: 1 + max: 3 + prefix: '' + suffix: '' +field_type: integer diff --git a/modules/oe_whitelabel_paragraphs/config/install/field.field.paragraph.oe_links_block.oe_bt_links_block_background.yml b/modules/oe_whitelabel_paragraphs/config/install/field.field.paragraph.oe_links_block.oe_bt_links_block_background.yml new file mode 100644 index 00000000..de66c697 --- /dev/null +++ b/modules/oe_whitelabel_paragraphs/config/install/field.field.paragraph.oe_links_block.oe_bt_links_block_background.yml @@ -0,0 +1,22 @@ +langcode: en +status: true +dependencies: + config: + - field.storage.paragraph.oe_bt_links_block_background + - paragraphs.paragraphs_type.oe_links_block + module: + - options +id: paragraph.oe_links_block.oe_bt_links_block_background +field_name: oe_bt_links_block_background +entity_type: paragraph +bundle: oe_links_block +label: Background +description: 'Allows to select the background color of the links block.' +required: false +translatable: false +default_value: + - + value: gray +default_value_callback: '' +settings: { } +field_type: list_string diff --git a/modules/oe_whitelabel_paragraphs/config/install/field.field.paragraph.oe_links_block.oe_bt_links_block_orientation.yml b/modules/oe_whitelabel_paragraphs/config/install/field.field.paragraph.oe_links_block.oe_bt_links_block_orientation.yml new file mode 100644 index 00000000..610c35d3 --- /dev/null +++ b/modules/oe_whitelabel_paragraphs/config/install/field.field.paragraph.oe_links_block.oe_bt_links_block_orientation.yml @@ -0,0 +1,22 @@ +langcode: en +status: true +dependencies: + config: + - field.storage.paragraph.oe_bt_links_block_orientation + - paragraphs.paragraphs_type.oe_links_block + module: + - options +id: paragraph.oe_links_block.oe_bt_links_block_orientation +field_name: oe_bt_links_block_orientation +entity_type: paragraph +bundle: oe_links_block +label: Orientation +description: 'Allows to select the direction of the links block.' +required: false +translatable: false +default_value: + - + value: vertical +default_value_callback: '' +settings: { } +field_type: list_string diff --git a/modules/oe_whitelabel_paragraphs/config/install/field.field.paragraph.oe_social_media_follow.oe_bt_links_block_background.yml b/modules/oe_whitelabel_paragraphs/config/install/field.field.paragraph.oe_social_media_follow.oe_bt_links_block_background.yml new file mode 100644 index 00000000..8e167195 --- /dev/null +++ b/modules/oe_whitelabel_paragraphs/config/install/field.field.paragraph.oe_social_media_follow.oe_bt_links_block_background.yml @@ -0,0 +1,22 @@ +langcode: en +status: true +dependencies: + config: + - field.storage.paragraph.oe_bt_links_block_background + - paragraphs.paragraphs_type.oe_social_media_follow + module: + - options +id: paragraph.oe_social_media_follow.oe_bt_links_block_background +field_name: oe_bt_links_block_background +entity_type: paragraph +bundle: oe_social_media_follow +label: Background +description: 'Allows to select the background color of the Social Media Links block.' +required: false +translatable: false +default_value: + - + value: gray +default_value_callback: '' +settings: { } +field_type: list_string diff --git a/modules/oe_whitelabel_paragraphs/config/install/field.storage.paragraph.oe_bt_links_block_background.yml b/modules/oe_whitelabel_paragraphs/config/install/field.storage.paragraph.oe_bt_links_block_background.yml new file mode 100644 index 00000000..1a7dbec0 --- /dev/null +++ b/modules/oe_whitelabel_paragraphs/config/install/field.storage.paragraph.oe_bt_links_block_background.yml @@ -0,0 +1,26 @@ +langcode: en +status: true +dependencies: + module: + - options + - paragraphs +id: paragraph.oe_bt_links_block_background +field_name: oe_bt_links_block_background +entity_type: paragraph +type: list_string +settings: + allowed_values: + - + value: gray + label: Gray + - + value: transparent + label: Transparent + allowed_values_function: '' +module: options +locked: false +cardinality: 1 +translatable: true +indexes: { } +persist_with_no_fields: false +custom_storage: false diff --git a/modules/oe_whitelabel_paragraphs/config/install/field.storage.paragraph.oe_bt_links_block_orientation.yml b/modules/oe_whitelabel_paragraphs/config/install/field.storage.paragraph.oe_bt_links_block_orientation.yml new file mode 100644 index 00000000..d582eb81 --- /dev/null +++ b/modules/oe_whitelabel_paragraphs/config/install/field.storage.paragraph.oe_bt_links_block_orientation.yml @@ -0,0 +1,26 @@ +langcode: en +status: true +dependencies: + module: + - options + - paragraphs +id: paragraph.oe_bt_links_block_orientation +field_name: oe_bt_links_block_orientation +entity_type: paragraph +type: list_string +settings: + allowed_values: + - + value: horizontal + label: Horizontal + - + value: vertical + label: Vertical + allowed_values_function: '' +module: options +locked: false +cardinality: 1 +translatable: true +indexes: { } +persist_with_no_fields: false +custom_storage: false diff --git a/modules/oe_whitelabel_paragraphs/config/install/field.storage.paragraph.oe_bt_n_columns.yml b/modules/oe_whitelabel_paragraphs/config/install/field.storage.paragraph.oe_bt_n_columns.yml new file mode 100644 index 00000000..f2a74071 --- /dev/null +++ b/modules/oe_whitelabel_paragraphs/config/install/field.storage.paragraph.oe_bt_n_columns.yml @@ -0,0 +1,19 @@ +langcode: en +status: true +dependencies: + module: + - paragraphs +id: paragraph.oe_bt_n_columns +field_name: oe_bt_n_columns +entity_type: paragraph +type: integer +settings: + unsigned: false + size: normal +module: core +locked: false +cardinality: 1 +translatable: true +indexes: { } +persist_with_no_fields: false +custom_storage: false diff --git a/modules/oe_whitelabel_paragraphs/config/install/field.storage.paragraph.oe_bt_orientation.yml b/modules/oe_whitelabel_paragraphs/config/install/field.storage.paragraph.oe_bt_orientation.yml new file mode 100644 index 00000000..94f290a8 --- /dev/null +++ b/modules/oe_whitelabel_paragraphs/config/install/field.storage.paragraph.oe_bt_orientation.yml @@ -0,0 +1,26 @@ +langcode: en +status: true +dependencies: + module: + - options + - paragraphs +id: paragraph.oe_bt_orientation +field_name: oe_bt_orientation +entity_type: paragraph +type: list_string +settings: + allowed_values: + - + value: vertical + label: Vertical + - + value: horizontal + label: Horizontal + allowed_values_function: '' +module: options +locked: false +cardinality: 1 +translatable: true +indexes: { } +persist_with_no_fields: false +custom_storage: false diff --git a/modules/oe_whitelabel_paragraphs/config/overrides/core.entity_form_display.paragraph.oe_accordion_item.default.yml b/modules/oe_whitelabel_paragraphs/config/overrides/core.entity_form_display.paragraph.oe_accordion_item.default.yml new file mode 100644 index 00000000..3b7368e6 --- /dev/null +++ b/modules/oe_whitelabel_paragraphs/config/overrides/core.entity_form_display.paragraph.oe_accordion_item.default.yml @@ -0,0 +1,36 @@ +langcode: en +status: true +dependencies: + config: + - field.field.paragraph.oe_accordion_item.field_oe_icon + - field.field.paragraph.oe_accordion_item.field_oe_text + - field.field.paragraph.oe_accordion_item.field_oe_text_long + - paragraphs.paragraphs_type.oe_accordion_item + module: + - text +id: paragraph.oe_accordion_item.default +targetEntityType: paragraph +bundle: oe_accordion_item +mode: default +content: + field_oe_text: + weight: 0 + settings: + size: 60 + placeholder: '' + third_party_settings: { } + type: string_textfield + region: content + field_oe_text_long: + weight: 1 + settings: + rows: 5 + placeholder: '' + third_party_settings: { } + type: text_textarea + region: content +hidden: + created: true + field_oe_icon: true + status: true + uid: true diff --git a/modules/oe_whitelabel_paragraphs/config/overrides/core.entity_form_display.paragraph.oe_description_list.default.yml b/modules/oe_whitelabel_paragraphs/config/overrides/core.entity_form_display.paragraph.oe_description_list.default.yml new file mode 100644 index 00000000..363809de --- /dev/null +++ b/modules/oe_whitelabel_paragraphs/config/overrides/core.entity_form_display.paragraph.oe_description_list.default.yml @@ -0,0 +1,38 @@ +langcode: en +status: true +dependencies: + config: + - field.field.paragraph.oe_description_list.field_oe_description_list_items + - field.field.paragraph.oe_description_list.field_oe_title + - field.field.paragraph.oe_description_list.oe_bt_orientation + - paragraphs.paragraphs_type.oe_description_list + module: + - description_list_field +id: paragraph.oe_description_list.default +targetEntityType: paragraph +bundle: oe_description_list +mode: default +content: + field_oe_description_list_items: + weight: 2 + settings: { } + third_party_settings: { } + type: description_list_widget + region: content + field_oe_title: + weight: 1 + settings: + size: 60 + placeholder: '' + third_party_settings: { } + type: string_textfield + region: content + oe_bt_orientation: + type: options_select + weight: 0 + region: content + settings: { } + third_party_settings: { } +hidden: + created: true + status: true diff --git a/modules/oe_whitelabel_paragraphs/config/overrides/core.entity_form_display.paragraph.oe_facts_figures.default.yml b/modules/oe_whitelabel_paragraphs/config/overrides/core.entity_form_display.paragraph.oe_facts_figures.default.yml new file mode 100644 index 00000000..96a0c1fb --- /dev/null +++ b/modules/oe_whitelabel_paragraphs/config/overrides/core.entity_form_display.paragraph.oe_facts_figures.default.yml @@ -0,0 +1,61 @@ +langcode: en +status: true +dependencies: + config: + - field.field.paragraph.oe_facts_figures.field_oe_link + - field.field.paragraph.oe_facts_figures.field_oe_paragraphs + - field.field.paragraph.oe_facts_figures.field_oe_title + - field.field.paragraph.oe_facts_figures.oe_bt_n_columns + - paragraphs.paragraphs_type.oe_facts_figures + module: + - link + - oe_paragraphs +id: paragraph.oe_facts_figures.default +targetEntityType: paragraph +bundle: oe_facts_figures +mode: default +content: + field_oe_link: + type: link_default + weight: 2 + region: content + settings: + placeholder_url: '' + placeholder_title: '' + third_party_settings: { } + field_oe_paragraphs: + type: oe_paragraphs_variants + weight: 8 + region: content + settings: + title: Paragraph + title_plural: Paragraphs + edit_mode: open + add_mode: dropdown + form_display_mode: default + default_paragraph_type: '' + closed_mode: summary + autocollapse: none + closed_mode_threshold: 0 + features: + collapse_edit_all: collapse_edit_all + duplicate: duplicate + third_party_settings: { } + field_oe_title: + type: string_textfield + weight: 1 + region: content + settings: + size: 60 + placeholder: '' + third_party_settings: { } + oe_bt_n_columns: + weight: 6 + settings: + placeholder: '' + third_party_settings: { } + type: number + region: content +hidden: + created: true + status: true diff --git a/modules/oe_whitelabel_paragraphs/config/overrides/core.entity_form_display.paragraph.oe_links_block.default.yml b/modules/oe_whitelabel_paragraphs/config/overrides/core.entity_form_display.paragraph.oe_links_block.default.yml new file mode 100644 index 00000000..1fab747a --- /dev/null +++ b/modules/oe_whitelabel_paragraphs/config/overrides/core.entity_form_display.paragraph.oe_links_block.default.yml @@ -0,0 +1,48 @@ +langcode: en +status: true +dependencies: + config: + - field.field.paragraph.oe_links_block.field_oe_links + - field.field.paragraph.oe_links_block.oe_bt_links_block_background + - field.field.paragraph.oe_links_block.oe_bt_links_block_orientation + - field.field.paragraph.oe_links_block.field_oe_text + - paragraphs.paragraphs_type.oe_links_block + module: + - link +id: paragraph.oe_links_block.default +targetEntityType: paragraph +bundle: oe_links_block +mode: default +content: + field_oe_links: + weight: 3 + settings: + placeholder_url: '' + placeholder_title: '' + third_party_settings: { } + type: link_default + region: content + oe_bt_links_block_background: + weight: 1 + settings: { } + third_party_settings: { } + type: options_select + region: content + oe_bt_links_block_orientation: + weight: 0 + settings: { } + third_party_settings: { } + type: options_select + region: content + field_oe_text: + weight: 2 + settings: + size: 60 + placeholder: '' + third_party_settings: { } + type: string_textfield + region: content +hidden: + created: true + status: true + uid: true diff --git a/modules/oe_whitelabel_paragraphs/config/overrides/core.entity_form_display.paragraph.oe_list_item.default.yml b/modules/oe_whitelabel_paragraphs/config/overrides/core.entity_form_display.paragraph.oe_list_item.default.yml new file mode 100644 index 00000000..a80ab707 --- /dev/null +++ b/modules/oe_whitelabel_paragraphs/config/overrides/core.entity_form_display.paragraph.oe_list_item.default.yml @@ -0,0 +1,71 @@ +langcode: en +status: true +dependencies: + config: + - field.field.paragraph.oe_list_item.field_oe_date + - field.field.paragraph.oe_list_item.field_oe_image + - field.field.paragraph.oe_list_item.field_oe_link + - field.field.paragraph.oe_list_item.field_oe_meta + - field.field.paragraph.oe_list_item.field_oe_text_long + - field.field.paragraph.oe_list_item.field_oe_title + - image.style.thumbnail + - paragraphs.paragraphs_type.oe_list_item + module: + - allowed_formats + - image + - link + - text +id: paragraph.oe_list_item.default +targetEntityType: paragraph +bundle: oe_list_item +mode: default +content: + field_oe_image: + type: image_image + weight: 3 + region: content + settings: + progress_indicator: throbber + preview_image_style: thumbnail + third_party_settings: { } + field_oe_link: + type: link_default + weight: 0 + region: content + settings: + placeholder_url: '' + placeholder_title: '' + third_party_settings: { } + field_oe_meta: + type: string_textfield + weight: 4 + region: content + settings: + size: 60 + placeholder: '' + third_party_settings: { } + field_oe_text_long: + type: text_textarea + weight: 2 + region: content + settings: + rows: 3 + placeholder: '' + third_party_settings: + allowed_formats: + hide_help: '1' + hide_guidelines: '1' + field_oe_title: + type: string_textfield + weight: 1 + region: content + settings: + size: 60 + placeholder: '' + third_party_settings: { } +hidden: + created: true + field_oe_date: true + status: true + translation: true + uid: true diff --git a/modules/oe_whitelabel_paragraphs/config/overrides/core.entity_form_display.paragraph.oe_list_item_block.default.yml b/modules/oe_whitelabel_paragraphs/config/overrides/core.entity_form_display.paragraph.oe_list_item_block.default.yml new file mode 100644 index 00000000..6497f1fd --- /dev/null +++ b/modules/oe_whitelabel_paragraphs/config/overrides/core.entity_form_display.paragraph.oe_list_item_block.default.yml @@ -0,0 +1,67 @@ +langcode: en +status: true +dependencies: + config: + - field.field.paragraph.oe_list_item_block.field_oe_link + - field.field.paragraph.oe_list_item_block.field_oe_list_item_block_layout + - field.field.paragraph.oe_list_item_block.field_oe_paragraphs + - field.field.paragraph.oe_list_item_block.field_oe_title + - paragraphs.paragraphs_type.oe_list_item_block + module: + - link + - paragraphs +id: paragraph.oe_list_item_block.default +targetEntityType: paragraph +bundle: oe_list_item_block +mode: default +content: + field_oe_link: + type: link_default + weight: 3 + region: content + settings: + placeholder_url: '' + placeholder_title: '' + third_party_settings: { } + field_oe_list_item_block_layout: + type: options_select + weight: 0 + region: content + settings: { } + third_party_settings: { } + field_oe_paragraphs: + type: paragraphs + weight: 2 + region: content + settings: + title: Paragraph + title_plural: Paragraphs + edit_mode: closed + closed_mode: summary + autocollapse: none + closed_mode_threshold: 0 + add_mode: dropdown + form_display_mode: default + default_paragraph_type: oe_list_item + features: + add_above: '0' + collapse_edit_all: collapse_edit_all + duplicate: duplicate + third_party_settings: { } + field_oe_title: + type: string_textfield + weight: 1 + region: content + settings: + size: 60 + placeholder: '' + third_party_settings: { } + translation: + weight: 4 + region: content + settings: { } + third_party_settings: { } +hidden: + created: true + status: true + uid: true diff --git a/modules/oe_whitelabel_paragraphs/config/overrides/core.entity_form_display.paragraph.oe_list_item_block.highlight.yml b/modules/oe_whitelabel_paragraphs/config/overrides/core.entity_form_display.paragraph.oe_list_item_block.highlight.yml new file mode 100644 index 00000000..28e0a334 --- /dev/null +++ b/modules/oe_whitelabel_paragraphs/config/overrides/core.entity_form_display.paragraph.oe_list_item_block.highlight.yml @@ -0,0 +1,68 @@ +langcode: en +status: true +dependencies: + config: + - core.entity_form_mode.paragraph.highlight + - field.field.paragraph.oe_list_item_block.field_oe_link + - field.field.paragraph.oe_list_item_block.field_oe_list_item_block_layout + - field.field.paragraph.oe_list_item_block.field_oe_paragraphs + - field.field.paragraph.oe_list_item_block.field_oe_title + - paragraphs.paragraphs_type.oe_list_item_block + module: + - link + - paragraphs +id: paragraph.oe_list_item_block.highlight +targetEntityType: paragraph +bundle: oe_list_item_block +mode: highlight +content: + field_oe_link: + type: link_default + weight: 3 + region: content + settings: + placeholder_url: '' + placeholder_title: '' + third_party_settings: { } + field_oe_list_item_block_layout: + type: options_select + weight: 0 + region: content + settings: { } + third_party_settings: { } + field_oe_paragraphs: + type: paragraphs + weight: 2 + region: content + settings: + title: Paragraph + title_plural: Paragraphs + edit_mode: closed + closed_mode: summary + autocollapse: none + closed_mode_threshold: 0 + add_mode: dropdown + form_display_mode: highlight + default_paragraph_type: oe_list_item + features: + add_above: '0' + collapse_edit_all: collapse_edit_all + duplicate: duplicate + third_party_settings: { } + field_oe_title: + type: string_textfield + weight: 1 + region: content + settings: + size: 60 + placeholder: '' + third_party_settings: { } + translation: + weight: 4 + region: content + settings: { } + third_party_settings: { } +hidden: + created: true + status: true + uid: true diff --git a/modules/oe_whitelabel_paragraphs/config/overrides/core.entity_form_display.paragraph.oe_social_media_follow.default.yml b/modules/oe_whitelabel_paragraphs/config/overrides/core.entity_form_display.paragraph.oe_social_media_follow.default.yml new file mode 100644 index 00000000..8b7cd07f --- /dev/null +++ b/modules/oe_whitelabel_paragraphs/config/overrides/core.entity_form_display.paragraph.oe_social_media_follow.default.yml @@ -0,0 +1,57 @@ +langcode: en +status: true +dependencies: + config: + - field.field.paragraph.oe_social_media_follow.oe_bt_links_block_background + - field.field.paragraph.oe_social_media_follow.field_oe_social_media_links + - field.field.paragraph.oe_social_media_follow.field_oe_social_media_see_more + - field.field.paragraph.oe_social_media_follow.field_oe_social_media_variant + - field.field.paragraph.oe_social_media_follow.field_oe_title + - paragraphs.paragraphs_type.oe_social_media_follow + module: + - link + - typed_link +id: paragraph.oe_social_media_follow.default +targetEntityType: paragraph +bundle: oe_social_media_follow +mode: default +content: + oe_bt_links_block_background: + type: options_select + weight: 1 + region: content + settings: { } + third_party_settings: { } + field_oe_social_media_links: + weight: 3 + settings: + placeholder_url: '' + placeholder_title: '' + third_party_settings: { } + type: typed_link + region: content + field_oe_social_media_see_more: + weight: 4 + settings: + placeholder_url: '' + placeholder_title: '' + third_party_settings: { } + type: link_default + region: content + field_oe_social_media_variant: + weight: 0 + settings: { } + third_party_settings: { } + type: options_select + region: content + field_oe_title: + weight: 2 + settings: + size: 60 + placeholder: '' + third_party_settings: { } + type: string_textfield + region: content +hidden: + created: true + status: true diff --git a/modules/oe_whitelabel_paragraphs/config/overrides/core.entity_view_display.paragraph.oe_accordion_item.default.yml b/modules/oe_whitelabel_paragraphs/config/overrides/core.entity_view_display.paragraph.oe_accordion_item.default.yml new file mode 100644 index 00000000..8c3a67f6 --- /dev/null +++ b/modules/oe_whitelabel_paragraphs/config/overrides/core.entity_view_display.paragraph.oe_accordion_item.default.yml @@ -0,0 +1,32 @@ +langcode: en +status: true +dependencies: + config: + - field.field.paragraph.oe_accordion_item.field_oe_icon + - field.field.paragraph.oe_accordion_item.field_oe_text + - field.field.paragraph.oe_accordion_item.field_oe_text_long + - paragraphs.paragraphs_type.oe_accordion_item + module: + - text +id: paragraph.oe_accordion_item.default +targetEntityType: paragraph +bundle: oe_accordion_item +mode: default +content: + field_oe_text: + weight: 0 + label: above + settings: + link_to_entity: false + third_party_settings: { } + type: string + region: content + field_oe_text_long: + weight: 1 + label: above + settings: { } + third_party_settings: { } + type: text_default + region: content +hidden: + field_oe_icon: true diff --git a/modules/oe_whitelabel_paragraphs/config/overrides/core.entity_view_display.paragraph.oe_description_list.default.yml b/modules/oe_whitelabel_paragraphs/config/overrides/core.entity_view_display.paragraph.oe_description_list.default.yml new file mode 100644 index 00000000..2e3b81d7 --- /dev/null +++ b/modules/oe_whitelabel_paragraphs/config/overrides/core.entity_view_display.paragraph.oe_description_list.default.yml @@ -0,0 +1,32 @@ +langcode: en +status: true +dependencies: + config: + - field.field.paragraph.oe_description_list.oe_bt_orientation + - field.field.paragraph.oe_description_list.field_oe_description_list_items + - field.field.paragraph.oe_description_list.field_oe_title + - paragraphs.paragraphs_type.oe_description_list + module: + - description_list_field +id: paragraph.oe_description_list.default +targetEntityType: paragraph +bundle: oe_description_list +mode: default +content: + field_oe_description_list_items: + weight: 1 + label: hidden + settings: { } + third_party_settings: { } + type: description_list_formatter + region: content + field_oe_title: + weight: 0 + label: hidden + settings: + link_to_entity: false + third_party_settings: { } + type: string + region: content +hidden: + oe_bt_orientation: true diff --git a/modules/oe_whitelabel_paragraphs/config/overrides/core.entity_view_display.paragraph.oe_facts_figures.default.yml b/modules/oe_whitelabel_paragraphs/config/overrides/core.entity_view_display.paragraph.oe_facts_figures.default.yml new file mode 100644 index 00000000..e9dd9cf6 --- /dev/null +++ b/modules/oe_whitelabel_paragraphs/config/overrides/core.entity_view_display.paragraph.oe_facts_figures.default.yml @@ -0,0 +1,48 @@ +langcode: en +status: true +dependencies: + config: + - field.field.paragraph.oe_facts_figures.field_oe_link + - field.field.paragraph.oe_facts_figures.field_oe_paragraphs + - field.field.paragraph.oe_facts_figures.field_oe_title + - field.field.paragraph.oe_facts_figures.oe_bt_n_columns + - paragraphs.paragraphs_type.oe_facts_figures + module: + - entity_reference_revisions + - link +id: paragraph.oe_facts_figures.default +targetEntityType: paragraph +bundle: oe_facts_figures +mode: default +content: + field_oe_link: + weight: 2 + label: above + settings: + trim_length: 80 + url_only: false + url_plain: false + rel: '' + target: '' + third_party_settings: { } + type: link + region: content + field_oe_paragraphs: + weight: 1 + label: above + settings: + view_mode: default + link: '' + third_party_settings: { } + type: entity_reference_revisions_entity_view + region: content + field_oe_title: + weight: 0 + label: above + settings: + link_to_entity: false + third_party_settings: { } + type: string + region: content +hidden: + oe_bt_n_columns: true diff --git a/modules/oe_whitelabel_paragraphs/config/overrides/core.entity_view_display.paragraph.oe_links_block.default.yml b/modules/oe_whitelabel_paragraphs/config/overrides/core.entity_view_display.paragraph.oe_links_block.default.yml new file mode 100644 index 00000000..0d927d07 --- /dev/null +++ b/modules/oe_whitelabel_paragraphs/config/overrides/core.entity_view_display.paragraph.oe_links_block.default.yml @@ -0,0 +1,39 @@ +langcode: en +status: true +dependencies: + config: + - field.field.paragraph.oe_links_block.field_oe_links + - field.field.paragraph.oe_links_block.field_oe_links_block_background + - field.field.paragraph.oe_links_block.field_oe_links_block_orientation + - field.field.paragraph.oe_links_block.field_oe_text + - paragraphs.paragraphs_type.oe_links_block + module: + - link +id: paragraph.oe_links_block.default +targetEntityType: paragraph +bundle: oe_links_block +mode: default +content: + field_oe_links: + weight: 1 + label: above + settings: + trim_length: 80 + url_only: false + url_plain: false + rel: '' + target: '' + third_party_settings: { } + type: link + region: content + field_oe_text: + weight: 0 + label: above + settings: + link_to_entity: false + third_party_settings: { } + type: string + region: content +hidden: + field_oe_links_block_background: true + field_oe_links_block_orientation: true diff --git a/modules/oe_whitelabel_paragraphs/config/overrides/core.entity_view_display.paragraph.oe_social_media_follow.default.yml b/modules/oe_whitelabel_paragraphs/config/overrides/core.entity_view_display.paragraph.oe_social_media_follow.default.yml new file mode 100644 index 00000000..8e15a231 --- /dev/null +++ b/modules/oe_whitelabel_paragraphs/config/overrides/core.entity_view_display.paragraph.oe_social_media_follow.default.yml @@ -0,0 +1,53 @@ +langcode: en +status: true +dependencies: + config: + - field.field.paragraph.oe_social_media_follow.oe_bt_links_block_background + - field.field.paragraph.oe_social_media_follow.field_oe_social_media_links + - field.field.paragraph.oe_social_media_follow.field_oe_social_media_see_more + - field.field.paragraph.oe_social_media_follow.field_oe_social_media_variant + - field.field.paragraph.oe_social_media_follow.field_oe_title + - paragraphs.paragraphs_type.oe_social_media_follow + module: + - link + - typed_link +id: paragraph.oe_social_media_follow.default +targetEntityType: paragraph +bundle: oe_social_media_follow +mode: default +content: + field_oe_social_media_links: + weight: 1 + label: hidden + settings: + trim_length: 80 + url_only: false + url_plain: false + rel: '' + target: '' + third_party_settings: { } + type: typed_link + region: content + field_oe_social_media_see_more: + weight: 2 + label: hidden + settings: + trim_length: 80 + url_only: false + url_plain: false + rel: '' + target: '' + third_party_settings: { } + type: link + region: content + field_oe_title: + weight: 0 + label: hidden + settings: + link_to_entity: false + third_party_settings: { } + type: string + region: content +hidden: + oe_bt_links_block_background: true + field_oe_social_media_variant: true diff --git a/modules/oe_whitelabel_paragraphs/config/overrides/field.field.paragraph.oe_social_media_follow.field_oe_social_media_variant.yml b/modules/oe_whitelabel_paragraphs/config/overrides/field.field.paragraph.oe_social_media_follow.field_oe_social_media_variant.yml new file mode 100755 index 00000000..ecf09e79 --- /dev/null +++ b/modules/oe_whitelabel_paragraphs/config/overrides/field.field.paragraph.oe_social_media_follow.field_oe_social_media_variant.yml @@ -0,0 +1,22 @@ +langcode: en +status: true +dependencies: + config: + - field.storage.paragraph.field_oe_social_media_variant + - paragraphs.paragraphs_type.oe_social_media_follow + module: + - options +id: paragraph.oe_social_media_follow.field_oe_social_media_variant +field_name: field_oe_social_media_variant +entity_type: paragraph +bundle: oe_social_media_follow +label: Orientation +description: '' +required: true +translatable: false +default_value: + - + value: horizontal +default_value_callback: '' +settings: { } +field_type: list_string diff --git a/modules/oe_whitelabel_paragraphs/config/post_updates/00001/core.entity_form_display.paragraph.oe_description_list.default.yml b/modules/oe_whitelabel_paragraphs/config/post_updates/00001/core.entity_form_display.paragraph.oe_description_list.default.yml new file mode 100644 index 00000000..363809de --- /dev/null +++ b/modules/oe_whitelabel_paragraphs/config/post_updates/00001/core.entity_form_display.paragraph.oe_description_list.default.yml @@ -0,0 +1,38 @@ +langcode: en +status: true +dependencies: + config: + - field.field.paragraph.oe_description_list.field_oe_description_list_items + - field.field.paragraph.oe_description_list.field_oe_title + - field.field.paragraph.oe_description_list.oe_bt_orientation + - paragraphs.paragraphs_type.oe_description_list + module: + - description_list_field +id: paragraph.oe_description_list.default +targetEntityType: paragraph +bundle: oe_description_list +mode: default +content: + field_oe_description_list_items: + weight: 2 + settings: { } + third_party_settings: { } + type: description_list_widget + region: content + field_oe_title: + weight: 1 + settings: + size: 60 + placeholder: '' + third_party_settings: { } + type: string_textfield + region: content + oe_bt_orientation: + type: options_select + weight: 0 + region: content + settings: { } + third_party_settings: { } +hidden: + created: true + status: true diff --git a/modules/oe_whitelabel_paragraphs/config/post_updates/00001/core.entity_view_display.paragraph.oe_description_list.default.yml b/modules/oe_whitelabel_paragraphs/config/post_updates/00001/core.entity_view_display.paragraph.oe_description_list.default.yml new file mode 100644 index 00000000..2e3b81d7 --- /dev/null +++ b/modules/oe_whitelabel_paragraphs/config/post_updates/00001/core.entity_view_display.paragraph.oe_description_list.default.yml @@ -0,0 +1,32 @@ +langcode: en +status: true +dependencies: + config: + - field.field.paragraph.oe_description_list.oe_bt_orientation + - field.field.paragraph.oe_description_list.field_oe_description_list_items + - field.field.paragraph.oe_description_list.field_oe_title + - paragraphs.paragraphs_type.oe_description_list + module: + - description_list_field +id: paragraph.oe_description_list.default +targetEntityType: paragraph +bundle: oe_description_list +mode: default +content: + field_oe_description_list_items: + weight: 1 + label: hidden + settings: { } + third_party_settings: { } + type: description_list_formatter + region: content + field_oe_title: + weight: 0 + label: hidden + settings: + link_to_entity: false + third_party_settings: { } + type: string + region: content +hidden: + oe_bt_orientation: true diff --git a/modules/oe_whitelabel_paragraphs/config/post_updates/00001/field.field.paragraph.oe_description_list.oe_bt_orientation.yml b/modules/oe_whitelabel_paragraphs/config/post_updates/00001/field.field.paragraph.oe_description_list.oe_bt_orientation.yml new file mode 100644 index 00000000..73b09a47 --- /dev/null +++ b/modules/oe_whitelabel_paragraphs/config/post_updates/00001/field.field.paragraph.oe_description_list.oe_bt_orientation.yml @@ -0,0 +1,22 @@ +langcode: en +status: true +dependencies: + config: + - field.storage.paragraph.oe_bt_orientation + - paragraphs.paragraphs_type.oe_description_list + module: + - options +id: paragraph.oe_description_list.oe_bt_orientation +field_name: oe_bt_orientation +entity_type: paragraph +bundle: oe_description_list +label: Orientation +description: 'Sets the orientation (vertical|horizontal) for the paragraph.' +required: true +translatable: false +default_value: + - + value: horizontal +default_value_callback: '' +settings: { } +field_type: list_string diff --git a/modules/oe_whitelabel_paragraphs/config/post_updates/00001/field.storage.paragraph.oe_bt_orientation.yml b/modules/oe_whitelabel_paragraphs/config/post_updates/00001/field.storage.paragraph.oe_bt_orientation.yml new file mode 100644 index 00000000..94f290a8 --- /dev/null +++ b/modules/oe_whitelabel_paragraphs/config/post_updates/00001/field.storage.paragraph.oe_bt_orientation.yml @@ -0,0 +1,26 @@ +langcode: en +status: true +dependencies: + module: + - options + - paragraphs +id: paragraph.oe_bt_orientation +field_name: oe_bt_orientation +entity_type: paragraph +type: list_string +settings: + allowed_values: + - + value: vertical + label: Vertical + - + value: horizontal + label: Horizontal + allowed_values_function: '' +module: options +locked: false +cardinality: 1 +translatable: true +indexes: { } +persist_with_no_fields: false +custom_storage: false diff --git a/modules/oe_whitelabel_paragraphs/config/post_updates/00002/core.entity_form_display.paragraph.oe_accordion_item.default.yml b/modules/oe_whitelabel_paragraphs/config/post_updates/00002/core.entity_form_display.paragraph.oe_accordion_item.default.yml new file mode 100644 index 00000000..3b7368e6 --- /dev/null +++ b/modules/oe_whitelabel_paragraphs/config/post_updates/00002/core.entity_form_display.paragraph.oe_accordion_item.default.yml @@ -0,0 +1,36 @@ +langcode: en +status: true +dependencies: + config: + - field.field.paragraph.oe_accordion_item.field_oe_icon + - field.field.paragraph.oe_accordion_item.field_oe_text + - field.field.paragraph.oe_accordion_item.field_oe_text_long + - paragraphs.paragraphs_type.oe_accordion_item + module: + - text +id: paragraph.oe_accordion_item.default +targetEntityType: paragraph +bundle: oe_accordion_item +mode: default +content: + field_oe_text: + weight: 0 + settings: + size: 60 + placeholder: '' + third_party_settings: { } + type: string_textfield + region: content + field_oe_text_long: + weight: 1 + settings: + rows: 5 + placeholder: '' + third_party_settings: { } + type: text_textarea + region: content +hidden: + created: true + field_oe_icon: true + status: true + uid: true diff --git a/modules/oe_whitelabel_paragraphs/config/post_updates/00002/core.entity_view_display.paragraph.oe_accordion_item.default.yml b/modules/oe_whitelabel_paragraphs/config/post_updates/00002/core.entity_view_display.paragraph.oe_accordion_item.default.yml new file mode 100644 index 00000000..8c3a67f6 --- /dev/null +++ b/modules/oe_whitelabel_paragraphs/config/post_updates/00002/core.entity_view_display.paragraph.oe_accordion_item.default.yml @@ -0,0 +1,32 @@ +langcode: en +status: true +dependencies: + config: + - field.field.paragraph.oe_accordion_item.field_oe_icon + - field.field.paragraph.oe_accordion_item.field_oe_text + - field.field.paragraph.oe_accordion_item.field_oe_text_long + - paragraphs.paragraphs_type.oe_accordion_item + module: + - text +id: paragraph.oe_accordion_item.default +targetEntityType: paragraph +bundle: oe_accordion_item +mode: default +content: + field_oe_text: + weight: 0 + label: above + settings: + link_to_entity: false + third_party_settings: { } + type: string + region: content + field_oe_text_long: + weight: 1 + label: above + settings: { } + third_party_settings: { } + type: text_default + region: content +hidden: + field_oe_icon: true diff --git a/modules/oe_whitelabel_paragraphs/config/post_updates/00003/core.entity_form_display.paragraph.oe_facts_figures.default.yml b/modules/oe_whitelabel_paragraphs/config/post_updates/00003/core.entity_form_display.paragraph.oe_facts_figures.default.yml new file mode 100644 index 00000000..96a0c1fb --- /dev/null +++ b/modules/oe_whitelabel_paragraphs/config/post_updates/00003/core.entity_form_display.paragraph.oe_facts_figures.default.yml @@ -0,0 +1,61 @@ +langcode: en +status: true +dependencies: + config: + - field.field.paragraph.oe_facts_figures.field_oe_link + - field.field.paragraph.oe_facts_figures.field_oe_paragraphs + - field.field.paragraph.oe_facts_figures.field_oe_title + - field.field.paragraph.oe_facts_figures.oe_bt_n_columns + - paragraphs.paragraphs_type.oe_facts_figures + module: + - link + - oe_paragraphs +id: paragraph.oe_facts_figures.default +targetEntityType: paragraph +bundle: oe_facts_figures +mode: default +content: + field_oe_link: + type: link_default + weight: 2 + region: content + settings: + placeholder_url: '' + placeholder_title: '' + third_party_settings: { } + field_oe_paragraphs: + type: oe_paragraphs_variants + weight: 8 + region: content + settings: + title: Paragraph + title_plural: Paragraphs + edit_mode: open + add_mode: dropdown + form_display_mode: default + default_paragraph_type: '' + closed_mode: summary + autocollapse: none + closed_mode_threshold: 0 + features: + collapse_edit_all: collapse_edit_all + duplicate: duplicate + third_party_settings: { } + field_oe_title: + type: string_textfield + weight: 1 + region: content + settings: + size: 60 + placeholder: '' + third_party_settings: { } + oe_bt_n_columns: + weight: 6 + settings: + placeholder: '' + third_party_settings: { } + type: number + region: content +hidden: + created: true + status: true diff --git a/modules/oe_whitelabel_paragraphs/config/post_updates/00003/core.entity_form_display.paragraph.oe_list_item.default.yml b/modules/oe_whitelabel_paragraphs/config/post_updates/00003/core.entity_form_display.paragraph.oe_list_item.default.yml new file mode 100644 index 00000000..a80ab707 --- /dev/null +++ b/modules/oe_whitelabel_paragraphs/config/post_updates/00003/core.entity_form_display.paragraph.oe_list_item.default.yml @@ -0,0 +1,71 @@ +langcode: en +status: true +dependencies: + config: + - field.field.paragraph.oe_list_item.field_oe_date + - field.field.paragraph.oe_list_item.field_oe_image + - field.field.paragraph.oe_list_item.field_oe_link + - field.field.paragraph.oe_list_item.field_oe_meta + - field.field.paragraph.oe_list_item.field_oe_text_long + - field.field.paragraph.oe_list_item.field_oe_title + - image.style.thumbnail + - paragraphs.paragraphs_type.oe_list_item + module: + - allowed_formats + - image + - link + - text +id: paragraph.oe_list_item.default +targetEntityType: paragraph +bundle: oe_list_item +mode: default +content: + field_oe_image: + type: image_image + weight: 3 + region: content + settings: + progress_indicator: throbber + preview_image_style: thumbnail + third_party_settings: { } + field_oe_link: + type: link_default + weight: 0 + region: content + settings: + placeholder_url: '' + placeholder_title: '' + third_party_settings: { } + field_oe_meta: + type: string_textfield + weight: 4 + region: content + settings: + size: 60 + placeholder: '' + third_party_settings: { } + field_oe_text_long: + type: text_textarea + weight: 2 + region: content + settings: + rows: 3 + placeholder: '' + third_party_settings: + allowed_formats: + hide_help: '1' + hide_guidelines: '1' + field_oe_title: + type: string_textfield + weight: 1 + region: content + settings: + size: 60 + placeholder: '' + third_party_settings: { } +hidden: + created: true + field_oe_date: true + status: true + translation: true + uid: true diff --git a/modules/oe_whitelabel_paragraphs/config/post_updates/00003/core.entity_form_display.paragraph.oe_list_item_block.default.yml b/modules/oe_whitelabel_paragraphs/config/post_updates/00003/core.entity_form_display.paragraph.oe_list_item_block.default.yml new file mode 100644 index 00000000..6497f1fd --- /dev/null +++ b/modules/oe_whitelabel_paragraphs/config/post_updates/00003/core.entity_form_display.paragraph.oe_list_item_block.default.yml @@ -0,0 +1,67 @@ +langcode: en +status: true +dependencies: + config: + - field.field.paragraph.oe_list_item_block.field_oe_link + - field.field.paragraph.oe_list_item_block.field_oe_list_item_block_layout + - field.field.paragraph.oe_list_item_block.field_oe_paragraphs + - field.field.paragraph.oe_list_item_block.field_oe_title + - paragraphs.paragraphs_type.oe_list_item_block + module: + - link + - paragraphs +id: paragraph.oe_list_item_block.default +targetEntityType: paragraph +bundle: oe_list_item_block +mode: default +content: + field_oe_link: + type: link_default + weight: 3 + region: content + settings: + placeholder_url: '' + placeholder_title: '' + third_party_settings: { } + field_oe_list_item_block_layout: + type: options_select + weight: 0 + region: content + settings: { } + third_party_settings: { } + field_oe_paragraphs: + type: paragraphs + weight: 2 + region: content + settings: + title: Paragraph + title_plural: Paragraphs + edit_mode: closed + closed_mode: summary + autocollapse: none + closed_mode_threshold: 0 + add_mode: dropdown + form_display_mode: default + default_paragraph_type: oe_list_item + features: + add_above: '0' + collapse_edit_all: collapse_edit_all + duplicate: duplicate + third_party_settings: { } + field_oe_title: + type: string_textfield + weight: 1 + region: content + settings: + size: 60 + placeholder: '' + third_party_settings: { } + translation: + weight: 4 + region: content + settings: { } + third_party_settings: { } +hidden: + created: true + status: true + uid: true diff --git a/modules/oe_whitelabel_paragraphs/config/post_updates/00003/core.entity_form_display.paragraph.oe_list_item_block.highlight.yml b/modules/oe_whitelabel_paragraphs/config/post_updates/00003/core.entity_form_display.paragraph.oe_list_item_block.highlight.yml new file mode 100644 index 00000000..28e0a334 --- /dev/null +++ b/modules/oe_whitelabel_paragraphs/config/post_updates/00003/core.entity_form_display.paragraph.oe_list_item_block.highlight.yml @@ -0,0 +1,68 @@ +langcode: en +status: true +dependencies: + config: + - core.entity_form_mode.paragraph.highlight + - field.field.paragraph.oe_list_item_block.field_oe_link + - field.field.paragraph.oe_list_item_block.field_oe_list_item_block_layout + - field.field.paragraph.oe_list_item_block.field_oe_paragraphs + - field.field.paragraph.oe_list_item_block.field_oe_title + - paragraphs.paragraphs_type.oe_list_item_block + module: + - link + - paragraphs +id: paragraph.oe_list_item_block.highlight +targetEntityType: paragraph +bundle: oe_list_item_block +mode: highlight +content: + field_oe_link: + type: link_default + weight: 3 + region: content + settings: + placeholder_url: '' + placeholder_title: '' + third_party_settings: { } + field_oe_list_item_block_layout: + type: options_select + weight: 0 + region: content + settings: { } + third_party_settings: { } + field_oe_paragraphs: + type: paragraphs + weight: 2 + region: content + settings: + title: Paragraph + title_plural: Paragraphs + edit_mode: closed + closed_mode: summary + autocollapse: none + closed_mode_threshold: 0 + add_mode: dropdown + form_display_mode: highlight + default_paragraph_type: oe_list_item + features: + add_above: '0' + collapse_edit_all: collapse_edit_all + duplicate: duplicate + third_party_settings: { } + field_oe_title: + type: string_textfield + weight: 1 + region: content + settings: + size: 60 + placeholder: '' + third_party_settings: { } + translation: + weight: 4 + region: content + settings: { } + third_party_settings: { } +hidden: + created: true + status: true + uid: true diff --git a/modules/oe_whitelabel_paragraphs/config/post_updates/00003/core.entity_view_display.paragraph.oe_facts_figures.default.yml b/modules/oe_whitelabel_paragraphs/config/post_updates/00003/core.entity_view_display.paragraph.oe_facts_figures.default.yml new file mode 100644 index 00000000..e9dd9cf6 --- /dev/null +++ b/modules/oe_whitelabel_paragraphs/config/post_updates/00003/core.entity_view_display.paragraph.oe_facts_figures.default.yml @@ -0,0 +1,48 @@ +langcode: en +status: true +dependencies: + config: + - field.field.paragraph.oe_facts_figures.field_oe_link + - field.field.paragraph.oe_facts_figures.field_oe_paragraphs + - field.field.paragraph.oe_facts_figures.field_oe_title + - field.field.paragraph.oe_facts_figures.oe_bt_n_columns + - paragraphs.paragraphs_type.oe_facts_figures + module: + - entity_reference_revisions + - link +id: paragraph.oe_facts_figures.default +targetEntityType: paragraph +bundle: oe_facts_figures +mode: default +content: + field_oe_link: + weight: 2 + label: above + settings: + trim_length: 80 + url_only: false + url_plain: false + rel: '' + target: '' + third_party_settings: { } + type: link + region: content + field_oe_paragraphs: + weight: 1 + label: above + settings: + view_mode: default + link: '' + third_party_settings: { } + type: entity_reference_revisions_entity_view + region: content + field_oe_title: + weight: 0 + label: above + settings: + link_to_entity: false + third_party_settings: { } + type: string + region: content +hidden: + oe_bt_n_columns: true diff --git a/modules/oe_whitelabel_paragraphs/config/post_updates/00003/field.field.paragraph.oe_facts_figures.oe_bt_n_columns.yml b/modules/oe_whitelabel_paragraphs/config/post_updates/00003/field.field.paragraph.oe_facts_figures.oe_bt_n_columns.yml new file mode 100644 index 00000000..eec70a14 --- /dev/null +++ b/modules/oe_whitelabel_paragraphs/config/post_updates/00003/field.field.paragraph.oe_facts_figures.oe_bt_n_columns.yml @@ -0,0 +1,24 @@ +langcode: en +status: true +dependencies: + config: + - field.storage.paragraph.oe_bt_n_columns + - paragraphs.paragraphs_type.oe_facts_figures +id: paragraph.oe_facts_figures.oe_bt_n_columns +field_name: oe_bt_n_columns +entity_type: paragraph +bundle: oe_facts_figures +label: 'Number of columns' +description: 'Sets the number of grid columns. Minimum number is 1 column and maximum is 3.' +required: false +translatable: false +default_value: + - + value: 1 +default_value_callback: '' +settings: + min: 1 + max: 3 + prefix: '' + suffix: '' +field_type: integer diff --git a/modules/oe_whitelabel_paragraphs/config/post_updates/00003/field.storage.paragraph.oe_bt_n_columns.yml b/modules/oe_whitelabel_paragraphs/config/post_updates/00003/field.storage.paragraph.oe_bt_n_columns.yml new file mode 100644 index 00000000..f2a74071 --- /dev/null +++ b/modules/oe_whitelabel_paragraphs/config/post_updates/00003/field.storage.paragraph.oe_bt_n_columns.yml @@ -0,0 +1,19 @@ +langcode: en +status: true +dependencies: + module: + - paragraphs +id: paragraph.oe_bt_n_columns +field_name: oe_bt_n_columns +entity_type: paragraph +type: integer +settings: + unsigned: false + size: normal +module: core +locked: false +cardinality: 1 +translatable: true +indexes: { } +persist_with_no_fields: false +custom_storage: false diff --git a/modules/oe_whitelabel_paragraphs/oe_whitelabel_paragraphs.info.yml b/modules/oe_whitelabel_paragraphs/oe_whitelabel_paragraphs.info.yml new file mode 100644 index 00000000..5f237ddd --- /dev/null +++ b/modules/oe_whitelabel_paragraphs/oe_whitelabel_paragraphs.info.yml @@ -0,0 +1,23 @@ +name: OpenEuropa Whitelabel Paragraphs +type: module +description: Companion module to add support and customisations for oe_paragraphs. +package: OpenEuropa Whitelabel Theme +core_version_requirement: ^9.2 +dependencies: + - oe_paragraphs:oe_paragraphs + - oe_whitelabel:oe_whitelabel_helper + - oe_paragraphs:oe_paragraphs_timeline + - oe_content:oe_content_timeline_field + - drupal:description_list_field + - oe_paragraphs:oe_paragraphs_description_list +config_devel: + install: + - field.field.paragraph.oe_links_block.oe_bt_links_block_background + - field.field.paragraph.oe_links_block.oe_bt_links_block_orientation + - field.field.paragraph.oe_social_media_follow.oe_bt_links_block_background + - field.field.paragraph.oe_facts_figures.oe_bt_n_columns + - field.storage.paragraph.oe_bt_links_block_orientation + - field.storage.paragraph.oe_bt_links_block_background + - field.field.paragraph.oe_description_list.oe_bt_orientation + - field.storage.paragraph.oe_bt_orientation + - field.storage.paragraph.oe_bt_n_columns diff --git a/modules/oe_whitelabel_paragraphs/oe_whitelabel_paragraphs.install b/modules/oe_whitelabel_paragraphs/oe_whitelabel_paragraphs.install new file mode 100644 index 00000000..ac746f3f --- /dev/null +++ b/modules/oe_whitelabel_paragraphs/oe_whitelabel_paragraphs.install @@ -0,0 +1,40 @@ +<?php + +/** + * @file + * Install and update functions for the OE Whitelabel Paragraphs module. + */ + +declare(strict_types = 1); + +use Drupal\oe_bootstrap_theme\ConfigImporter; + +/** + * Implements hook_install(). + * + * Customise fields for whitelabel paragraphs. + */ +function oe_whitelabel_paragraphs_install($is_syncing): void { + // If we are installing from config, we bail out. + if ($is_syncing) { + return; + } + + $configs = [ + 'core.entity_form_display.paragraph.oe_links_block.default', + 'core.entity_form_display.paragraph.oe_social_media_follow.default', + 'core.entity_view_display.paragraph.oe_links_block.default', + 'core.entity_view_display.paragraph.oe_social_media_follow.default', + 'core.entity_form_display.paragraph.oe_description_list.default', + 'core.entity_view_display.paragraph.oe_description_list.default', + 'core.entity_form_display.paragraph.oe_accordion_item.default', + 'core.entity_view_display.paragraph.oe_accordion_item.default', + 'core.entity_form_display.paragraph.oe_facts_figures.default', + 'core.entity_view_display.paragraph.oe_facts_figures.default', + 'core.entity_form_display.paragraph.oe_list_item_block.default', + 'core.entity_form_display.paragraph.oe_list_item_block.highlight', + 'core.entity_form_display.paragraph.oe_list_item.default', + ]; + + ConfigImporter::importMultiple('oe_whitelabel_paragraphs', '/config/overrides/', $configs); +} diff --git a/modules/oe_whitelabel_paragraphs/oe_whitelabel_paragraphs.module b/modules/oe_whitelabel_paragraphs/oe_whitelabel_paragraphs.module new file mode 100644 index 00000000..6113f0d0 --- /dev/null +++ b/modules/oe_whitelabel_paragraphs/oe_whitelabel_paragraphs.module @@ -0,0 +1,535 @@ +<?php + +/** + * @file + * OE Whitelabel Paragraphs module. + */ + +declare(strict_types = 1); + +use Drupal\Component\Utility\Html; +use Drupal\Core\Cache\CacheableMetadata; +use Drupal\Core\Entity\Entity\EntityViewDisplay; +use Drupal\Core\Render\Element; +use Drupal\Core\Url; +use Drupal\media\Entity\Media; +use Drupal\media\MediaInterface; +use Drupal\media\MediaSourceInterface; +use Drupal\media\Plugin\media\Source\Image; +use Drupal\media\Plugin\media\Source\OEmbed; +use Drupal\media_avportal\Plugin\media\Source\MediaAvPortalPhotoSource; +use Drupal\media_avportal\Plugin\media\Source\MediaAvPortalSourceInterface; +use Drupal\media_avportal\Plugin\media\Source\MediaAvPortalVideoSource; +use Drupal\oe_bootstrap_theme\ValueObject\ImageValueObject; +use Drupal\oe_media_iframe\Plugin\media\Source\Iframe; +use Drupal\paragraphs\Entity\Paragraph; + +/** + * Implements hook_theme_suggestions_HOOK_alter(). + * + * Adds a bare, markup-free template suggestion to all paragraph fields. + */ +function oe_whitelabel_paragraphs_theme_suggestions_field_alter(array &$suggestions, array $variables): void { + $element = $variables['element']; + + // Do not output field labels and wrapping markup for paragraph fields. + if (isset($element['#entity_type']) && $element['#entity_type'] === 'paragraph') { + // Prepend the new suggestion to the list. This will put it right after the + // default field template. By doing this we allow to override single + // fields, while keeping all the rest markup-free. + array_unshift($suggestions, 'field__bare'); + } +} + +/** + * Implements hook_preprocess_paragraph(). + */ +function oe_whitelabel_paragraphs_preprocess_paragraph__oe_links_block(array &$variables): void { + /** @var \Drupal\paragraphs\Entity\Paragraph $paragraph */ + $paragraph = $variables['paragraph']; + $variables['orientation'] = $paragraph->get('oe_bt_links_block_orientation')->value; + $variables['background'] = $paragraph->get('oe_bt_links_block_background')->value; + if (!$paragraph->get('field_oe_text')->isEmpty()) { + $variables['title'] = $paragraph->get('field_oe_text')->value; + } + + foreach (Element::children($variables['content']['field_oe_links']) as $index) { + $variables['links'][] = [ + 'label' => $variables['content']['field_oe_links'][$index]['#title'], + 'path' => $variables['content']['field_oe_links'][$index]['#url']->toString(), + ]; + } +} + +/** + * Implements hook_preprocess_paragraph() for oe_social_media_follow paragraph. + */ +function oe_whitelabel_preprocess_paragraph__oe_social_media_follow(array &$variables): void { + /** @var \Drupal\paragraphs\Entity\Paragraph $paragraph */ + $paragraph = $variables['paragraph']; + $variables['orientation'] = $paragraph->get('field_oe_social_media_variant')->value; + $variables['background'] = $paragraph->get('oe_bt_links_block_background')->value; + if (!$paragraph->get('field_oe_title')->isEmpty()) { + $variables['title'] = $paragraph->get('field_oe_title')->value; + } + $links = $paragraph->get('field_oe_social_media_links')->getValue(); + $variables['links'] = []; + foreach ($links as $key => $link) { + $variables['links'][$key]['icon_position'] = 'before'; + $variables['links'][$key]['icon']['path'] = $variables['bcl_icon_path']; + $variables['links'][$key]['icon']['name'] = $link['link_type']; + $variables['links'][$key]['label'] = $link['title']; + $variables['links'][$key]['path'] = Url::fromUri($link['uri'])->toString(); + } + if (!$paragraph->get('field_oe_social_media_see_more')->isEmpty()) { + $other_link = $paragraph->get('field_oe_social_media_see_more') + ->first() + ->getValue(); + $variables['links'][] = [ + 'label' => $other_link['title'], + 'path' => Url::fromUri($other_link['uri'])->toString(), + ]; + } +} + +/** + * Implements hook_preprocess_paragraph__oe_accordion(). + */ +function oe_whitelabel_preprocess_paragraph__oe_accordion(array &$variables): void { + // Massage data to be compliant with OE Bootstrap Theme accordion component + // data structure. + $builder = \Drupal::entityTypeManager()->getViewBuilder('paragraph'); + $variables['items'] = []; + + /** @var \Drupal\entity_reference_revisions\Plugin\Field\FieldType\EntityReferenceRevisionsItem $field_item */ + foreach ($variables['paragraph']->get('field_oe_paragraphs') as $field_item) { + $paragraph = \Drupal::service('entity.repository')->getTranslationFromContext($field_item->entity); + $variables['items'][] = [ + 'title' => $builder->viewField($paragraph->get('field_oe_text')), + 'content' => $builder->viewField($paragraph->get('field_oe_text_long')), + ]; + } +} + +/** + * Implements hook_preprocess_paragraph() for paragraph--oe-text-feature-media.html.twig. + */ +function oe_whitelabel_preprocess_paragraph__oe_text_feature_media(array &$variables): void { + /** @var \Drupal\paragraphs\Entity\Paragraph $paragraph */ + $paragraph = $variables['paragraph']; + + // Bail out if there is no media present. + if ($paragraph->get('field_oe_media')->isEmpty()) { + return; + } + + /** @var \Drupal\media\Entity\Media $media */ + $media = $paragraph->get('field_oe_media')->entity; + if (!$media instanceof MediaInterface) { + // The media entity is not available anymore, bail out. + return; + } + + // Retrieve the correct media translation. + /** @var \Drupal\media\Entity\Media $media */ + $media = \Drupal::service('entity.repository')->getTranslationFromContext($media, $paragraph->language()->getId()); + + // Caches are handled by the formatter usually. Since we are not rendering + // the original render arrays, we need to propagate our caches to the + // paragraph template. + $cacheability = CacheableMetadata::createFromRenderArray($variables); + $cacheability->addCacheableDependency($media); + + // Run access checks on the media entity. + $access = $media->access('view', $variables['user'], TRUE); + $cacheability->addCacheableDependency($access); + if (!$access->isAllowed()) { + $cacheability->applyTo($variables); + return; + } + + // Get the media source. + $source = $media->getSource(); + + $is_image = $source instanceof MediaAvPortalPhotoSource || $source instanceof Image; + $is_video = $source instanceof MediaAvPortalVideoSource || $source instanceof OEmbed || $source instanceof Iframe; + + // If it's not an image and not a video, bail out. + if (!$is_image && !$is_video) { + $cacheability->applyTo($variables); + return; + } + + $variant = $paragraph->get('oe_paragraphs_variant')->value ?? 'default'; + $variables['text_position'] = str_replace([ + '_featured', + '_simple', + ], '', $variant); + + if ($is_image) { + $thumbnail = $media->get('thumbnail')->first(); + $variables['image'] = ImageValueObject::fromStyledImageItem($thumbnail, 'oe_bootstrap_theme_medium_no_crop'); + } + elseif ($is_video) { + _oe_whitelabel_featured_media_set_embedded_media($variables, $media, $cacheability, $source); + } + + $cacheability->applyTo($variables); + + if (empty($paragraph->get('field_oe_link')->first())) { + return; + } + + /** @var \Drupal\link\Plugin\Field\FieldType\LinkItem $link_item */ + $link_item = $paragraph->get('field_oe_link')->first(); + $variables['link'] = [ + 'path' => $link_item->getUrl()->toString(), + 'label' => $link_item->get('title')->getValue(), + ]; +} + +/** + * Implements hook_preprocess_paragraph() for paragraph--oe-list-item-block.html.twig. + */ +function oe_whitelabel_preprocess_paragraph__oe_list_item_block(array &$variables): void { + /** @var \Drupal\paragraphs\Entity\Paragraph $paragraph */ + $paragraph = $variables['paragraph']; + + // @todo Use ->isEmpty() as in other preprocess functions. + // In the OpenEuropa team it was decided that ->isEmpty() calls should be + // the preferred way to deal with empty field values. + // This function instead relies on ->value or ->first() returning NULL for + // empty fields, which the team is not fully confident about, and which does + // not follow the team convention. + // It was agreed to keep it like this for now in this function, but refactor + // it in the future. + // See also https://www.drupal.org/project/drupal/issues/3268137. + $variables['variant'] = $paragraph->get('oe_paragraphs_variant')->value; + $variables['title'] = $paragraph->get('field_oe_title')->value; + + $layout_name = $paragraph->get('field_oe_list_item_block_layout')->value; + $variables['columns'] = ['two_columns' => '2', 'three_columns' => '3'][$layout_name] ?? '1'; + + $variables['items'] = []; + foreach ($variables['paragraph']->get('field_oe_paragraphs') as $card_paragraph_item) { + /** @var \Drupal\paragraphs\ParagraphInterface $card_paragraph */ + $card_paragraph = $card_paragraph_item->entity; + + /** @var \Drupal\file\Plugin\Field\FieldType\FileFieldItemList $card_image_items */ + $card_image_items = $card_paragraph->get('field_oe_image'); + /** @var \Drupal\file\FileInterface|null $card_image_file */ + $card_image_file = $card_image_items->entity; + $card_image = $card_image_file ? [ + 'path' => file_url_transform_relative(file_create_url($card_image_file->getFileUri())), + 'alt' => $card_image_items->alt, + ] : []; + + // Prepare the metas if available. + $card_badges = []; + foreach ($card_paragraph->get('field_oe_meta') as $meta_item) { + $card_badges[] = $meta_item->value; + } + + $card_title = $card_paragraph->get('field_oe_title')->value; + /** @var \Drupal\link\LinkItemInterface|null $card_link_item */ + $card_link_item = $card_paragraph->get('field_oe_link')->first(); + $variables['items'][] = [ + 'title' => $card_title, + 'url' => $card_link_item ? $card_link_item->getUrl() : '', + 'text' => $card_paragraph->get('field_oe_text_long')->value, + 'image' => $card_image, + 'badges' => $card_badges, + ]; + } + + // Prepare the button variables if a link has been specified. + /** @var \Drupal\link\Plugin\Field\FieldType\LinkItem $link_item */ + $link_item = $paragraph->get('field_oe_link')->first(); + $variables['link'] = $link_item ? [ + 'path' => $link_item->getUrl()->toString(), + 'label' => $link_item->title, + 'icon' => [ + 'path' => $variables['bcl_icon_path'], + 'name' => 'chevron-right', + ], + ] : NULL; +} + +/** + * Implements hook_preprocess_paragraph() for oe_banner paragraph. + */ +function oe_whitelabel_preprocess_paragraph__oe_banner(array &$variables): void { + /** @var Drupal\paragraphs\Entity\Paragraph $paragraph */ + $paragraph = $variables['paragraph']; + $variables['title'] = $paragraph->get('field_oe_title')->value; + $variables['description'] = $paragraph->get('field_oe_text')->value; + $variables['full_width'] = (bool) $paragraph->get('field_oe_banner_full_width')->value; + oe_whitelabel_set_banner_link($paragraph, $variables); + + // The alignment field value contains the information regarding the pattern + // type and centering. + $alignment = $paragraph->get('field_oe_banner_type')->value; + [$banner_type, $banner_alignment] = explode('_', $alignment); + // The beginning of the string determines the pattern. + $variables['pattern'] = 'banner_' . $banner_type; + // The end of the string determines the position. + $variables['alignment'] = $banner_alignment; + + $variant = $paragraph->get('oe_paragraphs_variant')->value ?? 'default'; + $variables['variant'] = str_replace('oe_banner_', '', $variant); + + if ($variables['variant'] === 'default' || $variables['variant'] === 'primary') { + return; + } + + // Bail out if there is no media present. + if ($paragraph->get('field_oe_media')->isEmpty()) { + return; + } + $cacheability = CacheableMetadata::createFromRenderArray($variables); + + /** @var \Drupal\media\Entity\Media $media */ + $media = $paragraph->get('field_oe_media')->entity; + if (!$media instanceof MediaInterface) { + // The media entity is not available anymore, bail out. + return; + } + + // Retrieve the correct translation to display. + $media = \Drupal::service('entity.repository')->getTranslationFromContext($media, $paragraph->language()->getId()); + + // Caches are handled by the formatter usually. Since we are not rendering + // the original render arrays, we need to propagate our caches to the + // paragraph template. + $cacheability->addCacheableDependency($media); + + // Run access checks on the media entity. + $access = $media->access('view', $variables['user'], TRUE); + $cacheability->addCacheableDependency($access); + if (!$access->isAllowed()) { + $cacheability->applyTo($variables); + return; + } + + $source = $media->getSource(); + // We only support images and AV Portal photos for now. + if (!$source instanceof MediaAvPortalSourceInterface && !$source instanceof Image) { + $cacheability->applyTo($variables); + return; + } + + $uri = oe_whitelabel_get_media_uri($source, $media, $cacheability); + + // The uri might be empty if the source is of type Image and the file entity + // was deleted. + if (empty($uri)) { + $cacheability->applyTo($variables); + return; + } + + $variables['image'] = ImageValueObject::fromArray([ + 'src' => file_create_url($uri), + 'alt' => $source->getMetadata($media, 'thumbnail_alt_value') ?? $media->label(), + 'name' => $media->getName(), + ]); + $cacheability->applyTo($variables); +} + +/** + * Implements hook_preprocess_paragraph() for timeline paragraph. + */ +function oe_whitelabel_preprocess_paragraph__oe_timeline(array &$variables): void { + $paragraph = $variables['paragraph']; + if (!$paragraph->get('field_oe_title')->isEmpty()) { + $variables['heading'] = $paragraph->get('field_oe_title')->value; + } + + if (!isset($variables['content']['field_oe_timeline']['#items'])) { + return; + } + // Adapting body to content as defined in pattern. + foreach ($variables['content']['field_oe_timeline']['#items'] as &$timeline_item) { + $timeline_item['content'] = $timeline_item['body']; + unset($timeline_item['body']); + $variables['content']['items'][] = $timeline_item; + } + $variables['hide_from'] = $paragraph->get('field_oe_timeline_expand')->value; +} + +/** + * Implements hook_preprocess_paragraph() for paragraph--oe-content-row--variant-inpage-navigation.html.twig. + */ +function oe_whitelabel_preprocess_paragraph__oe_content_row__variant_inpage_navigation(array &$variables): void { + /** @var \Drupal\paragraphs\Entity\Paragraph $paragraph */ + $paragraph = $variables['paragraph']; + + if ($paragraph->get('field_oe_paragraphs')->isEmpty()) { + return; + } + + $variables['attributes']['id'] = Html::getUniqueId('bcl-inpage-navigation-pid-' . $paragraph->id()); + + $variables['title'] = t('Page contents'); + if (!$paragraph->get('field_oe_title')->isEmpty()) { + $variables['title'] = $paragraph->get('field_oe_title')->value; + } + + $field_render = &$variables['content']['field_oe_paragraphs']; + $links = []; + foreach ($paragraph->get('field_oe_paragraphs')->referencedEntities() as $delta => $sub_paragraph) { + /** @var \Drupal\paragraphs\Entity\Paragraph $sub_paragraph */ + if (!$sub_paragraph->hasField('field_oe_title') || $sub_paragraph->get('field_oe_title')->isEmpty()) { + continue; + } + + $unique_id = Html::getUniqueId('bcl-inpage-item-' . $sub_paragraph->id()); + $field_render[$delta]['#theme_wrappers']['container'] = [ + '#attributes' => ['id' => $unique_id], + ]; + + $sub_paragraph = \Drupal::service('entity.repository') + ->getTranslationFromContext($sub_paragraph, $paragraph->language()->getId()); + + $links[] = [ + 'path' => '#' . $unique_id, + 'label' => $sub_paragraph->get('field_oe_title')->first()->value, + ]; + } + + $variables['links'] = $links; +} + +/** + * Implements hook_preprocess_paragraph() for oe_description-list paragraph. + */ +function oe_whitelabel_preprocess_paragraph__oe_description_list(array &$variables): void { + /** @var Drupal\paragraphs\Entity\Paragraph $paragraph */ + $paragraph = $variables['paragraph']; + $variables['title'] = $paragraph->get('field_oe_title')->value ?? ''; + $variables['orientation'] = $paragraph->get('oe_bt_orientation')->value; + + foreach ($paragraph->get('field_oe_description_list_items') as $item) { + $variables['items'][] = [ + 'term' => $item->term, + 'definition' => $item->description, + ]; + } +} + +/** + * Implements hook_preprocess_paragraph(). + */ +function oe_whitelabel_preprocess_paragraph__oe_facts_figures(array &$variables): void { + /** @var \Drupal\paragraphs\ParagraphInterface $paragraph */ + $paragraph = $variables['paragraph']; + if (!$paragraph->get('field_oe_title')->isEmpty()) { + $variables['title'] = $paragraph->get('field_oe_title')->value; + } + + if (!$paragraph->get('field_oe_link')->isEmpty()) { + $link_item = $paragraph->get('field_oe_link')->first(); + $variables['link_more']['path'] = $link_item->getUrl()->toString(); + $variables['link_more']['label'] = $link_item->get('title')->getValue(); + } + $variables['items'] = []; + + /** @var \Drupal\paragraphs\Entity\Paragraph $sub_paragraph */ + foreach ($paragraph->get('field_oe_paragraphs')->referencedEntities() as $sub_paragraph) { + // Get the paragraph translation. + $sub_paragraph = \Drupal::service('entity.repository') + ->getTranslationFromContext($sub_paragraph, $paragraph->language()->getId()); + $description = ''; + if (!$sub_paragraph->get('field_oe_plain_text_long')->isEmpty()) { + $description = $sub_paragraph->get('field_oe_plain_text_long')->value; + } + $variables['items'][] = [ + 'icon' => $sub_paragraph->get('field_oe_icon')->value, + 'title' => $sub_paragraph->get('field_oe_title')->value, + 'subtitle' => $sub_paragraph->get('field_oe_subtitle')->value, + 'description' => $description, + ]; + } + + if (!$paragraph->get('oe_bt_n_columns')->isEmpty()) { + $variables['columns'] = $paragraph->get('oe_bt_n_columns')->value; + } +} + +/** + * Sets link variable for banner paragraph. + * + * @param \Drupal\paragraphs\Entity\Paragraph $paragraph + * The paragraph. + * @param array $variables + * The render array. + */ +function oe_whitelabel_set_banner_link(Paragraph $paragraph, array &$variables): void { + if ($paragraph->get('field_oe_link')->isEmpty()) { + return; + } + + $link = $paragraph->get('field_oe_link')->first(); + $variables['url'] = $link->getUrl()->toString(); + $variables['label'] = $link->get('title')->getValue(); +} + +/** + * Gets the uri from a media object. + * + * @param \Drupal\media\MediaSourceInterface $source + * The media source. + * @param \Drupal\media\Entity\Media $media + * The media object. + * @param \Drupal\Core\Cache\CacheableMetadata $cacheability + * The cacheability object. + * + * @return string + * The uri string. + */ +function oe_whitelabel_get_media_uri(MediaSourceInterface $source, Media $media, CacheableMetadata $cacheability): string { + $field_name = $source->getConfiguration()['source_field']; + + if ($source instanceof Image && ($file_entity = $media->get($field_name)->entity)) { + $cacheability->addCacheableDependency($file_entity); + return $file_entity->getFileUri(); + } + + if ($source instanceof MediaAvPortalSourceInterface) { + $resource_ref = $media->get($field_name)->value; + return 'avportal://' . $resource_ref . '.jpg'; + } + + return ''; +} + +/** + * Prepares embedded media variables for "text with featured media" paragraph. + * + * @param array $variables + * The render array. + * @param \Drupal\media\MediaInterface $media + * Media object. + * @param \Drupal\Core\Cache\CacheableMetadata $cacheability + * CacheableMetadata object. + * @param \Drupal\media\MediaSourceInterface $source + * Media source. + */ +function _oe_whitelabel_featured_media_set_embedded_media(array &$variables, MediaInterface $media, CacheableMetadata $cacheability, MediaSourceInterface $source): void { + // Default video aspect ratio is set to 16x9. + $variables['ratio'] = '16x9'; + + // Load information about the media and the display. + $media_type = \Drupal::entityTypeManager()->getStorage('media_type')->load($media->bundle()); + $cacheability->addCacheableDependency($media_type); + $source_field = $source->getSourceFieldDefinition($media_type); + $display = EntityViewDisplay::collectRenderDisplay($media, 'default'); + $cacheability->addCacheableDependency($display); + $display_options = $display->getComponent($source_field->getName()); + + $variables['embedded_media'] = $media->{$source_field->getName()}->view($display_options); + + if ($media->bundle() === 'video_iframe') { + $ratio = $media->get('oe_media_iframe_ratio')->value; + $variables['ratio'] = str_replace('_', 'x', $ratio); + } +} diff --git a/modules/oe_whitelabel_paragraphs/oe_whitelabel_paragraphs.post_update.php b/modules/oe_whitelabel_paragraphs/oe_whitelabel_paragraphs.post_update.php new file mode 100644 index 00000000..4806627e --- /dev/null +++ b/modules/oe_whitelabel_paragraphs/oe_whitelabel_paragraphs.post_update.php @@ -0,0 +1,65 @@ +<?php + +/** + * @file + * Post update functions for the OE Bootstrap theme paragraphs module. + */ + +declare(strict_types = 1); + +use Drupal\oe_whitelabel\ConfigImporter; + +/** + * Add extra fields to description list paragraph. + */ +function oe_whitelabel_paragraphs_post_update_00001(array &$sandbox): void { + \Drupal::service('module_installer')->install(['oe_paragraphs_description_list']); + + $configs = [ + 'field.storage.paragraph.oe_bt_orientation', + 'field.field.paragraph.oe_description_list.oe_bt_orientation', + 'core.entity_form_display.paragraph.oe_description_list.default', + 'core.entity_view_display.paragraph.oe_description_list.default', + ]; + + ConfigImporter::importMultiple('oe_whitelabel_paragraphs', '/config/post_updates/00001/', $configs, TRUE); +} + +/** + * Hides the field icon at Accordion item paragraph. + */ +function oe_whitelabel_paragraphs_post_update_00002(array &$sandbox): void { + $configs = [ + 'core.entity_form_display.paragraph.oe_accordion_item.default', + 'core.entity_view_display.paragraph.oe_accordion_item.default', + ]; + + ConfigImporter::importMultiple('oe_whitelabel_paragraphs', '/config/post_updates/00002/', $configs, TRUE); +} + +/** + * Display new layout field at facts&figures paragraph. + */ +function oe_whitelabel_paragraphs_post_update_00003(array &$sandbox): void { + $configs = [ + 'field.storage.paragraph.oe_bt_n_columns', + 'field.field.paragraph.oe_facts_figures.oe_bt_n_columns', + 'core.entity_form_display.paragraph.oe_facts_figures.default', + 'core.entity_view_display.paragraph.oe_facts_figures.default', + ]; + + ConfigImporter::importMultiple('oe_whitelabel_paragraphs', '/config/post_updates/00003/', $configs, TRUE); +} + +/** + * Form modes for variants of list paragraphs. + */ +function oe_whitelabel_paragraphs_post_update_00004(array &$sandbox): void { + $configs = [ + 'core.entity_form_display.paragraph.oe_list_item_block.default', + 'core.entity_form_display.paragraph.oe_list_item_block.highlight', + 'core.entity_form_display.paragraph.oe_list_item.default', + ]; + + ConfigImporter::importMultiple('oe_whitelabel_paragraphs', '/config/post_updates/00003/', $configs, TRUE); +} diff --git a/modules/oe_whitelabel_paragraphs/oe_whitelabel_paragraphs.services.yml b/modules/oe_whitelabel_paragraphs/oe_whitelabel_paragraphs.services.yml new file mode 100644 index 00000000..5dfebd8d --- /dev/null +++ b/modules/oe_whitelabel_paragraphs/oe_whitelabel_paragraphs.services.yml @@ -0,0 +1,5 @@ +services: + oe_whitelabel_paragraphs.icon_options_subscriber: + class: 'Drupal\oe_whitelabel_paragraphs\EventSubscriber\IconOptionsSubscriber' + tags: + - { name: 'event_subscriber' } diff --git a/modules/oe_whitelabel_paragraphs/src/EventSubscriber/IconOptionsSubscriber.php b/modules/oe_whitelabel_paragraphs/src/EventSubscriber/IconOptionsSubscriber.php new file mode 100644 index 00000000..38785ea5 --- /dev/null +++ b/modules/oe_whitelabel_paragraphs/src/EventSubscriber/IconOptionsSubscriber.php @@ -0,0 +1,57 @@ +<?php + +declare(strict_types = 1); + +namespace Drupal\oe_whitelabel_paragraphs\EventSubscriber; + +use Drupal\oe_paragraphs\Event\IconOptionsEvent; +use Symfony\Component\EventDispatcher\EventSubscriberInterface; + +/** + * Provides options for the icon field. + * + * @see \Drupal\oe_paragraphs\EventSubscriber\OptionsSubscriber + * @see _oe_paragraphs_allowed_values_icons() + */ +class IconOptionsSubscriber implements EventSubscriberInterface { + + /** + * {@inheritdoc} + */ + public static function getSubscribedEvents(): array { + return [ + IconOptionsEvent::class => ['getIconOptions', -1], + ]; + } + + /** + * Gets the icon options. + * + * @param \Drupal\oe_paragraphs\Event\IconOptionsEvent $event + * Allowed format event object. + */ + public function getIconOptions(IconOptionsEvent $event): void { + $event->setIconOptions([ + 'arrow-down' => 'Arrow down', + 'box-arrow-up' => 'External', + 'arrow-up' => 'Arrow up', + 'book' => 'Book', + 'camera' => 'Camera', + 'check' => 'Check', + 'download' => 'Download', + 'currency-euro' => 'Euro', + 'facebook' => 'Facebook', + 'file' => 'File', + 'image' => 'Image', + 'info' => 'Info', + 'linkedin' => 'LinkedIn', + 'files' => 'Multiple files', + 'rss' => 'RSS', + 'search' => 'Search', + 'share' => 'Share', + 'twitter' => 'Twitter', + 'camera-video' => 'Video', + ]); + } + +} -- GitLab From 1891f4fa75fa19430cb8c97c0b7a5ca538689252 Mon Sep 17 00:00:00 2001 From: Abel Santos <abel.santos.corral@gmail.com> Date: Mon, 14 Mar 2022 08:36:17 +0100 Subject: [PATCH 03/21] OEL-1280: Add templates of paragraphs. --- .../paragraph--oe-accordion.html.twig | 11 +++++ .../paragraphs/paragraph--oe-banner.html.twig | 41 +++++++++++++++++++ ...t-row--variant-inpage-navigation.html.twig | 15 +++++++ .../paragraph--oe-content-row.html.twig | 13 ++++++ .../paragraph--oe-description-list.html.twig | 17 ++++++++ .../paragraph--oe-facts-figures.html.twig | 14 +++++++ .../paragraph--oe-links-block.html.twig | 14 +++++++ .../paragraph--oe-list-item-block.html.twig | 16 ++++++++ .../paragraphs/paragraph--oe-quote.html.twig | 12 ++++++ .../paragraph--oe-rich-text.html.twig | 10 +++++ ...aragraph--oe-social-media-follow.html.twig | 14 +++++++ ...paragraph--oe-text-feature-media.html.twig | 25 +++++++++++ .../paragraph--oe-timeline--default.html.twig | 14 +++++++ 13 files changed, 216 insertions(+) create mode 100644 templates/paragraphs/paragraph--oe-accordion.html.twig create mode 100644 templates/paragraphs/paragraph--oe-banner.html.twig create mode 100644 templates/paragraphs/paragraph--oe-content-row--variant-inpage-navigation.html.twig create mode 100644 templates/paragraphs/paragraph--oe-content-row.html.twig create mode 100644 templates/paragraphs/paragraph--oe-description-list.html.twig create mode 100644 templates/paragraphs/paragraph--oe-facts-figures.html.twig create mode 100644 templates/paragraphs/paragraph--oe-links-block.html.twig create mode 100644 templates/paragraphs/paragraph--oe-list-item-block.html.twig create mode 100644 templates/paragraphs/paragraph--oe-quote.html.twig create mode 100644 templates/paragraphs/paragraph--oe-rich-text.html.twig create mode 100644 templates/paragraphs/paragraph--oe-social-media-follow.html.twig create mode 100644 templates/paragraphs/paragraph--oe-text-feature-media.html.twig create mode 100644 templates/paragraphs/paragraph--oe-timeline--default.html.twig diff --git a/templates/paragraphs/paragraph--oe-accordion.html.twig b/templates/paragraphs/paragraph--oe-accordion.html.twig new file mode 100644 index 00000000..4f84608b --- /dev/null +++ b/templates/paragraphs/paragraph--oe-accordion.html.twig @@ -0,0 +1,11 @@ +{# +/** + * @file + * Theme override to display the 'accordion' #type paragraph. + * + * @see ./modules/contrib/paragraphs/templates/paragraph.html.twig + */ +#} +{{ pattern('accordion', { + 'items': items, +}) }} diff --git a/templates/paragraphs/paragraph--oe-banner.html.twig b/templates/paragraphs/paragraph--oe-banner.html.twig new file mode 100644 index 00000000..cbe34141 --- /dev/null +++ b/templates/paragraphs/paragraph--oe-banner.html.twig @@ -0,0 +1,41 @@ +{# +/** + * @file + * Theme override to display the 'banner' type paragraph. + * + * @see ./modules/contrib/paragraphs/templates/paragraph.html.twig + */ +#} +{% set attributes = create_attribute() %} +{% if url %} + {% set _call_to_action = { + 'label': label, + 'path': url, + 'attributes': create_attribute({ + 'class': [ + 'btn', + variant == 'primary' ? 'btn-light' : 'btn-primary', + ], + }), + 'icon': { + 'name': 'chevron-right', + 'size': 'fluid', + 'path': bcl_icon_path, + }, + } %} +{% endif %} +{% set _hero = 'hero' in pattern %} +{% set _shade = 'shade' in variant %} +{{ pattern('banner', { + 'variant': variant, + 'title': content.field_oe_title, + 'description': content.field_oe_text, + 'call_to_action': _call_to_action, + 'image': image.src, + 'hero': _hero, + 'shade': _shade, + 'full_width': full_width, + 'centered': 'center' in alignment, + 'attributes': attributes, +}) }} + diff --git a/templates/paragraphs/paragraph--oe-content-row--variant-inpage-navigation.html.twig b/templates/paragraphs/paragraph--oe-content-row--variant-inpage-navigation.html.twig new file mode 100644 index 00000000..42899b15 --- /dev/null +++ b/templates/paragraphs/paragraph--oe-content-row--variant-inpage-navigation.html.twig @@ -0,0 +1,15 @@ +{# +/** + * @file + * Theme override to display the 'Content row' #type and 'Inpage navigation' #variant paragraph. + * + * @see ./modules/contrib/paragraphs/templates/paragraph.html.twig + */ +#} +{{ pattern('inpage_navigation', { + 'title': title, + 'links': links, + 'content': content.field_oe_paragraphs, + 'full_layout': true, + 'attributes': attributes, +}) }} diff --git a/templates/paragraphs/paragraph--oe-content-row.html.twig b/templates/paragraphs/paragraph--oe-content-row.html.twig new file mode 100644 index 00000000..385a7771 --- /dev/null +++ b/templates/paragraphs/paragraph--oe-content-row.html.twig @@ -0,0 +1,13 @@ +{# +/** + * @file + * Theme override to display the 'content row' type paragraph. + * + * @see ./modules/contrib/paragraphs/templates/paragraph.html.twig + */ +#} +<div class="row"> + <div class="col-md-12"> + {{ content.field_oe_paragraphs }} + </div> +</div> diff --git a/templates/paragraphs/paragraph--oe-description-list.html.twig b/templates/paragraphs/paragraph--oe-description-list.html.twig new file mode 100644 index 00000000..a78c5d6e --- /dev/null +++ b/templates/paragraphs/paragraph--oe-description-list.html.twig @@ -0,0 +1,17 @@ +{# +/** + * @file + * Theme override to display the 'Description list' #type paragraph. + * + * @see ./modules/contrib/paragraphs/templates/paragraph.html.twig + */ +#} + +{% if title is not empty %} + <h4 class="fw-bold mb-4">{{ title }}</h4> +{% endif %} + +{{ pattern('description_list', { + 'items': items, + 'orientation': orientation, +}) }} diff --git a/templates/paragraphs/paragraph--oe-facts-figures.html.twig b/templates/paragraphs/paragraph--oe-facts-figures.html.twig new file mode 100644 index 00000000..31ede665 --- /dev/null +++ b/templates/paragraphs/paragraph--oe-facts-figures.html.twig @@ -0,0 +1,14 @@ +{# +/** + * @file + * Theme override to display the 'Facts and Figures' #type paragraph. + * + * @see ./modules/contrib/paragraphs/templates/paragraph.html.twig + */ +#} +{{ pattern('fact_figures', { + 'title': title|default(''), + 'items': items, + 'columns': columns, + 'link': link_more, +}) }} diff --git a/templates/paragraphs/paragraph--oe-links-block.html.twig b/templates/paragraphs/paragraph--oe-links-block.html.twig new file mode 100644 index 00000000..36eee190 --- /dev/null +++ b/templates/paragraphs/paragraph--oe-links-block.html.twig @@ -0,0 +1,14 @@ +{# +/** + * @file + * Theme override to display the 'links block' #type paragraph. + * + * @see ./modules/contrib/paragraphs/templates/paragraph.html.twig + */ +#} +{{ pattern('links_block', { + 'orientation': orientation, + 'background': background, + 'title': title, + 'links': links, +}) }} diff --git a/templates/paragraphs/paragraph--oe-list-item-block.html.twig b/templates/paragraphs/paragraph--oe-list-item-block.html.twig new file mode 100644 index 00000000..22c1a716 --- /dev/null +++ b/templates/paragraphs/paragraph--oe-list-item-block.html.twig @@ -0,0 +1,16 @@ +{# +/** + * @file + * Theme override to display the 'List item block' type paragraph. + * + * @see ./modules/contrib/paragraphs/templates/paragraph.html.twig + */ +#} +{{ pattern('listing', { + 'variant': variant, + 'columns': columns, + 'items': items, + 'link': link, + 'title': title, +}) }} + diff --git a/templates/paragraphs/paragraph--oe-quote.html.twig b/templates/paragraphs/paragraph--oe-quote.html.twig new file mode 100644 index 00000000..a01bbbe7 --- /dev/null +++ b/templates/paragraphs/paragraph--oe-quote.html.twig @@ -0,0 +1,12 @@ +{# +/** + * @file + * Theme override to display the 'quote' type paragraph. + * + * @see ./modules/contrib/paragraphs/templates/paragraph.html.twig + */ +#} +{{ pattern('blockquote', { + 'quote': content.field_oe_plain_text_long, + 'attribution': content.field_oe_text, +}) }} diff --git a/templates/paragraphs/paragraph--oe-rich-text.html.twig b/templates/paragraphs/paragraph--oe-rich-text.html.twig new file mode 100644 index 00000000..80246556 --- /dev/null +++ b/templates/paragraphs/paragraph--oe-rich-text.html.twig @@ -0,0 +1,10 @@ +{# +/** + * @file + * Theme override to display the 'rich text' type paragraph. + * + * @see ./modules/contrib/paragraphs/templates/paragraph.html.twig + */ +#} +<h4 class="fw-bold mb-4">{{ content.field_oe_title }}</h4> +{{ content|without('field_oe_title') }} diff --git a/templates/paragraphs/paragraph--oe-social-media-follow.html.twig b/templates/paragraphs/paragraph--oe-social-media-follow.html.twig new file mode 100644 index 00000000..36eee190 --- /dev/null +++ b/templates/paragraphs/paragraph--oe-social-media-follow.html.twig @@ -0,0 +1,14 @@ +{# +/** + * @file + * Theme override to display the 'links block' #type paragraph. + * + * @see ./modules/contrib/paragraphs/templates/paragraph.html.twig + */ +#} +{{ pattern('links_block', { + 'orientation': orientation, + 'background': background, + 'title': title, + 'links': links, +}) }} diff --git a/templates/paragraphs/paragraph--oe-text-feature-media.html.twig b/templates/paragraphs/paragraph--oe-text-feature-media.html.twig new file mode 100644 index 00000000..ff2a4d42 --- /dev/null +++ b/templates/paragraphs/paragraph--oe-text-feature-media.html.twig @@ -0,0 +1,25 @@ +{# +/** + * @file + * Theme override to display the 'featured_media' type paragraph. + * + * @see ./modules/contrib/paragraphs/templates/paragraph.html.twig + */ +#} + +{% if not paragraph.field_oe_link.isEmpty %} + {# Add cache info from the Link field to the page. #} + {% set bubble_cache = content.field_oe_link|render %} +{% endif %} + +{{ pattern('featured_media', { + 'embedded_media': embedded_media, + 'image': image, + 'ratio': ratio, + 'text_position': text_position, + 'title': not paragraph.field_oe_title.isEmpty ? content.field_oe_title, + 'subtitle': not paragraph.field_oe_feature_media_title.isEmpty ? content.field_oe_feature_media_title, + 'caption': not paragraph.field_oe_plain_text_long.isEmpty ? content.field_oe_plain_text_long, + 'text': not paragraph.field_oe_text_long.isEmpty ? content.field_oe_text_long, + 'link': link|default([]), +}) }} diff --git a/templates/paragraphs/paragraph--oe-timeline--default.html.twig b/templates/paragraphs/paragraph--oe-timeline--default.html.twig new file mode 100644 index 00000000..813ac0dd --- /dev/null +++ b/templates/paragraphs/paragraph--oe-timeline--default.html.twig @@ -0,0 +1,14 @@ +{# +/** + * @file + * Theme override to display the 'timeline' #type paragraph. + * + * @see ./modules/contrib/paragraphs/templates/paragraph.html.twig + */ +#} +{{ + pattern('timeline', { + hide_from: hide_from, + items: content.items, + }) +}} -- GitLab From 4eb3cbeff2389f8611d2f960e15a6be1eeead2b6 Mon Sep 17 00:00:00 2001 From: Abel Santos <abel.santos.corral@gmail.com> Date: Mon, 14 Mar 2022 08:37:05 +0100 Subject: [PATCH 04/21] OEL-1280: Add oe_whitelabel_paragraphs at runner. --- runner.yml.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/runner.yml.dist b/runner.yml.dist index 782e6c99..5a33a96b 100644 --- a/runner.yml.dist +++ b/runner.yml.dist @@ -25,6 +25,7 @@ drupal: - "./vendor/bin/drush en oe_whitelabel_search -y" - "./vendor/bin/drush en oe_whitelabel_starter_news -y" - "./vendor/bin/drush en oe_whitelabel_starter_event -y" + - "./vendor/bin/drush en oe_whitelabel_paragraphs -y" - "./vendor/bin/drush en toolbar -y" - "./vendor/bin/drush theme:enable oe_whitelabel -y" - "./vendor/bin/drush theme:enable seven -y" -- GitLab From 2c892615f36fab36e27590e3553c42e4aa762a00 Mon Sep 17 00:00:00 2001 From: Abel Santos <abel.santos.corral@gmail.com> Date: Mon, 14 Mar 2022 08:37:29 +0100 Subject: [PATCH 05/21] OEL-1280: Add tests for oe_whitelabel_paragraphs. --- .../oe_whitelabel_paragraphs.module | 2 +- .../oe_whitelabel_paragraphs.post_update.php | 2 +- .../tests/fixtures/example_1.jpeg | Bin 0 -> 8873 bytes .../tests/src/Functional/ParagraphsTest.php | 330 +++++++++ .../src/Kernel/AbstractKernelTestBase.php | 104 +++ .../src/Kernel/Paragraphs/ContentRowTest.php | 184 +++++ .../Kernel/Paragraphs/DescriptionListTest.php | 92 +++ .../EntityReferenceRevisionTest.php | 107 +++ .../Kernel/Paragraphs/FactsFiguresTest.php | 211 ++++++ .../src/Kernel/Paragraphs/LinksBlockTest.php | 73 ++ .../Paragraphs/ListingParagraphsTest.php | 194 ++++++ .../Kernel/Paragraphs/MediaParagraphsTest.php | 644 ++++++++++++++++++ .../Kernel/Paragraphs/ParagraphsTestBase.php | 96 +++ .../tests/src/Kernel/Paragraphs/QuoteTest.php | 40 ++ .../src/Kernel/Paragraphs/RichTextTest.php | 121 ++++ .../Paragraphs/SocialMediaFollowTest.php | 90 +++ .../Paragraphs/TimelineParagraphTest.php | 157 +++++ .../PatternAssertions/LinksBlockAssertion.php | 223 ++++++ .../PatternAssertions/ListingAssertion.php | 99 +++ .../tests/src/Kernel/Traits/RenderTrait.php | 30 + 20 files changed, 2797 insertions(+), 2 deletions(-) create mode 100644 modules/oe_whitelabel_paragraphs/tests/fixtures/example_1.jpeg create mode 100644 modules/oe_whitelabel_paragraphs/tests/src/Functional/ParagraphsTest.php create mode 100644 modules/oe_whitelabel_paragraphs/tests/src/Kernel/AbstractKernelTestBase.php create mode 100644 modules/oe_whitelabel_paragraphs/tests/src/Kernel/Paragraphs/ContentRowTest.php create mode 100644 modules/oe_whitelabel_paragraphs/tests/src/Kernel/Paragraphs/DescriptionListTest.php create mode 100644 modules/oe_whitelabel_paragraphs/tests/src/Kernel/Paragraphs/EntityReferenceRevisionTest.php create mode 100644 modules/oe_whitelabel_paragraphs/tests/src/Kernel/Paragraphs/FactsFiguresTest.php create mode 100644 modules/oe_whitelabel_paragraphs/tests/src/Kernel/Paragraphs/LinksBlockTest.php create mode 100644 modules/oe_whitelabel_paragraphs/tests/src/Kernel/Paragraphs/ListingParagraphsTest.php create mode 100644 modules/oe_whitelabel_paragraphs/tests/src/Kernel/Paragraphs/MediaParagraphsTest.php create mode 100644 modules/oe_whitelabel_paragraphs/tests/src/Kernel/Paragraphs/ParagraphsTestBase.php create mode 100644 modules/oe_whitelabel_paragraphs/tests/src/Kernel/Paragraphs/QuoteTest.php create mode 100644 modules/oe_whitelabel_paragraphs/tests/src/Kernel/Paragraphs/RichTextTest.php create mode 100644 modules/oe_whitelabel_paragraphs/tests/src/Kernel/Paragraphs/SocialMediaFollowTest.php create mode 100644 modules/oe_whitelabel_paragraphs/tests/src/Kernel/Paragraphs/TimelineParagraphTest.php create mode 100644 modules/oe_whitelabel_paragraphs/tests/src/Kernel/PatternAssertions/LinksBlockAssertion.php create mode 100644 modules/oe_whitelabel_paragraphs/tests/src/Kernel/PatternAssertions/ListingAssertion.php create mode 100644 modules/oe_whitelabel_paragraphs/tests/src/Kernel/Traits/RenderTrait.php diff --git a/modules/oe_whitelabel_paragraphs/oe_whitelabel_paragraphs.module b/modules/oe_whitelabel_paragraphs/oe_whitelabel_paragraphs.module index 6113f0d0..d70b613b 100644 --- a/modules/oe_whitelabel_paragraphs/oe_whitelabel_paragraphs.module +++ b/modules/oe_whitelabel_paragraphs/oe_whitelabel_paragraphs.module @@ -96,7 +96,7 @@ function oe_whitelabel_preprocess_paragraph__oe_social_media_follow(array &$vari * Implements hook_preprocess_paragraph__oe_accordion(). */ function oe_whitelabel_preprocess_paragraph__oe_accordion(array &$variables): void { - // Massage data to be compliant with OE Bootstrap Theme accordion component + // Massage data to be compliant with OE Bootstrap Theme accordion pattern // data structure. $builder = \Drupal::entityTypeManager()->getViewBuilder('paragraph'); $variables['items'] = []; diff --git a/modules/oe_whitelabel_paragraphs/oe_whitelabel_paragraphs.post_update.php b/modules/oe_whitelabel_paragraphs/oe_whitelabel_paragraphs.post_update.php index 4806627e..b358b83b 100644 --- a/modules/oe_whitelabel_paragraphs/oe_whitelabel_paragraphs.post_update.php +++ b/modules/oe_whitelabel_paragraphs/oe_whitelabel_paragraphs.post_update.php @@ -2,7 +2,7 @@ /** * @file - * Post update functions for the OE Bootstrap theme paragraphs module. + * Post update functions for the OE Whitelabel paragraphs module. */ declare(strict_types = 1); diff --git a/modules/oe_whitelabel_paragraphs/tests/fixtures/example_1.jpeg b/modules/oe_whitelabel_paragraphs/tests/fixtures/example_1.jpeg new file mode 100644 index 0000000000000000000000000000000000000000..e04cde60ca8fa8d23a3668010a40f976abb78e8b GIT binary patch literal 8873 zcmb7qbzD?k7w#FlVJMOA?gr_Ulnxb;7-Z-eN+d<PyJ1Lak(3Yxqy(e{2?>!#q*3w? zsJ!p}zVH5VH|NaRd#z`!z4tlm+4bY{^W_3SpsJ*z1b{#w;4b11xLgE<DSAPz0YF0o zU<UvI13(8607!@&3F5W@kprlRCkSzSfhcbB0U%ZY`C5)ZA`$(`BT%7G0Ob!pER5-I z9^nO%6kOe%&FyIwjZ~Cq<;@)+uI99SSMsZNT-WgXi4l}>Q_pr#_D%jMjOBMdpf~_P zT<8cZ6kdKl-Z<pz_7Wq?7YSH@@gTyyzZgDV-aOE6+sjJ?>UTo4_R150hqyufynKS< zyrSa#qO`oi;zIo5yu4Q^kt-dd7oh7JkTkDkNY^zWdJob<_`G^kNQzf-lpDFtRS}T{ z5%<-bqyGJTl!}1vBl5U^<fOl!-LZ&<c3&<c58A+B&f+{gj&9uMR!$ZWZc8Tz9xroe z9zJef9za6c%h}x04g#aKfINmeO0xWDX=kB@T1m1P3Tg0aILkw9pm(3RLUf;K>RCRq zvlO#pk(R=e@DlfOaCU&e%xS$G>>b_2y(C$#or@##S7II(1jyCOT3km#=??@^l4SYQ z7Ee!4ZchPjC)dY3d}3l^JiPoo{QO)91ecq)Bh1{3%h8Pi;Q@>G+J^$f&C(U>41+p3 z{_zDt1lNtT|EptHn(Lk+%xP&Qu8QIsPF4_mss9cX37&tcZ_q|M5H}}#_p92ZMEL(; z{w=&g8vifkzlAr*e}MXqP?(g8qovIs$N!<Zu`rgmkayK`a)VyA1M2u#N*>|}gSbMh z{@DGO{>D-f(PaaOtJ_ukuky5i3bg#(e1DAp4Y{#XvNw0L(SmyYwf$SZu}8$qAN#+m zzt9^W@=o?nuDXbTf=KB*TAJHKEnLlEH*Nlx_Qpcxs#i|V2-;de?V&Jl6-O(Gmz3t8 zivG9u|7rZUJwp7Pv;w?{o1a@m=x?Y0)7M|{jW=a2U3DkN$55EN6+{POEv5LU5&tRw zp9WHV0-Ut`h<f>jxP=4-{>II}Z4m(}!E?olf5kH*#(&EYJV7vq=Z05^!VNPajtDxs zUh(d729O7kk&vz~L_$Gas2HfIC@82{=;&w|I9ND1*jU)uxOjvFxOiYZY-|Ej0x%IV z2?+@f{w*?6VlqNv65=Z-AY_CM3MwWlDkd>5HZJl1ce?BVz!-or(2EQL14v*HG8lB( z1yEj%X~<Xez)eC!ziJ~038AGx$gh<D(xRZEAtRxKE~fz;WP~XJG67<6JG=`7YL@4` ztNY^w6#nb|dUxd1BXMo!S>sB7|ERp*8ZpQF7iZn}8?0O<ADvH^5_5eLS(+Mc>K3lm zl=BapbiT?s3AlTNvOJq7z@Pa5K8VyTKDgErzX@eBgzldBS_0@jKl&@tYj`gK#n8`V zom{0%$tn9~EpHJxj+UtN2fk@x4~79?beSi+<6ia4c9mdLYb$5YO^UOw5R#A*Q?qvI z+6`Y6@u3`TlgGw3{QLJKzs#9zei--^saPB^_xR^|fkLH?^}z{tHCw}SU!>Yb4eyi- zr}}o8GO5+Ys}(ButmKIqgT|>!&DN@llxYULd%3xHQHT7|-xywStm)xRu6~?^*O)2n zH_WWwdHM}TH&j;lvs&})bi*~w!$NY7$;D0sroGPKTj252Gr(jO?va#mm(=Ttcdgrr zz1bTmmj_KF9?YYox`_N?3~I_M_i(wb$&g7iCFAFDaVJhEDF^d0v(E>UI}fmWlQzz% zTU8f68;>`RZWCR-0_?4}T=^FOK$o!KU27P*s1_()-aLJFSb6$uHj@7m7_x1k$wL4E z09k*f?NwRShv#h{3ip~Pv^$Kh#sB=!AfkYU005x^AS5)TtGWIvp@NW*QP2Q%A}}Ed zt*{KQ00F5MA|fylfdWEBI=bs?OL{WoDnw(gW<U1OArd6Cj~nF@@topd%XrJB?lflD z#<B?KRWnqyr&(mR{(RM!qG3v@;?_bnIQvOo9|ZRC$WjnXjtAcIX8WL_D0hxCA&NEf zYX)*ZZs|DFLbSfl=!JMja-G}#vhVoK-V#LVQz>t`^ZcS(!F{=(bROlONaFU7nT`=M zF?<BaN~gE*f$ooaDkTitkdu>UNZ%2-pUl7=tF}&gSa9AtkvJjBuyWEK?{+84CDjmF zu7zir)dU(qD&MT~6B}3ZU}TA1hKGBe+2;jK0n6_Bz&e`-4Ew&e(3FwmijdaNQu3Y5 z(8A(+)yRTy^7!fRjn-=YEqK^&x2wSWzTcT3RgdYd=%j;!q4*U9RW2&d$C1IE*mm!$ zZ`l;;cdo(1q$GD{CW4za&xM=C8%ulq3ii8ERk7L39c}N&ju{g;`_vjg)=JdK(20Dg zz5er#kVpK;+iKZTb}9ZOhaTEf<H{uYyo)u8{s%AoSSNJv+IQ3MoDEIY=fmwLiqDu_ zU&V3#7+$572FV<CYP`#X-pXqtd{LfTERsH}kdoESXn&$BPZhTPD8v|+Ew~G#5~&Ci z5tmTC1X2-SUJ?v|5F-~V20AL{?=OG#;Q>@IArT#)tTq8LJp;eFOAQIFOkn)G9W-7c z_y{SZfS{a~j^*NYJRk-SY0x1FtKd(l56R2pQ(0}TwR12138m!W0A9=&BKgC(y%VBi zg!khF1S@>wRX;4rl5Ofg<i?1JB5Fu^^)({7cP0{QJnSsw*n)mia>()VbC!_<lP#RC zjzv7CIn%o*Z;;E@c}072!@m4sCtYjgcYO196*g64&2v~|mRm!Gub1ZjW1T9ss0#~1 z*QIE`5&!c2OCT9<YoOlhb9JlrdQs}2tCRTdqG6GB8oU$Vq|jgcTTI1Pk;$i{(3kUX zDmCC*@o6smLLQG45{M@%+)p=_U3`m#jSWC5=<d?4sjL@kc-n6*m7dmhjFP}=7hgJ; zKNz|jMG5<A`$JseaR<2pGT!z{)2sp`AoOB5)6Hm<g;GMuTmRLXRk_@;T`c+Qhrdb; z=IXr-C7U6mo1LA8$q%@n?w7migsy5`0;E#xzdo&tsvG)Irp!Py+{$%OMUXh;S?#^Y zBh?L$SlG5pQ;y*|DRsMrLT&nl<Bd-=H)yie8wEpDr^gi)ZyU*MSJz2~oFCd;sI>d1 zmv3|wG9f#ccL=INYhTmD8&V4L7#+(uTp}=*PCmuUbae&_J=M~CiMGJLA)6(4gu`~* zHL8VeHfZzH)_|1Jc!ea(r2T*tWxT4c8@Xh9YzO>;^Qr!R`6*RuPbgD89hd@h@dMpT zhVnyqy~hi;o?yN`KDYgb_`141hTQ>gAF=O(*HvV!ET7X;eZm|mA&^ks)Y|Ho&w#QJ z9X3?$&?If>^}CRH>awvput~5T5z)OGJtEg{eyT`?C+bNa2=!DeNnTo7GSrTK`|Qg% zwq8%N9)%I6J1?b;^k0n{8KhrKEE=jAr%u#Q?-wu5W^G{7Nr{&Uy^<$F+B*P!71p!i zr)YwX=ftptoI#It>0V7Ak;mh@%(4nO<POHeeXKVQlJ4#Am)`On!1t~o@6=#34xg2R zEktdq>Y9+?&f1dn(%Q`b98()Rd{*0Xcv|X_+?!Z}wRlXJPp{)_FdYy6yows5WKmC7 zlRR+i?MPkUc9r#vS-0D4wl#bPQ*3^!qrvAkNFG^phT(NJjs(Z>i`izybojKk;DCYA z7R%{l1nb1FS%(;4(J-$zU5IqeIxs4Nb@Y6)1jG#d+AbutyfWr+K_Q*M_?mZ%JB$Ka zmLu1cL%OCM5ruZPf(xbZ66?JuFINO-*d_FJUgj+h4Rvb1TtXYd_Q})Olx$#z%j)(w zm$G5pR+bx1MbpQQ$P7toQEKu@&@rgUkHlkLMusSMa<wiq(INF6x{x(v55%C)I)@-d zWJ~F#49Bb;E{jx6CyrpzJYY1PsFu3~YL`#Pv&24kN`t>sb=EDpN6pcQcf2paH?dtF zK5=b^?^aN>Hg}O0_Up&)eF|x|;?-H1(?`SRW-=df#Vt((r_qeZ`->ASr9XM(xZFNe zgBI7hj2oRC(gitE&C(d$AZB1wNVJOJdqn$9xIOz`=QCveDiS1g<9RcW<_hfft@hj> zx(n_O2cEX~KFz!Ot9IgkEy;&15<@gUkw5Ii7U2*aVxY_Mq#=(KdM)o6`<%^>goRMe zr}DcHsZSY<X~>=N%d+<b?wpB*nX1`-vN;CZqZj)^A=TR4oNn5s?A#Lh)#M$xg%m#x zI1?D>y9@~VdtUEW+*wP#M^#rbIk%*-BI*x4(%|!hPwm#M#bE}vcXt$?n;f$oR8Vd2 zD}T&)jVP=-=d4>Q+bWY6fE_2h40rb+wF+MlYYcAU#ErYNHan;#hqA63j4kWb@YX?j zIXQ4sKHw%bl{=JR==2efm6@A&xx$4hlcLSC)w>>yjm8?e)bT!Df6Z%l`wPHc@|Et} zx==^ny^SxK+4KFW%t&{%KvH^VM<x-vnO?Ecl6=oQMzQ8zp0lOu^>>CZtM{t)Vv|VW zHP_!?GLgGCbyk|ili6Lhd{9urN_hz^Gxj>XO%(|&P4jch&h5xj3hVor`zksN9wHdw z8w_QSDvu!^NSVJSyXK)5CDs~QvS^xM(L5I852f*5)Tsf`l>BL6ufMXjDjvACJ<)$S zrcB~|EK_17e*E+jh(ZLrJYsQym{U;EFfsp`VgQuu8HQd~+uQ|}fS6w{o|Zu-5MJ|c zWRX`#SI@%LE$9^qBIFYi3p#fGEIiPpk#?{JgmqarD)@g)6IXibjSYS~WDc;4{bJ{N z7~vP)>e^$f6%G?IPa%@QW1QqS=Tt8o_z)E)4n2Mk$-!n2w1ThfDHLM&q>kI$%{Mtk z_9Z@T9%pzNgY3A!7Bpi$Iz%RyQmfCA&LI~;nkAQDqriOM*OYf5bPsFxX?V}%C(X(h zlv~-ZW1A!<LXHcxjXbIOSQDyA?zyP0PG#erlKPYrv7vDvR2hdsPph?#dZJuZXYYk{ zeXa`H$P+3t+FpUkW^Q))=oMPhOSkMqW{^^kCsY2UNjlFRsaUVPm2zaLFQTxzTyhYL z*SivTKU&{4Bl{p+y0zL$b=rZwvZ802cP61@jTIfZ2hsmTSeERu-k7GA^a{^enYnJm zSkqSCBm7wLB!?}X$WS2(YjhBrM7KKWwW!^lG>PG8vROwORBA<OYfeWi#=EM|Lf88K z1bf42l`fk`57Ri0=ahr0IttAQq{~jy!-%m?n%i9DFuQh=_i6_t{chE5R@pPpHr4Ps zwsYjPrbVs~w8QZkG4DuqnI}n#M}F|y44V(C+Tkl{FQGPQYL@T>Yx7cPv!_^ni<xd4 z-rTd{678*1%$Eyk`gXqc+;fT0-`lh|@ofG@rv?jQ$nIAQ*~CoOQe~JLUEPQ<C^(Ma zi)dB>5ReZhQ`L<~7}fC_&$VacPV~qGb_yBkQ`nwom0~s(#Uw;EEShPUn=q$(uGc>- z4dr)a^YqKh6w@V>jyW#X<`G7V7=w95DL1xcs58(<nz{`=u^px`ASH=z7jD`m%qCf; zB5BRyXd%*shKx;mJuHc+Q?4SIMkNd&L{VclE*}lDD@3m%{NNc?#}8TzEk+qXg@1Zx z`&OuQT3zt9HIEhrTsWY+1RA1KL7W6AXHccWY&dm;SyktVb7ruMyxwLm<FJ-{5Ze|} z?R?c#$a{iv+xxMZhuO;qrqx!MrOjq|1(p;NmW65~0)STG(FHG)USo!3nZxUR6uP&4 zYrU|Mj=DpSRWt{C9n-`259+d_p;c5VrlhY72gRchr!<jxdBbC@gtfAU@-MzBLP^$h zmkgV+#3b|aM_aZC(zlJ$A8vL2%r_}ox>x7!9Qq|m^;@xVe$}i=Ud?@Tqz6fQ_AD<B z*}cfrM|BGOMb0SXp4;}8hrqkGe=&%r4ksmK6AC{KsB<g^kHhd~zua=uF#cQ<q5pQD ze#Mt_?>Q{PAMnt<;7erj{dRwuTFXK8q_sF>==*T$FIjd-R3}SC)g4+US|$bnt(t+W zIk@Rrh5<XyeS0yk*Y%HlmgJM{ODxi>PnBb`y!}Ive0Ob4joIAR@e*1-?tMfI9c%=M z?Z(xv8ujlE6|u9uT9=x;1jZA<cW7l00|xKz&CW!c?gaDs^02b6n$o85Da5)-KPU-I zuSLi6EQby%Drl&2hyI&wLymQ2U?!wSn5-832FnjGWl#Tf={qhDzsVwD17nVo9@%cd zb1$n|((x=4Vn5YAXMbDkAj1(dg&K<R2)D)FQ3;0H&}hGIn0Y7LBQd=@<38crwWt=1 zmMzI}h9=h2Y=0^{Zow0j1d62e9<D6x?aw^S#-~J#H5w~sI6gKz#0y?0Th<fAjoyMl zDn*k0Bc5o=I}=5)ir`e7To#(O4ZvFTOJ9ExldJ^(4{6h%Vh6f74lj^?ajXg#wbvC` zN3pgAa1Y=*R(B`9uG0cUHKsq{EBDsQy}#X=tf0baKx&bC8j`fKib}SZMIQx6!9HPi z2D1b)b&VN(5gIb3IKZ;q)rJMmyh&RLcIfw1`bdL?^oWl-a*rQC`;HD1q+S?r&L5iZ z`&#JQD|B|J>1<N?hv6}S-<J4%#NA|b)6$Mxjb~cz`81!Nu8bdzlZWkO(D#Jx8|o{5 zVgfp%ZtLhTmviLqp1)@^Aad}>Wpc4uqec}6lt!6ixljr*j==8;=t*6g<I?%5`*Y}- z<HAM@Wmbzxze)lTYOA-K6QrVpkXmC~Hij(T<t&s#aI-nkmquiaFIaZebI_V%*g&Z2 zZ@tnndW$+S_}53{^3IhxE9UR{vLlY93l*c+%og}i#_}LU913f5nKM!Xh0K1|b;26z z{hNMvqW$Z712{5S^!^dGZ<~Va9~@i)LAiu7WNlo1MW6XH<Kf1$O}Hc2HRO8lPM0lg zT69&dEgT4=PjLl(jkq-_lR5ofqb6z8MyL)7GwsS5kVeu_zG2-nS@67Ipq7~*9NJSE zPh27X_DGw8X|7&qsNaH23}{JJ^N*k9qqoPO{D~za5dW@{38;8FFeC9qK}jz1O_lH# zyVNa*oaOs+kG!9#)So8#>V}*@ZdaB3iVpCiPerB%J_#)7J52q|=@B9L1AT=A^YQcJ zqQEYbEfuPQOF#fIJ6<2uT%UUrBq%c`s9ayJ^?x$#wcEcXY`XU0*D8e>haXIP2%&nW zL(9tKG?P#vc7)sO=`JUqAURu2tJC$9VAtX_;#^l1#<)Jl`1atG-yURBMt^5+e(xb@ z$_~D!>DBSUpM#`-Xi5-|nACS<Mre5#wRUfIj06{?eQ946Vm)R*F1;WejlOekvP$J* z;3xdWNPpAufEXT_Saor3i-ul0{_(33hy#5Vt$Khs!rNo`dpp-rlumK-=7r-g(+oB< zkQ%NkEK+vt!1ofs^r|_YNO{P;+Z{}^T_^i`DCf!1vr4w4_JA@~;RL2*k<Ipn;^Eov zu@8<4%+a}8+cQ)?2d=Hus_IW$(=&uVA*~Biw8x{4Iiu^k1T5;q@RsgQh?L079OUM% za==SM#qezp-*n`;XUh!V>O$fIjoIUq>t_th^>2&o#u?wn{($2G9_q?R+hjDuq}UZ= zM|A>)2C&~Vw;=gudq*oDuQTAwPcD(RG84(gb7C1JQnC<*k%<WpA<?wLdE^`uydQif zjRF)RBb37^AdQzI!Wx<@HOD^s)N7`Jy9@Eo#Qj@O+qmi@vV!&@`IB+AWB5t?2Gi;| zo>Plkb(?Ei==VOIh|fpcSjvlO3k}uyH@FM?7*-xplilG@I@FJ4^%-3b+0)6(lHE>d zGe}dy`h_1?u-ruBZ(YS4zR9tbH2CN!(07`a!5kbmDmop8m)d%oC@bKcWlq$ku&bq@ zA2$sSS8-&ZH2m^i-{Jv}+qa!gIqL88hVSVKM_PBu&ohQ-FzR+ar*;>Szn#$tDu$KT zC5qs5uPY__5ZD#INK=VpN`<W)M?Y-VGr{1D?BB>7zJr1O!hj=|E2rQI64Z|PJ7aA3 z2USwK8i;WY(bEr=)STTR8O_7%lGE<+U3t`{<gV|e0s_Gp9dg2;$R9-qL3dwpat=NN zXU5xbO@~g3Izn*Nmm-X*?T3&^)5k|+H)(zzRn+7ZhZ}^<Mi#DR+KDaM>295~yPOW< zr}hVMwh-<%j|KFk;iwy^2U!fQPW3u)T5=DyZD?T#*_|lHRIHz?3}IUcJd%<wAVs6P zxA&4S-+U*c@&R(4T}&Gm5kbrNDfWcu(rbkXLE9%6FF<J0xH7#z)MTa1aFY7mdJ9+k z@xMHxo9D^A;^`lvAR$h95k$G(_5uG81;G=7cOyG8i?n|yw5xp{!3EZ&V|04(H#4Um z)EYUV_5BhYFH0Rwos;|T`VU4J``#@U-Qx*m+2xsd7kMm+4=u!4m=wva8FI;g4mv&) zpAL(TRiIbTU~11A_$A>7-tu^9YBcW)Ifuy8%$)3Zgb<_ebPuAqZ^z`)1j!5-f25wX zJz?3W{L~p^8azS7){}m>|M^#eF>aRA^YmvBaIIKB4DOxLwlwqWt^9CopLf;lacLFr zyD7D<=elX>n-O|%HFeUI!gcB;($KLJ+a0z$YRNL0A8YDk0Hkj+$Gw9sQl2SH)M}v% z4IhtX%kjZm2F3*E#566_Q;L6?h~x5^MVl&38FUrH2Ky^@^sB?xUl;Vv<9~lbCaBwd zdO}Y9R>(KDT4f1c4$C>a{>$zU3jN+^5j`oz=N7^B<X#QRAEVdD5(bbcU*>z4wYbf- zI$_oESq7jS<|G+`sLYEpj6LjK3y|K2YX2%U21)qnRtBncAomW-h^S@37YZ{uszry~ z+5|;w1w-yA@|tiMw|4J`9C~M%R0>2*z1cVNw;P5VzFRyxu<!4o?{U%!uo|dy>wg|n zgSOii{$p+R<uB^-uo~N+af+!XXz7U6--ga7IN>xd&>3sL;jd)Gl{ajM12H{}vA6^@ zA*CHiR?MP&G|q6&uZ*;~_~f^BsKU2xl&n;8$=*zj+52%5y@YoENE9KSI_cbY=L=(e z*v7d%L5+0xJ(QWD&6FHRKCFNDw%7!Rw6+m%yG4S|ma^pF#cmt5KfAe@{Fk4bs<jp) z(5YOSLtjjVU<M-JH@o^AO$#ee_4Xm(J~)cCHeSHFb)4)cS5NpXYJ|=w_{l|cq8a-f zH6E|OhxerxDYjCA-<)N@5?13DRV$h<$S__G^9H`&Rs>INo>Z{8`*9HKs^f*8T`kv` z2@u0S5@NyjU&}QDmq1z>M1=Edz5BD7LxlFpov2~sa#p;`dZ{_~+j^k>YBZ!ITE;Cm zT4y|^<Swp;$OhFi)v_YSMZwPlL`bwP0O8(!qKQZMp?BY(YCPSNeHYWvset2s*iU6q z&HEtlRm>M_<ZiZ^c4br(L+0Ja&s&t}mSd)mOZ$xUbYcy0@nj0}?lvf}fzhY5)3%@= zfsgUewf6Y1c$M_(J>mvQ1Wxcx!yEacx7Ztg?sy6M0&nTSi$e~ObdZ`JyiUJh%Mq%E z*`pkxz43}!Sbdc6c<qf}5y%9M%W9AOEfp)%VoaQiE(+baYtku&zG?lDOE4@)`(l^U zV-r_POlI+x-RldR+iGf_fm=Im)(S#JdA4_m+a@=OeM+<O=3?VE$~BgiSBKr<!DpMr zJ8^6Bpl8nk8v_}>xcqJH`nix6bL4z@P*}ic2H_SQS5v=GC3K|^tJFt52_Ouc-H_IE z3&lI{)Pz!{jV(vz_}5TgY{e)Op)hZEKWlkxNZ9x5G3q#4Sl}o!%CD{kEp&UGI+9Vm z35g!}`AdLk$ORl66QmK8(g-bk!f6|(y;6DpCU`Y)w=66etj3CLJTdhCG|0yY))W4U zk5YHfrftY&t*oU(qNjYo+!dd@Z+__wRA(GisKsDtJ{AxoUpq%PrA6?zOCv^Xieo`q zdE9ls;8g_1+4r9oHatoZ(o^C6yeM;95!IfY3wkafKjm*9q93~^NrUIx?Kk2WFw7Ev z4YkG>itPE$;^D>t7}-$9@s0tE1-rg2X;IDR@%INe-@uxR1Jh!OZmpYo;$%AnkLRQa zW-HTGY|p_YbArM64I`7YM~NjB-G_Mz^wG~=m~_$?{osW)sP<B)z}I>LkG7&_u_zge zNi4?#pDo}d37lvha!_*{WhMV&gH1R8$fPC-2vQ_|S4Tp^y)aoqhxbg*Nu+3+45YzF zEl?cz2)rLa#nxsa<}8@77VxZtw&LN+>K<1Ue_$_rKJ5bocMkGfr%4_vA!&JSTTDi; z8&A;hh70xw#5I&XdI(G0U2x_`{13y|Q(KQ@j5#{<9X;J5auAM(V5U=)A|PSe(dce( zGWa!~#vVX7!g6O_cX>uRHXaj{q*5cgM57e1Y`&>Vu10^i6*PAVGy-c-pAB|Nuuo)f zcV*OwV{;IOpa53m5?{ckRW9(UYx>~X0t&Lstw8a`NUZ01*4^PMFE0Vws_1<m>qh_F zox%zf$UM@}GWc^c#bC=><p347R#xPirR&3fErX!em;(a^9>pKS7d6Pw$=-B;m4>~@ z)0m8!eay$YnR5=yqEnmML3seMw6$P6;Mk#X%xff`RkX<nBioG#cTl2!cW&<1<)0-z V2POr{zZi}jPn?PUm3uk$e*kndCb<9r literal 0 HcmV?d00001 diff --git a/modules/oe_whitelabel_paragraphs/tests/src/Functional/ParagraphsTest.php b/modules/oe_whitelabel_paragraphs/tests/src/Functional/ParagraphsTest.php new file mode 100644 index 00000000..e8ec1ef8 --- /dev/null +++ b/modules/oe_whitelabel_paragraphs/tests/src/Functional/ParagraphsTest.php @@ -0,0 +1,330 @@ +<?php + +declare(strict_types = 1); + +namespace Drupal\Tests\oe_whitelabel_paragraphs\Functional; + +use Drupal\field\Entity\FieldConfig; +use Drupal\field\Entity\FieldStorageConfig; +use Drupal\Tests\BrowserTestBase; + +/** + * Tests paragraphs forms. + */ +class ParagraphsTest extends BrowserTestBase { + + /** + * {@inheritdoc} + */ + protected static $modules = [ + 'node', + 'oe_whitelabel_paragraphs', + ]; + + /** + * {@inheritdoc} + */ + protected $defaultTheme = 'stark'; + + /** + * {@inheritdoc} + */ + protected function setUp(): void { + parent::setUp(); + + $this->createTestContentType(); + $this->drupalLogin($this->drupalCreateUser([], '', TRUE)); + } + + /** + * Test Links Block paragraphs form. + */ + public function testLinksBlockParagraph(): void { + $this->drupalGet('/node/add/paragraphs_test'); + $this->getSession()->getPage()->pressButton('Add Links block'); + + // Assert the Links Block fields appears. + $this->assertSession()->fieldExists('oe_bt_paragraphs[0][subform][field_oe_links][0][uri]'); + $this->assertSession()->fieldExists('oe_bt_paragraphs[0][subform][field_oe_links][0][title]'); + $this->assertSession()->fieldExists('oe_bt_paragraphs[0][subform][field_oe_text][0][value]'); + $this->assertSession()->fieldExists('oe_bt_paragraphs[0][subform][oe_bt_links_block_background]'); + $this->assertSession()->fieldExists('oe_bt_paragraphs[0][subform][oe_bt_links_block_orientation]'); + + $this->submitForm([], 'Add another item'); + + $values = [ + 'title[0][value]' => 'Test Links block node title', + 'oe_bt_paragraphs[0][subform][field_oe_text][0][value]' => 'EU Links', + 'oe_bt_paragraphs[0][subform][field_oe_links][0][uri]' => 'https://www.example.com', + 'oe_bt_paragraphs[0][subform][field_oe_links][0][title]' => 'Example link number 1', + 'oe_bt_paragraphs[0][subform][field_oe_links][1][uri]' => 'https://www.more-example.com', + 'oe_bt_paragraphs[0][subform][field_oe_links][1][title]' => 'Example link number 2', + 'oe_bt_paragraphs[0][subform][oe_bt_links_block_background]' => 'gray', + 'oe_bt_paragraphs[0][subform][oe_bt_links_block_orientation]' => 'vertical', + ]; + + $this->submitForm($values, 'Save'); + $this->drupalGet('/node/1'); + + // Assert paragraph values are printed. + $this->assertSession()->pageTextContains('EU Links'); + $this->assertSession()->pageTextContains('Example link number 1'); + $this->assertSession()->pageTextContains('Example link number 2'); + } + + /** + * Test Social media follow paragraphs form. + */ + public function testSocialMediaFollowParagraph(): void { + $this->drupalGet('/node/add/paragraphs_test'); + $this->getSession()->getPage()->pressButton('Add Social media follow'); + + // Assert the Social Media Follow fields appears. + $this->assertSession()->fieldExists('oe_bt_paragraphs[0][subform][field_oe_social_media_links][0][uri]'); + $this->assertSession()->fieldExists('oe_bt_paragraphs[0][subform][field_oe_social_media_links][0][title]'); + $this->assertSession()->fieldExists('oe_bt_paragraphs[0][subform][field_oe_social_media_links][0][link_type]'); + $this->assertSession()->fieldExists('oe_bt_paragraphs[0][subform][field_oe_title][0][value]'); + $this->assertSession()->fieldExists('oe_bt_paragraphs[0][subform][oe_bt_links_block_background]'); + $this->assertSession()->fieldExists('oe_bt_paragraphs[0][subform][field_oe_social_media_variant]'); + $this->assertSession()->fieldExists('oe_bt_paragraphs[0][subform][field_oe_social_media_see_more][0][uri]'); + $this->assertSession()->fieldExists('oe_bt_paragraphs[0][subform][field_oe_social_media_see_more][0][title]'); + + $this->submitForm([], 'Add another item'); + + $values = [ + 'title[0][value]' => 'Test Social Media follow Links node title', + 'oe_bt_paragraphs[0][subform][field_oe_title][0][value]' => 'EU Social Media Follow Links', + 'oe_bt_paragraphs[0][subform][field_oe_social_media_links][0][uri]' => 'https://www.facebook.com', + 'oe_bt_paragraphs[0][subform][field_oe_social_media_links][0][title]' => 'Example Facebook', + 'oe_bt_paragraphs[0][subform][field_oe_social_media_links][0][link_type]' => 'facebook', + 'oe_bt_paragraphs[0][subform][oe_bt_links_block_background]' => 'transparent', + 'oe_bt_paragraphs[0][subform][field_oe_social_media_variant]' => 'horizontal', + 'oe_bt_paragraphs[0][subform][field_oe_social_media_see_more][0][uri]' => 'https://example.com', + 'oe_bt_paragraphs[0][subform][field_oe_social_media_see_more][0][title]' => 'More channels', + ]; + + $this->submitForm($values, 'Save'); + $this->drupalGet('/node/1'); + + // Assert paragraph values are printed. + $this->assertSession()->pageTextContains('EU Social Media Follow Links'); + $this->assertSession()->pageTextContains('Example Facebook'); + $this->assertSession()->pageTextContains('More channels'); + } + + /** + * Test Accordion paragraphs form. + */ + public function testAccordionParagraph(): void { + $this->drupalGet('/node/add/paragraphs_test'); + $page = $this->getSession()->getPage(); + $page->pressButton('Add Accordion'); + + $this->assertSession()->fieldExists('oe_bt_paragraphs[0][subform][field_oe_paragraphs][0][subform][field_oe_text][0][value]'); + $this->assertSession()->fieldExists('oe_bt_paragraphs[0][subform][field_oe_paragraphs][0][subform][field_oe_text_long][0][value]'); + // Assert the Icon field is not shown. + $this->assertSession()->fieldNotExists('oe_bt_paragraphs[0][subform][field_oe_paragraphs][0][subform][field_oe_icon][0][value]'); + + $values = [ + 'title[0][value]' => 'Test Accordion', + 'oe_bt_paragraphs[0][subform][field_oe_paragraphs][0][subform][field_oe_text][0][value]' => 'Title item 1', + 'oe_bt_paragraphs[0][subform][field_oe_paragraphs][0][subform][field_oe_text_long][0][value]' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.', + ]; + + $this->submitForm($values, 'Save'); + $this->drupalGet('/node/1'); + + // Assert paragraph values are displayed correctly. + $this->assertSession()->pageTextContains('Title item 1'); + $this->assertSession()->pageTextContains('Lorem ipsum dolor sit amet, consectetur adipiscing elit.'); + } + + /** + * Test Facts and figures paragraphs form. + */ + public function testFactsFiguresParagraph(): void { + $this->drupalGet('/node/add/paragraphs_test'); + $page = $this->getSession()->getPage(); + $page->pressButton('Add Facts and figures'); + // Assert the Facts and figures fields are present. + $this->assertSession()->fieldExists('oe_bt_paragraphs[0][subform][field_oe_link][0][uri]'); + $this->assertSession()->fieldExists('oe_bt_paragraphs[0][subform][field_oe_link][0][title]'); + $this->assertSession()->fieldExists('oe_bt_paragraphs[0][subform][field_oe_title][0][value]'); + $this->assertSession()->fieldExists('oe_bt_paragraphs[0][subform][oe_bt_n_columns][0][value]'); + $this->assertSession()->fieldExists('oe_bt_paragraphs[0][subform][field_oe_paragraphs][0][subform][field_oe_title][0][value]'); + $this->assertSession()->fieldExists('oe_bt_paragraphs[0][subform][field_oe_paragraphs][0][subform][field_oe_subtitle][0][value]'); + $this->assertSession()->fieldExists('oe_bt_paragraphs[0][subform][field_oe_paragraphs][0][subform][field_oe_plain_text_long][0][value]'); + + $values = [ + 'title[0][value]' => 'Test Fact and figures node title', + 'oe_bt_paragraphs[0][subform][field_oe_title][0][value]' => 'Fact and figures block', + 'oe_bt_paragraphs[0][subform][field_oe_link][0][uri]' => 'https://www.google.com', + 'oe_bt_paragraphs[0][subform][field_oe_link][0][title]' => 'Read more', + 'oe_bt_paragraphs[0][subform][oe_bt_n_columns][0][value]' => 2, + 'oe_bt_paragraphs[0][subform][field_oe_paragraphs][0][subform][field_oe_title][0][value]' => "1529 JIRA Ticket", + 'oe_bt_paragraphs[0][subform][field_oe_paragraphs][0][subform][field_oe_subtitle][0][value]' => "Jira Tickets", + 'oe_bt_paragraphs[0][subform][field_oe_paragraphs][0][subform][field_oe_plain_text_long][0][value]' => "Nunc condimentum sapien ut nibh finibus suscipit vitae at justo. Morbi quis odio faucibus, commodo tortor id, elementum libero.", + ]; + + $this->submitForm($values, 'Save'); + $this->drupalGet('/node/1'); + + // Assert paragraph values are displayed correctly. + $this->assertSession()->pageTextContains('Fact and figures block'); + $this->assertSession()->pageTextContains('Read more'); + $this->assertSession()->pageTextContains('1529 JIRA Ticket'); + $this->assertSession()->pageTextContains('Jira Tickets'); + $this->assertSession()->pageTextContains('Nunc condimentum sapien ut nibh finibus suscipit vitae at justo. Morbi quis odio faucibus, commodo tortor id, elementum libero.'); + } + + /** + * Test icon options event subscriber. + */ + public function testIconOptionsEventsubscriber(): void { + $this->drupalGet('/node/add/paragraphs_test'); + $page = $this->getSession()->getPage(); + $page->pressButton('Add Fact'); + + $this->assertSession()->fieldExists('oe_bt_paragraphs[0][subform][field_oe_icon]'); + $allowed_values = [ + '_none', + 'arrow-down', + 'box-arrow-up', + 'arrow-up', + 'book', + 'camera', + 'check', + 'download', + 'currency-euro', + 'facebook', + 'file', + 'image', + 'info', + 'linkedin', + 'files', + 'rss', + 'search', + 'share', + 'twitter', + 'camera-video', + ]; + foreach ($allowed_values as $allowed_value) { + $this->assertSession()->elementsCount('css', 'option[value="' . $allowed_value . '"]', 1); + } + $this->assertSession()->elementsCount('css', 'select#edit-oe-bt-paragraphs-0-subform-field-oe-icon option', 20); + + } + + /** + * Test Description list paragraphs form. + */ + public function testDescriptionListParagraph(): void { + $this->drupalGet('/node/add/paragraphs_test'); + $this->getSession()->getPage()->pressButton('Add Description list'); + + $assert_session = $this->assertSession(); + $assert_session->fieldExists('oe_bt_paragraphs[0][subform][field_oe_title][0][value]'); + $this->assertEquals([ + 'horizontal' => 'Horizontal', + 'vertical' => 'Vertical', + ], $this->getOptions('oe_bt_paragraphs[0][subform][oe_bt_orientation]')); + $assert_session->fieldExists('oe_bt_paragraphs[0][subform][field_oe_description_list_items][0][term]'); + $assert_session->fieldExists('oe_bt_paragraphs[0][subform][field_oe_description_list_items][0][description][value]'); + + $values = [ + 'title[0][value]' => 'Test Description list node title', + 'oe_bt_paragraphs[0][subform][field_oe_title][0][value]' => 'Description list paragraph', + 'oe_bt_paragraphs[0][subform][oe_bt_orientation]' => 'horizontal', + 'oe_bt_paragraphs[0][subform][field_oe_description_list_items][0][term]' => 'Aliquam ultricies', + 'oe_bt_paragraphs[0][subform][field_oe_description_list_items][0][description][value]' => 'Donec et leo ac velit posuere tempor mattis ac mi. Vivamus nec dictum lectus. Aliquam ultricies placerat eros, vitae ornare sem.', + ]; + + $this->submitForm($values, 'Save'); + $this->drupalGet('/node/1'); + + // Assert paragraph values are displayed correctly. + $assert_session->pageTextContains('Description list paragraph'); + $assert_session->pageTextContains('Aliquam ultricies'); + $assert_session->pageTextContains('Donec et leo ac velit posuere tempor mattis ac mi. Vivamus nec dictum lectus. Aliquam ultricies placerat eros, vitae ornare sem.'); + } + + /** + * Test Links Block paragraphs form. + */ + public function testListingParagraph(): void { + $this->drupalGet('/node/add/paragraphs_test'); + $page = $this->getSession()->getPage(); + $page->pressButton('Add Listing item block'); + + // Assert the Listing fields appears. + $this->assertSession()->fieldExists('oe_bt_paragraphs[0][variant]'); + $this->assertSession()->fieldExists('oe_bt_paragraphs[0][subform][field_oe_title][0][value]'); + $this->assertSession()->fieldExists('oe_bt_paragraphs[0][subform][field_oe_list_item_block_layout]'); + $this->assertSession()->fieldExists('oe_bt_paragraphs[0][subform][field_oe_paragraphs][0][subform][field_oe_link][0][uri]'); + $this->assertSession()->fieldExists('oe_bt_paragraphs[0][subform][field_oe_paragraphs][0][subform][field_oe_title][0][value]'); + $this->assertSession()->fieldExists('oe_bt_paragraphs[0][subform][field_oe_paragraphs][0][subform][field_oe_text_long][0][value]'); + $this->assertSession()->fieldExists('oe_bt_paragraphs[0][subform][field_oe_paragraphs][0][subform][field_oe_meta][0][value]'); + $this->assertSession()->fieldExists('files[oe_bt_paragraphs_0_subform_field_oe_paragraphs_0_subform_field_oe_image_0]'); + + $this->submitForm([], 'Add another item'); + + $values = [ + 'title[0][value]' => 'Listing node title', + 'oe_bt_paragraphs[0][variant]' => 'default', + 'oe_bt_paragraphs[0][subform][field_oe_title][0][value]' => 'Listing example', + 'oe_bt_paragraphs[0][subform][field_oe_list_item_block_layout]' => 'two_columns', + 'oe_bt_paragraphs[0][subform][field_oe_paragraphs][0][subform][field_oe_link][0][uri]' => 'https://www.example.com', + 'oe_bt_paragraphs[0][subform][field_oe_paragraphs][0][subform][field_oe_title][0][value]' => 'Card title', + 'oe_bt_paragraphs[0][subform][field_oe_paragraphs][0][subform][field_oe_text_long][0][value]' => 'Lorem Ipsum dolor sit amet.', + 'oe_bt_paragraphs[0][subform][field_oe_paragraphs][0][subform][field_oe_meta][0][value]' => 'label1', + ]; + + $this->submitForm($values, 'Save'); + $this->drupalGet('/node/1'); + + // Assert paragraph values are displayed correctly. + $this->assertSession()->pageTextContains('Listing example'); + $this->assertSession()->pageTextContains('Card title'); + $this->assertSession()->pageTextContains('Lorem Ipsum dolor sit amet.'); + $this->assertSession()->pageTextContains('label1'); + } + + /** + * Creates a node type with a paragraphs field. + */ + protected function createTestContentType() { + $this->drupalCreateContentType([ + 'type' => 'paragraphs_test', + 'name' => 'Paragraphs Test', + ]); + + // Add a paragraphs field. + $field_storage = FieldStorageConfig::create([ + 'field_name' => 'oe_bt_paragraphs', + 'entity_type' => 'node', + 'type' => 'entity_reference_revisions', + 'cardinality' => '-1', + 'settings' => [ + 'target_type' => 'paragraph', + ], + ]); + $field_storage->save(); + FieldConfig::create([ + 'field_storage' => $field_storage, + 'bundle' => 'paragraphs_test', + 'settings' => [ + 'handler' => 'default:paragraph', + 'handler_settings' => ['target_bundles' => NULL], + ], + ])->save(); + + $form_display = \Drupal::service('entity_display.repository')->getFormDisplay('node', 'paragraphs_test'); + $form_display = $form_display->setComponent('oe_bt_paragraphs', ['type' => 'oe_paragraphs_variants']); + $form_display->save(); + + $view_display = \Drupal::service('entity_display.repository')->getViewDisplay('node', 'paragraphs_test'); + $view_display->setComponent('oe_bt_paragraphs', ['type' => 'entity_reference_revisions_entity_view']); + $view_display->save(); + } + +} diff --git a/modules/oe_whitelabel_paragraphs/tests/src/Kernel/AbstractKernelTestBase.php b/modules/oe_whitelabel_paragraphs/tests/src/Kernel/AbstractKernelTestBase.php new file mode 100644 index 00000000..437d1e64 --- /dev/null +++ b/modules/oe_whitelabel_paragraphs/tests/src/Kernel/AbstractKernelTestBase.php @@ -0,0 +1,104 @@ +<?php + +declare(strict_types = 1); + +namespace Drupal\Tests\oe_whitelabel_paragraphs\Kernel; + +use Drupal\Core\Plugin\ContextAwarePluginInterface; +use Drupal\KernelTests\KernelTestBase; +use Drupal\Tests\oe_whitelabel_paragraphs\Kernel\Traits\RenderTrait; +use Symfony\Component\Yaml\Yaml; + +/** + * Base class for theme's kernel tests. + */ +abstract class AbstractKernelTestBase extends KernelTestBase { + + use RenderTrait; + + /** + * {@inheritdoc} + */ + protected static $modules = [ + 'breakpoint', + 'image', + 'oe_bootstrap_theme_helper', + 'oe_whitelabel_helper', + 'responsive_image', + 'system', + 'ui_patterns', + 'ui_patterns_settings', + 'ui_patterns_library', + 'user', + 'node', + ]; + + /** + * {@inheritdoc} + */ + protected function setUp(): void { + parent::setUp(); + + $this->installEntitySchema('user'); + $this->installSchema('system', 'sequences'); + $this->installConfig(['user']); + $this->installConfig([ + 'system', + 'image', + 'responsive_image', + 'oe_bootstrap_theme_helper', + 'oe_whitelabel_helper', + ]); + + $this->container->get('theme_installer')->install(['oe_whitelabel']); + $this->config('system.theme')->set('default', 'oe_whitelabel')->save(); + $this->container->set('theme.registry', NULL); + + // Call the install hook of the User module which creates the Anonymous user + // and User 1. This is needed because the Anonymous user is loaded to + // provide the current User context which is needed in places like route + // enhancers. + // @see CurrentUserContext::getRuntimeContexts(). + // @see EntityConverter::convert(). + module_load_include('install', 'user'); + user_install(); + } + + /** + * Get fixture content. + * + * @param string $filepath + * File path. + * + * @return array + * A set of test data. + */ + protected function getFixtureContent(string $filepath): array { + return Yaml::parse(file_get_contents(__DIR__ . "/fixtures/{$filepath}")); + } + + /** + * Builds and returns the renderable array for a block. + * + * @param string $block_id + * The ID of the block. + * @param array $config + * An array of configuration. + * + * @return array + * A renderable array representing the content of the block. + */ + protected function buildBlock(string $block_id, array $config): array { + /** @var \Drupal\Core\Block\BlockBase $plugin */ + $plugin = $this->container->get('plugin.manager.block')->createInstance($block_id, $config); + + // Inject runtime contexts. + if ($plugin instanceof ContextAwarePluginInterface) { + $contexts = $this->container->get('context.repository')->getRuntimeContexts($plugin->getContextMapping()); + $this->container->get('context.handler')->applyContextMapping($plugin, $contexts); + } + + return $plugin->build(); + } + +} diff --git a/modules/oe_whitelabel_paragraphs/tests/src/Kernel/Paragraphs/ContentRowTest.php b/modules/oe_whitelabel_paragraphs/tests/src/Kernel/Paragraphs/ContentRowTest.php new file mode 100644 index 00000000..e58f4bf2 --- /dev/null +++ b/modules/oe_whitelabel_paragraphs/tests/src/Kernel/Paragraphs/ContentRowTest.php @@ -0,0 +1,184 @@ +<?php + +declare(strict_types = 1); + +namespace Drupal\Tests\oe_whitelabel_paragraphs\Kernel\Paragraphs; + +use Drupal\paragraphs\Entity\Paragraph; +use Symfony\Component\DomCrawler\Crawler; + +/** + * Tests the "Content row" paragraph, "Inpage navigation" variant. + */ +class ContentRowTest extends ParagraphsTestBase { + + /** + * Tests the rendering of the paragraph type. + */ + public function testWithInpageNavigationRendering(): void { + $paragraph_fact = [ + Paragraph::create([ + 'type' => 'oe_fact', + 'field_oe_icon' => 'box-arrow-up', + 'field_oe_title' => '1529 JIRA Ticket', + 'field_oe_subtitle' => 'Jira Tickets', + 'field_oe_plain_text_long' => 'Nunc condimentum sapien ut nibh finibus suscipit vitae at justo. Morbi quis odio faucibus, commodo tortor id, elementum libero.', + ]), + Paragraph::create([ + 'type' => 'oe_fact', + 'field_oe_icon' => 'box-arrow-up', + 'field_oe_title' => '337 Features', + 'field_oe_subtitle' => 'Feature tickets', + 'field_oe_plain_text_long' => 'Turpis varius congue venenatis, erat dui feugiat felis.', + ]), + Paragraph::create([ + 'type' => 'oe_fact', + 'field_oe_icon' => 'box-arrow-up', + 'field_oe_title' => '107 Tests', + 'field_oe_subtitle' => 'Test tickets', + 'field_oe_plain_text_long' => 'Cras vestibulum efficitur mi, quis porta tellus rutrum ut. Quisque at pulvinar sem.', + ]), + ]; + + $paragraph_accordion = [ + Paragraph::create([ + 'type' => 'oe_accordion_item', + 'field_oe_icon' => 'box-arrow-up', + 'field_oe_text' => 'Accordion item 1', + 'field_oe_text_long' => 'Aenean at viverra tellus. Donec egestas ut ligula a condimentum. Cras sapien nulla, ornare eget lobortis vulputate, bibendum nec tellus. Fusce tristique diam quis mauris vehicula eleifend. Maecenas vitae luctus mi. Sed accumsan fermentum fermentum. Ut tristique quam at aliquam viverra. Suspendisse pulvinar risus tristique augue elementum, nec blandit sem mattis', + ]), + Paragraph::create([ + 'type' => 'oe_accordion_item', + 'field_oe_icon' => 'box-arrow-up', + 'field_oe_text' => 'Accordion item 2', + 'field_oe_text_long' => 'Morbi pretium efficitur dolor, a vulputate sem vulputate quis. Sed dictum massa eu nulla finibus, et porta dolor efficitur. Mauris pharetra dui sed consequat faucibus. Pellentesque felis nisi, fringilla non tortor ac, laoreet feugiat ante. Curabitur vel gravida augue. Nullam erat dui, viverra a arcu non, tincidunt pulvinar tortor. Maecenas non libero consequat massa ornare posuere. Quisque ultrices ullamcorper leo, non vulputate felis vestibulum a. Nam eu tellus enim.', + ]), + Paragraph::create([ + 'type' => 'oe_accordion_item', + 'field_oe_icon' => 'box-arrow-up', + 'field_oe_text' => 'Accordion item 3', + 'field_oe_text_long' => 'Mauris accumsan vulputate imperdiet. Aenean nec metus sem. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum maximus placerat orci, a placerat dolor iaculis vel. Nam pulvinar elementum odio ut tempor. In fermentum neque ut placerat rutrum.', + ]), + ]; + + $sub_paragraphs = [ + Paragraph::create([ + 'type' => 'oe_rich_text', + 'field_oe_title' => 'Title rich text test 1', + 'field_oe_text_long' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque ornare et elit a dictum. Maecenas lacinia eros quis eros iaculis, sit amet bibendum massa facilisis. Integer arcu nisl, fringilla nec quam vel, tincidunt maximus ex. Suspendisse ac arcu efficitur, feugiat tellus vel, viverra sapien. Etiam vitae condimentum lorem. Nulla congue ligula lacinia efficitur tempus. Duis vitae auctor enim. Nulla iaculis, diam et sagittis scelerisque, est mauris luctus sem, a imperdiet lacus diam eu dui. Morbi accumsan, augue eu gravida elementum, libero mi blandit odio, eu fringilla nunc ipsum non tellus. Suspendisse dapibus elit at lobortis pretium. Quisque vestibulum ut purus sit amet molestie. Sed eget volutpat justo, vel varius augue. Vestibulum vel risus facilisis, feugiat sem aliquam, lobortis ante.', + ]), + Paragraph::create([ + 'type' => 'oe_links_block', + 'field_oe_text' => 'Links block test', + 'oe_bt_links_block_orientation' => 'vertical', + 'oe_bt_links_block_background' => 'gray', + 'field_oe_links' => [ + [ + 'title' => 'Example 2', + 'uri' => 'https://example2.com', + ], + [ + 'title' => 'Example 3', + 'uri' => 'https://example3.com', + ], + [ + 'title' => 'Example 4', + 'uri' => 'https://example4.com', + ], + ], + ]), + Paragraph::create([ + 'type' => 'oe_facts_figures', + 'field_oe_title' => 'Facts and Figures test', + 'field_oe_link' => [ + 'uri' => 'https://www.readmore.com', + 'title' => 'Read more', + ], + 'field_oe_paragraphs' => $paragraph_fact, + 'field_oe_list_item_block_layout' => 3, + ]), + Paragraph::create([ + 'type' => 'oe_quote', + 'field_oe_text' => 'Quote 1', + 'field_oe_plain_text_long' => 'Maecenas id urna eleifend, elementum sapien vitae, semper massa. Curabitur mi leo, sagittis eget euismod egestas, ornare nec justo.', + ]), + Paragraph::create([ + 'type' => 'oe_social_media_follow', + 'field_oe_title' => 'Social media block', + 'field_oe_social_media_variant' => 'horizontal', + 'oe_bt_links_block_background' => 'gray', + 'field_oe_social_media_links' => [ + [ + 'title' => 'Email', + 'uri' => 'mailto:example@com', + 'link_type' => 'email', + ], + [ + 'title' => 'Facebook', + 'uri' => 'https://facebook.com', + 'link_type' => 'facebook', + ], + ], + 'field_oe_social_media_see_more' => [ + 'title' => 'Other social networks', + 'uri' => 'https://europa.eu/european-union/contact/social-networks_en', + ], + ]), + Paragraph::create([ + 'type' => 'oe_accordion', + 'field_oe_paragraphs' => $paragraph_accordion, + ]), + ]; + + $paragraph = Paragraph::create([ + 'type' => 'oe_content_row', + 'field_oe_title' => 'Page content', + 'field_oe_paragraphs' => $sub_paragraphs, + 'oe_paragraphs_variant' => 'inpage_navigation', + ]); + $paragraph->save(); + + $html = $this->renderParagraph($paragraph); + $crawler = new Crawler($html); + + $this->assertCount(1, $crawler->filter('div.row > div > nav.bcl-inpage-navigation')); + $this->assertCount(8, $crawler->filter('p')); + // Assert the left column navigation. + $left = $crawler->filter('div.col-md-3.d-none.d-md-block'); + $nav = $left->filter('nav.bcl-inpage-navigation'); + $this->assertCount(1, $nav); + $h5 = $nav->filter('h5'); + $this->assertSame('Page content', $h5->text()); + $ul = $left->filter('ul.nav.nav-pills.flex-column'); + $this->assertCount(1, $ul); + $links = $ul->filter('li.nav-item a.nav-link'); + $this->assertCount(3, $links); + $this->assertSame('Title rich text test 1', $links->eq(0)->text()); + $this->assertSame('Facts and Figures test', $links->eq(1)->text()); + $this->assertSame('Social media block', $links->eq(2)->text()); + // Assert the paragraphs where added into the right side column. + $content = $crawler->filter('div.col-md-9'); + $this->assertCount(1, $content); + $rich_text_title = $content->filter('h4.fw-bold.mb-4'); + $this->assertSame('Title rich text test 1', trim($rich_text_title->text())); + $links_block_title = $content->filter('h2.fw-bold.pb-3.mb-3.border-bottom'); + $this->assertSame('Links block test', $links_block_title->text()); + $facts_figures = $content->filter('div.bcl-fact-figures--default'); + $this->assertStringContainsString('Facts and Figures test', $facts_figures->filter('h2.fw-bold')->text()); + $blockquote_blockquote = $content->filter('blockquote.blockquote'); + $this->assertStringContainsString('Maecenas id urna eleifend', $blockquote_blockquote->text()); + $blockquote_footer = $content->filter('figcaption.blockquote-footer'); + $this->assertSame('Quote 1', trim($blockquote_footer->text())); + $social_media_title = $content->filter('h2.fw-bold.pb-3.mb-3.border-bottom')->eq(1); + $this->assertStringContainsString('Social media block', $social_media_title->text()); + $accordion_items = $content->filter('.accordion-item'); + $this->assertStringContainsString('Accordion item 1', $accordion_items->eq(0)->text()); + $this->assertStringContainsString('Accordion item 2', $accordion_items->eq(1)->text()); + $this->assertStringContainsString('Accordion item 3', $accordion_items->eq(2)->text()); + // Check that the wrappers where added to the correct paragraphs. + $this->assertSame('bcl-inpage-item-1', $rich_text_title->parents()->eq(0)->attr('id')); + $this->assertSame('bcl-inpage-item-6', $facts_figures->parents()->eq(0)->attr('id')); + $this->assertSame('bcl-inpage-item-8', $social_media_title->parents()->eq(1)->attr('id')); + } + +} diff --git a/modules/oe_whitelabel_paragraphs/tests/src/Kernel/Paragraphs/DescriptionListTest.php b/modules/oe_whitelabel_paragraphs/tests/src/Kernel/Paragraphs/DescriptionListTest.php new file mode 100644 index 00000000..2e7132df --- /dev/null +++ b/modules/oe_whitelabel_paragraphs/tests/src/Kernel/Paragraphs/DescriptionListTest.php @@ -0,0 +1,92 @@ +<?php + +declare(strict_types = 1); + +namespace Drupal\Tests\oe_whitelabel_paragraphs\Kernel\Paragraphs; + +use Drupal\paragraphs\Entity\Paragraph; +use Symfony\Component\DomCrawler\Crawler; + +/** + * Tests the "Description list" paragraphs. + */ +class DescriptionListTest extends ParagraphsTestBase { + + /** + * Tests the rendering of the paragraph type. + */ + public function testRendering(): void { + // Create Description list paragraph with horizontal variant. + $paragraph = Paragraph::create([ + 'type' => 'oe_description_list', + 'field_oe_title' => 'Description list paragraph', + 'oe_bt_orientation' => 'horizontal', + 'field_oe_description_list_items' => [ + 0 => [ + 'term' => 'Aliquam ultricies', + 'description' => 'Donec et leo ac velit posuere tempor mattis ac mi. Vivamus nec dictum lectus. Aliquam ultricies placerat eros, vitae ornare sem.', + ], + 1 => [ + 'term' => 'Etiam lacinia', + 'description' => 'Quisque tempor sollicitudin lacinia. Morbi imperdiet nulla et nunc aliquet, vel lobortis nunc cursus. Mauris vitae hendrerit felis.', + ], + ], + ]); + $paragraph->save(); + + // Testing: Description list paragraph with horizontal variant. + $html = $this->renderParagraph($paragraph); + $crawler = new Crawler($html); + + $this->assertCount(1, $crawler->filter('h4')); + $this->assertCount(1, $crawler->filter('dl.d-md-grid.grid-3-9')); + $this->assertCount(2, $crawler->filter('dd')); + $this->assertCount(2, $crawler->filter('dt')); + + $title = $crawler->filter('h4.fw-bold.mb-4'); + $this->assertEquals('Description list paragraph', $title->text()); + + $term_1 = $crawler->filter('dl > div:nth-child(1) > dt'); + $this->assertEquals('Aliquam ultricies', $term_1->text()); + $description_1 = $crawler->filter('dl > div:nth-child(1) + dd'); + $this->assertEquals( + 'Donec et leo ac velit posuere tempor mattis ac mi. Vivamus nec dictum lectus. Aliquam ultricies placerat eros, vitae ornare sem.', + $description_1->text() + ); + + $term_2 = $crawler->filter('dl > div:nth-child(3) > dt'); + $this->assertEquals('Etiam lacinia', $term_2->text()); + $description_2 = $crawler->filter('dl > div:nth-child(3) + dd'); + $this->assertEquals( + 'Quisque tempor sollicitudin lacinia. Morbi imperdiet nulla et nunc aliquet, vel lobortis nunc cursus. Mauris vitae hendrerit felis.', + $description_2->text() + ); + + // Testing: Description list paragraph with vertical variant. + $paragraph->get('oe_bt_orientation')->setValue('vertical'); + $paragraph->save(); + + $html = $this->renderParagraph($paragraph); + $crawler = new Crawler($html); + + $title = $crawler->filter('h4.fw-bold.mb-4'); + $this->assertEquals('Description list paragraph', $title->text()); + + $term_1 = $crawler->filter('dl > dt:nth-child(1)'); + $this->assertEquals('Aliquam ultricies', $term_1->text()); + $description_1 = $crawler->filter('dl > dt:nth-child(1) + dd'); + $this->assertEquals( + 'Donec et leo ac velit posuere tempor mattis ac mi. Vivamus nec dictum lectus. Aliquam ultricies placerat eros, vitae ornare sem.', + $description_1->text() + ); + + $term_2 = $crawler->filter('dl > dt:nth-child(3)'); + $this->assertEquals('Etiam lacinia', $term_2->text()); + $description_2 = $crawler->filter('dl > dt:nth-child(3) + dd'); + $this->assertEquals( + 'Quisque tempor sollicitudin lacinia. Morbi imperdiet nulla et nunc aliquet, vel lobortis nunc cursus. Mauris vitae hendrerit felis.', + $description_2->text() + ); + } + +} diff --git a/modules/oe_whitelabel_paragraphs/tests/src/Kernel/Paragraphs/EntityReferenceRevisionTest.php b/modules/oe_whitelabel_paragraphs/tests/src/Kernel/Paragraphs/EntityReferenceRevisionTest.php new file mode 100644 index 00000000..5bc9cb59 --- /dev/null +++ b/modules/oe_whitelabel_paragraphs/tests/src/Kernel/Paragraphs/EntityReferenceRevisionTest.php @@ -0,0 +1,107 @@ +<?php + +declare(strict_types = 1); + +namespace Drupal\Tests\oe_whitelabel_paragraphs\Kernel\Paragraphs; + +use Drupal\field\Entity\FieldConfig; +use Drupal\field\Entity\FieldStorageConfig; +use Drupal\node\Entity\Node; +use Drupal\paragraphs\Entity\Paragraph; +use Drupal\Tests\node\Traits\ContentTypeCreationTrait; +use Drupal\Tests\user\Traits\UserCreationTrait; +use Symfony\Component\DomCrawler\Crawler; + +/** + * Tests the rendering of the entity reference fields for paragraphs. + */ +class EntityReferenceRevisionTest extends ParagraphsTestBase { + + use ContentTypeCreationTrait; + use UserCreationTrait; + + /** + * {@inheritdoc} + */ + protected function setUp(): void { + parent::setUp(); + + $this->installEntitySchema('node'); + $this->installEntitySchema('user'); + + $this->createContentType([ + 'type' => 'paragraphs_test', + 'name' => 'Paragraphs Test', + ]); + $field_storage = FieldStorageConfig::create([ + 'field_name' => 'test_paragraphs', + 'entity_type' => 'node', + 'type' => 'entity_reference_revisions', + 'cardinality' => '-1', + 'settings' => [ + 'target_type' => 'paragraph', + ], + ]); + $field_storage->save(); + FieldConfig::create([ + 'field_storage' => $field_storage, + 'bundle' => 'paragraphs_test', + 'settings' => [ + 'handler' => 'default:paragraph', + 'handler_settings' => ['target_bundles' => NULL], + ], + ])->save(); + + $this->container->get('theme_installer')->install(['oe_whitelabel']); + $this->config('system.theme')->set('default', 'oe_whitelabel')->save(); + + $this->setCurrentUser($this->createUser([], '', TRUE)); + } + + /** + * Test the rendering of an entity reference revision field. + */ + public function testEntityReferenceRevisionField(): void { + $paragraph1 = Paragraph::create([ + 'type' => 'oe_links_block', + 'field_oe_text' => 'More information', + 'oe_bt_links_block_orientation' => 'vertical', + 'oe_bt_links_block_background' => 'gray', + 'field_oe_links' => [ + [ + 'title' => 'European Commission', + 'uri' => 'https://example.com', + ], + ], + ]); + $paragraph1->save(); + + $paragraph2 = Paragraph::create([ + 'type' => 'oe_rich_text', + 'field_oe_title' => 'Rich text example', + ]); + $paragraph2->save(); + + /** @var \Drupal\node\Entity\Node $node */ + $node = Node::create([ + 'type' => 'paragraphs_test', + 'title' => 'Test node', + 'test_paragraphs' => [$paragraph1, $paragraph2], + 'uid' => 0, + 'status' => 1, + ]); + $node->save(); + + $build = $node->get('test_paragraphs')->view(); + $html = $this->render($build); + $crawler = new Crawler($html); + + $wrappers = $crawler->filter('div.my-4'); + $this->assertCount(2, $wrappers); + $rich_text = $wrappers->eq(1); + // Assert the paragraphs where rendered. + $this->assertStringContainsString('European Commission', $wrappers->eq(0)->text()); + $this->assertStringContainsString('Rich text example', $rich_text->text()); + } + +} diff --git a/modules/oe_whitelabel_paragraphs/tests/src/Kernel/Paragraphs/FactsFiguresTest.php b/modules/oe_whitelabel_paragraphs/tests/src/Kernel/Paragraphs/FactsFiguresTest.php new file mode 100644 index 00000000..b5a9267f --- /dev/null +++ b/modules/oe_whitelabel_paragraphs/tests/src/Kernel/Paragraphs/FactsFiguresTest.php @@ -0,0 +1,211 @@ +<?php + +declare(strict_types = 1); + +namespace Drupal\Tests\oe_whitelabel_paragraphs\Kernel\Paragraphs; + +use Symfony\Component\DomCrawler\Crawler; +use Drupal\paragraphs\Entity\Paragraph; + +/** + * Tests the "Facts and Figures" paragraphs. + */ +class FactsFiguresTest extends ParagraphsTestBase { + + /** + * Tests the rendering of the paragraph type. + */ + public function testRendering(): void { + // Create Fact paragraphs. + $paragraph_fact = + [ + 0 => Paragraph::create([ + 'type' => 'oe_fact', + 'field_oe_icon' => 'box-arrow-up', + 'field_oe_title' => '1529 JIRA Ticket', + 'field_oe_subtitle' => 'Jira Tickets', + 'field_oe_plain_text_long' => 'Nunc condimentum sapien ut nibh finibus suscipit vitae at justo. Morbi quis odio faucibus, commodo tortor id, elementum libero.', + ]), + 1 => Paragraph::create([ + 'type' => 'oe_fact', + 'field_oe_icon' => 'box-arrow-up', + 'field_oe_title' => '337 Features', + 'field_oe_subtitle' => 'Feature tickets', + 'field_oe_plain_text_long' => 'Turpis varius congue venenatis, erat dui feugiat felis.', + ]), + 2 => Paragraph::create([ + 'type' => 'oe_fact', + 'field_oe_icon' => 'box-arrow-up', + 'field_oe_title' => '107 Tests', + 'field_oe_subtitle' => 'Test tickets', + 'field_oe_plain_text_long' => 'Cras vestibulum efficitur mi, quis porta tellus rutrum ut. Quisque at pulvinar sem.', + ]), + 3 => Paragraph::create([ + 'type' => 'oe_fact', + 'field_oe_icon' => 'box-arrow-up', + 'field_oe_title' => '5670 Variants', + 'field_oe_subtitle' => 'Test variants', + 'field_oe_plain_text_long' => 'Aliquam lacinia diam eu sem malesuada, in interdum ante bibendum.', + ]), + 4 => Paragraph::create([ + 'type' => 'oe_fact', + 'field_oe_icon' => 'box-arrow-up', + 'field_oe_title' => '345 Dev Ticket', + 'field_oe_subtitle' => 'Jira ticket', + 'field_oe_plain_text_long' => 'Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Duis nec lectus tortor.', + ]), + 5 => Paragraph::create([ + 'type' => 'oe_fact', + 'field_oe_icon' => 'box-arrow-up', + 'field_oe_title' => '43 Components', + 'field_oe_subtitle' => 'Figma components', + 'field_oe_plain_text_long' => 'Sed efficitur bibendum rutrum. Nunc feugiat congue augue ac consectetur.', + ]), + ]; + // Create Facts and figures paragraph. + $paragraph = Paragraph::create([ + 'type' => 'oe_facts_figures', + 'field_oe_title' => 'Fact and figures block', + 'field_oe_link' => [ + 'uri' => 'https://www.readmore.com', + 'title' => 'Read more', + ], + 'oe_bt_n_columns' => 3, + 'field_oe_paragraphs' => $paragraph_fact, + ]); + $paragraph->save(); + + // Testing: Facts and figures - Default layout. + $html = $this->renderParagraph($paragraph); + $crawler = new Crawler($html); + + $this->assertCount(1, $crawler->filter('div.bcl-fact-figures.bcl-fact-figures--default')); + $this->assertCount(1, $crawler->filter('h2.fw-bold')); + $this->assertCount(1, $crawler->filter('div.row-cols-md-3.row')); + $this->assertCount(6, $crawler->filter('svg.bi.icon--l')); + $this->assertCount(6, $crawler->filter('h4.fw-bold')); + $this->assertCount(6, $crawler->filter('h5.fw-bold')); + $this->assertCount(6, $crawler->filter('div.col')); + + $link = $crawler->filter('a[href="https://www.readmore.com"]'); + $this->assertStringContainsString( + 'Read more', + $link->html() + ); + + $title_fact = $crawler->filter('div.row-cols-md-3.row > div.col:nth-child(1) > h4.text-capitalize.fw-bold'); + $this->assertStringContainsString( + '1529 JIRA Ticket', + $title_fact->html() + ); + $subtitle_fact = $crawler->filter('div.row-cols-md-3.row > div.col:nth-child(1) > h5.fw-bold'); + $this->assertStringContainsString( + 'Jira Tickets', + $subtitle_fact->html() + ); + $description_fact = $crawler->filter('div.row-cols-md-3.row > div.col:nth-child(1) > p'); + $this->assertStringContainsString( + 'Nunc condimentum sapien ut nibh finibus suscipit vitae at justo. Morbi quis odio faucibus, commodo tortor id, elementum libero.', + $description_fact->html() + ); + + $title_fact = $crawler->filter('div.row-cols-md-3.row > div.col:nth-child(2) > h4.text-capitalize.fw-bold'); + $this->assertStringContainsString( + '337 Features', + $title_fact->html() + ); + $subtitle_fact = $crawler->filter('div.row-cols-md-3.row > div.col:nth-child(2) > h5.fw-bold'); + $this->assertStringContainsString( + 'Feature tickets', + $subtitle_fact->html() + ); + $description_fact = $crawler->filter('div.row-cols-md-3.row > div.col:nth-child(2) > p'); + $this->assertStringContainsString( + 'Turpis varius congue venenatis, erat dui feugiat felis.', + $description_fact->html() + ); + + $title_fact = $crawler->filter('div.row-cols-md-3.row > div.col:nth-child(3) > h4.text-capitalize.fw-bold'); + $this->assertStringContainsString( + '107 Tests', + $title_fact->html() + ); + $subtitle_fact = $crawler->filter('div.row-cols-md-3.row > div.col:nth-child(3) > h5.fw-bold'); + $this->assertStringContainsString( + 'Test tickets', + $subtitle_fact->html() + ); + $description_fact = $crawler->filter('div.row-cols-md-3.row > div.col:nth-child(3) > p'); + $this->assertStringContainsString( + 'Cras vestibulum efficitur mi, quis porta tellus rutrum ut. Quisque at pulvinar sem.', + $description_fact->html() + ); + + $title_fact = $crawler->filter('div.row-cols-md-3.row > div.col:nth-child(4) > h4.text-capitalize.fw-bold'); + $this->assertStringContainsString( + '5670 Variants', + $title_fact->html() + ); + $subtitle_fact = $crawler->filter('div.row-cols-md-3.row > div.col:nth-child(4) > h5.fw-bold'); + $this->assertStringContainsString( + 'Test variants', + $subtitle_fact->html() + ); + $description_fact = $crawler->filter('div.row-cols-md-3.row > div.col:nth-child(4) > p'); + $this->assertStringContainsString( + 'Aliquam lacinia diam eu sem malesuada, in interdum ante bibendum.', + $description_fact->html() + ); + + $title_fact = $crawler->filter('div.row-cols-md-3.row > div.col:nth-child(5) > h4.text-capitalize.fw-bold'); + $this->assertStringContainsString( + '345 Dev Ticket', + $title_fact->html() + ); + $subtitle_fact = $crawler->filter('div.row-cols-md-3.row > div.col:nth-child(5) > h5.fw-bold'); + $this->assertStringContainsString( + 'Jira ticket', + $subtitle_fact->html() + ); + $description_fact = $crawler->filter('div.row-cols-md-3.row > div.col:nth-child(5) > p'); + $this->assertStringContainsString( + 'Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Duis nec lectus tortor.', + $description_fact->html() + ); + + $title_fact = $crawler->filter('div.row-cols-md-3.row > div.col:nth-child(6) > h4.text-capitalize.fw-bold'); + $this->assertStringContainsString( + '43 Components', + $title_fact->html() + ); + $subtitle_fact = $crawler->filter('div.row-cols-md-3.row > div.col:nth-child(6) > h5.fw-bold'); + $this->assertStringContainsString( + 'Figma components', + $subtitle_fact->html() + ); + $description_fact = $crawler->filter('div.row-cols-md-3.row > div.col:nth-child(6) > p'); + $this->assertStringContainsString( + 'Sed efficitur bibendum rutrum. Nunc feugiat congue augue ac consectetur.', + $description_fact->html() + ); + + // Testing: 2 columns. + $paragraph->get('oe_bt_n_columns')->setValue('2'); + $paragraph->save(); + + $html = $this->renderParagraph($paragraph); + $crawler = new Crawler($html); + + $this->assertCount(1, $crawler->filter('div.row-cols-md-2.row')); + + // Testing: 1 columns. + $paragraph->get('oe_bt_n_columns')->setValue('1'); + $paragraph->save(); + + $html = $this->renderParagraph($paragraph); + $crawler = new Crawler($html); + + $this->assertCount(1, $crawler->filter('div.row-cols-md-1.row')); + } + +} diff --git a/modules/oe_whitelabel_paragraphs/tests/src/Kernel/Paragraphs/LinksBlockTest.php b/modules/oe_whitelabel_paragraphs/tests/src/Kernel/Paragraphs/LinksBlockTest.php new file mode 100644 index 00000000..67b8c411 --- /dev/null +++ b/modules/oe_whitelabel_paragraphs/tests/src/Kernel/Paragraphs/LinksBlockTest.php @@ -0,0 +1,73 @@ +<?php + +declare(strict_types = 1); + +namespace Drupal\Tests\oe_whitelabel_paragraphs\Kernel\Paragraphs; + +use Drupal\paragraphs\Entity\Paragraph; +use Drupal\Tests\oe_whitelabel_paragraphs\Kernel\PatternAssertions\LinksBlockAssertion; +use Symfony\Component\DomCrawler\Crawler; + +/** + * Tests the "Social media follow" paragraphs. + */ +class LinksBlockTest extends LinksBlockAssertion { + + /** + * Tests the rendering of the paragraph type. + */ + public function testRendering(): void { + // Create Links Block paragraph. + $paragraph = Paragraph::create([ + 'type' => 'oe_links_block', + 'field_oe_text' => 'More information', + 'oe_bt_links_block_orientation' => 'vertical', + 'oe_bt_links_block_background' => 'gray', + 'field_oe_links' => $this->getBlockLinks(), + ]); + $paragraph->save(); + + // Testing: LinksBlock vertical gray. + $html = $this->renderParagraph($paragraph); + $crawler = new Crawler($html); + + $this->assertBackgroundGray($crawler); + $this->assertLinksBlockRendering($crawler); + $this->assertVerticalLinks($crawler); + + // Testing: LinksBlock horizontal gray. + $paragraph->get('oe_bt_links_block_orientation')->setValue('horizontal'); + $paragraph->save(); + + $html = $this->renderParagraph($paragraph); + $crawler = new Crawler($html); + + $this->assertBackgroundGray($crawler); + $this->assertLinksBlockRendering($crawler); + $this->assertHorizontalLinks($crawler, FALSE); + + // Testing: LinksBlock vertical transparent. + $paragraph->get('oe_bt_links_block_orientation')->setValue('vertical'); + $paragraph->get('oe_bt_links_block_background')->setValue('transparent'); + $paragraph->save(); + + $html = $this->renderParagraph($paragraph); + $crawler = new Crawler($html); + + $this->assertBackgroundTransparent($crawler); + $this->assertLinksBlockRendering($crawler); + $this->assertVerticalLinks($crawler); + + // Testing: LinksBlock horizontal transparent. + $paragraph->get('oe_bt_links_block_orientation')->setValue('horizontal'); + $paragraph->save(); + + $html = $this->renderParagraph($paragraph); + $crawler = new Crawler($html); + + $this->assertBackgroundTransparent($crawler); + $this->assertLinksBlockRendering($crawler); + $this->assertHorizontalLinks($crawler, FALSE); + } + +} diff --git a/modules/oe_whitelabel_paragraphs/tests/src/Kernel/Paragraphs/ListingParagraphsTest.php b/modules/oe_whitelabel_paragraphs/tests/src/Kernel/Paragraphs/ListingParagraphsTest.php new file mode 100644 index 00000000..2fe6ab37 --- /dev/null +++ b/modules/oe_whitelabel_paragraphs/tests/src/Kernel/Paragraphs/ListingParagraphsTest.php @@ -0,0 +1,194 @@ +<?php + +declare(strict_types = 1); + +namespace Drupal\Tests\oe_whitelabel_paragraphs\Kernel\Paragraphs; + +use Drupal\node\Entity\Node; +use Drupal\paragraphs\Entity\Paragraph; +use Drupal\Tests\oe_whitelabel_paragraphs\Kernel\PatternAssertions\ListingAssertion; +use Drupal\Tests\TestFileCreationTrait; +use Symfony\Component\DomCrawler\Crawler; +use Drupal\Tests\node\Traits\NodeCreationTrait; +use Drupal\Tests\node\Traits\ContentTypeCreationTrait; +use Drupal\file\Entity\File; + +/** + * Tests the rendering of paragraph Listing. + */ +class ListingParagraphsTest extends ParagraphsTestBase { + + use NodeCreationTrait; + use ContentTypeCreationTrait; + use TestFileCreationTrait; + + /** + * {@inheritdoc} + */ + protected function setUp(): void { + parent::setUp(); + + $this->installEntitySchema('node'); + $this->installSchema('node', ['node_access']); + } + + /** + * Test List Items Block paragraph rendering. + */ + public function testListing(): void { + + // Create a sample media entity to be embedded. + $image_file = File::create([ + 'uri' => $this->getTestFiles('image')[0]->uri, + ]); + $image_file->setPermanent(); + $image_file->save(); + + $this->createContentType([ + 'type' => 'article', + 'name' => 'Article', + ]); + + $node = $this->createNode([ + 'created' => 1636977600, + 'type' => 'article', + ]); + $nid = (int) $node->id(); + + $paragraph_storage = $this->container->get('entity_type.manager')->getStorage('paragraph'); + $paragraph = $paragraph_storage->create([ + 'type' => 'oe_list_item_block', + 'oe_paragraphs_variant' => 'default', + 'field_oe_list_item_block_layout' => 'one_column', + 'field_oe_title' => 'Listing item block title', + 'field_oe_paragraphs' => $this->createListItems($image_file, $node), + ]); + $paragraph->save(); + + // Testing Default 1 col. + $html = $this->renderParagraph($paragraph); + $crawler = new Crawler($html); + + $assert = new ListingAssertion(); + + $assert->assertListingRendering($crawler, $nid); + $assert->assertDefaultListingRendering($crawler, $image_file); + $this->assertCount(1, $crawler->filter('div.bcl-listing--default-1-col')); + $this->assertCount(1, $crawler->filter('div.row.row-cols-1')); + $this->assertCount(6, $crawler->filter('div.col-md-3.col-lg-2.rounded')); + $this->assertCount(6, $crawler->filter('div.col-md-9.col-lg-10')); + + // Testing Default 2 col. + $paragraph->get('field_oe_list_item_block_layout')->setValue('two_columns'); + $paragraph->save(); + + $html = $this->renderParagraph($paragraph); + $crawler = new Crawler($html); + + $assert->assertListingRendering($crawler, $nid); + $assert->assertDefaultListingRendering($crawler, $image_file); + $this->assertCount(1, $crawler->filter('div.bcl-listing--default-2-col')); + $this->assertCount(1, $crawler->filter('div.row.row-cols-1.row-cols-md-2')); + $this->assertCount(6, $crawler->filter('div.col-xl-3.col-md-5')); + $this->assertCount(6, $crawler->filter('div.col-xl-9.col-md-7')); + + // Testing Default 3 col. + $paragraph->get('field_oe_list_item_block_layout')->setValue('three_columns'); + $paragraph->save(); + + $html = $this->renderParagraph($paragraph); + $crawler = new Crawler($html); + + $assert->assertListingRendering($crawler, $nid); + $assert->assertDefaultListingRendering($crawler, $image_file); + $this->assertCount(1, $crawler->filter('div.bcl-listing--default-3-col')); + $this->assertCount(1, $crawler->filter('div.row.row-cols-1.row-cols-md-2.row-cols-xl-3')); + $this->assertCount(6, $crawler->filter('div.col-lg-4.col-md-6')); + $this->assertCount(6, $crawler->filter('div.col-lg-8.col-md-6')); + + // Testing Highlight 1 col. + $paragraph->get('oe_paragraphs_variant')->setValue('highlight'); + $paragraph->get('field_oe_list_item_block_layout')->setValue('one_column'); + $paragraph->save(); + + $html = $this->renderParagraph($paragraph); + $crawler = new Crawler($html); + + $assert->assertListingRendering($crawler, $nid); + $assert->assertHighlightListingRendering($crawler, $image_file); + $this->assertCount(1, $crawler->filter('div.bcl-listing--highlight-1-col')); + $this->assertCount(1, $crawler->filter('div.row.row-cols-1')); + $this->assertCount(6, $crawler->filter('div.col.mt-4-5')); + $this->assertCount(6, $crawler->filter('div.card-body')); + + // Testing Highlight 2 col. + $paragraph->get('field_oe_list_item_block_layout')->setValue('two_columns'); + $paragraph->save(); + + $html = $this->renderParagraph($paragraph); + $crawler = new Crawler($html); + + $assert->assertListingRendering($crawler, $nid); + $assert->assertHighlightListingRendering($crawler, $image_file); + $this->assertCount(1, $crawler->filter('div.bcl-listing--highlight-2-col')); + $this->assertCount(1, $crawler->filter('div.row.row-cols-1.row-cols-md-2')); + $this->assertCount(6, $crawler->filter('div.listing-item--highlight')); + $this->assertCount(6, $crawler->filter('div.card-body')); + + // Testing Highlight 3 col. + $paragraph->get('field_oe_list_item_block_layout')->setValue('three_columns'); + $paragraph->save(); + + $html = $this->renderParagraph($paragraph); + $crawler = new Crawler($html); + + $assert->assertListingRendering($crawler, $nid); + $assert->assertHighlightListingRendering($crawler, $image_file); + $this->assertCount(1, $crawler->filter('div.bcl-listing--highlight-3-col')); + $this->assertCount(1, $crawler->filter('div.row.row-cols-1.row-cols-md-3')); + $this->assertCount(6, $crawler->filter('div.listing-item--highlight')); + $this->assertCount(6, $crawler->filter('div.card-body')); + } + + /** + * Assert default variant of Listing is rendering correctly. + * + * @param \Drupal\file\Entity\File $image_file + * Image file to be added to the list item. + * @param \Drupal\node\Entity\Node $node + * A Node entity. + */ + protected function createListItems(File $image_file, Node $node): array { + $items = []; + for ($i = 1; $i <= 6; $i++) { + $paragraph = Paragraph::create([ + 'type' => 'oe_list_item', + 'oe_paragraphs_variant' => 'default', + 'field_oe_title' => 'Item title ' . $i, + 'field_oe_text_long' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus ut ex tristique, dignissim sem ac, bibendum est. ' . $i, + 'field_oe_link' => [ + 'uri' => 'entity:node/' . $node->id(), + 'title' => 'Example ' . $i, + ], + 'field_oe_image' => [ + 'alt' => 'Alt for image ' . $i, + 'target_id' => $image_file->id(), + ], + 'field_oe_date' => '2011-11-13', + 'field_oe_meta' => [ + 0 => [ + 'value' => 'Label 1 - ' . $i, + ], + 1 => [ + 'value' => 'Label 2 - ' . $i, + ], + ], + ]); + $paragraph->save(); + $items[$i] = $paragraph; + } + + return $items; + } + +} diff --git a/modules/oe_whitelabel_paragraphs/tests/src/Kernel/Paragraphs/MediaParagraphsTest.php b/modules/oe_whitelabel_paragraphs/tests/src/Kernel/Paragraphs/MediaParagraphsTest.php new file mode 100644 index 00000000..b434cda9 --- /dev/null +++ b/modules/oe_whitelabel_paragraphs/tests/src/Kernel/Paragraphs/MediaParagraphsTest.php @@ -0,0 +1,644 @@ +<?php + +declare(strict_types = 1); + +namespace Drupal\Tests\oe_whitelabel_paragraphs\Kernel\Paragraphs; + +use Drupal\Core\Url; +use Symfony\Component\DomCrawler\Crawler; + +/** + * Tests the rendering of paragraph types with media fields. + */ +class MediaParagraphsTest extends ParagraphsTestBase { + + /** + * {@inheritdoc} + */ + protected function setUp(): void { + parent::setUp(); + + $this->container->get('module_handler')->loadInclude('oe_paragraphs_media_field_storage', 'install'); + oe_paragraphs_media_field_storage_install(FALSE); + $this->installEntitySchema('media'); + $this->installConfig([ + 'media', + 'oe_media', + 'oe_paragraphs_media', + 'media_avportal', + 'oe_media_avportal', + 'oe_paragraphs_banner', + 'oe_paragraphs_iframe_media', + 'options', + 'oe_media_iframe', + ]); + // Call the install hook of the Media module. + module_load_include('install', 'media'); + media_install(); + } + + /** + * Test 'text with featured media' paragraph rendering. + */ + public function testFeaturedMedia(): void { + $image_file = file_save_data(file_get_contents(drupal_get_path('module', 'oe_whitelabel_paragraphs') . '/tests/fixtures/example_1.jpeg'), 'public://example_1.jpeg'); + $image_file->setPermanent(); + $image_file->save(); + + $media_storage = $this->container->get('entity_type.manager')->getStorage('media'); + $media = $media_storage->create([ + 'bundle' => 'image', + 'name' => 'test image', + 'oe_media_image' => [ + 'target_id' => $image_file->id(), + 'alt' => 'Alt en', + ], + ]); + $media->save(); + + $paragraph_storage = $this->container->get('entity_type.manager')->getStorage('paragraph'); + $paragraph = $paragraph_storage->create([ + 'type' => 'oe_text_feature_media', + 'field_oe_title' => 'Media Title', + 'field_oe_plain_text_long' => 'Media Caption', + 'field_oe_media' => [ + 'target_id' => $media->id(), + ], + ]); + $paragraph->save(); + + // Testing: Image without wrapper. + $html = $this->renderParagraph($paragraph); + $crawler = new Crawler($html); + + $this->assertCount(1, $crawler->filter('div.row')); + $this->assertCount(1, $crawler->filter('div.col-12.col-md-4')); + $this->assertCount(0, $crawler->filter('h3')); + $this->assertCount(0, $crawler->filter('div.col-12.col-md-6.order-md-1')); + $this->assertCount(0, $crawler->filter('div.col-12.col-md-6.order-md-2')); + $figure = $crawler->filter('figure'); + $this->assertCount(1, $figure); + $this->assertCount(1, $figure->filter('img.img-fluid')); + $this->assertCount(0, $figure->filter('iframe')); + $this->assertStringContainsString( + $image_file->getFilename(), + $figure->html() + ); + $this->assertEquals('Media Caption', trim($figure->filter('figcaption.bg-light.p-3')->text())); + + // Testing: Image with wrapper aligned to left. + $paragraph->get('field_oe_text_long')->setValue('Media Full Text'); + $paragraph->get('oe_paragraphs_variant')->setValue('left_featured'); + $paragraph->save(); + $html = $this->renderParagraph($paragraph); + $crawler = new Crawler($html); + + $this->assertCount(1, $crawler->filter('div.row')); + $this->assertCount(0, $crawler->filter('div.col-12.col-md-4')); + $this->assertCount(1, $crawler->filter('h3')); + $this->assertCount(1, $crawler->filter('div.col-12.col-md-6.order-md-1')); + $this->assertCount(1, $crawler->filter('div.col-12.col-md-6.order-md-2')); + $figure = $crawler->filter('figure'); + $this->assertCount(1, $figure); + $this->assertCount(1, $figure->filter('img.img-fluid')); + $this->assertCount(0, $figure->filter('iframe')); + $this->assertStringContainsString( + $image_file->getFilename(), + $figure->html() + ); + $full_text = $crawler->filter('div.col-12.col-md-6.order-md-1'); + $this->assertEquals('Media Full Text', trim($full_text->text())); + $this->assertEquals('Media Caption', trim($figure->filter('figcaption.bg-light.p-3')->text())); + + // Testing: Image with wrapper aligned to right. + $paragraph->get('field_oe_text_long')->setValue('Media Full Text'); + $paragraph->get('oe_paragraphs_variant')->setValue('right_featured'); + $paragraph->save(); + $html = $this->renderParagraph($paragraph); + $crawler = new Crawler($html); + + $this->assertCount(1, $crawler->filter('div.row')); + $this->assertCount(0, $crawler->filter('div.col-12.col-md-4')); + $this->assertCount(1, $crawler->filter('h3')); + $this->assertCount(1, $crawler->filter('div.col-12.col-md-6.order-md-1')); + $this->assertCount(1, $crawler->filter('div.col-12.col-md-6.order-md-2')); + $figure = $crawler->filter('figure'); + $this->assertCount(1, $figure); + $this->assertCount(1, $figure->filter('img.img-fluid')); + $this->assertCount(0, $figure->filter('iframe')); + $this->assertStringContainsString( + $image_file->getFilename(), + $figure->html() + ); + $full_text = $crawler->filter('div.col-12.col-md-6.order-md-2'); + $this->assertEquals('Media Full Text', trim($full_text->text())); + $this->assertEquals('Media Caption', trim($figure->filter('figcaption.bg-light.p-3')->text())); + + // Create a remote video and add it to the paragraph. + $media = $media_storage->create([ + 'bundle' => 'remote_video', + 'oe_media_oembed_video' => [ + 'value' => 'https://www.youtube.com/watch?v=1-g73ty9v04', + ], + ]); + $media->save(); + $paragraph->set('field_oe_media', ['target_id' => $media->id()]); + $paragraph->save(); + + $paragraph_storage = $this->container->get('entity_type.manager')->getStorage('paragraph'); + $paragraph = $paragraph_storage->create([ + 'type' => 'oe_text_feature_media', + 'field_oe_title' => 'Media Title', + 'field_oe_plain_text_long' => 'Media Caption', + 'field_oe_media' => [ + 'target_id' => $media->id(), + ], + ]); + $paragraph->save(); + + // Testing: Iframe without wrapper. + $html = $this->renderParagraph($paragraph); + $crawler = new Crawler($html); + + $this->assertCount(1, $crawler->filter('div.row')); + $this->assertCount(1, $crawler->filter('div.col-12.col-md-4')); + $this->assertCount(0, $crawler->filter('h3')); + $this->assertCount(0, $crawler->filter('div.col-12.col-md-6.order-md-1')); + $this->assertCount(0, $crawler->filter('div.col-12.col-md-6.order-md-2')); + $this->assertCount(1, $crawler->filter('div.ratio.ratio-16x9')); + $figure = $crawler->filter('figure'); + $this->assertCount(1, $figure); + $this->assertCount(0, $figure->filter('img.img-fluid')); + $this->assertCount(1, $figure->filter('iframe')); + // Assert remote video is rendered properly. + $video_iframe = $crawler->filter('iframe'); + $partial_iframe_url = Url::fromRoute('media.oembed_iframe', [], [ + 'query' => [ + 'url' => 'https://www.youtube.com/watch?v=1-g73ty9v04', + ], + ])->toString(); + $this->assertStringContainsString($partial_iframe_url, $video_iframe->attr('src')); + $this->assertEquals('Media Caption', trim($figure->filter('figcaption.bg-light.p-3')->text())); + + // Testing: Iframe with wrapper aligned to left. + $paragraph->get('field_oe_text_long')->setValue('Media Full Text'); + $paragraph->get('oe_paragraphs_variant')->setValue('left_featured'); + $paragraph->save(); + $html = $this->renderParagraph($paragraph); + $crawler = new Crawler($html); + + $this->assertCount(1, $crawler->filter('div.row')); + $this->assertCount(0, $crawler->filter('div.col-12.col-md-4')); + $this->assertCount(1, $crawler->filter('h3')); + $this->assertCount(1, $crawler->filter('div.col-12.col-md-6.order-md-1')); + $this->assertCount(1, $crawler->filter('div.col-12.col-md-6.order-md-2')); + $this->assertCount(1, $crawler->filter('div.ratio.ratio-16x9')); + $figure = $crawler->filter('figure'); + $this->assertCount(1, $figure); + $this->assertCount(0, $figure->filter('img.img-fluid')); + $this->assertCount(1, $figure->filter('iframe')); + // Assert remote video is rendered properly. + $video_iframe = $crawler->filter('iframe'); + $partial_iframe_url = Url::fromRoute('media.oembed_iframe', [], [ + 'query' => [ + 'url' => 'https://www.youtube.com/watch?v=1-g73ty9v04', + ], + ])->toString(); + $this->assertStringContainsString($partial_iframe_url, $video_iframe->attr('src')); + $full_text = $crawler->filter('div.col-12.col-md-6.order-md-1'); + $this->assertEquals('Media Full Text', trim($full_text->text())); + $this->assertEquals('Media Caption', trim($figure->filter('figcaption.bg-light.p-3')->text())); + + // Testing: Iframe with wrapper aligned to right. + $paragraph->get('field_oe_text_long')->setValue('Media Full Text'); + $paragraph->get('oe_paragraphs_variant')->setValue('right_featured'); + $paragraph->save(); + $html = $this->renderParagraph($paragraph); + $crawler = new Crawler($html); + + $this->assertCount(1, $crawler->filter('div.row')); + $this->assertCount(0, $crawler->filter('div.col-12.col-md-4')); + $this->assertCount(1, $crawler->filter('h3')); + $this->assertCount(1, $crawler->filter('div.col-12.col-md-6.order-md-1')); + $this->assertCount(1, $crawler->filter('div.col-12.col-md-6.order-md-2')); + $this->assertCount(1, $crawler->filter('div.ratio.ratio-16x9')); + $figure = $crawler->filter('figure'); + $this->assertCount(1, $figure); + $this->assertCount(0, $figure->filter('img.img-fluid')); + $this->assertCount(1, $figure->filter('iframe')); + // Assert remote video is rendered properly. + $video_iframe = $crawler->filter('iframe'); + $partial_iframe_url = Url::fromRoute('media.oembed_iframe', [], [ + 'query' => [ + 'url' => 'https://www.youtube.com/watch?v=1-g73ty9v04', + ], + ])->toString(); + $this->assertStringContainsString($partial_iframe_url, $video_iframe->attr('src')); + $full_text = $crawler->filter('div.col-12.col-md-6.order-md-2'); + $this->assertEquals('Media Full Text', trim($full_text->text())); + $this->assertEquals('Media Caption', trim($figure->filter('figcaption.bg-light.p-3')->text())); + + // Create an avportal video and add it to the paragraph. + $media = $media_storage->create([ + 'bundle' => 'av_portal_video', + 'oe_media_avportal_video' => 'I-163162', + ]); + $media->save(); + $paragraph->set('field_oe_media', ['target_id' => $media->id()]); + $paragraph->save(); + + $html = $this->renderParagraph($paragraph); + $crawler = new Crawler($html); + + $this->assertCount(1, $crawler->filter('div.row')); + $this->assertCount(0, $crawler->filter('div.col-12.col-md-4')); + $this->assertCount(1, $crawler->filter('h3')); + $this->assertCount(1, $crawler->filter('div.col-12.col-md-6.order-md-1')); + $this->assertCount(1, $crawler->filter('div.col-12.col-md-6.order-md-2')); + $this->assertCount(1, $crawler->filter('div.ratio.ratio-16x9')); + $figure = $crawler->filter('figure'); + $this->assertCount(1, $figure); + $this->assertCount(0, $figure->filter('img.img-fluid')); + $this->assertCount(1, $figure->filter('iframe')); + // Assert remote video is rendered properly. + $video_iframe = $crawler->filter('iframe'); + $this->assertStringContainsString('ec.europa.eu/avservices/play.cfm?ref=I-163162', $video_iframe->attr('src')); + $full_text = $crawler->filter('div.col-12.col-md-6.order-md-2'); + $this->assertEquals('Media Full Text', trim($full_text->text())); + $this->assertEquals('Media Caption', trim($figure->filter('figcaption.bg-light.p-3')->text())); + + // Testing: Link and media title. + $paragraph->get('field_oe_text_long')->setValue('Media Full Text'); + $paragraph->get('oe_paragraphs_variant')->setValue('right_featured'); + $paragraph->get('field_oe_feature_media_title')->setValue('Text title'); + $paragraph->get('field_oe_link')->setValue([ + 'uri' => 'https://example1', + 'title' => 'Example 1', + ]); + $paragraph->save(); + $html = $this->renderParagraph($paragraph); + $crawler = new Crawler($html); + + $this->assertCount(1, $crawler->filter('div.row')); + $this->assertCount(0, $crawler->filter('div.col-12.col-md-4')); + $media_title_text = $crawler->filter('h5.text-secondary'); + $this->assertEquals('Text title', trim($media_title_text->text())); + $link = $crawler->filter('a[href="https://example1"]'); + $this->assertCount(1, $link); + $this->assertEquals('Example 1', trim($link->text())); + } + + /** + * Test 'banner' paragraph rendering. + */ + public function testBanner(): void { + // Create English file. + $en_file = file_save_data(file_get_contents(drupal_get_path('module', 'oe_whitelabel_paragraphs') . '/tests/fixtures/example_1.jpeg'), 'public://example_1_en.jpeg'); + $en_file->setPermanent(); + $en_file->save(); + + // Create a media. + $media_storage = $this->container->get('entity_type.manager')->getStorage('media'); + $media = $media_storage->create([ + 'bundle' => 'image', + 'name' => 'test image en', + 'oe_media_image' => [ + 'target_id' => $en_file->id(), + 'alt' => 'Alt en', + ], + ]); + $media->save(); + + $paragraph_storage = $this->container->get('entity_type.manager')->getStorage('paragraph'); + $paragraph = $paragraph_storage->create([ + 'type' => 'oe_banner', + 'oe_paragraphs_variant' => 'oe_banner_image', + 'field_oe_title' => 'Banner', + 'field_oe_text' => 'Description', + 'field_oe_link' => [ + 'uri' => 'http://www.example.com/', + 'title' => 'Example', + ], + 'field_oe_media' => [ + 'target_id' => $media->id(), + ], + 'field_oe_banner_type' => 'hero_center', + ]); + $paragraph->save(); + + // Variant - image / Modifier - hero_center / Full width - No. + $html = $this->renderParagraph($paragraph); + $crawler = new Crawler($html); + + $this->assertCount(1, $crawler->filter('.bcl-banner.bg-lighter.text-dark.overlay.text-center.hero')); + $image_element = $crawler->filter('.bcl-banner__image'); + $this->assertCount(1, $image_element); + $this->assertStringContainsString( + 'url(' . file_create_url($en_file->getFileUri()) . ')', + $image_element->attr('style') + ); + $this->assertBannerRendering($crawler); + $this->assertCount(0, $crawler->filter('.bcl-banner.full-width')); + + // Variant - image / Modifier - hero_left / Full width - No. + $paragraph->get('field_oe_banner_type')->setValue('hero_left'); + $paragraph->save(); + + $html = $this->renderParagraph($paragraph); + $crawler = new Crawler($html); + + $this->assertCount(0, $crawler->filter('.bcl-banner.bg-lighter.text-dark.overlay.text-center.hero')); + $this->assertCount(1, $crawler->filter('.bcl-banner.bg-lighter.text-dark.overlay.hero')); + $image_element = $crawler->filter('.bcl-banner__image'); + $this->assertCount(1, $image_element); + $this->assertStringContainsString( + 'url(' . file_create_url($en_file->getFileUri()) . ')', + $image_element->attr('style') + ); + $this->assertBannerRendering($crawler); + $this->assertCount(0, $crawler->filter('.bcl-banner.full-width')); + + // Variant - image / Modifier - page_center / Full width - No. + $paragraph->get('field_oe_banner_type')->setValue('page_center'); + $paragraph->save(); + $html = $this->renderParagraph($paragraph); + $crawler = new Crawler($html); + + $this->assertCount(1, $crawler->filter('.bcl-banner.bg-lighter.text-dark.overlay.text-center')); + $this->assertCount(0, $crawler->filter('.bcl-banner.hero')); + $image_element = $crawler->filter('.bcl-banner__image'); + $this->assertCount(1, $image_element); + $this->assertStringContainsString( + 'url(' . file_create_url($en_file->getFileUri()) . ')', + $image_element->attr('style') + ); + $this->assertBannerRendering($crawler); + $this->assertCount(0, $crawler->filter('.bcl-banner.full-width')); + + // Variant - image / Modifier - page_left / Full width - Yes. + $paragraph->get('field_oe_banner_type')->setValue('page_left'); + $paragraph->get('field_oe_banner_full_width')->setValue('1'); + $paragraph->save(); + $html = $this->renderParagraph($paragraph); + $crawler = new Crawler($html); + + $this->assertCount(1, $crawler->filter('.bcl-banner.bg-lighter.text-dark.overlay.full-width')); + $this->assertCount(0, $crawler->filter('.bcl-banner.text-center')); + $this->assertCount(0, $crawler->filter('.bcl-banner.hero')); + $image_element = $crawler->filter('.bcl-banner__image'); + $this->assertCount(1, $image_element); + $this->assertStringContainsString( + 'url(' . file_create_url($en_file->getFileUri()) . ')', + $image_element->attr('style') + ); + $this->assertBannerRendering($crawler); + $this->assertCount(1, $crawler->filter('.bcl-banner.full-width')); + + // Variant - image-shade / Modifier - hero_center / Full width - Yes. + $paragraph->get('oe_paragraphs_variant')->setValue('oe_banner_image_shade'); + $paragraph->get('field_oe_banner_type')->setValue('hero_center'); + $paragraph->save(); + $html = $this->renderParagraph($paragraph); + $crawler = new Crawler($html); + + $this->assertCount(1, $crawler->filter('.bcl-banner.bg-lighter.shade.text-center.hero.full-width')); + $image_element = $crawler->filter('.bcl-banner__image'); + $this->assertCount(1, $image_element); + $this->assertStringContainsString( + 'url(' . file_create_url($en_file->getFileUri()) . ')', + $image_element->attr('style') + ); + $this->assertBannerRendering($crawler); + $this->assertCount(1, $crawler->filter('.bcl-banner.full-width')); + + // Variant - image-shade / Modifier - hero_left / Full width - Yes. + $paragraph->get('field_oe_banner_type')->setValue('hero_left'); + $paragraph->save(); + $html = $this->renderParagraph($paragraph); + $crawler = new Crawler($html); + + $this->assertCount(1, $crawler->filter('.bcl-banner.bg-lighter.shade.hero.full-width')); + $this->assertCount(0, $crawler->filter('.bcl-banner.text-center')); + $image_element = $crawler->filter('.bcl-banner__image'); + $this->assertCount(1, $image_element); + $this->assertStringContainsString( + 'url(' . file_create_url($en_file->getFileUri()) . ')', + $image_element->attr('style') + ); + $this->assertBannerRendering($crawler); + $this->assertCount(1, $crawler->filter('.bcl-banner.full-width')); + + // Variant - image-shade / Modifier - page_center / Full width - No. + $paragraph->get('field_oe_banner_type')->setValue('page_center'); + $paragraph->get('field_oe_banner_full_width')->setValue('0'); + $paragraph->save(); + $html = $this->renderParagraph($paragraph); + $crawler = new Crawler($html); + + $this->assertCount(1, $crawler->filter('.bcl-banner.bg-lighter.shade.text-center')); + $this->assertCount(0, $crawler->filter('.bcl-banner.hero')); + $image_element = $crawler->filter('.bcl-banner__image'); + $this->assertCount(1, $image_element); + $this->assertStringContainsString( + 'url(' . file_create_url($en_file->getFileUri()) . ')', + $image_element->attr('style') + ); + $this->assertBannerRendering($crawler); + $this->assertCount(0, $crawler->filter('.bcl-banner.full-width')); + + // Variant - image-shade / Modifier - page_left / Full width - No. + $paragraph->get('field_oe_banner_type')->setValue('page_left'); + $paragraph->save(); + $html = $this->renderParagraph($paragraph); + $crawler = new Crawler($html); + + $this->assertCount(1, $crawler->filter('.bcl-banner.bg-lighter.shade')); + $this->assertCount(0, $crawler->filter('.bcl-banner.hero')); + $this->assertCount(0, $crawler->filter('.bcl-banner.text-center')); + $image_element = $crawler->filter('.bcl-banner__image'); + $this->assertCount(1, $image_element); + $this->assertStringContainsString( + 'url(' . file_create_url($en_file->getFileUri()) . ')', + $image_element->attr('style') + ); + $this->assertBannerRendering($crawler); + $this->assertCount(0, $crawler->filter('.bcl-banner.full-width')); + + // Variant - default / Modifier - hero_center / Full width - No. + $paragraph->get('oe_paragraphs_variant')->setValue('default'); + $paragraph->get('field_oe_banner_type')->setValue('hero_center'); + $paragraph->save(); + $html = $this->renderParagraph($paragraph); + $crawler = new Crawler($html); + + $this->assertCount(1, $crawler->filter('.bcl-banner.bg-lighter.text-dark.text-center.hero')); + + // No image should be displayed on 'default' variant. + $image_element = $crawler->filter('.bcl-banner__image'); + $this->assertCount(0, $image_element); + + $this->assertBannerRendering($crawler); + $this->assertCount(0, $crawler->filter('.bcl-banner.full-width')); + + // Variant - default / Modifier - hero_left / Full width - Yes. + $paragraph->get('field_oe_banner_type')->setValue('hero_left'); + $paragraph->get('field_oe_banner_full_width')->setValue('1'); + $paragraph->save(); + $html = $this->renderParagraph($paragraph); + $crawler = new Crawler($html); + + $this->assertCount(1, $crawler->filter('.bcl-banner.bg-lighter.text-dark.hero.full-width')); + $this->assertCount(0, $crawler->filter('.bcl-banner.text-center')); + + // No image should be displayed on 'default' variant. + $image_element = $crawler->filter('.bcl-banner__image'); + $this->assertCount(0, $image_element); + + $this->assertBannerRendering($crawler); + $this->assertCount(1, $crawler->filter('.bcl-banner.full-width')); + + // Variant - default / Modifier - page_center / Full width - Yes. + $paragraph->get('field_oe_banner_type')->setValue('page_center'); + $paragraph->save(); + $html = $this->renderParagraph($paragraph); + $crawler = new Crawler($html); + + $this->assertCount(1, $crawler->filter('.bcl-banner.bg-lighter.text-dark.text-center.full-width')); + $this->assertCount(0, $crawler->filter('.bcl-banner.hero')); + + // No image should be displayed on 'default' variant. + $image_element = $crawler->filter('.bcl-banner__image'); + $this->assertCount(0, $image_element); + + $this->assertBannerRendering($crawler); + $this->assertCount(1, $crawler->filter('.bcl-banner.full-width')); + + // Variant - default / Modifier - page_left / Full width - Yes. + $paragraph->get('field_oe_banner_type')->setValue('page_left'); + $paragraph->save(); + $html = $this->renderParagraph($paragraph); + $crawler = new Crawler($html); + + $this->assertCount(1, $crawler->filter('.bcl-banner.bg-lighter.text-dark.full-width')); + $this->assertCount(0, $crawler->filter('.bcl-banner.hero')); + $this->assertCount(0, $crawler->filter('.bcl-banner.text-center')); + + // No image should be displayed on 'default' variant. + $image_element = $crawler->filter('.bcl-banner__image'); + $this->assertCount(0, $image_element); + + $this->assertBannerRendering($crawler); + $this->assertCount(1, $crawler->filter('.bcl-banner.full-width')); + + // Variant - primary / Modifier - hero_center / Full width - Yes. + $paragraph->get('oe_paragraphs_variant')->setValue('oe_banner_primary'); + $paragraph->get('field_oe_banner_type')->setValue('hero_center'); + $paragraph->save(); + $html = $this->renderParagraph($paragraph); + $crawler = new Crawler($html); + + $this->assertCount(1, $crawler->filter('.bcl-banner.bg-primary.text-white.text-center.hero.full-width')); + + // No image should be displayed on 'default' variant. + $image_element = $crawler->filter('.bcl-banner__image'); + $this->assertCount(0, $image_element); + + $this->assertBannerRendering($crawler); + $this->assertCount(1, $crawler->filter('.bcl-banner.full-width')); + + // Variant - primary / Modifier - hero_left / Full width - Yes. + $paragraph->get('field_oe_banner_type')->setValue('hero_left'); + $paragraph->save(); + $html = $this->renderParagraph($paragraph); + $crawler = new Crawler($html); + + $this->assertCount(1, $crawler->filter('.bcl-banner.bg-primary.text-white.hero.full-width')); + $this->assertCount(0, $crawler->filter('.bcl-banner.text-center')); + + // No image should be displayed on 'default' variant. + $image_element = $crawler->filter('.bcl-banner__image'); + $this->assertCount(0, $image_element); + + $this->assertBannerRendering($crawler); + $this->assertCount(1, $crawler->filter('.bcl-banner.full-width')); + + // Variant - primary / Modifier - page_center / Full width - Yes. + $paragraph->get('field_oe_banner_type')->setValue('page_center'); + $paragraph->save(); + $html = $this->renderParagraph($paragraph); + $crawler = new Crawler($html); + + $this->assertCount(1, $crawler->filter('.bcl-banner.bg-primary.text-white.text-center.full-width')); + $this->assertCount(0, $crawler->filter('.bcl-banner.hero')); + + // No image should be displayed on 'default' variant. + $image_element = $crawler->filter('.bcl-banner__image'); + $this->assertCount(0, $image_element); + + $this->assertBannerRendering($crawler); + $this->assertCount(1, $crawler->filter('.bcl-banner.full-width')); + + // Variant - primary / Modifier - page_left / Full width - No. + $paragraph->get('field_oe_banner_type')->setValue('page_left'); + $paragraph->get('field_oe_banner_full_width')->setValue('0'); + $paragraph->save(); + $html = $this->renderParagraph($paragraph); + $crawler = new Crawler($html); + + $this->assertCount(1, $crawler->filter('.bcl-banner.bg-primary.text-white')); + $this->assertCount(0, $crawler->filter('.bcl-banner.hero')); + $this->assertCount(0, $crawler->filter('.bcl-banner.text-center')); + + // No image should be displayed on 'default' variant. + $image_element = $crawler->filter('.bcl-banner__image'); + $this->assertCount(0, $image_element); + + $this->assertBannerRendering($crawler); + $this->assertCount(0, $crawler->filter('.bcl-banner.full-width')); + + // Create a media using AV Portal image and add it to the paragraph. + $media = $media_storage->create([ + 'bundle' => 'av_portal_photo', + 'oe_media_avportal_photo' => 'P-038924/00-15', + 'uid' => 0, + 'status' => 1, + ]); + + $media->save(); + + $paragraph = $paragraph_storage->create([ + 'type' => 'oe_banner', + 'oe_paragraphs_variant' => 'oe_banner_image', + 'field_oe_text' => 'Description', + 'field_oe_media' => [ + 'target_id' => $media->id(), + ], + 'field_oe_banner_type' => 'hero_center', + ]); + $paragraph->save(); + $html = $this->renderParagraph($paragraph); + $crawler = new Crawler($html); + + $image_element = $crawler->filter('.bcl-banner__image'); + $this->assertCount(1, $image_element); + $this->assertStringContainsString( + 'url(' . (file_create_url('avportal://P-038924/00-15.jpg')) . ')', + $image_element->attr('style') + ); + } + + /** + * Assert Banner is rendering correctly. + * + * @param \Symfony\Component\DomCrawler\Crawler $crawler + * The DomCrawler where to check the element. + */ + protected function assertBannerRendering(Crawler $crawler): void { + $this->assertEquals('Banner', trim($crawler->filter('.bcl-banner__content div')->text())); + $this->assertEquals('Description', trim($crawler->filter('.bcl-banner__content p')->text())); + $this->assertCount(1, $crawler->filter('svg.bi.icon--fluid')); + $this->assertStringContainsString('Example', trim($crawler->filter('a.btn')->text())); + $this->assertStringContainsString('#chevron-right', trim($crawler->filter('a.btn')->html())); + } + +} diff --git a/modules/oe_whitelabel_paragraphs/tests/src/Kernel/Paragraphs/ParagraphsTestBase.php b/modules/oe_whitelabel_paragraphs/tests/src/Kernel/Paragraphs/ParagraphsTestBase.php new file mode 100644 index 00000000..6152802f --- /dev/null +++ b/modules/oe_whitelabel_paragraphs/tests/src/Kernel/Paragraphs/ParagraphsTestBase.php @@ -0,0 +1,96 @@ +<?php + +declare(strict_types = 1); + +namespace Drupal\Tests\oe_whitelabel_paragraphs\Kernel\Paragraphs; + +use Drupal\paragraphs\ParagraphInterface; +use Drupal\Tests\oe_whitelabel_paragraphs\Kernel\AbstractKernelTestBase; + +/** + * Base class for paragraphs tests. + */ +abstract class ParagraphsTestBase extends AbstractKernelTestBase { + + /** + * {@inheritdoc} + */ + protected static $modules = [ + 'allowed_formats', + 'datetime', + 'description_list_field', + 'entity_browser', + 'entity_reference_revisions', + 'field', + 'file', + 'file_link', + 'filter', + 'language', + 'link', + 'locale', + 'media', + 'media_avportal', + 'node', + 'oe_media', + 'oe_media_avportal', + 'oe_media_iframe', + 'oe_paragraphs', + 'oe_paragraphs_banner', + 'oe_paragraphs_description_list', + 'oe_paragraphs_iframe_media', + 'oe_paragraphs_media', + 'oe_paragraphs_media_field_storage', + 'oe_whitelabel_paragraphs', + 'options', + 'paragraphs', + 'text', + 'typed_link', + 'user', + 'views', + ]; + + /** + * {@inheritdoc} + */ + protected function setUp(): void { + parent::setUp(); + + $this->installEntitySchema('paragraph'); + $this->installEntitySchema('file'); + $this->installSchema('file', ['file_usage']); + $this->installSchema('locale', [ + 'locales_location', + 'locales_source', + 'locales_target', + ]); + $this->installConfig([ + 'oe_paragraphs', + 'oe_paragraphs_description_list', + 'oe_whitelabel_paragraphs', + 'filter', + 'locale', + 'language', + 'node', + ]); + } + + /** + * Render a paragraph. + * + * @param \Drupal\paragraphs\ParagraphInterface $paragraph + * Paragraph entity. + * + * @return string + * Rendered output. + * + * @throws \Exception + */ + protected function renderParagraph(ParagraphInterface $paragraph): string { + $render = \Drupal::entityTypeManager() + ->getViewBuilder('paragraph') + ->view($paragraph, 'default'); + + return $this->renderRoot($render); + } + +} diff --git a/modules/oe_whitelabel_paragraphs/tests/src/Kernel/Paragraphs/QuoteTest.php b/modules/oe_whitelabel_paragraphs/tests/src/Kernel/Paragraphs/QuoteTest.php new file mode 100644 index 00000000..21a0dee2 --- /dev/null +++ b/modules/oe_whitelabel_paragraphs/tests/src/Kernel/Paragraphs/QuoteTest.php @@ -0,0 +1,40 @@ +<?php + +declare(strict_types = 1); + +namespace Drupal\Tests\oe_whitelabel_paragraphs\Kernel\Paragraphs; + +use Drupal\paragraphs\Entity\Paragraph; +use Symfony\Component\DomCrawler\Crawler; + +/** + * Tests the quote paragraphs. + */ +class QuoteTest extends ParagraphsTestBase { + + /** + * Tests the rendering of the paragraph type. + */ + public function testRendering(): void { + $paragraph = Paragraph::create([ + 'type' => 'oe_quote', + 'field_oe_plain_text_long' => 'Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit.', + 'field_oe_text' => 'Cicero', + ]); + $paragraph->save(); + + $html = $this->renderParagraph($paragraph); + $crawler = new Crawler($html); + + $this->assertCount(1, $crawler->filter('figure.text-left')); + $quote = $crawler->filter('blockquote.blockquote'); + $this->assertCount(1, $quote); + $this->assertEquals( + 'Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit.', + trim($quote->text()) + ); + $caption = $crawler->filter('figcaption.blockquote-footer'); + $this->assertEquals('Cicero', trim($caption->text())); + } + +} diff --git a/modules/oe_whitelabel_paragraphs/tests/src/Kernel/Paragraphs/RichTextTest.php b/modules/oe_whitelabel_paragraphs/tests/src/Kernel/Paragraphs/RichTextTest.php new file mode 100644 index 00000000..609a5bb0 --- /dev/null +++ b/modules/oe_whitelabel_paragraphs/tests/src/Kernel/Paragraphs/RichTextTest.php @@ -0,0 +1,121 @@ +<?php + +declare(strict_types = 1); + +namespace Drupal\Tests\oe_whitelabel_paragraphs\Kernel\Paragraphs; + +use Drupal\filter\Entity\FilterFormat; +use Drupal\paragraphs\Entity\Paragraph; +use Symfony\Component\DomCrawler\Crawler; + +/** + * Tests the "Rich text" paragraphs. + */ +class RichTextTest extends ParagraphsTestBase { + + /** + * {@inheritdoc} + */ + protected function setUp(): void { + parent::setUp(); + + $this->filterFormat = FilterFormat::create([ + 'format' => 'filtered_html', + 'name' => 'Filtered HTML', + 'weight' => 0, + ]); + $this->filterFormat->save(); + } + + /** + * Tests the rendering of the paragraph type. + */ + public function testRendering(): void { + $text_original = '<p id="paragraph-1">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque ornare et elit a dictum. Maecenas lacinia eros quis eros iaculis, sit amet bibendum massa facilisis. Integer arcu nisl, fringilla nec quam vel, tincidunt maximus ex. Suspendisse ac arcu efficitur, feugiat tellus vel, viverra sapien. Etiam vitae condimentum lorem. Nulla congue ligula lacinia efficitur tempus. Duis vitae auctor enim. Nulla iaculis, diam et sagittis scelerisque, est mauris luctus sem, a imperdiet lacus diam eu dui. Morbi accumsan, augue eu gravida elementum, libero mi blandit odio, eu fringilla nunc ipsum non tellus. Suspendisse dapibus elit at lobortis pretium. Quisque vestibulum ut purus sit amet molestie. Sed eget volutpat justo, vel varius augue. Vestibulum vel risus facilisis, feugiat sem aliquam, lobortis ante.</p><p id="paragraph-2"><strong>Bold</strong></p><p id="paragraph-3"><em>Italic</em></p><p id="paragraph-4"><a href="https://www.example-1.com">Link</a></p><p id="paragraph-5">List:</p><ul><li>option a</li><li">option b</li></ul><p id="paragraph-6">Numbered list:</p><ol><li>first option</li><li>second option</li></ol><p id="paragraph-7">Block quote:</p><blockquote><p>I am a block quote</p></blockquote>'; + $paragraph = Paragraph::create([ + 'type' => 'oe_rich_text', + 'field_oe_title' => 'Rich text example', + 'field_oe_text_long' => [ + 'value' => $text_original, + 'format' => 'filtered_html', + ], + ]); + $paragraph->save(); + + $html = $this->renderParagraph($paragraph); + $crawler = new Crawler($html); + + $title = $crawler->filter('h4'); + $this->assertCount(1, $title); + $this->assertStringContainsString( + 'Rich text example', + $title->html() + ); + // Simple text. + $text = $crawler->filter('p#paragraph-1'); + $this->assertCount(1, $text); + $this->assertStringContainsString( + 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque ornare et elit a dictum. Maecenas lacinia eros quis eros iaculis, sit amet bibendum massa facilisis. Integer arcu nisl, fringilla nec quam vel, tincidunt maximus ex. Suspendisse ac arcu efficitur, feugiat tellus vel, viverra sapien. Etiam vitae condimentum lorem. Nulla congue ligula lacinia efficitur tempus. Duis vitae auctor enim. Nulla iaculis, diam et sagittis scelerisque, est mauris luctus sem, a imperdiet lacus diam eu dui. Morbi accumsan, augue eu gravida elementum, libero mi blandit odio, eu fringilla nunc ipsum non tellus. Suspendisse dapibus elit at lobortis pretium. Quisque vestibulum ut purus sit amet molestie. Sed eget volutpat justo, vel varius augue. Vestibulum vel risus facilisis, feugiat sem aliquam, lobortis ante.', + $text->html() + ); + // Bold format. + $text = $crawler->filter('p#paragraph-2 strong'); + $this->assertCount(1, $text); + $this->assertStringContainsString( + 'Bold', + $text->html() + ); + // Italic. + $text = $crawler->filter('p#paragraph-3 em'); + $this->assertCount(1, $text); + $this->assertStringContainsString( + 'Italic', + $text->html() + ); + // Link. + $text = $crawler->filter('p#paragraph-4 a'); + $this->assertCount(1, $text); + $this->assertStringContainsString( + 'Link', + $text->html() + ); + $this->assertStringContainsString( + 'https://www.example-1.com', + $text->attr('href') + ); + // Unordered list. + $text = $crawler->filter('ul li:nth-child(1)'); + $this->assertCount(1, $text); + $this->assertStringContainsString( + 'option a', + $text->html() + ); + $text = $crawler->filter('ul li:nth-child(2)'); + $this->assertCount(1, $text); + $this->assertStringContainsString( + 'option b', + $text->html() + ); + // Ordered list. + $text = $crawler->filter('ol li:nth-child(1)'); + $this->assertCount(1, $text); + $this->assertStringContainsString( + 'first option', + $text->html() + ); + $text = $crawler->filter('ol li:nth-child(2)'); + $this->assertCount(1, $text); + $this->assertStringContainsString( + 'second option', + $text->html() + ); + // Blcokquote. + $text = $crawler->filter('blockquote p'); + $this->assertCount(1, $text); + $this->assertStringContainsString( + 'I am a block quote', + $text->html() + ); + } + +} diff --git a/modules/oe_whitelabel_paragraphs/tests/src/Kernel/Paragraphs/SocialMediaFollowTest.php b/modules/oe_whitelabel_paragraphs/tests/src/Kernel/Paragraphs/SocialMediaFollowTest.php new file mode 100644 index 00000000..dc38c36e --- /dev/null +++ b/modules/oe_whitelabel_paragraphs/tests/src/Kernel/Paragraphs/SocialMediaFollowTest.php @@ -0,0 +1,90 @@ +<?php + +declare(strict_types = 1); + +namespace Drupal\Tests\oe_whitelabel_paragraphs\Kernel\Paragraphs; + +use Drupal\paragraphs\Entity\Paragraph; +use Drupal\Tests\oe_whitelabel_paragraphs\Kernel\PatternAssertions\LinksBlockAssertion; +use Symfony\Component\DomCrawler\Crawler; + +/** + * Tests the "Social media follow" paragraphs. + */ +class SocialMediaFollowTest extends LinksBlockAssertion { + + /** + * Tests the rendering of the paragraph type. + */ + public function testRendering(): void { + // Create social media follow paragraph with horizontal variant. + $paragraph = Paragraph::create([ + 'type' => 'oe_social_media_follow', + 'field_oe_title' => 'Social media title', + 'field_oe_social_media_variant' => 'horizontal', + 'oe_bt_links_block_background' => 'gray', + 'field_oe_social_media_links' => $this->getSocialMediaLinks(), + 'field_oe_social_media_see_more' => [ + 'title' => 'Other social networks', + 'uri' => 'https://europa.eu/european-union/contact/social-networks_en', + ], + ]); + $paragraph->save(); + + // Testing: SocialMediaFollow horizontal gray. + $html = $this->renderParagraph($paragraph); + $crawler = new Crawler($html); + + $this->assertBackgroundGray($crawler); + $this->assertSocialMediaLinksBlockRendering($crawler); + $this->assertHorizontalLinks($crawler); + + // Verify that links are rendered. + $this->assertSocialLinks($crawler); + + // Testing: SocialMediaFollow vertical gray. + $paragraph->get('field_oe_social_media_variant')->setValue('vertical'); + $paragraph->save(); + + $html = $this->renderParagraph($paragraph); + $crawler = new Crawler($html); + + $this->assertBackgroundGray($crawler); + $this->assertSocialMediaLinksBlockRendering($crawler); + $this->assertVerticalLinks($crawler); + + // Verify that the paragraph contains all the links. + $this->assertSocialLinks($crawler); + + // Testing: SocialMediaFollow horizontal transparent. + $paragraph->get('field_oe_social_media_variant')->setValue('horizontal'); + $paragraph->get('oe_bt_links_block_background')->setValue('transparent'); + $paragraph->save(); + + $html = $this->renderParagraph($paragraph); + $crawler = new Crawler($html); + + $this->assertBackgroundTransparent($crawler); + $this->assertSocialMediaLinksBlockRendering($crawler); + $this->assertHorizontalLinks($crawler); + + // Verify that the paragraph contains all the links. + $this->assertSocialLinks($crawler); + + // Testing: SocialMediaFollow vertical transparent. + $paragraph->get('field_oe_social_media_variant')->setValue('vertical'); + $paragraph->get('oe_bt_links_block_background')->setValue('transparent'); + $paragraph->save(); + + $html = $this->renderParagraph($paragraph); + $crawler = new Crawler($html); + + $this->assertBackgroundTransparent($crawler); + $this->assertSocialMediaLinksBlockRendering($crawler); + $this->assertVerticalLinks($crawler); + + // Verify that the paragraph contains all the links. + $this->assertSocialLinks($crawler); + } + +} diff --git a/modules/oe_whitelabel_paragraphs/tests/src/Kernel/Paragraphs/TimelineParagraphTest.php b/modules/oe_whitelabel_paragraphs/tests/src/Kernel/Paragraphs/TimelineParagraphTest.php new file mode 100644 index 00000000..490a6598 --- /dev/null +++ b/modules/oe_whitelabel_paragraphs/tests/src/Kernel/Paragraphs/TimelineParagraphTest.php @@ -0,0 +1,157 @@ +<?php + +declare(strict_types = 1); + +namespace Drupal\Tests\oe_whitelabel_paragraphs\Kernel\Paragraphs; + +use Drupal\filter\Entity\FilterFormat; +use Drupal\paragraphs\Entity\Paragraph; +use Symfony\Component\DomCrawler\Crawler; + +/** + * Tests the rendering for timeline paragraph type. + */ +class TimelineParagraphTest extends ParagraphsTestBase { + + /** + * {@inheritdoc} + */ + public static $modules = [ + 'oe_paragraphs_timeline', + 'oe_content_timeline_field', + 'node', + ]; + + /** + * {@inheritdoc} + */ + protected function setUp(): void { + parent::setUp(); + + $this->installConfig([ + 'oe_paragraphs_timeline', + 'oe_content_timeline_field', + 'node', + ]); + + // Remove the auto-paragraph and url-to-link filters from the plain text. + /** @var \Drupal\filter\Entity\FilterFormat $format */ + $format = FilterFormat::load('plain_text'); + $format->filters(); + $format->removeFilter('filter_url'); + $format->removeFilter('filter_autop'); + $format->save(); + + FilterFormat::create([ + 'format' => 'filtered_html', + 'name' => 'Filtered HTML', + 'filters' => [ + 'filter_html' => [ + 'status' => 1, + 'settings' => [ + 'allowed_html' => '<strong>', + ], + ], + ], + ])->save(); + + FilterFormat::create([ + 'format' => 'full_html', + 'name' => 'Full HTML', + ])->save(); + + $this->container->get('theme_installer')->install(['oe_whitelabel']); + $this->config('system.theme')->set('default', 'oe_whitelabel')->save(); + $this->container->set('theme.registry', NULL); + } + + /** + * Test 'timeline' paragraph rendering. + */ + public function testTimeline(): void { + $paragraph = Paragraph::create([ + 'type' => 'oe_timeline', + 'field_oe_timeline_expand' => '3', + 'field_oe_timeline' => [ + [ + 'label' => 'Label 1', + 'title' => 'Title 1', + 'body' => 'Description 1', + ], + [ + 'label' => 'Label 2', + 'title' => 'Title 2', + 'body' => '<p>Description 2</p>', + ], + [ + 'label' => 'Label 3', + 'title' => 'Title 3', + 'body' => '<p>Description <strong>3</strong></p>', + 'format' => 'plain_text', + ], + [ + 'label' => 'Label 4', + 'title' => 'Title 4', + 'body' => '<p>Description <strong>4</strong></p>', + 'format' => 'filtered_html', + ], + [ + 'label' => 'Label 5', + 'title' => 'Title 5', + 'body' => '<p>Description <strong>5</strong></p>', + 'format' => 'full_html', + ], + [ + 'label' => 'Label 6', + 'title' => 'Title 6', + 'body' => 'Description 6', + ], + ], + ]); + + $paragraph->save(); + $html = $this->renderParagraph($paragraph); + $crawler = new Crawler($html); + + // No heading should be rendered if the paragraph has no heading set. + $this->assertCount(0, $crawler->filter('h2.ecl-u-type-heading-2')); + $this->assertCount(1, $crawler->filter('ol.bcl-timeline')); + $this->assertCount(7, $crawler->filter('ol.bcl-timeline li')); + $this->assertCount(1, $crawler->filter('ol.bcl-timeline li .label-collapsed')); + $this->assertCount(1, $crawler->filter('ol.bcl-timeline li.bcl-timeline__item--toggle')); + $this->assertEquals('Label 1', trim($crawler->filter('ol.bcl-timeline li:nth-child(1) h5')->html())); + $this->assertEquals('Title 1', trim($crawler->filter('ol.bcl-timeline li:nth-child(1) h6')->html())); + $this->assertEquals('Description 1', trim($crawler->filter('ol.bcl-timeline li:nth-child(1) div')->html())); + $this->assertEquals('Label 2', trim($crawler->filter('ol.bcl-timeline li:nth-child(2) h5')->html())); + $this->assertEquals('Title 2', trim($crawler->filter('ol.bcl-timeline li:nth-child(2) h6')->html())); + // Explicit format "plain_text" specified. + $this->assertEquals('<p>Description 2</p>', trim($crawler->filter('ol.bcl-timeline li:nth-child(2) div')->html())); + $this->assertEquals('Label 3', trim($crawler->filter('ol.bcl-timeline li:nth-child(3) h5')->html())); + $this->assertEquals('Title 3', trim($crawler->filter('ol.bcl-timeline li:nth-child(3) h6')->html())); + $this->assertEquals('<p>Description <strong>3</strong></p>', trim($crawler->filter('ol.bcl-timeline li:nth-child(3) div')->html())); + $this->assertEquals('Label 4', trim($crawler->filter('ol.bcl-timeline li:nth-child(4) h5')->html())); + $this->assertEquals('Title 4', trim($crawler->filter('ol.bcl-timeline li:nth-child(4) h6')->html())); + // Explicit format "filtered_html" specified. + $this->assertEquals('Description <strong>4</strong>', trim($crawler->filter('ol.bcl-timeline li:nth-child(4) div')->html())); + $this->assertEquals('<p>Description <strong>5</strong></p>', trim($crawler->filter('ol.bcl-timeline li:nth-child(5) div')->html())); + $this->assertEquals('Label 5', trim($crawler->filter('ol.bcl-timeline li:nth-child(5) h5')->html())); + $this->assertEquals('Title 5', trim($crawler->filter('ol.bcl-timeline li:nth-child(5) h6')->html())); + $this->assertEquals('Label 6', trim($crawler->filter('ol.bcl-timeline li:nth-child(6) h5')->html())); + $this->assertEquals('Title 6', trim($crawler->filter('ol.bcl-timeline li:nth-child(6) h6')->html())); + // Explicit format "full_html" specified. + $this->assertEquals('Description 6', trim($crawler->filter('ol.bcl-timeline li:nth-child(6) div')->html())); + $this->assertEquals('Show more 3 items', trim($crawler->filter('button .label-collapsed')->text())); + + // Increase limit to print all the items and set timeline heading. + $paragraph->set('field_oe_timeline_expand', '7'); + $paragraph->save(); + $html = $this->renderParagraph($paragraph); + $crawler = new Crawler($html); + + // Assert rendering is updated. + $this->assertCount(6, $crawler->filter('ol.bcl-timeline li')); + $this->assertCount(0, $crawler->filter('ol.bcl-timeline label-collapsed')); + $this->assertCount(0, $crawler->filter('ol.bcl-timeline li.bcl-timeline__item--toggle')); + } + +} diff --git a/modules/oe_whitelabel_paragraphs/tests/src/Kernel/PatternAssertions/LinksBlockAssertion.php b/modules/oe_whitelabel_paragraphs/tests/src/Kernel/PatternAssertions/LinksBlockAssertion.php new file mode 100644 index 00000000..dfde169b --- /dev/null +++ b/modules/oe_whitelabel_paragraphs/tests/src/Kernel/PatternAssertions/LinksBlockAssertion.php @@ -0,0 +1,223 @@ +<?php + +declare(strict_types = 1); + +namespace Drupal\Tests\oe_whitelabel_paragraphs\Kernel\PatternAssertions; + +use Symfony\Component\DomCrawler\Crawler; + +/** + * Class for asserting links block paragraphs. + */ +class LinksBlockAssertion { + + /** + * Returns a list of link items for Social media follow paragraph. + * + * @return array + * An array of link items. + */ + protected function getSocialMediaLinks(): array { + return [ + [ + 'title' => 'Email', + 'uri' => 'mailto:example@com', + 'link_type' => 'email', + ], + [ + 'title' => 'Facebook', + 'uri' => 'https://facebook.com', + 'link_type' => 'facebook', + ], + [ + 'title' => 'Flickr', + 'uri' => 'https://www.flickr.com', + 'link_type' => 'flickr', + ], + [ + 'title' => 'Google+', + 'uri' => 'https://google.com', + 'link_type' => 'google', + ], + [ + 'title' => 'Instagram', + 'uri' => 'https://instagram.com', + 'link_type' => 'instagram', + ], + [ + 'title' => 'LinkedIn', + 'uri' => 'https://linkedin.com', + 'link_type' => 'linkedin', + ], + [ + 'title' => 'Pinterest', + 'uri' => 'https://pinterest.com', + 'link_type' => 'pinterest', + ], + [ + 'title' => 'RSS', + 'uri' => 'https://rss-example.com', + 'link_type' => 'rss', + ], + [ + 'title' => 'Storify', + 'uri' => 'https://storify.com', + 'link_type' => 'storify', + ], + [ + 'title' => '1st Twitter', + 'uri' => 'https://twitter.com', + 'link_type' => 'twitter', + ], + [ + 'title' => '2nd Twitter', + 'uri' => 'https://twitter.com', + 'link_type' => 'twitter', + ], + [ + 'title' => 'Yammer', + 'uri' => 'https://yammer.com', + 'link_type' => 'yammer', + ], + [ + 'title' => 'Youtube', + 'uri' => 'https://youtube.com', + 'link_type' => 'youtube', + ], + [ + 'title' => 'Vimeo', + 'uri' => 'https://vimeo.com', + 'link_type' => 'vimeo', + ], + ]; + } + + /** + * Returns a list of link items for Block Links paragraph. + * + * @return array + * An array of link items. + */ + protected function getBlockLinks(): array { + return [ + [ + 'title' => 'European Commission', + 'uri' => 'https://example.com', + ], + [ + 'title' => 'Priorities', + 'uri' => 'https://example.com', + ], + [ + 'title' => 'Jobs, Growth and Investment', + 'uri' => 'https://example.com', + ], + ]; + } + + /** + * Assert links from social media. + * + * @param \Symfony\Component\DomCrawler\Crawler $crawler + * The DomCrawler where to check the element. + */ + protected function assertSocialLinks(Crawler $crawler): void { + $links = $crawler->filter('ul'); + $links_html = $links->html(); + $this->assertStringContainsString('Email', $links_html); + $this->assertCount(1, $crawler->filterXPath('//*[name()=\'use\' and substring(@*, string-length(@*) - 5) = \'#email\']')); + $this->assertStringContainsString('Facebook', $links_html); + $this->assertCount(1, $crawler->filterXPath('//*[name()=\'use\' and substring(@*, string-length(@*) - 8) = \'#facebook\']')); + $this->assertStringContainsString('Flickr', $links_html); + $this->assertCount(1, $crawler->filterXPath('//*[name()=\'use\' and substring(@*, string-length(@*) - 6) = \'#flickr\']')); + $this->assertStringContainsString('Google+', $links_html); + $this->assertCount(1, $crawler->filterXPath('//*[name()=\'use\' and substring(@*, string-length(@*) - 6) = \'#google\']')); + $this->assertStringContainsString('Instagram', $links_html); + $this->assertCount(1, $crawler->filterXPath('//*[name()=\'use\' and substring(@*, string-length(@*) - 9) = \'#instagram\']')); + $this->assertStringContainsString('LinkedIn', $links_html); + $this->assertCount(1, $crawler->filterXPath('//*[name()=\'use\' and substring(@*, string-length(@*) - 8) = \'#linkedin\']')); + $this->assertStringContainsString('Pinterest', $links_html); + $this->assertCount(1, $crawler->filterXPath('//*[name()=\'use\' and substring(@*, string-length(@*) - 9) = \'#pinterest\']')); + $this->assertStringContainsString('RSS', $links_html); + $this->assertCount(1, $crawler->filterXPath('//*[name()=\'use\' and substring(@*, string-length(@*) - 3) = \'#rss\']')); + $this->assertStringContainsString('Storify', $links_html); + $this->assertCount(1, $crawler->filterXPath('//*[name()=\'use\' and substring(@*, string-length(@*) - 7) = \'#storify\']')); + $this->assertStringContainsString('1st Twitter', $links_html); + $this->assertStringContainsString('2nd Twitter', $links_html); + $this->assertCount(2, $crawler->filterXPath('//*[name()=\'use\' and substring(@*, string-length(@*) - 7) = \'#twitter\']')); + $this->assertStringContainsString('Yammer', $links_html); + $this->assertCount(1, $crawler->filterXPath('//*[name()=\'use\' and substring(@*, string-length(@*) - 6) = \'#yammer\']')); + $this->assertStringContainsString('Youtube', $links_html); + $this->assertCount(1, $crawler->filterXPath('//*[name()=\'use\' and substring(@*, string-length(@*) - 7) = \'#youtube\']')); + $this->assertStringContainsString('Other social networks', $links_html); + } + + /** + * Assert Background is gray. + * + * @param \Symfony\Component\DomCrawler\Crawler $crawler + * The DomCrawler where to check the element. + */ + protected function assertBackgroundGray(Crawler $crawler): void { + $this->assertCount(1, $crawler->filter('div.bg-light.px-4.py-3')); + } + + /** + * Assert Background is transparent. + * + * @param \Symfony\Component\DomCrawler\Crawler $crawler + * The DomCrawler where to check the element. + */ + protected function assertBackgroundTransparent(Crawler $crawler): void { + $this->assertCount(0, $crawler->filter('div.bg-light.px-4.py-3')); + } + + /** + * Assert Links Block with Social Media is rendering correctly. + * + * @param \Symfony\Component\DomCrawler\Crawler $crawler + * The DomCrawler where to check the element. + */ + protected function assertSocialMediaLinksBlockRendering(Crawler $crawler): void { + $this->assertCount(1, $crawler->filter('h5.fw-bold.pb-3.mb-3.border-bottom')); + $this->assertCount(1, $crawler->filter('ul.ps-0.mb-0')); + $this->assertCount(15, $crawler->filter('li.list-unstyled')); + $this->assertCount(14, $crawler->filter('li.list-unstyled.me-4-5')); + } + + /** + * Assert direction is horizontal. + * + * @param \Symfony\Component\DomCrawler\Crawler $crawler + * The DomCrawler where to check the element. + * @param bool $social + * Flag to determine if is block links with social media or not. + */ + protected function assertHorizontalLinks(Crawler $crawler, $social = TRUE): void { + $this->assertCount($social ? 15 : 3, $crawler->filter('li.d-inline')); + } + + /** + * Assert direction is vertical. + * + * @param \Symfony\Component\DomCrawler\Crawler $crawler + * The DomCrawler where to check the element. + */ + protected function assertVerticalLinks(Crawler $crawler): void { + $this->assertCount(0, $crawler->filter('li.d-inline')); + } + + /** + * Assert Links Block is rendering correctly. + * + * @param \Symfony\Component\DomCrawler\Crawler $crawler + * The DomCrawler where to check the element. + */ + protected function assertLinksBlockRendering(Crawler $crawler): void { + $this->assertCount(1, $crawler->filter('h5.fw-bold.pb-3.mb-3.border-bottom')); + $this->assertCount(1, $crawler->filter('ul.ps-0.mb-0')); + $this->assertCount(3, $crawler->filter('li.list-unstyled')); + $this->assertCount(2, $crawler->filter('li.list-unstyled.me-4-5')); + } + +} diff --git a/modules/oe_whitelabel_paragraphs/tests/src/Kernel/PatternAssertions/ListingAssertion.php b/modules/oe_whitelabel_paragraphs/tests/src/Kernel/PatternAssertions/ListingAssertion.php new file mode 100644 index 00000000..f032eb90 --- /dev/null +++ b/modules/oe_whitelabel_paragraphs/tests/src/Kernel/PatternAssertions/ListingAssertion.php @@ -0,0 +1,99 @@ +<?php + +declare(strict_types = 1); + +namespace Drupal\Tests\oe_whitelabel_paragraphs\Kernel\PatternAssertions; + +use Drupal\file\Entity\File; +use PHPUnit\Framework\Assert; +use Symfony\Component\DomCrawler\Crawler; + +/** + * Class for asserting Listing pattern. + */ +class ListingAssertion extends Assert { + + /** + * Assert default variant of Listing is rendering correctly. + * + * @param \Symfony\Component\DomCrawler\Crawler $crawler + * The DomCrawler where to check the element. + * @param \Drupal\file\Entity\File $file + * + * Image file added to the list item. + */ + public function assertDefaultListingRendering(Crawler $crawler, File $file): void { + $this->assertCount(6, $crawler->filter('div.listing-item.border-bottom.border-md-0.border-0.card')); + $this->assertCount(6, $crawler->filter('div.mw-listing-img')); + $this->assertCount(6, $crawler->filter('div.card-body.p-0.pb-md-0.pb-3')); + $text_element = $crawler->filter('div.card-text'); + $this->assertCount(6, $text_element); + $this->assertImageRendering($crawler, $file); + } + + /** + * Assert highlight variant of Listing is rendering correctly. + * + * @param \Symfony\Component\DomCrawler\Crawler $crawler + * The DomCrawler where to check the element. + * @param \Drupal\file\Entity\File $file + * Image file added to the list item. + */ + public function assertHighlightListingRendering(Crawler $crawler, File $file): void { + $this->assertCount(6, $crawler->filter('div.listing-item--highlight.border-0.bg-lighter.card')); + $text_element = $crawler->filter('div.card-text'); + $this->assertCount(6, $text_element); + $this->assertImageRendering($crawler, $file); + } + + /** + * Assert Listing is rendering correctly. + * + * @param \Symfony\Component\DomCrawler\Crawler $crawler + * The DomCrawler where to check the element. + * @param int $nid + * Node identifier. + */ + public function assertListingRendering(Crawler $crawler, int $nid): void { + $this->assertCount(1, $crawler->filter('div.bcl-listing')); + $this->assertCount(6, $crawler->filter('div.row-cols-1.g-4 > div.col')); + $this->assertStringContainsString('Listing item block title', trim($crawler->filter('h2.fw-bold')->text())); + $this->assertCount(6, $crawler->filter('h5.card-title')); + $link_element = $crawler->filter('a.text-underline-hover'); + $this->assertCount(6, $link_element); + $this->assertStringContainsString( + 'node/' . $nid, + $link_element->attr('href') + ); + $text_element = $crawler->filter('div.card-text'); + $this->assertStringContainsString('Item title 1', trim($crawler->filter('h5.card-title > a.text-underline-hover')->text())); + $this->assertStringContainsString('Label 1 - 1', trim($crawler->filter('span.badge')->eq(0)->text())); + $this->assertStringContainsString('Label 2 - 1', trim($crawler->filter('span.badge')->eq(1)->text())); + $this->assertStringContainsString( + 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus ut ex tristique, dignissim sem ac, bibendum est.', + $text_element->text() + ); + } + + /** + * Assert image is rendering. + * + * @param \Symfony\Component\DomCrawler\Crawler $crawler + * The DomCrawler where to check the element. + * @param \Drupal\file\Entity\File $file + * Image file added to the card. + */ + public function assertImageRendering(Crawler $crawler, File $file): void { + $image_element = $crawler->filter('.card-img-top'); + $this->assertCount(6, $image_element); + $this->assertStringContainsString( + file_url_transform_relative(file_create_url($file->getFileUri())), + $image_element->attr('src') + ); + $this->assertStringContainsString( + 'Alt for image 1', + $image_element->attr('alt') + ); + } + +} diff --git a/modules/oe_whitelabel_paragraphs/tests/src/Kernel/Traits/RenderTrait.php b/modules/oe_whitelabel_paragraphs/tests/src/Kernel/Traits/RenderTrait.php new file mode 100644 index 00000000..b7864898 --- /dev/null +++ b/modules/oe_whitelabel_paragraphs/tests/src/Kernel/Traits/RenderTrait.php @@ -0,0 +1,30 @@ +<?php + +declare(strict_types = 1); + +namespace Drupal\Tests\oe_whitelabel_paragraphs\Kernel\Traits; + +/** + * Helper rendering trait. + */ +trait RenderTrait { + + /** + * Renders final HTML given a structured array tree. + * + * @param array $elements + * The structured array describing the data to be rendered. + * + * @return string + * The rendered HTML. + * + * @throws \Exception + * When called from inside another renderRoot() call. + * + * @see \Drupal\Core\Render\RendererInterface::render() + */ + protected function renderRoot(array &$elements): string { + return (string) $this->container->get('renderer')->renderRoot($elements); + } + +} -- GitLab From 79ab2f18aaef8408553b0436f781de52f2c37e1d Mon Sep 17 00:00:00 2001 From: Abel Santos <abel.santos.corral@gmail.com> Date: Mon, 14 Mar 2022 11:15:52 +0100 Subject: [PATCH 06/21] OEL-1280: Upgrade packages in composer.json. Upgrade oe_content to 2.8.0 version. Upgrade file_link to 2.6.0 version. --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 9ab60f54..a05611e0 100644 --- a/composer.json +++ b/composer.json @@ -21,7 +21,7 @@ "drupal/ctools": "^3.7", "drupal/description_list_field": "^1.0@alpha", "drupal/drupal-extension": "~4.1", - "drupal/file_link": "^2.0.4", + "drupal/file_link": "^2.0.6", "drupal/pathauto": "^1.8", "drupal/search_api": "^1.21", "drupal/search_api_autocomplete": "^1.5", -- GitLab From f8a807f1fa876d6c661e46236d0817a17854bccf Mon Sep 17 00:00:00 2001 From: Abel Santos <abel.santos.corral@gmail.com> Date: Tue, 15 Mar 2022 17:03:51 +0100 Subject: [PATCH 07/21] OEL-1280: Eliminate patch of oe_bootstrap_theme. --- composer.json | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/composer.json b/composer.json index a05611e0..61f12883 100644 --- a/composer.json +++ b/composer.json @@ -10,7 +10,7 @@ "cweagans/composer-patches": "^1.7", "drupal/core": "^9.2", "drupal/twig_field_value": "^2.0", - "openeuropa/oe_bootstrap_theme": "dev-OEL-1280" + "openeuropa/oe_bootstrap_theme": "0.1280.202203151730" }, "require-dev": { "composer/installers": "^1.11", @@ -67,11 +67,6 @@ } } }, - "patches": { - "openeuropa/oe_bootstrap_theme" : { - "1.x latest": "https://github.com/openeuropa/oe_bootstrap_theme/compare/1.0.0-alpha7..1.x.diff" - } - }, "drupal-scaffold": { "locations": { "web-root": "./build" -- GitLab From 432cca23e911d0de4384c8657f86ad8a2d25cef7 Mon Sep 17 00:00:00 2001 From: Abel Santos <abel.santos.corral@gmail.com> Date: Wed, 16 Mar 2022 17:36:45 +0100 Subject: [PATCH 08/21] OEL-1280: Change the prefix of fields of paragraphs. --- ....oe_description_list.oe_w_orientation.yml} | 6 +- ...graph.oe_facts_figures.oe_w_n_columns.yml} | 6 +- ...nks_block.oe_w_links_block_background.yml} | 6 +- ...ks_block.oe_w_links_block_orientation.yml} | 6 +- ...ia_follow.oe_w_links_block_background.yml} | 6 +- ...paragraph.oe_w_links_block_background.yml} | 4 +- ...aragraph.oe_w_links_block_orientation.yml} | 4 +- ...ield.storage.paragraph.oe_w_n_columns.yml} | 4 +- ...ld.storage.paragraph.oe_w_orientation.yml} | 4 +- ....paragraph.oe_description_list.default.yml | 4 +- ...lay.paragraph.oe_facts_figures.default.yml | 4 +- ...splay.paragraph.oe_links_block.default.yml | 8 +- ...ragraph.oe_social_media_follow.default.yml | 4 +- ....paragraph.oe_description_list.default.yml | 4 +- ...lay.paragraph.oe_facts_figures.default.yml | 4 +- ...ragraph.oe_social_media_follow.default.yml | 4 +- ....paragraph.oe_description_list.default.yml | 4 +- ....paragraph.oe_description_list.default.yml | 4 +- ....oe_description_list.oe_w_orientation.yml} | 6 +- ...ld.storage.paragraph.oe_w_orientation.yml} | 4 +- ...lay.paragraph.oe_facts_figures.default.yml | 4 +- ...lay.paragraph.oe_facts_figures.default.yml | 4 +- ...graph.oe_facts_figures.oe_w_n_columns.yml} | 6 +- ...ield.storage.paragraph.oe_w_n_columns.yml} | 4 +- .../oe_whitelabel_paragraphs.info.yml | 18 +-- .../oe_whitelabel_paragraphs.module | 12 +- .../oe_whitelabel_paragraphs.post_update.php | 8 +- .../tests/src/Functional/ParagraphsTest.php | 150 +++++++++--------- .../src/Kernel/Paragraphs/ContentRowTest.php | 6 +- .../Kernel/Paragraphs/DescriptionListTest.php | 4 +- .../EntityReferenceRevisionTest.php | 4 +- .../Kernel/Paragraphs/FactsFiguresTest.php | 6 +- .../src/Kernel/Paragraphs/LinksBlockTest.php | 12 +- .../Paragraphs/SocialMediaFollowTest.php | 6 +- 34 files changed, 170 insertions(+), 170 deletions(-) rename modules/oe_whitelabel_paragraphs/config/install/{field.field.paragraph.oe_description_list.oe_bt_orientation.yml => field.field.paragraph.oe_description_list.oe_w_orientation.yml} (76%) rename modules/oe_whitelabel_paragraphs/config/{post_updates/00003/field.field.paragraph.oe_facts_figures.oe_bt_n_columns.yml => install/field.field.paragraph.oe_facts_figures.oe_w_n_columns.yml} (78%) rename modules/oe_whitelabel_paragraphs/config/install/{field.field.paragraph.oe_links_block.oe_bt_links_block_background.yml => field.field.paragraph.oe_links_block.oe_w_links_block_background.yml} (71%) rename modules/oe_whitelabel_paragraphs/config/install/{field.field.paragraph.oe_links_block.oe_bt_links_block_orientation.yml => field.field.paragraph.oe_links_block.oe_w_links_block_orientation.yml} (70%) rename modules/oe_whitelabel_paragraphs/config/install/{field.field.paragraph.oe_social_media_follow.oe_bt_links_block_background.yml => field.field.paragraph.oe_social_media_follow.oe_w_links_block_background.yml} (71%) rename modules/oe_whitelabel_paragraphs/config/install/{field.storage.paragraph.oe_bt_links_block_background.yml => field.storage.paragraph.oe_w_links_block_background.yml} (82%) rename modules/oe_whitelabel_paragraphs/config/install/{field.storage.paragraph.oe_bt_links_block_orientation.yml => field.storage.paragraph.oe_w_links_block_orientation.yml} (82%) rename modules/oe_whitelabel_paragraphs/config/{post_updates/00003/field.storage.paragraph.oe_bt_n_columns.yml => install/field.storage.paragraph.oe_w_n_columns.yml} (82%) rename modules/oe_whitelabel_paragraphs/config/install/{field.storage.paragraph.oe_bt_orientation.yml => field.storage.paragraph.oe_w_orientation.yml} (86%) rename modules/oe_whitelabel_paragraphs/config/post_updates/00001/{field.field.paragraph.oe_description_list.oe_bt_orientation.yml => field.field.paragraph.oe_description_list.oe_w_orientation.yml} (76%) rename modules/oe_whitelabel_paragraphs/config/post_updates/00001/{field.storage.paragraph.oe_bt_orientation.yml => field.storage.paragraph.oe_w_orientation.yml} (86%) rename modules/oe_whitelabel_paragraphs/config/{install/field.field.paragraph.oe_facts_figures.oe_bt_n_columns.yml => post_updates/00003/field.field.paragraph.oe_facts_figures.oe_w_n_columns.yml} (78%) rename modules/oe_whitelabel_paragraphs/config/{install/field.storage.paragraph.oe_bt_n_columns.yml => post_updates/00003/field.storage.paragraph.oe_w_n_columns.yml} (82%) diff --git a/modules/oe_whitelabel_paragraphs/config/install/field.field.paragraph.oe_description_list.oe_bt_orientation.yml b/modules/oe_whitelabel_paragraphs/config/install/field.field.paragraph.oe_description_list.oe_w_orientation.yml similarity index 76% rename from modules/oe_whitelabel_paragraphs/config/install/field.field.paragraph.oe_description_list.oe_bt_orientation.yml rename to modules/oe_whitelabel_paragraphs/config/install/field.field.paragraph.oe_description_list.oe_w_orientation.yml index 73b09a47..1e448506 100644 --- a/modules/oe_whitelabel_paragraphs/config/install/field.field.paragraph.oe_description_list.oe_bt_orientation.yml +++ b/modules/oe_whitelabel_paragraphs/config/install/field.field.paragraph.oe_description_list.oe_w_orientation.yml @@ -2,12 +2,12 @@ langcode: en status: true dependencies: config: - - field.storage.paragraph.oe_bt_orientation + - field.storage.paragraph.oe_w_orientation - paragraphs.paragraphs_type.oe_description_list module: - options -id: paragraph.oe_description_list.oe_bt_orientation -field_name: oe_bt_orientation +id: paragraph.oe_description_list.oe_w_orientation +field_name: oe_w_orientation entity_type: paragraph bundle: oe_description_list label: Orientation diff --git a/modules/oe_whitelabel_paragraphs/config/post_updates/00003/field.field.paragraph.oe_facts_figures.oe_bt_n_columns.yml b/modules/oe_whitelabel_paragraphs/config/install/field.field.paragraph.oe_facts_figures.oe_w_n_columns.yml similarity index 78% rename from modules/oe_whitelabel_paragraphs/config/post_updates/00003/field.field.paragraph.oe_facts_figures.oe_bt_n_columns.yml rename to modules/oe_whitelabel_paragraphs/config/install/field.field.paragraph.oe_facts_figures.oe_w_n_columns.yml index eec70a14..0165929a 100644 --- a/modules/oe_whitelabel_paragraphs/config/post_updates/00003/field.field.paragraph.oe_facts_figures.oe_bt_n_columns.yml +++ b/modules/oe_whitelabel_paragraphs/config/install/field.field.paragraph.oe_facts_figures.oe_w_n_columns.yml @@ -2,10 +2,10 @@ langcode: en status: true dependencies: config: - - field.storage.paragraph.oe_bt_n_columns + - field.storage.paragraph.oe_w_n_columns - paragraphs.paragraphs_type.oe_facts_figures -id: paragraph.oe_facts_figures.oe_bt_n_columns -field_name: oe_bt_n_columns +id: paragraph.oe_facts_figures.oe_w_n_columns +field_name: oe_w_n_columns entity_type: paragraph bundle: oe_facts_figures label: 'Number of columns' diff --git a/modules/oe_whitelabel_paragraphs/config/install/field.field.paragraph.oe_links_block.oe_bt_links_block_background.yml b/modules/oe_whitelabel_paragraphs/config/install/field.field.paragraph.oe_links_block.oe_w_links_block_background.yml similarity index 71% rename from modules/oe_whitelabel_paragraphs/config/install/field.field.paragraph.oe_links_block.oe_bt_links_block_background.yml rename to modules/oe_whitelabel_paragraphs/config/install/field.field.paragraph.oe_links_block.oe_w_links_block_background.yml index de66c697..5ac9c728 100644 --- a/modules/oe_whitelabel_paragraphs/config/install/field.field.paragraph.oe_links_block.oe_bt_links_block_background.yml +++ b/modules/oe_whitelabel_paragraphs/config/install/field.field.paragraph.oe_links_block.oe_w_links_block_background.yml @@ -2,12 +2,12 @@ langcode: en status: true dependencies: config: - - field.storage.paragraph.oe_bt_links_block_background + - field.storage.paragraph.oe_w_links_block_background - paragraphs.paragraphs_type.oe_links_block module: - options -id: paragraph.oe_links_block.oe_bt_links_block_background -field_name: oe_bt_links_block_background +id: paragraph.oe_links_block.oe_w_links_block_background +field_name: oe_w_links_block_background entity_type: paragraph bundle: oe_links_block label: Background diff --git a/modules/oe_whitelabel_paragraphs/config/install/field.field.paragraph.oe_links_block.oe_bt_links_block_orientation.yml b/modules/oe_whitelabel_paragraphs/config/install/field.field.paragraph.oe_links_block.oe_w_links_block_orientation.yml similarity index 70% rename from modules/oe_whitelabel_paragraphs/config/install/field.field.paragraph.oe_links_block.oe_bt_links_block_orientation.yml rename to modules/oe_whitelabel_paragraphs/config/install/field.field.paragraph.oe_links_block.oe_w_links_block_orientation.yml index 610c35d3..2b3bf721 100644 --- a/modules/oe_whitelabel_paragraphs/config/install/field.field.paragraph.oe_links_block.oe_bt_links_block_orientation.yml +++ b/modules/oe_whitelabel_paragraphs/config/install/field.field.paragraph.oe_links_block.oe_w_links_block_orientation.yml @@ -2,12 +2,12 @@ langcode: en status: true dependencies: config: - - field.storage.paragraph.oe_bt_links_block_orientation + - field.storage.paragraph.oe_w_links_block_orientation - paragraphs.paragraphs_type.oe_links_block module: - options -id: paragraph.oe_links_block.oe_bt_links_block_orientation -field_name: oe_bt_links_block_orientation +id: paragraph.oe_links_block.oe_w_links_block_orientation +field_name: oe_w_links_block_orientation entity_type: paragraph bundle: oe_links_block label: Orientation diff --git a/modules/oe_whitelabel_paragraphs/config/install/field.field.paragraph.oe_social_media_follow.oe_bt_links_block_background.yml b/modules/oe_whitelabel_paragraphs/config/install/field.field.paragraph.oe_social_media_follow.oe_w_links_block_background.yml similarity index 71% rename from modules/oe_whitelabel_paragraphs/config/install/field.field.paragraph.oe_social_media_follow.oe_bt_links_block_background.yml rename to modules/oe_whitelabel_paragraphs/config/install/field.field.paragraph.oe_social_media_follow.oe_w_links_block_background.yml index 8e167195..2d8fae09 100644 --- a/modules/oe_whitelabel_paragraphs/config/install/field.field.paragraph.oe_social_media_follow.oe_bt_links_block_background.yml +++ b/modules/oe_whitelabel_paragraphs/config/install/field.field.paragraph.oe_social_media_follow.oe_w_links_block_background.yml @@ -2,12 +2,12 @@ langcode: en status: true dependencies: config: - - field.storage.paragraph.oe_bt_links_block_background + - field.storage.paragraph.oe_w_links_block_background - paragraphs.paragraphs_type.oe_social_media_follow module: - options -id: paragraph.oe_social_media_follow.oe_bt_links_block_background -field_name: oe_bt_links_block_background +id: paragraph.oe_social_media_follow.oe_w_links_block_background +field_name: oe_w_links_block_background entity_type: paragraph bundle: oe_social_media_follow label: Background diff --git a/modules/oe_whitelabel_paragraphs/config/install/field.storage.paragraph.oe_bt_links_block_background.yml b/modules/oe_whitelabel_paragraphs/config/install/field.storage.paragraph.oe_w_links_block_background.yml similarity index 82% rename from modules/oe_whitelabel_paragraphs/config/install/field.storage.paragraph.oe_bt_links_block_background.yml rename to modules/oe_whitelabel_paragraphs/config/install/field.storage.paragraph.oe_w_links_block_background.yml index 1a7dbec0..28999496 100644 --- a/modules/oe_whitelabel_paragraphs/config/install/field.storage.paragraph.oe_bt_links_block_background.yml +++ b/modules/oe_whitelabel_paragraphs/config/install/field.storage.paragraph.oe_w_links_block_background.yml @@ -4,8 +4,8 @@ dependencies: module: - options - paragraphs -id: paragraph.oe_bt_links_block_background -field_name: oe_bt_links_block_background +id: paragraph.oe_w_links_block_background +field_name: oe_w_links_block_background entity_type: paragraph type: list_string settings: diff --git a/modules/oe_whitelabel_paragraphs/config/install/field.storage.paragraph.oe_bt_links_block_orientation.yml b/modules/oe_whitelabel_paragraphs/config/install/field.storage.paragraph.oe_w_links_block_orientation.yml similarity index 82% rename from modules/oe_whitelabel_paragraphs/config/install/field.storage.paragraph.oe_bt_links_block_orientation.yml rename to modules/oe_whitelabel_paragraphs/config/install/field.storage.paragraph.oe_w_links_block_orientation.yml index d582eb81..afdf66e7 100644 --- a/modules/oe_whitelabel_paragraphs/config/install/field.storage.paragraph.oe_bt_links_block_orientation.yml +++ b/modules/oe_whitelabel_paragraphs/config/install/field.storage.paragraph.oe_w_links_block_orientation.yml @@ -4,8 +4,8 @@ dependencies: module: - options - paragraphs -id: paragraph.oe_bt_links_block_orientation -field_name: oe_bt_links_block_orientation +id: paragraph.oe_w_links_block_orientation +field_name: oe_w_links_block_orientation entity_type: paragraph type: list_string settings: diff --git a/modules/oe_whitelabel_paragraphs/config/post_updates/00003/field.storage.paragraph.oe_bt_n_columns.yml b/modules/oe_whitelabel_paragraphs/config/install/field.storage.paragraph.oe_w_n_columns.yml similarity index 82% rename from modules/oe_whitelabel_paragraphs/config/post_updates/00003/field.storage.paragraph.oe_bt_n_columns.yml rename to modules/oe_whitelabel_paragraphs/config/install/field.storage.paragraph.oe_w_n_columns.yml index f2a74071..3a1a9cbc 100644 --- a/modules/oe_whitelabel_paragraphs/config/post_updates/00003/field.storage.paragraph.oe_bt_n_columns.yml +++ b/modules/oe_whitelabel_paragraphs/config/install/field.storage.paragraph.oe_w_n_columns.yml @@ -3,8 +3,8 @@ status: true dependencies: module: - paragraphs -id: paragraph.oe_bt_n_columns -field_name: oe_bt_n_columns +id: paragraph.oe_w_n_columns +field_name: oe_w_n_columns entity_type: paragraph type: integer settings: diff --git a/modules/oe_whitelabel_paragraphs/config/install/field.storage.paragraph.oe_bt_orientation.yml b/modules/oe_whitelabel_paragraphs/config/install/field.storage.paragraph.oe_w_orientation.yml similarity index 86% rename from modules/oe_whitelabel_paragraphs/config/install/field.storage.paragraph.oe_bt_orientation.yml rename to modules/oe_whitelabel_paragraphs/config/install/field.storage.paragraph.oe_w_orientation.yml index 94f290a8..f277e814 100644 --- a/modules/oe_whitelabel_paragraphs/config/install/field.storage.paragraph.oe_bt_orientation.yml +++ b/modules/oe_whitelabel_paragraphs/config/install/field.storage.paragraph.oe_w_orientation.yml @@ -4,8 +4,8 @@ dependencies: module: - options - paragraphs -id: paragraph.oe_bt_orientation -field_name: oe_bt_orientation +id: paragraph.oe_w_orientation +field_name: oe_w_orientation entity_type: paragraph type: list_string settings: diff --git a/modules/oe_whitelabel_paragraphs/config/overrides/core.entity_form_display.paragraph.oe_description_list.default.yml b/modules/oe_whitelabel_paragraphs/config/overrides/core.entity_form_display.paragraph.oe_description_list.default.yml index 363809de..0391e256 100644 --- a/modules/oe_whitelabel_paragraphs/config/overrides/core.entity_form_display.paragraph.oe_description_list.default.yml +++ b/modules/oe_whitelabel_paragraphs/config/overrides/core.entity_form_display.paragraph.oe_description_list.default.yml @@ -4,7 +4,7 @@ dependencies: config: - field.field.paragraph.oe_description_list.field_oe_description_list_items - field.field.paragraph.oe_description_list.field_oe_title - - field.field.paragraph.oe_description_list.oe_bt_orientation + - field.field.paragraph.oe_description_list.oe_w_orientation - paragraphs.paragraphs_type.oe_description_list module: - description_list_field @@ -27,7 +27,7 @@ content: third_party_settings: { } type: string_textfield region: content - oe_bt_orientation: + oe_w_orientation: type: options_select weight: 0 region: content diff --git a/modules/oe_whitelabel_paragraphs/config/overrides/core.entity_form_display.paragraph.oe_facts_figures.default.yml b/modules/oe_whitelabel_paragraphs/config/overrides/core.entity_form_display.paragraph.oe_facts_figures.default.yml index 96a0c1fb..d12c5363 100644 --- a/modules/oe_whitelabel_paragraphs/config/overrides/core.entity_form_display.paragraph.oe_facts_figures.default.yml +++ b/modules/oe_whitelabel_paragraphs/config/overrides/core.entity_form_display.paragraph.oe_facts_figures.default.yml @@ -5,7 +5,7 @@ dependencies: - field.field.paragraph.oe_facts_figures.field_oe_link - field.field.paragraph.oe_facts_figures.field_oe_paragraphs - field.field.paragraph.oe_facts_figures.field_oe_title - - field.field.paragraph.oe_facts_figures.oe_bt_n_columns + - field.field.paragraph.oe_facts_figures.oe_w_n_columns - paragraphs.paragraphs_type.oe_facts_figures module: - link @@ -49,7 +49,7 @@ content: size: 60 placeholder: '' third_party_settings: { } - oe_bt_n_columns: + oe_w_n_columns: weight: 6 settings: placeholder: '' diff --git a/modules/oe_whitelabel_paragraphs/config/overrides/core.entity_form_display.paragraph.oe_links_block.default.yml b/modules/oe_whitelabel_paragraphs/config/overrides/core.entity_form_display.paragraph.oe_links_block.default.yml index 1fab747a..0e2b032e 100644 --- a/modules/oe_whitelabel_paragraphs/config/overrides/core.entity_form_display.paragraph.oe_links_block.default.yml +++ b/modules/oe_whitelabel_paragraphs/config/overrides/core.entity_form_display.paragraph.oe_links_block.default.yml @@ -3,8 +3,8 @@ status: true dependencies: config: - field.field.paragraph.oe_links_block.field_oe_links - - field.field.paragraph.oe_links_block.oe_bt_links_block_background - - field.field.paragraph.oe_links_block.oe_bt_links_block_orientation + - field.field.paragraph.oe_links_block.oe_w_links_block_background + - field.field.paragraph.oe_links_block.oe_w_links_block_orientation - field.field.paragraph.oe_links_block.field_oe_text - paragraphs.paragraphs_type.oe_links_block module: @@ -22,13 +22,13 @@ content: third_party_settings: { } type: link_default region: content - oe_bt_links_block_background: + oe_w_links_block_background: weight: 1 settings: { } third_party_settings: { } type: options_select region: content - oe_bt_links_block_orientation: + oe_w_links_block_orientation: weight: 0 settings: { } third_party_settings: { } diff --git a/modules/oe_whitelabel_paragraphs/config/overrides/core.entity_form_display.paragraph.oe_social_media_follow.default.yml b/modules/oe_whitelabel_paragraphs/config/overrides/core.entity_form_display.paragraph.oe_social_media_follow.default.yml index 8b7cd07f..95a38469 100644 --- a/modules/oe_whitelabel_paragraphs/config/overrides/core.entity_form_display.paragraph.oe_social_media_follow.default.yml +++ b/modules/oe_whitelabel_paragraphs/config/overrides/core.entity_form_display.paragraph.oe_social_media_follow.default.yml @@ -2,7 +2,7 @@ langcode: en status: true dependencies: config: - - field.field.paragraph.oe_social_media_follow.oe_bt_links_block_background + - field.field.paragraph.oe_social_media_follow.oe_w_links_block_background - field.field.paragraph.oe_social_media_follow.field_oe_social_media_links - field.field.paragraph.oe_social_media_follow.field_oe_social_media_see_more - field.field.paragraph.oe_social_media_follow.field_oe_social_media_variant @@ -16,7 +16,7 @@ targetEntityType: paragraph bundle: oe_social_media_follow mode: default content: - oe_bt_links_block_background: + oe_w_links_block_background: type: options_select weight: 1 region: content diff --git a/modules/oe_whitelabel_paragraphs/config/overrides/core.entity_view_display.paragraph.oe_description_list.default.yml b/modules/oe_whitelabel_paragraphs/config/overrides/core.entity_view_display.paragraph.oe_description_list.default.yml index 2e3b81d7..b303a9e9 100644 --- a/modules/oe_whitelabel_paragraphs/config/overrides/core.entity_view_display.paragraph.oe_description_list.default.yml +++ b/modules/oe_whitelabel_paragraphs/config/overrides/core.entity_view_display.paragraph.oe_description_list.default.yml @@ -2,7 +2,7 @@ langcode: en status: true dependencies: config: - - field.field.paragraph.oe_description_list.oe_bt_orientation + - field.field.paragraph.oe_description_list.oe_w_orientation - field.field.paragraph.oe_description_list.field_oe_description_list_items - field.field.paragraph.oe_description_list.field_oe_title - paragraphs.paragraphs_type.oe_description_list @@ -29,4 +29,4 @@ content: type: string region: content hidden: - oe_bt_orientation: true + oe_w_orientation: true diff --git a/modules/oe_whitelabel_paragraphs/config/overrides/core.entity_view_display.paragraph.oe_facts_figures.default.yml b/modules/oe_whitelabel_paragraphs/config/overrides/core.entity_view_display.paragraph.oe_facts_figures.default.yml index e9dd9cf6..6b3d6961 100644 --- a/modules/oe_whitelabel_paragraphs/config/overrides/core.entity_view_display.paragraph.oe_facts_figures.default.yml +++ b/modules/oe_whitelabel_paragraphs/config/overrides/core.entity_view_display.paragraph.oe_facts_figures.default.yml @@ -5,7 +5,7 @@ dependencies: - field.field.paragraph.oe_facts_figures.field_oe_link - field.field.paragraph.oe_facts_figures.field_oe_paragraphs - field.field.paragraph.oe_facts_figures.field_oe_title - - field.field.paragraph.oe_facts_figures.oe_bt_n_columns + - field.field.paragraph.oe_facts_figures.oe_w_n_columns - paragraphs.paragraphs_type.oe_facts_figures module: - entity_reference_revisions @@ -45,4 +45,4 @@ content: type: string region: content hidden: - oe_bt_n_columns: true + oe_w_n_columns: true diff --git a/modules/oe_whitelabel_paragraphs/config/overrides/core.entity_view_display.paragraph.oe_social_media_follow.default.yml b/modules/oe_whitelabel_paragraphs/config/overrides/core.entity_view_display.paragraph.oe_social_media_follow.default.yml index 8e15a231..1177db68 100644 --- a/modules/oe_whitelabel_paragraphs/config/overrides/core.entity_view_display.paragraph.oe_social_media_follow.default.yml +++ b/modules/oe_whitelabel_paragraphs/config/overrides/core.entity_view_display.paragraph.oe_social_media_follow.default.yml @@ -2,7 +2,7 @@ langcode: en status: true dependencies: config: - - field.field.paragraph.oe_social_media_follow.oe_bt_links_block_background + - field.field.paragraph.oe_social_media_follow.oe_w_links_block_background - field.field.paragraph.oe_social_media_follow.field_oe_social_media_links - field.field.paragraph.oe_social_media_follow.field_oe_social_media_see_more - field.field.paragraph.oe_social_media_follow.field_oe_social_media_variant @@ -49,5 +49,5 @@ content: type: string region: content hidden: - oe_bt_links_block_background: true + oe_w_links_block_background: true field_oe_social_media_variant: true diff --git a/modules/oe_whitelabel_paragraphs/config/post_updates/00001/core.entity_form_display.paragraph.oe_description_list.default.yml b/modules/oe_whitelabel_paragraphs/config/post_updates/00001/core.entity_form_display.paragraph.oe_description_list.default.yml index 363809de..0391e256 100644 --- a/modules/oe_whitelabel_paragraphs/config/post_updates/00001/core.entity_form_display.paragraph.oe_description_list.default.yml +++ b/modules/oe_whitelabel_paragraphs/config/post_updates/00001/core.entity_form_display.paragraph.oe_description_list.default.yml @@ -4,7 +4,7 @@ dependencies: config: - field.field.paragraph.oe_description_list.field_oe_description_list_items - field.field.paragraph.oe_description_list.field_oe_title - - field.field.paragraph.oe_description_list.oe_bt_orientation + - field.field.paragraph.oe_description_list.oe_w_orientation - paragraphs.paragraphs_type.oe_description_list module: - description_list_field @@ -27,7 +27,7 @@ content: third_party_settings: { } type: string_textfield region: content - oe_bt_orientation: + oe_w_orientation: type: options_select weight: 0 region: content diff --git a/modules/oe_whitelabel_paragraphs/config/post_updates/00001/core.entity_view_display.paragraph.oe_description_list.default.yml b/modules/oe_whitelabel_paragraphs/config/post_updates/00001/core.entity_view_display.paragraph.oe_description_list.default.yml index 2e3b81d7..b303a9e9 100644 --- a/modules/oe_whitelabel_paragraphs/config/post_updates/00001/core.entity_view_display.paragraph.oe_description_list.default.yml +++ b/modules/oe_whitelabel_paragraphs/config/post_updates/00001/core.entity_view_display.paragraph.oe_description_list.default.yml @@ -2,7 +2,7 @@ langcode: en status: true dependencies: config: - - field.field.paragraph.oe_description_list.oe_bt_orientation + - field.field.paragraph.oe_description_list.oe_w_orientation - field.field.paragraph.oe_description_list.field_oe_description_list_items - field.field.paragraph.oe_description_list.field_oe_title - paragraphs.paragraphs_type.oe_description_list @@ -29,4 +29,4 @@ content: type: string region: content hidden: - oe_bt_orientation: true + oe_w_orientation: true diff --git a/modules/oe_whitelabel_paragraphs/config/post_updates/00001/field.field.paragraph.oe_description_list.oe_bt_orientation.yml b/modules/oe_whitelabel_paragraphs/config/post_updates/00001/field.field.paragraph.oe_description_list.oe_w_orientation.yml similarity index 76% rename from modules/oe_whitelabel_paragraphs/config/post_updates/00001/field.field.paragraph.oe_description_list.oe_bt_orientation.yml rename to modules/oe_whitelabel_paragraphs/config/post_updates/00001/field.field.paragraph.oe_description_list.oe_w_orientation.yml index 73b09a47..1e448506 100644 --- a/modules/oe_whitelabel_paragraphs/config/post_updates/00001/field.field.paragraph.oe_description_list.oe_bt_orientation.yml +++ b/modules/oe_whitelabel_paragraphs/config/post_updates/00001/field.field.paragraph.oe_description_list.oe_w_orientation.yml @@ -2,12 +2,12 @@ langcode: en status: true dependencies: config: - - field.storage.paragraph.oe_bt_orientation + - field.storage.paragraph.oe_w_orientation - paragraphs.paragraphs_type.oe_description_list module: - options -id: paragraph.oe_description_list.oe_bt_orientation -field_name: oe_bt_orientation +id: paragraph.oe_description_list.oe_w_orientation +field_name: oe_w_orientation entity_type: paragraph bundle: oe_description_list label: Orientation diff --git a/modules/oe_whitelabel_paragraphs/config/post_updates/00001/field.storage.paragraph.oe_bt_orientation.yml b/modules/oe_whitelabel_paragraphs/config/post_updates/00001/field.storage.paragraph.oe_w_orientation.yml similarity index 86% rename from modules/oe_whitelabel_paragraphs/config/post_updates/00001/field.storage.paragraph.oe_bt_orientation.yml rename to modules/oe_whitelabel_paragraphs/config/post_updates/00001/field.storage.paragraph.oe_w_orientation.yml index 94f290a8..f277e814 100644 --- a/modules/oe_whitelabel_paragraphs/config/post_updates/00001/field.storage.paragraph.oe_bt_orientation.yml +++ b/modules/oe_whitelabel_paragraphs/config/post_updates/00001/field.storage.paragraph.oe_w_orientation.yml @@ -4,8 +4,8 @@ dependencies: module: - options - paragraphs -id: paragraph.oe_bt_orientation -field_name: oe_bt_orientation +id: paragraph.oe_w_orientation +field_name: oe_w_orientation entity_type: paragraph type: list_string settings: diff --git a/modules/oe_whitelabel_paragraphs/config/post_updates/00003/core.entity_form_display.paragraph.oe_facts_figures.default.yml b/modules/oe_whitelabel_paragraphs/config/post_updates/00003/core.entity_form_display.paragraph.oe_facts_figures.default.yml index 96a0c1fb..d12c5363 100644 --- a/modules/oe_whitelabel_paragraphs/config/post_updates/00003/core.entity_form_display.paragraph.oe_facts_figures.default.yml +++ b/modules/oe_whitelabel_paragraphs/config/post_updates/00003/core.entity_form_display.paragraph.oe_facts_figures.default.yml @@ -5,7 +5,7 @@ dependencies: - field.field.paragraph.oe_facts_figures.field_oe_link - field.field.paragraph.oe_facts_figures.field_oe_paragraphs - field.field.paragraph.oe_facts_figures.field_oe_title - - field.field.paragraph.oe_facts_figures.oe_bt_n_columns + - field.field.paragraph.oe_facts_figures.oe_w_n_columns - paragraphs.paragraphs_type.oe_facts_figures module: - link @@ -49,7 +49,7 @@ content: size: 60 placeholder: '' third_party_settings: { } - oe_bt_n_columns: + oe_w_n_columns: weight: 6 settings: placeholder: '' diff --git a/modules/oe_whitelabel_paragraphs/config/post_updates/00003/core.entity_view_display.paragraph.oe_facts_figures.default.yml b/modules/oe_whitelabel_paragraphs/config/post_updates/00003/core.entity_view_display.paragraph.oe_facts_figures.default.yml index e9dd9cf6..6b3d6961 100644 --- a/modules/oe_whitelabel_paragraphs/config/post_updates/00003/core.entity_view_display.paragraph.oe_facts_figures.default.yml +++ b/modules/oe_whitelabel_paragraphs/config/post_updates/00003/core.entity_view_display.paragraph.oe_facts_figures.default.yml @@ -5,7 +5,7 @@ dependencies: - field.field.paragraph.oe_facts_figures.field_oe_link - field.field.paragraph.oe_facts_figures.field_oe_paragraphs - field.field.paragraph.oe_facts_figures.field_oe_title - - field.field.paragraph.oe_facts_figures.oe_bt_n_columns + - field.field.paragraph.oe_facts_figures.oe_w_n_columns - paragraphs.paragraphs_type.oe_facts_figures module: - entity_reference_revisions @@ -45,4 +45,4 @@ content: type: string region: content hidden: - oe_bt_n_columns: true + oe_w_n_columns: true diff --git a/modules/oe_whitelabel_paragraphs/config/install/field.field.paragraph.oe_facts_figures.oe_bt_n_columns.yml b/modules/oe_whitelabel_paragraphs/config/post_updates/00003/field.field.paragraph.oe_facts_figures.oe_w_n_columns.yml similarity index 78% rename from modules/oe_whitelabel_paragraphs/config/install/field.field.paragraph.oe_facts_figures.oe_bt_n_columns.yml rename to modules/oe_whitelabel_paragraphs/config/post_updates/00003/field.field.paragraph.oe_facts_figures.oe_w_n_columns.yml index eec70a14..0165929a 100644 --- a/modules/oe_whitelabel_paragraphs/config/install/field.field.paragraph.oe_facts_figures.oe_bt_n_columns.yml +++ b/modules/oe_whitelabel_paragraphs/config/post_updates/00003/field.field.paragraph.oe_facts_figures.oe_w_n_columns.yml @@ -2,10 +2,10 @@ langcode: en status: true dependencies: config: - - field.storage.paragraph.oe_bt_n_columns + - field.storage.paragraph.oe_w_n_columns - paragraphs.paragraphs_type.oe_facts_figures -id: paragraph.oe_facts_figures.oe_bt_n_columns -field_name: oe_bt_n_columns +id: paragraph.oe_facts_figures.oe_w_n_columns +field_name: oe_w_n_columns entity_type: paragraph bundle: oe_facts_figures label: 'Number of columns' diff --git a/modules/oe_whitelabel_paragraphs/config/install/field.storage.paragraph.oe_bt_n_columns.yml b/modules/oe_whitelabel_paragraphs/config/post_updates/00003/field.storage.paragraph.oe_w_n_columns.yml similarity index 82% rename from modules/oe_whitelabel_paragraphs/config/install/field.storage.paragraph.oe_bt_n_columns.yml rename to modules/oe_whitelabel_paragraphs/config/post_updates/00003/field.storage.paragraph.oe_w_n_columns.yml index f2a74071..3a1a9cbc 100644 --- a/modules/oe_whitelabel_paragraphs/config/install/field.storage.paragraph.oe_bt_n_columns.yml +++ b/modules/oe_whitelabel_paragraphs/config/post_updates/00003/field.storage.paragraph.oe_w_n_columns.yml @@ -3,8 +3,8 @@ status: true dependencies: module: - paragraphs -id: paragraph.oe_bt_n_columns -field_name: oe_bt_n_columns +id: paragraph.oe_w_n_columns +field_name: oe_w_n_columns entity_type: paragraph type: integer settings: diff --git a/modules/oe_whitelabel_paragraphs/oe_whitelabel_paragraphs.info.yml b/modules/oe_whitelabel_paragraphs/oe_whitelabel_paragraphs.info.yml index 5f237ddd..649b4b57 100644 --- a/modules/oe_whitelabel_paragraphs/oe_whitelabel_paragraphs.info.yml +++ b/modules/oe_whitelabel_paragraphs/oe_whitelabel_paragraphs.info.yml @@ -12,12 +12,12 @@ dependencies: - oe_paragraphs:oe_paragraphs_description_list config_devel: install: - - field.field.paragraph.oe_links_block.oe_bt_links_block_background - - field.field.paragraph.oe_links_block.oe_bt_links_block_orientation - - field.field.paragraph.oe_social_media_follow.oe_bt_links_block_background - - field.field.paragraph.oe_facts_figures.oe_bt_n_columns - - field.storage.paragraph.oe_bt_links_block_orientation - - field.storage.paragraph.oe_bt_links_block_background - - field.field.paragraph.oe_description_list.oe_bt_orientation - - field.storage.paragraph.oe_bt_orientation - - field.storage.paragraph.oe_bt_n_columns + - field.field.paragraph.oe_links_block.oe_w_links_block_background + - field.field.paragraph.oe_links_block.oe_w_links_block_orientation + - field.field.paragraph.oe_social_media_follow.oe_w_links_block_background + - field.field.paragraph.oe_facts_figures.oe_w_n_columns + - field.storage.paragraph.oe_w_links_block_orientation + - field.storage.paragraph.oe_w_links_block_background + - field.field.paragraph.oe_description_list.oe_w_orientation + - field.storage.paragraph.oe_w_orientation + - field.storage.paragraph.oe_w_n_columns diff --git a/modules/oe_whitelabel_paragraphs/oe_whitelabel_paragraphs.module b/modules/oe_whitelabel_paragraphs/oe_whitelabel_paragraphs.module index d70b613b..f6e641c3 100644 --- a/modules/oe_whitelabel_paragraphs/oe_whitelabel_paragraphs.module +++ b/modules/oe_whitelabel_paragraphs/oe_whitelabel_paragraphs.module @@ -47,8 +47,8 @@ function oe_whitelabel_paragraphs_theme_suggestions_field_alter(array &$suggesti function oe_whitelabel_paragraphs_preprocess_paragraph__oe_links_block(array &$variables): void { /** @var \Drupal\paragraphs\Entity\Paragraph $paragraph */ $paragraph = $variables['paragraph']; - $variables['orientation'] = $paragraph->get('oe_bt_links_block_orientation')->value; - $variables['background'] = $paragraph->get('oe_bt_links_block_background')->value; + $variables['orientation'] = $paragraph->get('oe_w_links_block_orientation')->value; + $variables['background'] = $paragraph->get('oe_w_links_block_background')->value; if (!$paragraph->get('field_oe_text')->isEmpty()) { $variables['title'] = $paragraph->get('field_oe_text')->value; } @@ -68,7 +68,7 @@ function oe_whitelabel_preprocess_paragraph__oe_social_media_follow(array &$vari /** @var \Drupal\paragraphs\Entity\Paragraph $paragraph */ $paragraph = $variables['paragraph']; $variables['orientation'] = $paragraph->get('field_oe_social_media_variant')->value; - $variables['background'] = $paragraph->get('oe_bt_links_block_background')->value; + $variables['background'] = $paragraph->get('oe_w_links_block_background')->value; if (!$paragraph->get('field_oe_title')->isEmpty()) { $variables['title'] = $paragraph->get('field_oe_title')->value; } @@ -406,7 +406,7 @@ function oe_whitelabel_preprocess_paragraph__oe_description_list(array &$variabl /** @var Drupal\paragraphs\Entity\Paragraph $paragraph */ $paragraph = $variables['paragraph']; $variables['title'] = $paragraph->get('field_oe_title')->value ?? ''; - $variables['orientation'] = $paragraph->get('oe_bt_orientation')->value; + $variables['orientation'] = $paragraph->get('oe_w_orientation')->value; foreach ($paragraph->get('field_oe_description_list_items') as $item) { $variables['items'][] = [ @@ -450,8 +450,8 @@ function oe_whitelabel_preprocess_paragraph__oe_facts_figures(array &$variables) ]; } - if (!$paragraph->get('oe_bt_n_columns')->isEmpty()) { - $variables['columns'] = $paragraph->get('oe_bt_n_columns')->value; + if (!$paragraph->get('oe_w_n_columns')->isEmpty()) { + $variables['columns'] = $paragraph->get('oe_w_n_columns')->value; } } diff --git a/modules/oe_whitelabel_paragraphs/oe_whitelabel_paragraphs.post_update.php b/modules/oe_whitelabel_paragraphs/oe_whitelabel_paragraphs.post_update.php index b358b83b..142f335d 100644 --- a/modules/oe_whitelabel_paragraphs/oe_whitelabel_paragraphs.post_update.php +++ b/modules/oe_whitelabel_paragraphs/oe_whitelabel_paragraphs.post_update.php @@ -16,8 +16,8 @@ function oe_whitelabel_paragraphs_post_update_00001(array &$sandbox): void { \Drupal::service('module_installer')->install(['oe_paragraphs_description_list']); $configs = [ - 'field.storage.paragraph.oe_bt_orientation', - 'field.field.paragraph.oe_description_list.oe_bt_orientation', + 'field.storage.paragraph.oe_w_orientation', + 'field.field.paragraph.oe_description_list.oe_w_orientation', 'core.entity_form_display.paragraph.oe_description_list.default', 'core.entity_view_display.paragraph.oe_description_list.default', ]; @@ -42,8 +42,8 @@ function oe_whitelabel_paragraphs_post_update_00002(array &$sandbox): void { */ function oe_whitelabel_paragraphs_post_update_00003(array &$sandbox): void { $configs = [ - 'field.storage.paragraph.oe_bt_n_columns', - 'field.field.paragraph.oe_facts_figures.oe_bt_n_columns', + 'field.storage.paragraph.oe_w_n_columns', + 'field.field.paragraph.oe_facts_figures.oe_w_n_columns', 'core.entity_form_display.paragraph.oe_facts_figures.default', 'core.entity_view_display.paragraph.oe_facts_figures.default', ]; diff --git a/modules/oe_whitelabel_paragraphs/tests/src/Functional/ParagraphsTest.php b/modules/oe_whitelabel_paragraphs/tests/src/Functional/ParagraphsTest.php index e8ec1ef8..87956076 100644 --- a/modules/oe_whitelabel_paragraphs/tests/src/Functional/ParagraphsTest.php +++ b/modules/oe_whitelabel_paragraphs/tests/src/Functional/ParagraphsTest.php @@ -44,23 +44,23 @@ class ParagraphsTest extends BrowserTestBase { $this->getSession()->getPage()->pressButton('Add Links block'); // Assert the Links Block fields appears. - $this->assertSession()->fieldExists('oe_bt_paragraphs[0][subform][field_oe_links][0][uri]'); - $this->assertSession()->fieldExists('oe_bt_paragraphs[0][subform][field_oe_links][0][title]'); - $this->assertSession()->fieldExists('oe_bt_paragraphs[0][subform][field_oe_text][0][value]'); - $this->assertSession()->fieldExists('oe_bt_paragraphs[0][subform][oe_bt_links_block_background]'); - $this->assertSession()->fieldExists('oe_bt_paragraphs[0][subform][oe_bt_links_block_orientation]'); + $this->assertSession()->fieldExists('oe_w_paragraphs[0][subform][field_oe_links][0][uri]'); + $this->assertSession()->fieldExists('oe_w_paragraphs[0][subform][field_oe_links][0][title]'); + $this->assertSession()->fieldExists('oe_w_paragraphs[0][subform][field_oe_text][0][value]'); + $this->assertSession()->fieldExists('oe_w_paragraphs[0][subform][oe_w_links_block_background]'); + $this->assertSession()->fieldExists('oe_w_paragraphs[0][subform][oe_w_links_block_orientation]'); $this->submitForm([], 'Add another item'); $values = [ 'title[0][value]' => 'Test Links block node title', - 'oe_bt_paragraphs[0][subform][field_oe_text][0][value]' => 'EU Links', - 'oe_bt_paragraphs[0][subform][field_oe_links][0][uri]' => 'https://www.example.com', - 'oe_bt_paragraphs[0][subform][field_oe_links][0][title]' => 'Example link number 1', - 'oe_bt_paragraphs[0][subform][field_oe_links][1][uri]' => 'https://www.more-example.com', - 'oe_bt_paragraphs[0][subform][field_oe_links][1][title]' => 'Example link number 2', - 'oe_bt_paragraphs[0][subform][oe_bt_links_block_background]' => 'gray', - 'oe_bt_paragraphs[0][subform][oe_bt_links_block_orientation]' => 'vertical', + 'oe_w_paragraphs[0][subform][field_oe_text][0][value]' => 'EU Links', + 'oe_w_paragraphs[0][subform][field_oe_links][0][uri]' => 'https://www.example.com', + 'oe_w_paragraphs[0][subform][field_oe_links][0][title]' => 'Example link number 1', + 'oe_w_paragraphs[0][subform][field_oe_links][1][uri]' => 'https://www.more-example.com', + 'oe_w_paragraphs[0][subform][field_oe_links][1][title]' => 'Example link number 2', + 'oe_w_paragraphs[0][subform][oe_w_links_block_background]' => 'gray', + 'oe_w_paragraphs[0][subform][oe_w_links_block_orientation]' => 'vertical', ]; $this->submitForm($values, 'Save'); @@ -80,27 +80,27 @@ class ParagraphsTest extends BrowserTestBase { $this->getSession()->getPage()->pressButton('Add Social media follow'); // Assert the Social Media Follow fields appears. - $this->assertSession()->fieldExists('oe_bt_paragraphs[0][subform][field_oe_social_media_links][0][uri]'); - $this->assertSession()->fieldExists('oe_bt_paragraphs[0][subform][field_oe_social_media_links][0][title]'); - $this->assertSession()->fieldExists('oe_bt_paragraphs[0][subform][field_oe_social_media_links][0][link_type]'); - $this->assertSession()->fieldExists('oe_bt_paragraphs[0][subform][field_oe_title][0][value]'); - $this->assertSession()->fieldExists('oe_bt_paragraphs[0][subform][oe_bt_links_block_background]'); - $this->assertSession()->fieldExists('oe_bt_paragraphs[0][subform][field_oe_social_media_variant]'); - $this->assertSession()->fieldExists('oe_bt_paragraphs[0][subform][field_oe_social_media_see_more][0][uri]'); - $this->assertSession()->fieldExists('oe_bt_paragraphs[0][subform][field_oe_social_media_see_more][0][title]'); + $this->assertSession()->fieldExists('oe_w_paragraphs[0][subform][field_oe_social_media_links][0][uri]'); + $this->assertSession()->fieldExists('oe_w_paragraphs[0][subform][field_oe_social_media_links][0][title]'); + $this->assertSession()->fieldExists('oe_w_paragraphs[0][subform][field_oe_social_media_links][0][link_type]'); + $this->assertSession()->fieldExists('oe_w_paragraphs[0][subform][field_oe_title][0][value]'); + $this->assertSession()->fieldExists('oe_w_paragraphs[0][subform][oe_w_links_block_background]'); + $this->assertSession()->fieldExists('oe_w_paragraphs[0][subform][field_oe_social_media_variant]'); + $this->assertSession()->fieldExists('oe_w_paragraphs[0][subform][field_oe_social_media_see_more][0][uri]'); + $this->assertSession()->fieldExists('oe_w_paragraphs[0][subform][field_oe_social_media_see_more][0][title]'); $this->submitForm([], 'Add another item'); $values = [ 'title[0][value]' => 'Test Social Media follow Links node title', - 'oe_bt_paragraphs[0][subform][field_oe_title][0][value]' => 'EU Social Media Follow Links', - 'oe_bt_paragraphs[0][subform][field_oe_social_media_links][0][uri]' => 'https://www.facebook.com', - 'oe_bt_paragraphs[0][subform][field_oe_social_media_links][0][title]' => 'Example Facebook', - 'oe_bt_paragraphs[0][subform][field_oe_social_media_links][0][link_type]' => 'facebook', - 'oe_bt_paragraphs[0][subform][oe_bt_links_block_background]' => 'transparent', - 'oe_bt_paragraphs[0][subform][field_oe_social_media_variant]' => 'horizontal', - 'oe_bt_paragraphs[0][subform][field_oe_social_media_see_more][0][uri]' => 'https://example.com', - 'oe_bt_paragraphs[0][subform][field_oe_social_media_see_more][0][title]' => 'More channels', + 'oe_w_paragraphs[0][subform][field_oe_title][0][value]' => 'EU Social Media Follow Links', + 'oe_w_paragraphs[0][subform][field_oe_social_media_links][0][uri]' => 'https://www.facebook.com', + 'oe_w_paragraphs[0][subform][field_oe_social_media_links][0][title]' => 'Example Facebook', + 'oe_w_paragraphs[0][subform][field_oe_social_media_links][0][link_type]' => 'facebook', + 'oe_w_paragraphs[0][subform][oe_w_links_block_background]' => 'transparent', + 'oe_w_paragraphs[0][subform][field_oe_social_media_variant]' => 'horizontal', + 'oe_w_paragraphs[0][subform][field_oe_social_media_see_more][0][uri]' => 'https://example.com', + 'oe_w_paragraphs[0][subform][field_oe_social_media_see_more][0][title]' => 'More channels', ]; $this->submitForm($values, 'Save'); @@ -120,15 +120,15 @@ class ParagraphsTest extends BrowserTestBase { $page = $this->getSession()->getPage(); $page->pressButton('Add Accordion'); - $this->assertSession()->fieldExists('oe_bt_paragraphs[0][subform][field_oe_paragraphs][0][subform][field_oe_text][0][value]'); - $this->assertSession()->fieldExists('oe_bt_paragraphs[0][subform][field_oe_paragraphs][0][subform][field_oe_text_long][0][value]'); + $this->assertSession()->fieldExists('oe_w_paragraphs[0][subform][field_oe_paragraphs][0][subform][field_oe_text][0][value]'); + $this->assertSession()->fieldExists('oe_w_paragraphs[0][subform][field_oe_paragraphs][0][subform][field_oe_text_long][0][value]'); // Assert the Icon field is not shown. - $this->assertSession()->fieldNotExists('oe_bt_paragraphs[0][subform][field_oe_paragraphs][0][subform][field_oe_icon][0][value]'); + $this->assertSession()->fieldNotExists('oe_w_paragraphs[0][subform][field_oe_paragraphs][0][subform][field_oe_icon][0][value]'); $values = [ 'title[0][value]' => 'Test Accordion', - 'oe_bt_paragraphs[0][subform][field_oe_paragraphs][0][subform][field_oe_text][0][value]' => 'Title item 1', - 'oe_bt_paragraphs[0][subform][field_oe_paragraphs][0][subform][field_oe_text_long][0][value]' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.', + 'oe_w_paragraphs[0][subform][field_oe_paragraphs][0][subform][field_oe_text][0][value]' => 'Title item 1', + 'oe_w_paragraphs[0][subform][field_oe_paragraphs][0][subform][field_oe_text_long][0][value]' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.', ]; $this->submitForm($values, 'Save'); @@ -147,23 +147,23 @@ class ParagraphsTest extends BrowserTestBase { $page = $this->getSession()->getPage(); $page->pressButton('Add Facts and figures'); // Assert the Facts and figures fields are present. - $this->assertSession()->fieldExists('oe_bt_paragraphs[0][subform][field_oe_link][0][uri]'); - $this->assertSession()->fieldExists('oe_bt_paragraphs[0][subform][field_oe_link][0][title]'); - $this->assertSession()->fieldExists('oe_bt_paragraphs[0][subform][field_oe_title][0][value]'); - $this->assertSession()->fieldExists('oe_bt_paragraphs[0][subform][oe_bt_n_columns][0][value]'); - $this->assertSession()->fieldExists('oe_bt_paragraphs[0][subform][field_oe_paragraphs][0][subform][field_oe_title][0][value]'); - $this->assertSession()->fieldExists('oe_bt_paragraphs[0][subform][field_oe_paragraphs][0][subform][field_oe_subtitle][0][value]'); - $this->assertSession()->fieldExists('oe_bt_paragraphs[0][subform][field_oe_paragraphs][0][subform][field_oe_plain_text_long][0][value]'); + $this->assertSession()->fieldExists('oe_w_paragraphs[0][subform][field_oe_link][0][uri]'); + $this->assertSession()->fieldExists('oe_w_paragraphs[0][subform][field_oe_link][0][title]'); + $this->assertSession()->fieldExists('oe_w_paragraphs[0][subform][field_oe_title][0][value]'); + $this->assertSession()->fieldExists('oe_w_paragraphs[0][subform][oe_w_n_columns][0][value]'); + $this->assertSession()->fieldExists('oe_w_paragraphs[0][subform][field_oe_paragraphs][0][subform][field_oe_title][0][value]'); + $this->assertSession()->fieldExists('oe_w_paragraphs[0][subform][field_oe_paragraphs][0][subform][field_oe_subtitle][0][value]'); + $this->assertSession()->fieldExists('oe_w_paragraphs[0][subform][field_oe_paragraphs][0][subform][field_oe_plain_text_long][0][value]'); $values = [ 'title[0][value]' => 'Test Fact and figures node title', - 'oe_bt_paragraphs[0][subform][field_oe_title][0][value]' => 'Fact and figures block', - 'oe_bt_paragraphs[0][subform][field_oe_link][0][uri]' => 'https://www.google.com', - 'oe_bt_paragraphs[0][subform][field_oe_link][0][title]' => 'Read more', - 'oe_bt_paragraphs[0][subform][oe_bt_n_columns][0][value]' => 2, - 'oe_bt_paragraphs[0][subform][field_oe_paragraphs][0][subform][field_oe_title][0][value]' => "1529 JIRA Ticket", - 'oe_bt_paragraphs[0][subform][field_oe_paragraphs][0][subform][field_oe_subtitle][0][value]' => "Jira Tickets", - 'oe_bt_paragraphs[0][subform][field_oe_paragraphs][0][subform][field_oe_plain_text_long][0][value]' => "Nunc condimentum sapien ut nibh finibus suscipit vitae at justo. Morbi quis odio faucibus, commodo tortor id, elementum libero.", + 'oe_w_paragraphs[0][subform][field_oe_title][0][value]' => 'Fact and figures block', + 'oe_w_paragraphs[0][subform][field_oe_link][0][uri]' => 'https://www.google.com', + 'oe_w_paragraphs[0][subform][field_oe_link][0][title]' => 'Read more', + 'oe_w_paragraphs[0][subform][oe_w_n_columns][0][value]' => 2, + 'oe_w_paragraphs[0][subform][field_oe_paragraphs][0][subform][field_oe_title][0][value]' => "1529 JIRA Ticket", + 'oe_w_paragraphs[0][subform][field_oe_paragraphs][0][subform][field_oe_subtitle][0][value]' => "Jira Tickets", + 'oe_w_paragraphs[0][subform][field_oe_paragraphs][0][subform][field_oe_plain_text_long][0][value]' => "Nunc condimentum sapien ut nibh finibus suscipit vitae at justo. Morbi quis odio faucibus, commodo tortor id, elementum libero.", ]; $this->submitForm($values, 'Save'); @@ -185,7 +185,7 @@ class ParagraphsTest extends BrowserTestBase { $page = $this->getSession()->getPage(); $page->pressButton('Add Fact'); - $this->assertSession()->fieldExists('oe_bt_paragraphs[0][subform][field_oe_icon]'); + $this->assertSession()->fieldExists('oe_w_paragraphs[0][subform][field_oe_icon]'); $allowed_values = [ '_none', 'arrow-down', @@ -211,7 +211,7 @@ class ParagraphsTest extends BrowserTestBase { foreach ($allowed_values as $allowed_value) { $this->assertSession()->elementsCount('css', 'option[value="' . $allowed_value . '"]', 1); } - $this->assertSession()->elementsCount('css', 'select#edit-oe-bt-paragraphs-0-subform-field-oe-icon option', 20); + $this->assertSession()->elementsCount('css', 'select#edit-oe-w-paragraphs-0-subform-field-oe-icon option', 20); } @@ -223,20 +223,20 @@ class ParagraphsTest extends BrowserTestBase { $this->getSession()->getPage()->pressButton('Add Description list'); $assert_session = $this->assertSession(); - $assert_session->fieldExists('oe_bt_paragraphs[0][subform][field_oe_title][0][value]'); + $assert_session->fieldExists('oe_w_paragraphs[0][subform][field_oe_title][0][value]'); $this->assertEquals([ 'horizontal' => 'Horizontal', 'vertical' => 'Vertical', - ], $this->getOptions('oe_bt_paragraphs[0][subform][oe_bt_orientation]')); - $assert_session->fieldExists('oe_bt_paragraphs[0][subform][field_oe_description_list_items][0][term]'); - $assert_session->fieldExists('oe_bt_paragraphs[0][subform][field_oe_description_list_items][0][description][value]'); + ], $this->getOptions('oe_w_paragraphs[0][subform][oe_w_orientation]')); + $assert_session->fieldExists('oe_w_paragraphs[0][subform][field_oe_description_list_items][0][term]'); + $assert_session->fieldExists('oe_w_paragraphs[0][subform][field_oe_description_list_items][0][description][value]'); $values = [ 'title[0][value]' => 'Test Description list node title', - 'oe_bt_paragraphs[0][subform][field_oe_title][0][value]' => 'Description list paragraph', - 'oe_bt_paragraphs[0][subform][oe_bt_orientation]' => 'horizontal', - 'oe_bt_paragraphs[0][subform][field_oe_description_list_items][0][term]' => 'Aliquam ultricies', - 'oe_bt_paragraphs[0][subform][field_oe_description_list_items][0][description][value]' => 'Donec et leo ac velit posuere tempor mattis ac mi. Vivamus nec dictum lectus. Aliquam ultricies placerat eros, vitae ornare sem.', + 'oe_w_paragraphs[0][subform][field_oe_title][0][value]' => 'Description list paragraph', + 'oe_w_paragraphs[0][subform][oe_w_orientation]' => 'horizontal', + 'oe_w_paragraphs[0][subform][field_oe_description_list_items][0][term]' => 'Aliquam ultricies', + 'oe_w_paragraphs[0][subform][field_oe_description_list_items][0][description][value]' => 'Donec et leo ac velit posuere tempor mattis ac mi. Vivamus nec dictum lectus. Aliquam ultricies placerat eros, vitae ornare sem.', ]; $this->submitForm($values, 'Save'); @@ -257,26 +257,26 @@ class ParagraphsTest extends BrowserTestBase { $page->pressButton('Add Listing item block'); // Assert the Listing fields appears. - $this->assertSession()->fieldExists('oe_bt_paragraphs[0][variant]'); - $this->assertSession()->fieldExists('oe_bt_paragraphs[0][subform][field_oe_title][0][value]'); - $this->assertSession()->fieldExists('oe_bt_paragraphs[0][subform][field_oe_list_item_block_layout]'); - $this->assertSession()->fieldExists('oe_bt_paragraphs[0][subform][field_oe_paragraphs][0][subform][field_oe_link][0][uri]'); - $this->assertSession()->fieldExists('oe_bt_paragraphs[0][subform][field_oe_paragraphs][0][subform][field_oe_title][0][value]'); - $this->assertSession()->fieldExists('oe_bt_paragraphs[0][subform][field_oe_paragraphs][0][subform][field_oe_text_long][0][value]'); - $this->assertSession()->fieldExists('oe_bt_paragraphs[0][subform][field_oe_paragraphs][0][subform][field_oe_meta][0][value]'); - $this->assertSession()->fieldExists('files[oe_bt_paragraphs_0_subform_field_oe_paragraphs_0_subform_field_oe_image_0]'); + $this->assertSession()->fieldExists('oe_w_paragraphs[0][variant]'); + $this->assertSession()->fieldExists('oe_w_paragraphs[0][subform][field_oe_title][0][value]'); + $this->assertSession()->fieldExists('oe_w_paragraphs[0][subform][field_oe_list_item_block_layout]'); + $this->assertSession()->fieldExists('oe_w_paragraphs[0][subform][field_oe_paragraphs][0][subform][field_oe_link][0][uri]'); + $this->assertSession()->fieldExists('oe_w_paragraphs[0][subform][field_oe_paragraphs][0][subform][field_oe_title][0][value]'); + $this->assertSession()->fieldExists('oe_w_paragraphs[0][subform][field_oe_paragraphs][0][subform][field_oe_text_long][0][value]'); + $this->assertSession()->fieldExists('oe_w_paragraphs[0][subform][field_oe_paragraphs][0][subform][field_oe_meta][0][value]'); + $this->assertSession()->fieldExists('files[oe_w_paragraphs_0_subform_field_oe_paragraphs_0_subform_field_oe_image_0]'); $this->submitForm([], 'Add another item'); $values = [ 'title[0][value]' => 'Listing node title', - 'oe_bt_paragraphs[0][variant]' => 'default', - 'oe_bt_paragraphs[0][subform][field_oe_title][0][value]' => 'Listing example', - 'oe_bt_paragraphs[0][subform][field_oe_list_item_block_layout]' => 'two_columns', - 'oe_bt_paragraphs[0][subform][field_oe_paragraphs][0][subform][field_oe_link][0][uri]' => 'https://www.example.com', - 'oe_bt_paragraphs[0][subform][field_oe_paragraphs][0][subform][field_oe_title][0][value]' => 'Card title', - 'oe_bt_paragraphs[0][subform][field_oe_paragraphs][0][subform][field_oe_text_long][0][value]' => 'Lorem Ipsum dolor sit amet.', - 'oe_bt_paragraphs[0][subform][field_oe_paragraphs][0][subform][field_oe_meta][0][value]' => 'label1', + 'oe_w_paragraphs[0][variant]' => 'default', + 'oe_w_paragraphs[0][subform][field_oe_title][0][value]' => 'Listing example', + 'oe_w_paragraphs[0][subform][field_oe_list_item_block_layout]' => 'two_columns', + 'oe_w_paragraphs[0][subform][field_oe_paragraphs][0][subform][field_oe_link][0][uri]' => 'https://www.example.com', + 'oe_w_paragraphs[0][subform][field_oe_paragraphs][0][subform][field_oe_title][0][value]' => 'Card title', + 'oe_w_paragraphs[0][subform][field_oe_paragraphs][0][subform][field_oe_text_long][0][value]' => 'Lorem Ipsum dolor sit amet.', + 'oe_w_paragraphs[0][subform][field_oe_paragraphs][0][subform][field_oe_meta][0][value]' => 'label1', ]; $this->submitForm($values, 'Save'); @@ -300,7 +300,7 @@ class ParagraphsTest extends BrowserTestBase { // Add a paragraphs field. $field_storage = FieldStorageConfig::create([ - 'field_name' => 'oe_bt_paragraphs', + 'field_name' => 'oe_w_paragraphs', 'entity_type' => 'node', 'type' => 'entity_reference_revisions', 'cardinality' => '-1', @@ -319,11 +319,11 @@ class ParagraphsTest extends BrowserTestBase { ])->save(); $form_display = \Drupal::service('entity_display.repository')->getFormDisplay('node', 'paragraphs_test'); - $form_display = $form_display->setComponent('oe_bt_paragraphs', ['type' => 'oe_paragraphs_variants']); + $form_display = $form_display->setComponent('oe_w_paragraphs', ['type' => 'oe_paragraphs_variants']); $form_display->save(); $view_display = \Drupal::service('entity_display.repository')->getViewDisplay('node', 'paragraphs_test'); - $view_display->setComponent('oe_bt_paragraphs', ['type' => 'entity_reference_revisions_entity_view']); + $view_display->setComponent('oe_w_paragraphs', ['type' => 'entity_reference_revisions_entity_view']); $view_display->save(); } diff --git a/modules/oe_whitelabel_paragraphs/tests/src/Kernel/Paragraphs/ContentRowTest.php b/modules/oe_whitelabel_paragraphs/tests/src/Kernel/Paragraphs/ContentRowTest.php index e58f4bf2..bbd451ed 100644 --- a/modules/oe_whitelabel_paragraphs/tests/src/Kernel/Paragraphs/ContentRowTest.php +++ b/modules/oe_whitelabel_paragraphs/tests/src/Kernel/Paragraphs/ContentRowTest.php @@ -70,8 +70,8 @@ class ContentRowTest extends ParagraphsTestBase { Paragraph::create([ 'type' => 'oe_links_block', 'field_oe_text' => 'Links block test', - 'oe_bt_links_block_orientation' => 'vertical', - 'oe_bt_links_block_background' => 'gray', + 'oe_w_links_block_orientation' => 'vertical', + 'oe_w_links_block_background' => 'gray', 'field_oe_links' => [ [ 'title' => 'Example 2', @@ -106,7 +106,7 @@ class ContentRowTest extends ParagraphsTestBase { 'type' => 'oe_social_media_follow', 'field_oe_title' => 'Social media block', 'field_oe_social_media_variant' => 'horizontal', - 'oe_bt_links_block_background' => 'gray', + 'oe_w_links_block_background' => 'gray', 'field_oe_social_media_links' => [ [ 'title' => 'Email', diff --git a/modules/oe_whitelabel_paragraphs/tests/src/Kernel/Paragraphs/DescriptionListTest.php b/modules/oe_whitelabel_paragraphs/tests/src/Kernel/Paragraphs/DescriptionListTest.php index 2e7132df..d96781b1 100644 --- a/modules/oe_whitelabel_paragraphs/tests/src/Kernel/Paragraphs/DescriptionListTest.php +++ b/modules/oe_whitelabel_paragraphs/tests/src/Kernel/Paragraphs/DescriptionListTest.php @@ -20,7 +20,7 @@ class DescriptionListTest extends ParagraphsTestBase { $paragraph = Paragraph::create([ 'type' => 'oe_description_list', 'field_oe_title' => 'Description list paragraph', - 'oe_bt_orientation' => 'horizontal', + 'oe_w_orientation' => 'horizontal', 'field_oe_description_list_items' => [ 0 => [ 'term' => 'Aliquam ultricies', @@ -63,7 +63,7 @@ class DescriptionListTest extends ParagraphsTestBase { ); // Testing: Description list paragraph with vertical variant. - $paragraph->get('oe_bt_orientation')->setValue('vertical'); + $paragraph->get('oe_w_orientation')->setValue('vertical'); $paragraph->save(); $html = $this->renderParagraph($paragraph); diff --git a/modules/oe_whitelabel_paragraphs/tests/src/Kernel/Paragraphs/EntityReferenceRevisionTest.php b/modules/oe_whitelabel_paragraphs/tests/src/Kernel/Paragraphs/EntityReferenceRevisionTest.php index 5bc9cb59..9f7e0668 100644 --- a/modules/oe_whitelabel_paragraphs/tests/src/Kernel/Paragraphs/EntityReferenceRevisionTest.php +++ b/modules/oe_whitelabel_paragraphs/tests/src/Kernel/Paragraphs/EntityReferenceRevisionTest.php @@ -65,8 +65,8 @@ class EntityReferenceRevisionTest extends ParagraphsTestBase { $paragraph1 = Paragraph::create([ 'type' => 'oe_links_block', 'field_oe_text' => 'More information', - 'oe_bt_links_block_orientation' => 'vertical', - 'oe_bt_links_block_background' => 'gray', + 'oe_w_links_block_orientation' => 'vertical', + 'oe_w_links_block_background' => 'gray', 'field_oe_links' => [ [ 'title' => 'European Commission', diff --git a/modules/oe_whitelabel_paragraphs/tests/src/Kernel/Paragraphs/FactsFiguresTest.php b/modules/oe_whitelabel_paragraphs/tests/src/Kernel/Paragraphs/FactsFiguresTest.php index b5a9267f..23633bad 100644 --- a/modules/oe_whitelabel_paragraphs/tests/src/Kernel/Paragraphs/FactsFiguresTest.php +++ b/modules/oe_whitelabel_paragraphs/tests/src/Kernel/Paragraphs/FactsFiguresTest.php @@ -70,7 +70,7 @@ class FactsFiguresTest extends ParagraphsTestBase { 'uri' => 'https://www.readmore.com', 'title' => 'Read more', ], - 'oe_bt_n_columns' => 3, + 'oe_w_n_columns' => 3, 'field_oe_paragraphs' => $paragraph_fact, ]); $paragraph->save(); @@ -190,7 +190,7 @@ class FactsFiguresTest extends ParagraphsTestBase { ); // Testing: 2 columns. - $paragraph->get('oe_bt_n_columns')->setValue('2'); + $paragraph->get('oe_w_n_columns')->setValue('2'); $paragraph->save(); $html = $this->renderParagraph($paragraph); @@ -199,7 +199,7 @@ class FactsFiguresTest extends ParagraphsTestBase { $this->assertCount(1, $crawler->filter('div.row-cols-md-2.row')); // Testing: 1 columns. - $paragraph->get('oe_bt_n_columns')->setValue('1'); + $paragraph->get('oe_w_n_columns')->setValue('1'); $paragraph->save(); $html = $this->renderParagraph($paragraph); diff --git a/modules/oe_whitelabel_paragraphs/tests/src/Kernel/Paragraphs/LinksBlockTest.php b/modules/oe_whitelabel_paragraphs/tests/src/Kernel/Paragraphs/LinksBlockTest.php index 67b8c411..e3cf89e7 100644 --- a/modules/oe_whitelabel_paragraphs/tests/src/Kernel/Paragraphs/LinksBlockTest.php +++ b/modules/oe_whitelabel_paragraphs/tests/src/Kernel/Paragraphs/LinksBlockTest.php @@ -21,8 +21,8 @@ class LinksBlockTest extends LinksBlockAssertion { $paragraph = Paragraph::create([ 'type' => 'oe_links_block', 'field_oe_text' => 'More information', - 'oe_bt_links_block_orientation' => 'vertical', - 'oe_bt_links_block_background' => 'gray', + 'oe_w_links_block_orientation' => 'vertical', + 'oe_w_links_block_background' => 'gray', 'field_oe_links' => $this->getBlockLinks(), ]); $paragraph->save(); @@ -36,7 +36,7 @@ class LinksBlockTest extends LinksBlockAssertion { $this->assertVerticalLinks($crawler); // Testing: LinksBlock horizontal gray. - $paragraph->get('oe_bt_links_block_orientation')->setValue('horizontal'); + $paragraph->get('oe_w_links_block_orientation')->setValue('horizontal'); $paragraph->save(); $html = $this->renderParagraph($paragraph); @@ -47,8 +47,8 @@ class LinksBlockTest extends LinksBlockAssertion { $this->assertHorizontalLinks($crawler, FALSE); // Testing: LinksBlock vertical transparent. - $paragraph->get('oe_bt_links_block_orientation')->setValue('vertical'); - $paragraph->get('oe_bt_links_block_background')->setValue('transparent'); + $paragraph->get('oe_w_links_block_orientation')->setValue('vertical'); + $paragraph->get('oe_w_links_block_background')->setValue('transparent'); $paragraph->save(); $html = $this->renderParagraph($paragraph); @@ -59,7 +59,7 @@ class LinksBlockTest extends LinksBlockAssertion { $this->assertVerticalLinks($crawler); // Testing: LinksBlock horizontal transparent. - $paragraph->get('oe_bt_links_block_orientation')->setValue('horizontal'); + $paragraph->get('oe_w_links_block_orientation')->setValue('horizontal'); $paragraph->save(); $html = $this->renderParagraph($paragraph); diff --git a/modules/oe_whitelabel_paragraphs/tests/src/Kernel/Paragraphs/SocialMediaFollowTest.php b/modules/oe_whitelabel_paragraphs/tests/src/Kernel/Paragraphs/SocialMediaFollowTest.php index dc38c36e..6834eafb 100644 --- a/modules/oe_whitelabel_paragraphs/tests/src/Kernel/Paragraphs/SocialMediaFollowTest.php +++ b/modules/oe_whitelabel_paragraphs/tests/src/Kernel/Paragraphs/SocialMediaFollowTest.php @@ -22,7 +22,7 @@ class SocialMediaFollowTest extends LinksBlockAssertion { 'type' => 'oe_social_media_follow', 'field_oe_title' => 'Social media title', 'field_oe_social_media_variant' => 'horizontal', - 'oe_bt_links_block_background' => 'gray', + 'oe_w_links_block_background' => 'gray', 'field_oe_social_media_links' => $this->getSocialMediaLinks(), 'field_oe_social_media_see_more' => [ 'title' => 'Other social networks', @@ -58,7 +58,7 @@ class SocialMediaFollowTest extends LinksBlockAssertion { // Testing: SocialMediaFollow horizontal transparent. $paragraph->get('field_oe_social_media_variant')->setValue('horizontal'); - $paragraph->get('oe_bt_links_block_background')->setValue('transparent'); + $paragraph->get('oe_w_links_block_background')->setValue('transparent'); $paragraph->save(); $html = $this->renderParagraph($paragraph); @@ -73,7 +73,7 @@ class SocialMediaFollowTest extends LinksBlockAssertion { // Testing: SocialMediaFollow vertical transparent. $paragraph->get('field_oe_social_media_variant')->setValue('vertical'); - $paragraph->get('oe_bt_links_block_background')->setValue('transparent'); + $paragraph->get('oe_w_links_block_background')->setValue('transparent'); $paragraph->save(); $html = $this->renderParagraph($paragraph); -- GitLab From 02678f9b87c1d37cd3f0f4234a32cd4fa19522d3 Mon Sep 17 00:00:00 2001 From: Abel Santos <abel.santos.corral@gmail.com> Date: Wed, 16 Mar 2022 17:42:51 +0100 Subject: [PATCH 09/21] OEL-1280: Set correct function prefix at oe_whitelabel_paragraphs.module. --- .../oe_whitelabel_paragraphs.module | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/modules/oe_whitelabel_paragraphs/oe_whitelabel_paragraphs.module b/modules/oe_whitelabel_paragraphs/oe_whitelabel_paragraphs.module index f6e641c3..866e5865 100644 --- a/modules/oe_whitelabel_paragraphs/oe_whitelabel_paragraphs.module +++ b/modules/oe_whitelabel_paragraphs/oe_whitelabel_paragraphs.module @@ -29,7 +29,7 @@ use Drupal\paragraphs\Entity\Paragraph; * * Adds a bare, markup-free template suggestion to all paragraph fields. */ -function oe_whitelabel_paragraphs_theme_suggestions_field_alter(array &$suggestions, array $variables): void { +function oe_whitelabel_paragraphs_paragraphs_theme_suggestions_field_alter(array &$suggestions, array $variables): void { $element = $variables['element']; // Do not output field labels and wrapping markup for paragraph fields. @@ -64,7 +64,7 @@ function oe_whitelabel_paragraphs_preprocess_paragraph__oe_links_block(array &$v /** * Implements hook_preprocess_paragraph() for oe_social_media_follow paragraph. */ -function oe_whitelabel_preprocess_paragraph__oe_social_media_follow(array &$variables): void { +function oe_whitelabel_paragraphs_preprocess_paragraph__oe_social_media_follow(array &$variables): void { /** @var \Drupal\paragraphs\Entity\Paragraph $paragraph */ $paragraph = $variables['paragraph']; $variables['orientation'] = $paragraph->get('field_oe_social_media_variant')->value; @@ -95,7 +95,7 @@ function oe_whitelabel_preprocess_paragraph__oe_social_media_follow(array &$vari /** * Implements hook_preprocess_paragraph__oe_accordion(). */ -function oe_whitelabel_preprocess_paragraph__oe_accordion(array &$variables): void { +function oe_whitelabel_paragraphs_preprocess_paragraph__oe_accordion(array &$variables): void { // Massage data to be compliant with OE Bootstrap Theme accordion pattern // data structure. $builder = \Drupal::entityTypeManager()->getViewBuilder('paragraph'); @@ -114,7 +114,7 @@ function oe_whitelabel_preprocess_paragraph__oe_accordion(array &$variables): vo /** * Implements hook_preprocess_paragraph() for paragraph--oe-text-feature-media.html.twig. */ -function oe_whitelabel_preprocess_paragraph__oe_text_feature_media(array &$variables): void { +function oe_whitelabel_paragraphs_preprocess_paragraph__oe_text_feature_media(array &$variables): void { /** @var \Drupal\paragraphs\Entity\Paragraph $paragraph */ $paragraph = $variables['paragraph']; @@ -191,7 +191,7 @@ function oe_whitelabel_preprocess_paragraph__oe_text_feature_media(array &$varia /** * Implements hook_preprocess_paragraph() for paragraph--oe-list-item-block.html.twig. */ -function oe_whitelabel_preprocess_paragraph__oe_list_item_block(array &$variables): void { +function oe_whitelabel_paragraphs_preprocess_paragraph__oe_list_item_block(array &$variables): void { /** @var \Drupal\paragraphs\Entity\Paragraph $paragraph */ $paragraph = $variables['paragraph']; @@ -258,7 +258,7 @@ function oe_whitelabel_preprocess_paragraph__oe_list_item_block(array &$variable /** * Implements hook_preprocess_paragraph() for oe_banner paragraph. */ -function oe_whitelabel_preprocess_paragraph__oe_banner(array &$variables): void { +function oe_whitelabel_paragraphs_preprocess_paragraph__oe_banner(array &$variables): void { /** @var Drupal\paragraphs\Entity\Paragraph $paragraph */ $paragraph = $variables['paragraph']; $variables['title'] = $paragraph->get('field_oe_title')->value; @@ -338,7 +338,7 @@ function oe_whitelabel_preprocess_paragraph__oe_banner(array &$variables): void /** * Implements hook_preprocess_paragraph() for timeline paragraph. */ -function oe_whitelabel_preprocess_paragraph__oe_timeline(array &$variables): void { +function oe_whitelabel_paragraphs_preprocess_paragraph__oe_timeline(array &$variables): void { $paragraph = $variables['paragraph']; if (!$paragraph->get('field_oe_title')->isEmpty()) { $variables['heading'] = $paragraph->get('field_oe_title')->value; @@ -359,7 +359,7 @@ function oe_whitelabel_preprocess_paragraph__oe_timeline(array &$variables): voi /** * Implements hook_preprocess_paragraph() for paragraph--oe-content-row--variant-inpage-navigation.html.twig. */ -function oe_whitelabel_preprocess_paragraph__oe_content_row__variant_inpage_navigation(array &$variables): void { +function oe_whitelabel_paragraphs_preprocess_paragraph__oe_content_row__variant_inpage_navigation(array &$variables): void { /** @var \Drupal\paragraphs\Entity\Paragraph $paragraph */ $paragraph = $variables['paragraph']; @@ -402,7 +402,7 @@ function oe_whitelabel_preprocess_paragraph__oe_content_row__variant_inpage_navi /** * Implements hook_preprocess_paragraph() for oe_description-list paragraph. */ -function oe_whitelabel_preprocess_paragraph__oe_description_list(array &$variables): void { +function oe_whitelabel_paragraphs_preprocess_paragraph__oe_description_list(array &$variables): void { /** @var Drupal\paragraphs\Entity\Paragraph $paragraph */ $paragraph = $variables['paragraph']; $variables['title'] = $paragraph->get('field_oe_title')->value ?? ''; @@ -419,7 +419,7 @@ function oe_whitelabel_preprocess_paragraph__oe_description_list(array &$variabl /** * Implements hook_preprocess_paragraph(). */ -function oe_whitelabel_preprocess_paragraph__oe_facts_figures(array &$variables): void { +function oe_whitelabel_paragraphs_preprocess_paragraph__oe_facts_figures(array &$variables): void { /** @var \Drupal\paragraphs\ParagraphInterface $paragraph */ $paragraph = $variables['paragraph']; if (!$paragraph->get('field_oe_title')->isEmpty()) { @@ -514,7 +514,7 @@ function oe_whitelabel_get_media_uri(MediaSourceInterface $source, Media $media, * @param \Drupal\media\MediaSourceInterface $source * Media source. */ -function _oe_whitelabel_featured_media_set_embedded_media(array &$variables, MediaInterface $media, CacheableMetadata $cacheability, MediaSourceInterface $source): void { +function _oe_whitelabel_paragraphs_featured_media_set_embedded_media(array &$variables, MediaInterface $media, CacheableMetadata $cacheability, MediaSourceInterface $source): void { // Default video aspect ratio is set to 16x9. $variables['ratio'] = '16x9'; -- GitLab From a343a1632f3c25a2c67f2d1a3dd209707ff0e6de Mon Sep 17 00:00:00 2001 From: Abel Santos <abel.santos.corral@gmail.com> Date: Thu, 17 Mar 2022 08:37:47 +0100 Subject: [PATCH 10/21] OEL-1280: Add paragraphs.inc. --- includes/paragraphs.inc | 21 +++++++++++++++++++++ oe_whitelabel.theme | 8 ++++++++ 2 files changed, 29 insertions(+) create mode 100644 includes/paragraphs.inc diff --git a/includes/paragraphs.inc b/includes/paragraphs.inc new file mode 100644 index 00000000..5e2d923a --- /dev/null +++ b/includes/paragraphs.inc @@ -0,0 +1,21 @@ +<?php + +/** + * @file + * Theme functions for paragraphs. + */ + +declare(strict_types = 1); + +/** + * Implements hook_theme_suggestions_HOOK_alter(). + */ +function oe_whitelabel_theme_suggestions_paragraph_alter(array &$suggestions, array $variables): void { + /** @var \Drupal\paragraphs\ParagraphInterface $paragraph */ + $paragraph = $variables['elements']['#paragraph']; + + if ($paragraph->bundle() === 'oe_content_row') { + $variant = $paragraph->get('oe_paragraphs_variant')->first()->value; + $suggestions[] = 'paragraph__' . $paragraph->bundle() . '__variant_' . $variant; + } +} diff --git a/oe_whitelabel.theme b/oe_whitelabel.theme index bb3573db..d591f9cf 100644 --- a/oe_whitelabel.theme +++ b/oe_whitelabel.theme @@ -11,6 +11,14 @@ use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Url; use Drupal\oe_whitelabel_helper\EuropeanUnionLanguages; +// Include all files from the includes directory. +$includes_path = __DIR__ . '/includes/*.inc'; +foreach (glob($includes_path) as $filename) { + // The inspection disallowing basename() is not relevant for known paths. + // phpcs:ignore QualityAssurance.Functions.DrupalWrappers.FoundWithAlternative + require_once __DIR__ . '/includes/' . basename($filename); +} + /** * Implements hook__preprocess_links__language_block(). */ -- GitLab From d8476b8007eac3bfb2be468855e5b5f264606d1f Mon Sep 17 00:00:00 2001 From: Abel Santos <abel.santos.corral@gmail.com> Date: Wed, 16 Mar 2022 18:43:25 +0100 Subject: [PATCH 11/21] OEL-1280: Add temporary release 0.1280.202203170900 into composer. --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 61f12883..451e0645 100644 --- a/composer.json +++ b/composer.json @@ -10,7 +10,7 @@ "cweagans/composer-patches": "^1.7", "drupal/core": "^9.2", "drupal/twig_field_value": "^2.0", - "openeuropa/oe_bootstrap_theme": "0.1280.202203151730" + "openeuropa/oe_bootstrap_theme": "0.1280.202203170900" }, "require-dev": { "composer/installers": "^1.11", -- GitLab From b340533215c2f48fd7c15075e91520ea3386f0d4 Mon Sep 17 00:00:00 2001 From: Abel Santos <abel.santos.corral@gmail.com> Date: Thu, 17 Mar 2022 10:13:55 +0100 Subject: [PATCH 12/21] OEL-1280: Fix typos at name of hook_theme_suggestions_HOOK_alter. --- .../oe_whitelabel_paragraphs/oe_whitelabel_paragraphs.module | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/oe_whitelabel_paragraphs/oe_whitelabel_paragraphs.module b/modules/oe_whitelabel_paragraphs/oe_whitelabel_paragraphs.module index 866e5865..edda21ae 100644 --- a/modules/oe_whitelabel_paragraphs/oe_whitelabel_paragraphs.module +++ b/modules/oe_whitelabel_paragraphs/oe_whitelabel_paragraphs.module @@ -29,7 +29,7 @@ use Drupal\paragraphs\Entity\Paragraph; * * Adds a bare, markup-free template suggestion to all paragraph fields. */ -function oe_whitelabel_paragraphs_paragraphs_theme_suggestions_field_alter(array &$suggestions, array $variables): void { +function oe_whitelabel_paragraphs_theme_suggestions_field_alter(array &$suggestions, array $variables): void { $element = $variables['element']; // Do not output field labels and wrapping markup for paragraph fields. @@ -171,7 +171,7 @@ function oe_whitelabel_paragraphs_preprocess_paragraph__oe_text_feature_media(ar $variables['image'] = ImageValueObject::fromStyledImageItem($thumbnail, 'oe_bootstrap_theme_medium_no_crop'); } elseif ($is_video) { - _oe_whitelabel_featured_media_set_embedded_media($variables, $media, $cacheability, $source); + _oe_whitelabel_paragraphs_featured_media_set_embedded_media($variables, $media, $cacheability, $source); } $cacheability->applyTo($variables); -- GitLab From 5d357a847149be6e3d5238303f13f3c28f235447 Mon Sep 17 00:00:00 2001 From: Abel Santos <abel.santos.corral@gmail.com> Date: Thu, 17 Mar 2022 12:01:11 +0100 Subject: [PATCH 13/21] OEL-1280: Rename hooks preprocess on behalf of oe_whitelabel theme. --- .../oe_whitelabel_paragraphs.module | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/modules/oe_whitelabel_paragraphs/oe_whitelabel_paragraphs.module b/modules/oe_whitelabel_paragraphs/oe_whitelabel_paragraphs.module index edda21ae..5e02e5b1 100644 --- a/modules/oe_whitelabel_paragraphs/oe_whitelabel_paragraphs.module +++ b/modules/oe_whitelabel_paragraphs/oe_whitelabel_paragraphs.module @@ -3,6 +3,9 @@ /** * @file * OE Whitelabel Paragraphs module. + * + * Preprocess hooks are implemented on behalf of the oe_whitelabel theme. + * This prevents hooks from running if oe_whitelabel is not the active theme. */ declare(strict_types = 1); @@ -44,7 +47,7 @@ function oe_whitelabel_paragraphs_theme_suggestions_field_alter(array &$suggesti /** * Implements hook_preprocess_paragraph(). */ -function oe_whitelabel_paragraphs_preprocess_paragraph__oe_links_block(array &$variables): void { +function oe_whitelabel_preprocess_paragraph__oe_links_block(array &$variables): void { /** @var \Drupal\paragraphs\Entity\Paragraph $paragraph */ $paragraph = $variables['paragraph']; $variables['orientation'] = $paragraph->get('oe_w_links_block_orientation')->value; @@ -64,7 +67,7 @@ function oe_whitelabel_paragraphs_preprocess_paragraph__oe_links_block(array &$v /** * Implements hook_preprocess_paragraph() for oe_social_media_follow paragraph. */ -function oe_whitelabel_paragraphs_preprocess_paragraph__oe_social_media_follow(array &$variables): void { +function oe_whitelabel_preprocess_paragraph__oe_social_media_follow(array &$variables): void { /** @var \Drupal\paragraphs\Entity\Paragraph $paragraph */ $paragraph = $variables['paragraph']; $variables['orientation'] = $paragraph->get('field_oe_social_media_variant')->value; @@ -95,7 +98,7 @@ function oe_whitelabel_paragraphs_preprocess_paragraph__oe_social_media_follow(a /** * Implements hook_preprocess_paragraph__oe_accordion(). */ -function oe_whitelabel_paragraphs_preprocess_paragraph__oe_accordion(array &$variables): void { +function oe_whitelabel_preprocess_paragraph__oe_accordion(array &$variables): void { // Massage data to be compliant with OE Bootstrap Theme accordion pattern // data structure. $builder = \Drupal::entityTypeManager()->getViewBuilder('paragraph'); @@ -114,7 +117,7 @@ function oe_whitelabel_paragraphs_preprocess_paragraph__oe_accordion(array &$var /** * Implements hook_preprocess_paragraph() for paragraph--oe-text-feature-media.html.twig. */ -function oe_whitelabel_paragraphs_preprocess_paragraph__oe_text_feature_media(array &$variables): void { +function oe_whitelabel_preprocess_paragraph__oe_text_feature_media(array &$variables): void { /** @var \Drupal\paragraphs\Entity\Paragraph $paragraph */ $paragraph = $variables['paragraph']; @@ -191,7 +194,7 @@ function oe_whitelabel_paragraphs_preprocess_paragraph__oe_text_feature_media(ar /** * Implements hook_preprocess_paragraph() for paragraph--oe-list-item-block.html.twig. */ -function oe_whitelabel_paragraphs_preprocess_paragraph__oe_list_item_block(array &$variables): void { +function oe_whitelabel_preprocess_paragraph__oe_list_item_block(array &$variables): void { /** @var \Drupal\paragraphs\Entity\Paragraph $paragraph */ $paragraph = $variables['paragraph']; @@ -338,7 +341,7 @@ function oe_whitelabel_paragraphs_preprocess_paragraph__oe_banner(array &$variab /** * Implements hook_preprocess_paragraph() for timeline paragraph. */ -function oe_whitelabel_paragraphs_preprocess_paragraph__oe_timeline(array &$variables): void { +function oe_whitelabel_preprocess_paragraph__oe_timeline(array &$variables): void { $paragraph = $variables['paragraph']; if (!$paragraph->get('field_oe_title')->isEmpty()) { $variables['heading'] = $paragraph->get('field_oe_title')->value; @@ -359,7 +362,7 @@ function oe_whitelabel_paragraphs_preprocess_paragraph__oe_timeline(array &$vari /** * Implements hook_preprocess_paragraph() for paragraph--oe-content-row--variant-inpage-navigation.html.twig. */ -function oe_whitelabel_paragraphs_preprocess_paragraph__oe_content_row__variant_inpage_navigation(array &$variables): void { +function oe_whitelabel_preprocess_paragraph__oe_content_row__variant_inpage_navigation(array &$variables): void { /** @var \Drupal\paragraphs\Entity\Paragraph $paragraph */ $paragraph = $variables['paragraph']; @@ -402,7 +405,7 @@ function oe_whitelabel_paragraphs_preprocess_paragraph__oe_content_row__variant_ /** * Implements hook_preprocess_paragraph() for oe_description-list paragraph. */ -function oe_whitelabel_paragraphs_preprocess_paragraph__oe_description_list(array &$variables): void { +function oe_whitelabel_preprocess_paragraph__oe_description_list(array &$variables): void { /** @var Drupal\paragraphs\Entity\Paragraph $paragraph */ $paragraph = $variables['paragraph']; $variables['title'] = $paragraph->get('field_oe_title')->value ?? ''; @@ -419,7 +422,7 @@ function oe_whitelabel_paragraphs_preprocess_paragraph__oe_description_list(arra /** * Implements hook_preprocess_paragraph(). */ -function oe_whitelabel_paragraphs_preprocess_paragraph__oe_facts_figures(array &$variables): void { +function oe_whitelabel_preprocess_paragraph__oe_facts_figures(array &$variables): void { /** @var \Drupal\paragraphs\ParagraphInterface $paragraph */ $paragraph = $variables['paragraph']; if (!$paragraph->get('field_oe_title')->isEmpty()) { -- GitLab From f05f64ba718e2f2447b0c91d5addc8c6b03faedb Mon Sep 17 00:00:00 2001 From: Abel Santos <abel.santos.corral@gmail.com> Date: Thu, 17 Mar 2022 12:01:41 +0100 Subject: [PATCH 14/21] OEL-1280: Rename inner functions at oe_whitelabel_paragraphs.module. --- .../oe_whitelabel_paragraphs.module | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/modules/oe_whitelabel_paragraphs/oe_whitelabel_paragraphs.module b/modules/oe_whitelabel_paragraphs/oe_whitelabel_paragraphs.module index 5e02e5b1..e8a17b93 100644 --- a/modules/oe_whitelabel_paragraphs/oe_whitelabel_paragraphs.module +++ b/modules/oe_whitelabel_paragraphs/oe_whitelabel_paragraphs.module @@ -174,7 +174,7 @@ function oe_whitelabel_preprocess_paragraph__oe_text_feature_media(array &$varia $variables['image'] = ImageValueObject::fromStyledImageItem($thumbnail, 'oe_bootstrap_theme_medium_no_crop'); } elseif ($is_video) { - _oe_whitelabel_paragraphs_featured_media_set_embedded_media($variables, $media, $cacheability, $source); + _oe_whitelabel_featured_media_set_embedded_media($variables, $media, $cacheability, $source); } $cacheability->applyTo($variables); @@ -261,13 +261,13 @@ function oe_whitelabel_preprocess_paragraph__oe_list_item_block(array &$variable /** * Implements hook_preprocess_paragraph() for oe_banner paragraph. */ -function oe_whitelabel_paragraphs_preprocess_paragraph__oe_banner(array &$variables): void { +function oe_whitelabel_preprocess_paragraph__oe_banner(array &$variables): void { /** @var Drupal\paragraphs\Entity\Paragraph $paragraph */ $paragraph = $variables['paragraph']; $variables['title'] = $paragraph->get('field_oe_title')->value; $variables['description'] = $paragraph->get('field_oe_text')->value; $variables['full_width'] = (bool) $paragraph->get('field_oe_banner_full_width')->value; - oe_whitelabel_set_banner_link($paragraph, $variables); + _oe_whitelabel_set_banner_link($paragraph, $variables); // The alignment field value contains the information regarding the pattern // type and centering. @@ -321,7 +321,7 @@ function oe_whitelabel_paragraphs_preprocess_paragraph__oe_banner(array &$variab return; } - $uri = oe_whitelabel_get_media_uri($source, $media, $cacheability); + $uri = _oe_whitelabel_get_media_uri($source, $media, $cacheability); // The uri might be empty if the source is of type Image and the file entity // was deleted. @@ -466,7 +466,7 @@ function oe_whitelabel_preprocess_paragraph__oe_facts_figures(array &$variables) * @param array $variables * The render array. */ -function oe_whitelabel_set_banner_link(Paragraph $paragraph, array &$variables): void { +function _oe_whitelabel_set_banner_link(Paragraph $paragraph, array &$variables): void { if ($paragraph->get('field_oe_link')->isEmpty()) { return; } @@ -489,7 +489,7 @@ function oe_whitelabel_set_banner_link(Paragraph $paragraph, array &$variables): * @return string * The uri string. */ -function oe_whitelabel_get_media_uri(MediaSourceInterface $source, Media $media, CacheableMetadata $cacheability): string { +function _oe_whitelabel_get_media_uri(MediaSourceInterface $source, Media $media, CacheableMetadata $cacheability): string { $field_name = $source->getConfiguration()['source_field']; if ($source instanceof Image && ($file_entity = $media->get($field_name)->entity)) { @@ -517,7 +517,7 @@ function oe_whitelabel_get_media_uri(MediaSourceInterface $source, Media $media, * @param \Drupal\media\MediaSourceInterface $source * Media source. */ -function _oe_whitelabel_paragraphs_featured_media_set_embedded_media(array &$variables, MediaInterface $media, CacheableMetadata $cacheability, MediaSourceInterface $source): void { +function _oe_whitelabel_featured_media_set_embedded_media(array &$variables, MediaInterface $media, CacheableMetadata $cacheability, MediaSourceInterface $source): void { // Default video aspect ratio is set to 16x9. $variables['ratio'] = '16x9'; -- GitLab From f7c1ddfeeb4d5935088d671638157da97d7687cf Mon Sep 17 00:00:00 2001 From: Abel Santos <abel.santos.corral@gmail.com> Date: Thu, 17 Mar 2022 13:18:15 +0100 Subject: [PATCH 15/21] OEL-1280: Bring sections of paragraphs into README.md file. --- README.md | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a223d5cb..86fcf3ed 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,17 @@ # The OpenEuropa Whitelabel theme +## Paragraphs + +The paragraphs below are not yet themed therefore not recommended for usage: + +- Contextual navigation +- Document + +Some paragraphs are considered "internal", and only meant to be used inside other paragraphs: + +- Listing item: To be used as item paragraph within 'Listing item block'. +- Fact: To be used as item paragraph within 'Facts and figures'. + ## Requirements This depends on the following software: @@ -18,7 +30,13 @@ composer require openeuropa/oe_whitelabel In order to enable the theme in your project perform the following steps: -- Enable the OpenEuropa Whitelabel Theme and set it as default ```./vendor/bin/drush config-set system.theme default oe_bootstrap_theme``` +- Enable the OpenEuropa Whitelabel Theme and set it as default ```./vendor/bin/drush config-set system.theme default oe_whitelabel_theme``` + +### Integration with oe_paragraphs + +In order to have full working integration with paragraphs in your project, you must enable oe_whitelabel_paragraphs module: + +```./vendor/bin/drush en oe_whitelabel_paragraphs``` ## Development setup -- GitLab From dbc02efa10e71e1018a5add73203998f7dd29163 Mon Sep 17 00:00:00 2001 From: Abel Santos <abel.santos.corral@gmail.com> Date: Thu, 17 Mar 2022 13:18:42 +0100 Subject: [PATCH 16/21] OEL-1280: Add oe_whitelabel_helper.install to check paragraphs requirements. --- .../oe_whitelabel_helper.install | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 modules/oe_whitelabel_helper/oe_whitelabel_helper.install diff --git a/modules/oe_whitelabel_helper/oe_whitelabel_helper.install b/modules/oe_whitelabel_helper/oe_whitelabel_helper.install new file mode 100644 index 00000000..f7f14615 --- /dev/null +++ b/modules/oe_whitelabel_helper/oe_whitelabel_helper.install @@ -0,0 +1,25 @@ +<?php + +/** + * @file + * Install and update functions for the OE Whitelabel Helper module. + */ + +declare(strict_types = 1); + +/** + * Implements hook_requirements(). + */ +function oe_whitelabel_helper_requirements($phase): array { + $requirements = []; + + if (\Drupal::moduleHandler()->moduleExists('oe_paragraphs') && !\Drupal::moduleHandler()->moduleExists('oe_whitelabel_paragraphs')) { + $requirements['oe_whitelabel_paragraphs'] = [ + 'title' => 'OpenEuropa Whitelabel Paragraphs', + 'description' => t('OpenEuropa Whitelabel Paragraphs is required if OpenEuropa Paragraphs is enabled.'), + 'severity' => REQUIREMENT_ERROR, + ]; + } + + return $requirements; +} -- GitLab From abc87f56a22c2c7b7e1b8b0e5a0637c7db1e9d1d Mon Sep 17 00:00:00 2001 From: Abel Santos <abel.santos.corral@gmail.com> Date: Thu, 17 Mar 2022 13:59:59 +0100 Subject: [PATCH 17/21] OEL-1280: Reorder lists dependencies and install at oe_whitelabel_paragraphs.info.yml. --- .../oe_whitelabel_paragraphs.info.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/modules/oe_whitelabel_paragraphs/oe_whitelabel_paragraphs.info.yml b/modules/oe_whitelabel_paragraphs/oe_whitelabel_paragraphs.info.yml index 649b4b57..8495f5f4 100644 --- a/modules/oe_whitelabel_paragraphs/oe_whitelabel_paragraphs.info.yml +++ b/modules/oe_whitelabel_paragraphs/oe_whitelabel_paragraphs.info.yml @@ -4,20 +4,20 @@ description: Companion module to add support and customisations for oe_paragraph package: OpenEuropa Whitelabel Theme core_version_requirement: ^9.2 dependencies: - - oe_paragraphs:oe_paragraphs - - oe_whitelabel:oe_whitelabel_helper - - oe_paragraphs:oe_paragraphs_timeline - - oe_content:oe_content_timeline_field - drupal:description_list_field + - oe_content:oe_content_timeline_field + - oe_paragraphs:oe_paragraphs - oe_paragraphs:oe_paragraphs_description_list + - oe_paragraphs:oe_paragraphs_timeline + - oe_whitelabel:oe_whitelabel_helper config_devel: install: + - field.field.paragraph.oe_description_list.oe_w_orientation + - field.field.paragraph.oe_facts_figures.oe_w_n_columns - field.field.paragraph.oe_links_block.oe_w_links_block_background - field.field.paragraph.oe_links_block.oe_w_links_block_orientation - field.field.paragraph.oe_social_media_follow.oe_w_links_block_background - - field.field.paragraph.oe_facts_figures.oe_w_n_columns - - field.storage.paragraph.oe_w_links_block_orientation - field.storage.paragraph.oe_w_links_block_background - - field.field.paragraph.oe_description_list.oe_w_orientation - - field.storage.paragraph.oe_w_orientation + - field.storage.paragraph.oe_w_links_block_orientation - field.storage.paragraph.oe_w_n_columns + - field.storage.paragraph.oe_w_orientation -- GitLab From e1bdf818243adcf089cdf61f0a39439766bd30cf Mon Sep 17 00:00:00 2001 From: Abel Santos <abel.santos.corral@gmail.com> Date: Thu, 17 Mar 2022 14:02:56 +0100 Subject: [PATCH 18/21] OEL-1280: Eliminate post_update file and related config folder. --- ....paragraph.oe_description_list.default.yml | 38 ---------- ....paragraph.oe_description_list.default.yml | 32 --------- ...h.oe_description_list.oe_w_orientation.yml | 22 ------ ...eld.storage.paragraph.oe_w_orientation.yml | 26 ------- ...ay.paragraph.oe_accordion_item.default.yml | 36 ---------- ...ay.paragraph.oe_accordion_item.default.yml | 32 --------- ...lay.paragraph.oe_facts_figures.default.yml | 61 ---------------- ...display.paragraph.oe_list_item.default.yml | 71 ------------------- ...y.paragraph.oe_list_item_block.default.yml | 67 ----------------- ...paragraph.oe_list_item_block.highlight.yml | 68 ------------------ ...lay.paragraph.oe_facts_figures.default.yml | 48 ------------- ...agraph.oe_facts_figures.oe_w_n_columns.yml | 24 ------- ...field.storage.paragraph.oe_w_n_columns.yml | 19 ----- .../oe_whitelabel_paragraphs.post_update.php | 65 ----------------- 14 files changed, 609 deletions(-) delete mode 100644 modules/oe_whitelabel_paragraphs/config/post_updates/00001/core.entity_form_display.paragraph.oe_description_list.default.yml delete mode 100644 modules/oe_whitelabel_paragraphs/config/post_updates/00001/core.entity_view_display.paragraph.oe_description_list.default.yml delete mode 100644 modules/oe_whitelabel_paragraphs/config/post_updates/00001/field.field.paragraph.oe_description_list.oe_w_orientation.yml delete mode 100644 modules/oe_whitelabel_paragraphs/config/post_updates/00001/field.storage.paragraph.oe_w_orientation.yml delete mode 100644 modules/oe_whitelabel_paragraphs/config/post_updates/00002/core.entity_form_display.paragraph.oe_accordion_item.default.yml delete mode 100644 modules/oe_whitelabel_paragraphs/config/post_updates/00002/core.entity_view_display.paragraph.oe_accordion_item.default.yml delete mode 100644 modules/oe_whitelabel_paragraphs/config/post_updates/00003/core.entity_form_display.paragraph.oe_facts_figures.default.yml delete mode 100644 modules/oe_whitelabel_paragraphs/config/post_updates/00003/core.entity_form_display.paragraph.oe_list_item.default.yml delete mode 100644 modules/oe_whitelabel_paragraphs/config/post_updates/00003/core.entity_form_display.paragraph.oe_list_item_block.default.yml delete mode 100644 modules/oe_whitelabel_paragraphs/config/post_updates/00003/core.entity_form_display.paragraph.oe_list_item_block.highlight.yml delete mode 100644 modules/oe_whitelabel_paragraphs/config/post_updates/00003/core.entity_view_display.paragraph.oe_facts_figures.default.yml delete mode 100644 modules/oe_whitelabel_paragraphs/config/post_updates/00003/field.field.paragraph.oe_facts_figures.oe_w_n_columns.yml delete mode 100644 modules/oe_whitelabel_paragraphs/config/post_updates/00003/field.storage.paragraph.oe_w_n_columns.yml delete mode 100644 modules/oe_whitelabel_paragraphs/oe_whitelabel_paragraphs.post_update.php diff --git a/modules/oe_whitelabel_paragraphs/config/post_updates/00001/core.entity_form_display.paragraph.oe_description_list.default.yml b/modules/oe_whitelabel_paragraphs/config/post_updates/00001/core.entity_form_display.paragraph.oe_description_list.default.yml deleted file mode 100644 index 0391e256..00000000 --- a/modules/oe_whitelabel_paragraphs/config/post_updates/00001/core.entity_form_display.paragraph.oe_description_list.default.yml +++ /dev/null @@ -1,38 +0,0 @@ -langcode: en -status: true -dependencies: - config: - - field.field.paragraph.oe_description_list.field_oe_description_list_items - - field.field.paragraph.oe_description_list.field_oe_title - - field.field.paragraph.oe_description_list.oe_w_orientation - - paragraphs.paragraphs_type.oe_description_list - module: - - description_list_field -id: paragraph.oe_description_list.default -targetEntityType: paragraph -bundle: oe_description_list -mode: default -content: - field_oe_description_list_items: - weight: 2 - settings: { } - third_party_settings: { } - type: description_list_widget - region: content - field_oe_title: - weight: 1 - settings: - size: 60 - placeholder: '' - third_party_settings: { } - type: string_textfield - region: content - oe_w_orientation: - type: options_select - weight: 0 - region: content - settings: { } - third_party_settings: { } -hidden: - created: true - status: true diff --git a/modules/oe_whitelabel_paragraphs/config/post_updates/00001/core.entity_view_display.paragraph.oe_description_list.default.yml b/modules/oe_whitelabel_paragraphs/config/post_updates/00001/core.entity_view_display.paragraph.oe_description_list.default.yml deleted file mode 100644 index b303a9e9..00000000 --- a/modules/oe_whitelabel_paragraphs/config/post_updates/00001/core.entity_view_display.paragraph.oe_description_list.default.yml +++ /dev/null @@ -1,32 +0,0 @@ -langcode: en -status: true -dependencies: - config: - - field.field.paragraph.oe_description_list.oe_w_orientation - - field.field.paragraph.oe_description_list.field_oe_description_list_items - - field.field.paragraph.oe_description_list.field_oe_title - - paragraphs.paragraphs_type.oe_description_list - module: - - description_list_field -id: paragraph.oe_description_list.default -targetEntityType: paragraph -bundle: oe_description_list -mode: default -content: - field_oe_description_list_items: - weight: 1 - label: hidden - settings: { } - third_party_settings: { } - type: description_list_formatter - region: content - field_oe_title: - weight: 0 - label: hidden - settings: - link_to_entity: false - third_party_settings: { } - type: string - region: content -hidden: - oe_w_orientation: true diff --git a/modules/oe_whitelabel_paragraphs/config/post_updates/00001/field.field.paragraph.oe_description_list.oe_w_orientation.yml b/modules/oe_whitelabel_paragraphs/config/post_updates/00001/field.field.paragraph.oe_description_list.oe_w_orientation.yml deleted file mode 100644 index 1e448506..00000000 --- a/modules/oe_whitelabel_paragraphs/config/post_updates/00001/field.field.paragraph.oe_description_list.oe_w_orientation.yml +++ /dev/null @@ -1,22 +0,0 @@ -langcode: en -status: true -dependencies: - config: - - field.storage.paragraph.oe_w_orientation - - paragraphs.paragraphs_type.oe_description_list - module: - - options -id: paragraph.oe_description_list.oe_w_orientation -field_name: oe_w_orientation -entity_type: paragraph -bundle: oe_description_list -label: Orientation -description: 'Sets the orientation (vertical|horizontal) for the paragraph.' -required: true -translatable: false -default_value: - - - value: horizontal -default_value_callback: '' -settings: { } -field_type: list_string diff --git a/modules/oe_whitelabel_paragraphs/config/post_updates/00001/field.storage.paragraph.oe_w_orientation.yml b/modules/oe_whitelabel_paragraphs/config/post_updates/00001/field.storage.paragraph.oe_w_orientation.yml deleted file mode 100644 index f277e814..00000000 --- a/modules/oe_whitelabel_paragraphs/config/post_updates/00001/field.storage.paragraph.oe_w_orientation.yml +++ /dev/null @@ -1,26 +0,0 @@ -langcode: en -status: true -dependencies: - module: - - options - - paragraphs -id: paragraph.oe_w_orientation -field_name: oe_w_orientation -entity_type: paragraph -type: list_string -settings: - allowed_values: - - - value: vertical - label: Vertical - - - value: horizontal - label: Horizontal - allowed_values_function: '' -module: options -locked: false -cardinality: 1 -translatable: true -indexes: { } -persist_with_no_fields: false -custom_storage: false diff --git a/modules/oe_whitelabel_paragraphs/config/post_updates/00002/core.entity_form_display.paragraph.oe_accordion_item.default.yml b/modules/oe_whitelabel_paragraphs/config/post_updates/00002/core.entity_form_display.paragraph.oe_accordion_item.default.yml deleted file mode 100644 index 3b7368e6..00000000 --- a/modules/oe_whitelabel_paragraphs/config/post_updates/00002/core.entity_form_display.paragraph.oe_accordion_item.default.yml +++ /dev/null @@ -1,36 +0,0 @@ -langcode: en -status: true -dependencies: - config: - - field.field.paragraph.oe_accordion_item.field_oe_icon - - field.field.paragraph.oe_accordion_item.field_oe_text - - field.field.paragraph.oe_accordion_item.field_oe_text_long - - paragraphs.paragraphs_type.oe_accordion_item - module: - - text -id: paragraph.oe_accordion_item.default -targetEntityType: paragraph -bundle: oe_accordion_item -mode: default -content: - field_oe_text: - weight: 0 - settings: - size: 60 - placeholder: '' - third_party_settings: { } - type: string_textfield - region: content - field_oe_text_long: - weight: 1 - settings: - rows: 5 - placeholder: '' - third_party_settings: { } - type: text_textarea - region: content -hidden: - created: true - field_oe_icon: true - status: true - uid: true diff --git a/modules/oe_whitelabel_paragraphs/config/post_updates/00002/core.entity_view_display.paragraph.oe_accordion_item.default.yml b/modules/oe_whitelabel_paragraphs/config/post_updates/00002/core.entity_view_display.paragraph.oe_accordion_item.default.yml deleted file mode 100644 index 8c3a67f6..00000000 --- a/modules/oe_whitelabel_paragraphs/config/post_updates/00002/core.entity_view_display.paragraph.oe_accordion_item.default.yml +++ /dev/null @@ -1,32 +0,0 @@ -langcode: en -status: true -dependencies: - config: - - field.field.paragraph.oe_accordion_item.field_oe_icon - - field.field.paragraph.oe_accordion_item.field_oe_text - - field.field.paragraph.oe_accordion_item.field_oe_text_long - - paragraphs.paragraphs_type.oe_accordion_item - module: - - text -id: paragraph.oe_accordion_item.default -targetEntityType: paragraph -bundle: oe_accordion_item -mode: default -content: - field_oe_text: - weight: 0 - label: above - settings: - link_to_entity: false - third_party_settings: { } - type: string - region: content - field_oe_text_long: - weight: 1 - label: above - settings: { } - third_party_settings: { } - type: text_default - region: content -hidden: - field_oe_icon: true diff --git a/modules/oe_whitelabel_paragraphs/config/post_updates/00003/core.entity_form_display.paragraph.oe_facts_figures.default.yml b/modules/oe_whitelabel_paragraphs/config/post_updates/00003/core.entity_form_display.paragraph.oe_facts_figures.default.yml deleted file mode 100644 index d12c5363..00000000 --- a/modules/oe_whitelabel_paragraphs/config/post_updates/00003/core.entity_form_display.paragraph.oe_facts_figures.default.yml +++ /dev/null @@ -1,61 +0,0 @@ -langcode: en -status: true -dependencies: - config: - - field.field.paragraph.oe_facts_figures.field_oe_link - - field.field.paragraph.oe_facts_figures.field_oe_paragraphs - - field.field.paragraph.oe_facts_figures.field_oe_title - - field.field.paragraph.oe_facts_figures.oe_w_n_columns - - paragraphs.paragraphs_type.oe_facts_figures - module: - - link - - oe_paragraphs -id: paragraph.oe_facts_figures.default -targetEntityType: paragraph -bundle: oe_facts_figures -mode: default -content: - field_oe_link: - type: link_default - weight: 2 - region: content - settings: - placeholder_url: '' - placeholder_title: '' - third_party_settings: { } - field_oe_paragraphs: - type: oe_paragraphs_variants - weight: 8 - region: content - settings: - title: Paragraph - title_plural: Paragraphs - edit_mode: open - add_mode: dropdown - form_display_mode: default - default_paragraph_type: '' - closed_mode: summary - autocollapse: none - closed_mode_threshold: 0 - features: - collapse_edit_all: collapse_edit_all - duplicate: duplicate - third_party_settings: { } - field_oe_title: - type: string_textfield - weight: 1 - region: content - settings: - size: 60 - placeholder: '' - third_party_settings: { } - oe_w_n_columns: - weight: 6 - settings: - placeholder: '' - third_party_settings: { } - type: number - region: content -hidden: - created: true - status: true diff --git a/modules/oe_whitelabel_paragraphs/config/post_updates/00003/core.entity_form_display.paragraph.oe_list_item.default.yml b/modules/oe_whitelabel_paragraphs/config/post_updates/00003/core.entity_form_display.paragraph.oe_list_item.default.yml deleted file mode 100644 index a80ab707..00000000 --- a/modules/oe_whitelabel_paragraphs/config/post_updates/00003/core.entity_form_display.paragraph.oe_list_item.default.yml +++ /dev/null @@ -1,71 +0,0 @@ -langcode: en -status: true -dependencies: - config: - - field.field.paragraph.oe_list_item.field_oe_date - - field.field.paragraph.oe_list_item.field_oe_image - - field.field.paragraph.oe_list_item.field_oe_link - - field.field.paragraph.oe_list_item.field_oe_meta - - field.field.paragraph.oe_list_item.field_oe_text_long - - field.field.paragraph.oe_list_item.field_oe_title - - image.style.thumbnail - - paragraphs.paragraphs_type.oe_list_item - module: - - allowed_formats - - image - - link - - text -id: paragraph.oe_list_item.default -targetEntityType: paragraph -bundle: oe_list_item -mode: default -content: - field_oe_image: - type: image_image - weight: 3 - region: content - settings: - progress_indicator: throbber - preview_image_style: thumbnail - third_party_settings: { } - field_oe_link: - type: link_default - weight: 0 - region: content - settings: - placeholder_url: '' - placeholder_title: '' - third_party_settings: { } - field_oe_meta: - type: string_textfield - weight: 4 - region: content - settings: - size: 60 - placeholder: '' - third_party_settings: { } - field_oe_text_long: - type: text_textarea - weight: 2 - region: content - settings: - rows: 3 - placeholder: '' - third_party_settings: - allowed_formats: - hide_help: '1' - hide_guidelines: '1' - field_oe_title: - type: string_textfield - weight: 1 - region: content - settings: - size: 60 - placeholder: '' - third_party_settings: { } -hidden: - created: true - field_oe_date: true - status: true - translation: true - uid: true diff --git a/modules/oe_whitelabel_paragraphs/config/post_updates/00003/core.entity_form_display.paragraph.oe_list_item_block.default.yml b/modules/oe_whitelabel_paragraphs/config/post_updates/00003/core.entity_form_display.paragraph.oe_list_item_block.default.yml deleted file mode 100644 index 6497f1fd..00000000 --- a/modules/oe_whitelabel_paragraphs/config/post_updates/00003/core.entity_form_display.paragraph.oe_list_item_block.default.yml +++ /dev/null @@ -1,67 +0,0 @@ -langcode: en -status: true -dependencies: - config: - - field.field.paragraph.oe_list_item_block.field_oe_link - - field.field.paragraph.oe_list_item_block.field_oe_list_item_block_layout - - field.field.paragraph.oe_list_item_block.field_oe_paragraphs - - field.field.paragraph.oe_list_item_block.field_oe_title - - paragraphs.paragraphs_type.oe_list_item_block - module: - - link - - paragraphs -id: paragraph.oe_list_item_block.default -targetEntityType: paragraph -bundle: oe_list_item_block -mode: default -content: - field_oe_link: - type: link_default - weight: 3 - region: content - settings: - placeholder_url: '' - placeholder_title: '' - third_party_settings: { } - field_oe_list_item_block_layout: - type: options_select - weight: 0 - region: content - settings: { } - third_party_settings: { } - field_oe_paragraphs: - type: paragraphs - weight: 2 - region: content - settings: - title: Paragraph - title_plural: Paragraphs - edit_mode: closed - closed_mode: summary - autocollapse: none - closed_mode_threshold: 0 - add_mode: dropdown - form_display_mode: default - default_paragraph_type: oe_list_item - features: - add_above: '0' - collapse_edit_all: collapse_edit_all - duplicate: duplicate - third_party_settings: { } - field_oe_title: - type: string_textfield - weight: 1 - region: content - settings: - size: 60 - placeholder: '' - third_party_settings: { } - translation: - weight: 4 - region: content - settings: { } - third_party_settings: { } -hidden: - created: true - status: true - uid: true diff --git a/modules/oe_whitelabel_paragraphs/config/post_updates/00003/core.entity_form_display.paragraph.oe_list_item_block.highlight.yml b/modules/oe_whitelabel_paragraphs/config/post_updates/00003/core.entity_form_display.paragraph.oe_list_item_block.highlight.yml deleted file mode 100644 index 28e0a334..00000000 --- a/modules/oe_whitelabel_paragraphs/config/post_updates/00003/core.entity_form_display.paragraph.oe_list_item_block.highlight.yml +++ /dev/null @@ -1,68 +0,0 @@ -langcode: en -status: true -dependencies: - config: - - core.entity_form_mode.paragraph.highlight - - field.field.paragraph.oe_list_item_block.field_oe_link - - field.field.paragraph.oe_list_item_block.field_oe_list_item_block_layout - - field.field.paragraph.oe_list_item_block.field_oe_paragraphs - - field.field.paragraph.oe_list_item_block.field_oe_title - - paragraphs.paragraphs_type.oe_list_item_block - module: - - link - - paragraphs -id: paragraph.oe_list_item_block.highlight -targetEntityType: paragraph -bundle: oe_list_item_block -mode: highlight -content: - field_oe_link: - type: link_default - weight: 3 - region: content - settings: - placeholder_url: '' - placeholder_title: '' - third_party_settings: { } - field_oe_list_item_block_layout: - type: options_select - weight: 0 - region: content - settings: { } - third_party_settings: { } - field_oe_paragraphs: - type: paragraphs - weight: 2 - region: content - settings: - title: Paragraph - title_plural: Paragraphs - edit_mode: closed - closed_mode: summary - autocollapse: none - closed_mode_threshold: 0 - add_mode: dropdown - form_display_mode: highlight - default_paragraph_type: oe_list_item - features: - add_above: '0' - collapse_edit_all: collapse_edit_all - duplicate: duplicate - third_party_settings: { } - field_oe_title: - type: string_textfield - weight: 1 - region: content - settings: - size: 60 - placeholder: '' - third_party_settings: { } - translation: - weight: 4 - region: content - settings: { } - third_party_settings: { } -hidden: - created: true - status: true - uid: true diff --git a/modules/oe_whitelabel_paragraphs/config/post_updates/00003/core.entity_view_display.paragraph.oe_facts_figures.default.yml b/modules/oe_whitelabel_paragraphs/config/post_updates/00003/core.entity_view_display.paragraph.oe_facts_figures.default.yml deleted file mode 100644 index 6b3d6961..00000000 --- a/modules/oe_whitelabel_paragraphs/config/post_updates/00003/core.entity_view_display.paragraph.oe_facts_figures.default.yml +++ /dev/null @@ -1,48 +0,0 @@ -langcode: en -status: true -dependencies: - config: - - field.field.paragraph.oe_facts_figures.field_oe_link - - field.field.paragraph.oe_facts_figures.field_oe_paragraphs - - field.field.paragraph.oe_facts_figures.field_oe_title - - field.field.paragraph.oe_facts_figures.oe_w_n_columns - - paragraphs.paragraphs_type.oe_facts_figures - module: - - entity_reference_revisions - - link -id: paragraph.oe_facts_figures.default -targetEntityType: paragraph -bundle: oe_facts_figures -mode: default -content: - field_oe_link: - weight: 2 - label: above - settings: - trim_length: 80 - url_only: false - url_plain: false - rel: '' - target: '' - third_party_settings: { } - type: link - region: content - field_oe_paragraphs: - weight: 1 - label: above - settings: - view_mode: default - link: '' - third_party_settings: { } - type: entity_reference_revisions_entity_view - region: content - field_oe_title: - weight: 0 - label: above - settings: - link_to_entity: false - third_party_settings: { } - type: string - region: content -hidden: - oe_w_n_columns: true diff --git a/modules/oe_whitelabel_paragraphs/config/post_updates/00003/field.field.paragraph.oe_facts_figures.oe_w_n_columns.yml b/modules/oe_whitelabel_paragraphs/config/post_updates/00003/field.field.paragraph.oe_facts_figures.oe_w_n_columns.yml deleted file mode 100644 index 0165929a..00000000 --- a/modules/oe_whitelabel_paragraphs/config/post_updates/00003/field.field.paragraph.oe_facts_figures.oe_w_n_columns.yml +++ /dev/null @@ -1,24 +0,0 @@ -langcode: en -status: true -dependencies: - config: - - field.storage.paragraph.oe_w_n_columns - - paragraphs.paragraphs_type.oe_facts_figures -id: paragraph.oe_facts_figures.oe_w_n_columns -field_name: oe_w_n_columns -entity_type: paragraph -bundle: oe_facts_figures -label: 'Number of columns' -description: 'Sets the number of grid columns. Minimum number is 1 column and maximum is 3.' -required: false -translatable: false -default_value: - - - value: 1 -default_value_callback: '' -settings: - min: 1 - max: 3 - prefix: '' - suffix: '' -field_type: integer diff --git a/modules/oe_whitelabel_paragraphs/config/post_updates/00003/field.storage.paragraph.oe_w_n_columns.yml b/modules/oe_whitelabel_paragraphs/config/post_updates/00003/field.storage.paragraph.oe_w_n_columns.yml deleted file mode 100644 index 3a1a9cbc..00000000 --- a/modules/oe_whitelabel_paragraphs/config/post_updates/00003/field.storage.paragraph.oe_w_n_columns.yml +++ /dev/null @@ -1,19 +0,0 @@ -langcode: en -status: true -dependencies: - module: - - paragraphs -id: paragraph.oe_w_n_columns -field_name: oe_w_n_columns -entity_type: paragraph -type: integer -settings: - unsigned: false - size: normal -module: core -locked: false -cardinality: 1 -translatable: true -indexes: { } -persist_with_no_fields: false -custom_storage: false diff --git a/modules/oe_whitelabel_paragraphs/oe_whitelabel_paragraphs.post_update.php b/modules/oe_whitelabel_paragraphs/oe_whitelabel_paragraphs.post_update.php deleted file mode 100644 index 142f335d..00000000 --- a/modules/oe_whitelabel_paragraphs/oe_whitelabel_paragraphs.post_update.php +++ /dev/null @@ -1,65 +0,0 @@ -<?php - -/** - * @file - * Post update functions for the OE Whitelabel paragraphs module. - */ - -declare(strict_types = 1); - -use Drupal\oe_whitelabel\ConfigImporter; - -/** - * Add extra fields to description list paragraph. - */ -function oe_whitelabel_paragraphs_post_update_00001(array &$sandbox): void { - \Drupal::service('module_installer')->install(['oe_paragraphs_description_list']); - - $configs = [ - 'field.storage.paragraph.oe_w_orientation', - 'field.field.paragraph.oe_description_list.oe_w_orientation', - 'core.entity_form_display.paragraph.oe_description_list.default', - 'core.entity_view_display.paragraph.oe_description_list.default', - ]; - - ConfigImporter::importMultiple('oe_whitelabel_paragraphs', '/config/post_updates/00001/', $configs, TRUE); -} - -/** - * Hides the field icon at Accordion item paragraph. - */ -function oe_whitelabel_paragraphs_post_update_00002(array &$sandbox): void { - $configs = [ - 'core.entity_form_display.paragraph.oe_accordion_item.default', - 'core.entity_view_display.paragraph.oe_accordion_item.default', - ]; - - ConfigImporter::importMultiple('oe_whitelabel_paragraphs', '/config/post_updates/00002/', $configs, TRUE); -} - -/** - * Display new layout field at facts&figures paragraph. - */ -function oe_whitelabel_paragraphs_post_update_00003(array &$sandbox): void { - $configs = [ - 'field.storage.paragraph.oe_w_n_columns', - 'field.field.paragraph.oe_facts_figures.oe_w_n_columns', - 'core.entity_form_display.paragraph.oe_facts_figures.default', - 'core.entity_view_display.paragraph.oe_facts_figures.default', - ]; - - ConfigImporter::importMultiple('oe_whitelabel_paragraphs', '/config/post_updates/00003/', $configs, TRUE); -} - -/** - * Form modes for variants of list paragraphs. - */ -function oe_whitelabel_paragraphs_post_update_00004(array &$sandbox): void { - $configs = [ - 'core.entity_form_display.paragraph.oe_list_item_block.default', - 'core.entity_form_display.paragraph.oe_list_item_block.highlight', - 'core.entity_form_display.paragraph.oe_list_item.default', - ]; - - ConfigImporter::importMultiple('oe_whitelabel_paragraphs', '/config/post_updates/00003/', $configs, TRUE); -} -- GitLab From 4fd7fda190cdc812f963d2f99c118e30f58c2c79 Mon Sep 17 00:00:00 2001 From: Abel Santos <abel.santos.corral@gmail.com> Date: Thu, 17 Mar 2022 14:09:49 +0100 Subject: [PATCH 19/21] OEL-1280: Sort list configs and add missing element at oe_whitelabel_paragraphs.install. --- .../oe_whitelabel_paragraphs.install | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/modules/oe_whitelabel_paragraphs/oe_whitelabel_paragraphs.install b/modules/oe_whitelabel_paragraphs/oe_whitelabel_paragraphs.install index ac746f3f..a6ba792d 100644 --- a/modules/oe_whitelabel_paragraphs/oe_whitelabel_paragraphs.install +++ b/modules/oe_whitelabel_paragraphs/oe_whitelabel_paragraphs.install @@ -21,19 +21,20 @@ function oe_whitelabel_paragraphs_install($is_syncing): void { } $configs = [ - 'core.entity_form_display.paragraph.oe_links_block.default', - 'core.entity_form_display.paragraph.oe_social_media_follow.default', - 'core.entity_view_display.paragraph.oe_links_block.default', - 'core.entity_view_display.paragraph.oe_social_media_follow.default', - 'core.entity_form_display.paragraph.oe_description_list.default', - 'core.entity_view_display.paragraph.oe_description_list.default', 'core.entity_form_display.paragraph.oe_accordion_item.default', - 'core.entity_view_display.paragraph.oe_accordion_item.default', + 'core.entity_form_display.paragraph.oe_description_list.default', 'core.entity_form_display.paragraph.oe_facts_figures.default', - 'core.entity_view_display.paragraph.oe_facts_figures.default', + 'core.entity_form_display.paragraph.oe_links_block.default', + 'core.entity_form_display.paragraph.oe_list_item.default', 'core.entity_form_display.paragraph.oe_list_item_block.default', 'core.entity_form_display.paragraph.oe_list_item_block.highlight', - 'core.entity_form_display.paragraph.oe_list_item.default', + 'core.entity_form_display.paragraph.oe_social_media_follow.default', + 'core.entity_view_display.paragraph.oe_accordion_item.default', + 'core.entity_view_display.paragraph.oe_description_list.default', + 'core.entity_view_display.paragraph.oe_facts_figures.default', + 'core.entity_view_display.paragraph.oe_links_block.default', + 'core.entity_view_display.paragraph.oe_social_media_follow.default', + 'field.field.paragraph.oe_social_media_follow.field_oe_social_media_variant', ]; ConfigImporter::importMultiple('oe_whitelabel_paragraphs', '/config/overrides/', $configs); -- GitLab From 4615487a9b651ddb4723f3af05c3cb109a26166c Mon Sep 17 00:00:00 2001 From: Abel Santos <abel.santos.corral@gmail.com> Date: Thu, 17 Mar 2022 14:26:47 +0100 Subject: [PATCH 20/21] OEL-1280: Bring file field--entity-reference-revisions--paragraph.html.twig. --- ...-entity-reference-revisions--paragraph.html.twig | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 templates/overrides/field/field--entity-reference-revisions--paragraph.html.twig diff --git a/templates/overrides/field/field--entity-reference-revisions--paragraph.html.twig b/templates/overrides/field/field--entity-reference-revisions--paragraph.html.twig new file mode 100644 index 00000000..e8157acd --- /dev/null +++ b/templates/overrides/field/field--entity-reference-revisions--paragraph.html.twig @@ -0,0 +1,13 @@ +{# +/** + * @file + * Theme override for the entity reference revisions field which allowed to use paragraphs. + * + * @see ./templates/field/field--bare.html.twig + */ +#} +{% for item in items %} + <div class="my-4"> + {{ item.content }} + </div> +{% endfor %} -- GitLab From efd8df0182f81dc40dc1111581a655fa4c9f9a09 Mon Sep 17 00:00:00 2001 From: Andreas Hennings <andreas@dqxtech.net> Date: Thu, 17 Mar 2022 18:03:28 +0100 Subject: [PATCH 21/21] OEL-1280: Use latest version of oe_bootstrap_theme in epic. --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 451e0645..b878e78b 100644 --- a/composer.json +++ b/composer.json @@ -10,7 +10,7 @@ "cweagans/composer-patches": "^1.7", "drupal/core": "^9.2", "drupal/twig_field_value": "^2.0", - "openeuropa/oe_bootstrap_theme": "0.1280.202203170900" + "openeuropa/oe_bootstrap_theme": "0.1255.202203171757" }, "require-dev": { "composer/installers": "^1.11", -- GitLab