From 30479fa2bf818860075af9ba00e3f8f30126c0b6 Mon Sep 17 00:00:00 2001 From: Evgenii Nikitin Date: Tue, 15 Jun 2021 18:34:12 +0300 Subject: [PATCH 01/41] EWPP-876: Theme the link and new variants on text with featued media paragraphs. --- composer.json | 2 +- oe_theme.theme | 14 +++++ ...paragraph--oe-text-feature-media.html.twig | 2 + .../pattern-text-featured-media.html.twig | 43 ++++++++++++-- .../text_featured_media.ui_patterns.yml | 20 +++++++ .../Kernel/Paragraphs/MediaParagraphsTest.php | 49 ++++++++++++++++ tests/Kernel/fixtures/rendering.yml | 47 +++++++++++++-- .../TextFeaturedMediaAssert.php | 58 ++++++++++++++++++- 8 files changed, 224 insertions(+), 11 deletions(-) diff --git a/composer.json b/composer.json index 9981d904c..542f04369 100644 --- a/composer.json +++ b/composer.json @@ -52,7 +52,7 @@ "openeuropa/oe_corporate_countries": "~2.0", "openeuropa/oe_media": "~1.12", "openeuropa/oe_multilingual": "dev-master", - "openeuropa/oe_paragraphs": "dev-master", + "openeuropa/oe_paragraphs": "dev-EPIC-EWPP-873-Text-media-2", "openeuropa/oe_search": "~1.0", "openeuropa/oe_webtools": "~1.10", "openeuropa/oe_contact_forms": "~1.0", diff --git a/oe_theme.theme b/oe_theme.theme index 2194d385a..9e3b4f776 100644 --- a/oe_theme.theme +++ b/oe_theme.theme @@ -906,6 +906,20 @@ function oe_theme_preprocess_paragraph__oe_text_feature_media(array &$variables) /** @var \Drupal\paragraphs\Entity\Paragraph $paragraph */ $paragraph = $variables['paragraph']; + // Set pattern variant. + if (!$paragraph->get('oe_paragraphs_variant')->isEmpty()) { + $variables['variant'] = $paragraph->get('oe_paragraphs_variant')->first()->value; + } + + // Add link field. + if (!$paragraph->get('field_oe_link')->isEmpty()) { + $link_field = $paragraph->get('field_oe_link')->first(); + $variables['link'] = [ + 'path' => $link_field->getUrl()->toString(), + 'label' => $link_field->get('title')->getValue(), + ]; + } + // Bail out if there is no media present. if ($paragraph->get('field_oe_media')->isEmpty()) { return; diff --git a/templates/paragraphs/paragraph--oe-text-feature-media.html.twig b/templates/paragraphs/paragraph--oe-text-feature-media.html.twig index 102d0e286..23e73a607 100644 --- a/templates/paragraphs/paragraph--oe-text-feature-media.html.twig +++ b/templates/paragraphs/paragraph--oe-text-feature-media.html.twig @@ -13,10 +13,12 @@ #} {{ pattern('text_featured_media', { + 'variant': variant, 'title': not paragraph.field_oe_title.isEmpty ? content.field_oe_title, 'image': image, 'video': video, 'video_ratio': ratio, '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/patterns/text_featured_media/pattern-text-featured-media.html.twig b/templates/patterns/text_featured_media/pattern-text-featured-media.html.twig index e69554de4..52abfec56 100644 --- a/templates/patterns/text_featured_media/pattern-text-featured-media.html.twig +++ b/templates/patterns/text_featured_media/pattern-text-featured-media.html.twig @@ -2,9 +2,13 @@ /** * @file * Text with featured media. + * + * Variant "left_simple" is used by default. */ #} +{% set variant = variant|default('left_simple') %} + {% set video_ratio = video_ratio|replace({':': '-'}) %} {% set allowed_values = ['16-9','4-3','3-2','1-1'] %} {% if video_ratio not in allowed_values %} @@ -12,13 +16,39 @@ {% endif %} {% set text = text|render %} -{% if image or video or text %} +{% set media_position_class = ' ecl-u-order-md-last' %} +{% if 'right' in variant %} + {% set media_position_class = '' %} +{% endif %} + +{% set call_to_action_link = '' %} +{% if link %} + {% set link_type = 'standalone' %} + {% if 'featured' in variant %} + {% set link_type = 'cta' %} + {% endif %} + + {% set call_to_action_link %} + {% include '@ecl-twig/link' with { + link: { + type: link_type, + label: link.label, + path: link.path, + icon_position: 'after' + }, + extra_classes: 'ecl-u-mt-m ecl-u-mt-md-l ecl-u-type-bold', + icon: get_link_icon(link.path) + } %} + {% endset %} +{% endif %} + +{% if image or video or text or call_to_action_link %} {% if title %}

{{ title }}

{% endif %}
{% if image or video %} -
+
{% if image %} {% include '@ecl-twig/media-container' with { 'image': image.src, @@ -34,8 +64,13 @@ {% endif %}
{% endif %} - {% if text %} -
{{ text }}
+ {% if text or call_to_action_link %} +
+ {% if text %} +
{{ text }}
+ {% endif %} + {{ call_to_action_link }} +
{% endif %}
{% endif %} diff --git a/templates/patterns/text_featured_media/text_featured_media.ui_patterns.yml b/templates/patterns/text_featured_media/text_featured_media.ui_patterns.yml index 19ad77a3a..f42e9a3f2 100644 --- a/templates/patterns/text_featured_media/text_featured_media.ui_patterns.yml +++ b/templates/patterns/text_featured_media/text_featured_media.ui_patterns.yml @@ -1,6 +1,19 @@ text_featured_media: label: "Text with Featured media" description: "Shows a rich text with a title and a featured media on the right, if any." + variants: + left_simple: + label: 'Left simple' + description: 'Text on the left, simple call to action.' + right_simple: + label: 'Right simple' + description: 'Text on the right, simple call to action.' + left_featured: + label: 'Left featured' + description: 'Text on the left, featured call to action' + right_featured: + label: 'Right featured' + description: 'Text on the right, featured call to action' fields: title: type: "text" @@ -35,3 +48,10 @@ text_featured_media: label: "Video aspect ratio" description: "Aspect ratio used to display videos in media container. Allowed values: 16:9, 4:3, 3:2, 1:1. Defaults to 16:9 if in invalid value is passed. This will not have any effects when used with images." preview: "16:9" + link: + type: "array" + label: "Link" + description: "Call to action link with icon" + preview: + label: "View all" + path: "#" diff --git a/tests/Kernel/Paragraphs/MediaParagraphsTest.php b/tests/Kernel/Paragraphs/MediaParagraphsTest.php index c37a41ee5..06096e930 100644 --- a/tests/Kernel/Paragraphs/MediaParagraphsTest.php +++ b/tests/Kernel/Paragraphs/MediaParagraphsTest.php @@ -282,6 +282,55 @@ public function testTextWithMedia(): void { $html = $this->renderParagraph($paragraph); $expected_values['video_ratio'] = '1:1'; $assert->assertPattern($expected_values, $html); + + // Assert Link field. + $paragraph->set('field_oe_link', [ + 'uri' => 'http://www.example.com/', + 'title' => 'Read more', + ])->save(); + + $html = $this->renderParagraph($paragraph); + $expected_values['link'] = [ + 'label' => 'Read more', + 'path' => 'http://www.example.com/', + 'icon' => 'external', + ]; + $assert->assertPattern($expected_values, $html); + $assert->assertVariant('left_simple', $html); + + // Assert icon of the Link field. + $paragraph->set('field_oe_link', [ + 'uri' => 'internal:/', + 'title' => 'Read more', + ])->save(); + + $html = $this->renderParagraph($paragraph); + $expected_values['link'] = [ + 'label' => 'Read more', + 'path' => '/', + 'icon' => 'corner-arrow', + ]; + $assert->assertPattern($expected_values, $html); + + // Assert "Text on the left, simple call to action" variant. + $paragraph->set('oe_paragraphs_variant', 'left_simple')->save(); + $html = $this->renderParagraph($paragraph); + $assert->assertVariant('left_simple', $html); + + // Assert "Text on the right, simple call to action" variant. + $paragraph->set('oe_paragraphs_variant', 'right_simple')->save(); + $html = $this->renderParagraph($paragraph); + $assert->assertVariant('right_simple', $html); + + // Assert "Text on the left, featured call to action" variant. + $paragraph->set('oe_paragraphs_variant', 'left_featured')->save(); + $html = $this->renderParagraph($paragraph); + $assert->assertVariant('left_featured', $html); + + // Assert "Text on the right, featured call to action" variant. + $paragraph->set('oe_paragraphs_variant', 'right_featured')->save(); + $html = $this->renderParagraph($paragraph); + $assert->assertVariant('right_featured', $html); } /** diff --git a/tests/Kernel/fixtures/rendering.yml b/tests/Kernel/fixtures/rendering.yml index 9d16ac662..510293445 100644 --- a/tests/Kernel/fixtures/rendering.yml +++ b/tests/Kernel/fixtures/rendering.yml @@ -2264,42 +2264,56 @@ - array: '#type': pattern '#id': text_featured_media + '#variant': "left_simple" '#fields': title: "Heading" image: src: "http://via.placeholder.com/150x150" caption: "Some caption text for the image" text: "Some more text" + link: + label: "Call to action" + path: "http://example.com" assertions: count: 'div.ecl-row': 1 + 'div.ecl-col-md-6.ecl-u-mb-m.ecl-u-mb-md-none.ecl-u-order-md-last': 1 'figure.ecl-media-container': 1 'img.ecl-media-container__media[src="http://via.placeholder.com/150x150"]': 1 'div.ecl-media-container__media--ratio-16-9 iframe': 0 'figcaption.ecl-media-container__caption': 1 + 'a.ecl-link.ecl-link--standalone[href="http://example.com"]': 1 equals: 'h2.ecl-u-type-heading-2': "Heading" 'figcaption.ecl-media-container__caption': "Some caption text for the image" - 'div.ecl-col-md-6.ecl-editor': "Some more text" + 'div.ecl-col-md-6 div.ecl-editor': "Some more text" + 'a.ecl-link span.ecl-link__label': "Call to action" - array: '#type': pattern '#id': text_featured_media + '#variant': "right_simple" '#fields': image: src: "http://via.placeholder.com/150x150" caption: "Some caption text for the image" text: "Some more text" + link: + label: "Call to action" + path: "http://example.com" assertions: count: 'h2.ecl-u-type-heading-2': 0 'div.ecl-row': 1 + 'div.ecl-col-md-6.ecl-u-mb-m.ecl-u-mb-md-none.ecl-u-order-md-last': 0 'figure.ecl-media-container': 1 'img.ecl-media-container__media[src="http://via.placeholder.com/150x150"]': 1 'div.ecl-media-container__media--ratio-16-9 iframe': 0 'figcaption.ecl-media-container__caption': 1 + 'a.ecl-link.ecl-link--standalone[href="http://example.com"]': 1 equals: 'figcaption.ecl-media-container__caption': "Some caption text for the image" - 'div.ecl-col-md-6.ecl-editor': "Some more text" + 'div.ecl-col-md-6 div.ecl-editor': "Some more text" + 'a.ecl-link span.ecl-link__label': "Call to action" - array: '#type': pattern '#id': text_featured_media @@ -2310,32 +2324,41 @@ assertions: count: 'div.ecl-row': 1 + 'div.ecl-col-md-6.ecl-u-mb-m.ecl-u-mb-md-none': 0 'figure.ecl-media-container': 0 'div.ecl-col-md-6.ecl-editor': 0 'img.ecl-media-container__media[src="http://via.placeholder.com/150x150"]': 0 'div.ecl-media-container__media--ratio-16-9 iframe': 0 'figcaption.ecl-media-container__caption': 0 + 'a.ecl-link': 0 equals: 'h2.ecl-u-type-heading-2': "Heading" - 'div.ecl-col-12.ecl-editor': "Some more text" + 'div.ecl-col-12 div.ecl-editor': "Some more text" - array: '#type': pattern '#id': text_featured_media + '#variant': "right_featured" '#fields': title: "Heading" image: src: "http://via.placeholder.com/150x150" text: "Some more text" + link: + label: "Call to action" + path: "http://example.com" assertions: count: 'div.ecl-row': 1 + 'div.ecl-col-md-6.ecl-u-mb-m.ecl-u-mb-md-none.ecl-u-order-md-last': 0 'figure.ecl-media-container': 1 'img.ecl-media-container__media[src="http://via.placeholder.com/150x150"]': 1 'div.ecl-media-container__media--ratio-16-9 iframe': 0 'figcaption.ecl-media-container__caption': 0 + 'a.ecl-link.ecl-link--cta[href="http://example.com"]': 1 equals: 'h2.ecl-u-type-heading-2': "Heading" - 'div.ecl-col-md-6.ecl-editor': "Some more text" + 'div.ecl-col-md-6 div.ecl-editor': "Some more text" + 'a.ecl-link span.ecl-link__label': "Call to action" - array: '#type': pattern '#id': text_featured_media @@ -2346,14 +2369,17 @@ count: 'div.ecl-row': 0 'figure.ecl-media-container': 0 + 'div.ecl-col-md-6.ecl-u-mb-m.ecl-u-mb-md-none': 0 'img.ecl-media-container__media[src="http://via.placeholder.com/150x150"]': 0 'div.ecl-media-container__media--ratio-16-9 iframe': 0 'figcaption.ecl-media-container__caption': 0 'h2.ecl-u-type-heading-2': 0 + 'a.ecl-link': 0 equals: {} - array: '#type': pattern '#id': text_featured_media + '#variant': "left_featured" '#fields': title: "Heading" video: @@ -2363,16 +2389,22 @@ id: 'videoplayerI-181645' src: '//ec.europa.eu/avservices/play.cfm?ref=I-181645' text: "Some more text" + link: + label: "Call to action" + path: "http://example.com" assertions: count: 'div.ecl-row': 1 + 'div.ecl-col-md-6.ecl-u-mb-m.ecl-u-mb-md-none.ecl-u-order-md-last': 1 'figure.ecl-media-container': 1 'img.ecl-media-container__media[src="http://via.placeholder.com/150x150"]': 0 'div.ecl-media-container__media--ratio-16-9 iframe[src="//ec.europa.eu/avservices/play.cfm?ref=I-181645"]': 1 'figcaption.ecl-media-container__caption': 0 + 'a.ecl-link.ecl-link--cta[href="http://example.com"]': 1 equals: 'h2.ecl-u-type-heading-2': "Heading" - 'div.ecl-col-md-6.ecl-editor': "Some more text" + 'div.ecl-col-md-6 div.ecl-editor': "Some more text" + 'a.ecl-link span.ecl-link__label': "Call to action" - array: '#type': pattern '#id': text_featured_media @@ -2398,9 +2430,14 @@ id: 'videoplayerI-181645' src: '//ec.europa.eu/avservices/play.cfm?ref=I-181645' video_ratio: "1:1" + link: + label: "Call to action" + path: "http://example.com" assertions: count: 'div.ecl-media-container__media--ratio-1-1 iframe[src="//ec.europa.eu/avservices/play.cfm?ref=I-181645"]': 1 + 'div.ecl-col-md-6.ecl-u-mb-m.ecl-u-mb-md-none.ecl-u-order-md-last': 1 + 'a.ecl-link.ecl-link--standalone[href="http://example.com"]': 1 - array: '#type': pattern '#id': icons_with_text diff --git a/tests/PatternAssertions/TextFeaturedMediaAssert.php b/tests/PatternAssertions/TextFeaturedMediaAssert.php index e1496baa2..7fecfa11c 100644 --- a/tests/PatternAssertions/TextFeaturedMediaAssert.php +++ b/tests/PatternAssertions/TextFeaturedMediaAssert.php @@ -37,12 +37,15 @@ protected function getAssertions($variant): array { ], 'text' => [ [$this, 'assertElementText'], - 'div.ecl-row > div.ecl-editor', + 'div.ecl-row div.ecl-editor div.ecl-editor', ], 'video_ratio' => [ [$this, 'assertVideoRatio'], 'div.ecl-row figure.ecl-media-container div.ecl-media-container__media', ], + 'link' => [ + [$this, 'assertLink'], + ], ]; } @@ -74,4 +77,57 @@ protected function assertVideoRatio(string $expected_ratio, string $selector, Cr } } + /** + * Asserts the link of the pattern. + * + * @param array $expected_link + * Array with keys: 'label', 'path', 'icon'. + * 'icon' can be 'external' or 'corner-arrow'. + * @param \Symfony\Component\DomCrawler\Crawler $crawler + * The DomCrawler where to check the element. + */ + protected function assertLink(array $expected_link, Crawler $crawler): void { + $link_element = $crawler->filter('a.ecl-link.ecl-link--icon.ecl-link--icon-after.ecl-u-mt-m.ecl-u-mt-md-l.ecl-u-type-bold'); + self::assertEquals($expected_link['path'], $link_element->attr('href')); + + $label_element = $link_element->filter('span.ecl-link__label'); + self::assertEquals($expected_link['label'], $label_element->text()); + + $svg = $link_element->filter('svg.ecl-icon.ecl-icon--s.ecl-icon--primary.ecl-link__icon use'); + self::assertContains('icons.svg#ui--' . $expected_link['icon'], $svg->attr('xlink:href')); + } + + /** + * {@inheritdoc} + */ + protected function getPatternVariant(string $html): string { + // Variant can be clearly recognised if image or video and link exist only. + // In case if the link isn't provided then "left_simple", "right_simple" + // will be returned based on the position of media. + // In case if the image or video aren't provided then + // "left_simple", "left_featured" will be returned based on the link style. + // If image or video and link aren't provided then "left_simple" will be + // returned as default value. + $crawler = new Crawler($html); + + $position_variant = 'left'; + $media_position = $crawler->filter('.ecl-u-order-md-last'); + if (!$media_position->count()) { + // Class doesn't exist. + $position_variant = 'right'; + } + + $link_variant = 'simple'; + $link_element = $crawler->filter('a.ecl-link.ecl-link--icon'); + if ($link_element->count()) { + // Link exists. + $link_class = $link_element->attr('class'); + if (strpos($link_class, 'ecl-link--cta') !== FALSE) { + $link_variant = 'featured'; + } + } + + return $position_variant . '_' . $link_variant; + } + } From dec6f4da8937d53befe9adb536d8ef4dfe07952d Mon Sep 17 00:00:00 2001 From: Evgenii Nikitin Date: Fri, 25 Jun 2021 11:49:36 +0300 Subject: [PATCH 02/41] EWPP-876: Ensure that variant without media is recognised properly. --- .../pattern-text-featured-media.html.twig | 10 ++---- .../text_featured_media.ui_patterns.yml | 2 +- .../Kernel/Paragraphs/MediaParagraphsTest.php | 31 ++++++++++++++++++- .../TextFeaturedMediaAssert.php | 20 ++++++------ 4 files changed, 44 insertions(+), 19 deletions(-) diff --git a/templates/patterns/text_featured_media/pattern-text-featured-media.html.twig b/templates/patterns/text_featured_media/pattern-text-featured-media.html.twig index 52abfec56..f6ff7000c 100644 --- a/templates/patterns/text_featured_media/pattern-text-featured-media.html.twig +++ b/templates/patterns/text_featured_media/pattern-text-featured-media.html.twig @@ -16,17 +16,11 @@ {% endif %} {% set text = text|render %} -{% set media_position_class = ' ecl-u-order-md-last' %} -{% if 'right' in variant %} - {% set media_position_class = '' %} -{% endif %} +{% set media_position_class = 'right' in variant ? '' : ' ecl-u-order-md-last' %} {% set call_to_action_link = '' %} {% if link %} - {% set link_type = 'standalone' %} - {% if 'featured' in variant %} - {% set link_type = 'cta' %} - {% endif %} + {% set link_type = 'featured' in variant ? 'cta' : 'standalone' %} {% set call_to_action_link %} {% include '@ecl-twig/link' with { diff --git a/templates/patterns/text_featured_media/text_featured_media.ui_patterns.yml b/templates/patterns/text_featured_media/text_featured_media.ui_patterns.yml index f42e9a3f2..07f3ba853 100644 --- a/templates/patterns/text_featured_media/text_featured_media.ui_patterns.yml +++ b/templates/patterns/text_featured_media/text_featured_media.ui_patterns.yml @@ -4,7 +4,7 @@ text_featured_media: variants: left_simple: label: 'Left simple' - description: 'Text on the left, simple call to action.' + description: 'Text on the left, simple call to action. This is the default behaviour.' right_simple: label: 'Right simple' description: 'Text on the right, simple call to action.' diff --git a/tests/Kernel/Paragraphs/MediaParagraphsTest.php b/tests/Kernel/Paragraphs/MediaParagraphsTest.php index 06096e930..71a1696c6 100644 --- a/tests/Kernel/Paragraphs/MediaParagraphsTest.php +++ b/tests/Kernel/Paragraphs/MediaParagraphsTest.php @@ -87,6 +87,7 @@ public function testTextWithMedia(): void { 'image' => NULL, ]; $assert->assertPattern($expected_values, $html); + $assert->assertVariant('left_simple', $html); // Set image media translatable. $this->container->get('content_translation.manager')->setEnabled('media', 'image', TRUE); @@ -145,6 +146,7 @@ public function testTextWithMedia(): void { ]; $html = $this->renderParagraph($paragraph, 'en'); $assert->assertPattern($expected_values, $html); + $assert->assertVariant('left_simple', $html); $expected_values = [ 'title' => 'Title bg', @@ -174,6 +176,7 @@ public function testTextWithMedia(): void { ]; $html = $this->renderParagraph($paragraph); $assert->assertPattern($expected_values, $html); + $assert->assertVariant('left_simple', $html); // Publish the media. $media->set('status', 1); @@ -198,6 +201,7 @@ public function testTextWithMedia(): void { ], ]; $assert->assertPattern($expected_values, $html); + $assert->assertVariant('left_simple', $html); // Remove the title and assert the element is no longer rendered. $paragraph->set('field_oe_title', ''); @@ -206,6 +210,7 @@ public function testTextWithMedia(): void { $html = $this->renderParagraph($paragraph); $expected_values['title'] = NULL; $assert->assertPattern($expected_values, $html); + $assert->assertVariant('left_simple', $html); // Create a remote video and add it to the paragraph. $media = $media_storage->create([ @@ -248,6 +253,7 @@ public function testTextWithMedia(): void { 'video_ratio' => '16:9', ]; $assert->assertPattern($expected_values, $html); + $assert->assertVariant('left_simple', $html); // Create iframe video with aspect ration 16:9 and add it to the paragraph. $media = $media_storage->create([ @@ -257,6 +263,7 @@ public function testTextWithMedia(): void { ]); $media->save(); $paragraph->set('field_oe_media', ['target_id' => $media->id()]); + $paragraph->set('oe_paragraphs_variant', 'left_featured'); $paragraph->save(); $html = $this->renderParagraph($paragraph); @@ -268,6 +275,8 @@ public function testTextWithMedia(): void { 'video_ratio' => '16:9', ]; $assert->assertPattern($expected_values, $html); + // Since link doesn't exist variant is recognized as "left_simple". + $assert->assertVariant('left_simple', $html); // Create iframe video with aspect ration 1:1 and add it to the paragraph. $media = $media_storage->create([ @@ -282,6 +291,7 @@ public function testTextWithMedia(): void { $html = $this->renderParagraph($paragraph); $expected_values['video_ratio'] = '1:1'; $assert->assertPattern($expected_values, $html); + $assert->assertVariant('left_simple', $html); // Assert Link field. $paragraph->set('field_oe_link', [ @@ -296,7 +306,7 @@ public function testTextWithMedia(): void { 'icon' => 'external', ]; $assert->assertPattern($expected_values, $html); - $assert->assertVariant('left_simple', $html); + $assert->assertVariant('left_featured', $html); // Assert icon of the Link field. $paragraph->set('field_oe_link', [ @@ -311,6 +321,7 @@ public function testTextWithMedia(): void { 'icon' => 'corner-arrow', ]; $assert->assertPattern($expected_values, $html); + $assert->assertVariant('left_featured', $html); // Assert "Text on the left, simple call to action" variant. $paragraph->set('oe_paragraphs_variant', 'left_simple')->save(); @@ -331,6 +342,24 @@ public function testTextWithMedia(): void { $paragraph->set('oe_paragraphs_variant', 'right_featured')->save(); $html = $this->renderParagraph($paragraph); $assert->assertVariant('right_featured', $html); + + // Assert Link field without media. + $paragraph->set('field_oe_media', [])->save(); + $expected_values = [ + 'title' => NULL, + 'caption' => NULL, + 'text' => NULL, + 'link' => [ + 'label' => 'Read more', + 'path' => '/', + 'icon' => 'corner-arrow', + ], + ]; + $html = $this->renderParagraph($paragraph); + $assert->assertPattern($expected_values, $html); + // Variant "right_featured" without media but with link will be determined + // as "left_featured". + $assert->assertVariant('left_featured', $html); } /** diff --git a/tests/PatternAssertions/TextFeaturedMediaAssert.php b/tests/PatternAssertions/TextFeaturedMediaAssert.php index 7fecfa11c..8943b4a50 100644 --- a/tests/PatternAssertions/TextFeaturedMediaAssert.php +++ b/tests/PatternAssertions/TextFeaturedMediaAssert.php @@ -101,19 +101,21 @@ protected function assertLink(array $expected_link, Crawler $crawler): void { * {@inheritdoc} */ protected function getPatternVariant(string $html): string { - // Variant can be clearly recognised if image or video and link exist only. - // In case if the link isn't provided then "left_simple", "right_simple" - // will be returned based on the position of media. - // In case if the image or video aren't provided then - // "left_simple", "left_featured" will be returned based on the link style. - // If image or video and link aren't provided then "left_simple" will be - // returned as default value. + // The variant is extracted by checking the presence and properties + // of the media and link. + // If the link is not present then we return "left_simple" or "right_simple" + // based on the media position. + // If the media is not present then "left simple" or "left featured" + // will be returned based on the link style. + // If neither media nor image are present then "left_simple? will be + // returned. $crawler = new Crawler($html); $position_variant = 'left'; + $media_wrapper = $crawler->filter('.ecl-col-md-6.ecl-u-mb-m.ecl-u-mb-md-none'); $media_position = $crawler->filter('.ecl-u-order-md-last'); - if (!$media_position->count()) { - // Class doesn't exist. + if ($media_wrapper->count() && !$media_position->count()) { + // Media exists but media position class doesn't exist. $position_variant = 'right'; } From 0a27a2e7e56122e8fd372d8c7a4fdb8c57748398 Mon Sep 17 00:00:00 2001 From: Antonio De Marco Date: Wed, 7 Jul 2021 12:20:56 +0200 Subject: [PATCH 03/41] EWPP-876: Add README entry. --- README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/README.md b/README.md index ace17c763..d475393d2 100644 --- a/README.md +++ b/README.md @@ -113,6 +113,20 @@ users can access to the main navigation menu only on sites using standardised EC To learn more about EC/EU families and ECL branding visit the [ECL website](https://ec.europa.eu/component-library). +### Upgrade to 2.21.0 + +#### Text with Featured media pattern + +The pattern [Text with Featured media](/templates/patterns/text_featured_media/text_featured_media.ui_patterns.yml) now +supports the following 4 variants: + +- Left simple / `left_simple`: text on the left, simple call to action. This is the default behaviour. +- Right simple / `right_simple`: text on the right, simple call to action. +- Left featured / `left_featured`: text on the left, featured call to action. +- Right featured / `right_featured`: text on the right, featured call to action. + +If no variant is set, then the pattern will be visualized using the default one. This guarantees backward compatibility. + ### Upgrade to 2.17.0 #### Dropdown UI pattern From 243e170e0ff475ded50d90505eab9cd06aa66d59 Mon Sep 17 00:00:00 2001 From: Evgenii Nikitin Date: Mon, 12 Jul 2021 18:31:52 +0300 Subject: [PATCH 04/41] EWPP-1327: Theme text with featured media title. --- composer.json | 2 +- ...paragraph--oe-text-feature-media.html.twig | 1 + .../pattern-text-featured-media.html.twig | 7 +++- .../text_featured_media.ui_patterns.yml | 5 +++ .../Kernel/Paragraphs/MediaParagraphsTest.php | 38 ++++++++++++----- tests/Kernel/fixtures/rendering.yml | 41 +++++++++++++++++++ .../TextFeaturedMediaAssert.php | 4 ++ 7 files changed, 85 insertions(+), 13 deletions(-) diff --git a/composer.json b/composer.json index 542f04369..fc694d051 100644 --- a/composer.json +++ b/composer.json @@ -52,7 +52,7 @@ "openeuropa/oe_corporate_countries": "~2.0", "openeuropa/oe_media": "~1.12", "openeuropa/oe_multilingual": "dev-master", - "openeuropa/oe_paragraphs": "dev-EPIC-EWPP-873-Text-media-2", + "openeuropa/oe_paragraphs": "dev-EWPP-1326", "openeuropa/oe_search": "~1.0", "openeuropa/oe_webtools": "~1.10", "openeuropa/oe_contact_forms": "~1.0", diff --git a/templates/paragraphs/paragraph--oe-text-feature-media.html.twig b/templates/paragraphs/paragraph--oe-text-feature-media.html.twig index 23e73a607..e6345ed2e 100644 --- a/templates/paragraphs/paragraph--oe-text-feature-media.html.twig +++ b/templates/paragraphs/paragraph--oe-text-feature-media.html.twig @@ -15,6 +15,7 @@ {{ pattern('text_featured_media', { 'variant': variant, 'title': not paragraph.field_oe_title.isEmpty ? content.field_oe_title, + 'text_title': not paragraph.field_oe_text_title.isEmpty ? content.field_oe_text_title, 'image': image, 'video': video, 'video_ratio': ratio, diff --git a/templates/patterns/text_featured_media/pattern-text-featured-media.html.twig b/templates/patterns/text_featured_media/pattern-text-featured-media.html.twig index f6ff7000c..40c7d77b3 100644 --- a/templates/patterns/text_featured_media/pattern-text-featured-media.html.twig +++ b/templates/patterns/text_featured_media/pattern-text-featured-media.html.twig @@ -36,7 +36,7 @@ {% endset %} {% endif %} -{% if image or video or text or call_to_action_link %} +{% if image or video or text or call_to_action_link or text_title %} {% if title %}

{{ title }}

{% endif %} @@ -58,8 +58,11 @@ {% endif %}
{% endif %} - {% if text or call_to_action_link %} + {% if text_title or text or call_to_action_link %}
+ {% if text_title %} +
{{ text_title }}
+ {% endif %} {% if text %}
{{ text }}
{% endif %} diff --git a/templates/patterns/text_featured_media/text_featured_media.ui_patterns.yml b/templates/patterns/text_featured_media/text_featured_media.ui_patterns.yml index 07f3ba853..7a6d999dc 100644 --- a/templates/patterns/text_featured_media/text_featured_media.ui_patterns.yml +++ b/templates/patterns/text_featured_media/text_featured_media.ui_patterns.yml @@ -16,6 +16,11 @@ text_featured_media: description: 'Text on the right, featured call to action' fields: title: + type: "text" + label: "Heading" + description: "The heading, displayed on the top." + preview: "Lorem ipsum" + text_title: type: "text" label: "Title" description: "The title, displayed above text and media." diff --git a/tests/Kernel/Paragraphs/MediaParagraphsTest.php b/tests/Kernel/Paragraphs/MediaParagraphsTest.php index 71a1696c6..88cb68e58 100644 --- a/tests/Kernel/Paragraphs/MediaParagraphsTest.php +++ b/tests/Kernel/Paragraphs/MediaParagraphsTest.php @@ -71,7 +71,8 @@ public function testTextWithMedia(): void { ->get('entity_type.manager') ->getStorage('paragraph')->create([ 'type' => 'oe_text_feature_media', - 'field_oe_title' => 'Title', + 'field_oe_title' => 'Heading', + 'field_oe_text_title' => 'Title', 'field_oe_plain_text_long' => 'Caption', 'field_oe_text_long' => 'Full text', ]); @@ -81,7 +82,8 @@ public function testTextWithMedia(): void { $html = $this->renderParagraph($paragraph); $assert = new TextFeaturedMediaAssert(); $expected_values = [ - 'title' => 'Title', + 'title' => 'Heading', + 'text_title' => 'Title', 'caption' => NULL, 'text' => 'Full text', 'image' => NULL, @@ -132,11 +134,17 @@ public function testTextWithMedia(): void { $paragraph->save(); // Add Bulgarian translation. - $paragraph->addTranslation('bg', ['field_oe_title' => 'Title bg'])->save(); + $paragraph->addTranslation('bg', [ + 'field_oe_title' => 'Heading bg', + 'field_oe_text_title' => 'Title bg', + 'field_oe_plain_text_long' => 'Caption bg', + 'field_oe_text_long' => 'Full text bg', + ])->save(); // Test the translated media is rendered with the translated paragraph. $expected_values = [ - 'title' => 'Title', + 'title' => 'Heading', + 'text_title' => 'Title', 'caption' => 'Caption', 'text' => 'Full text', 'image' => [ @@ -149,9 +157,10 @@ public function testTextWithMedia(): void { $assert->assertVariant('left_simple', $html); $expected_values = [ - 'title' => 'Title bg', - 'caption' => NULL, - 'text' => NULL, + 'title' => 'Heading bg', + 'text_title' => 'Title bg', + 'caption' => 'Caption bg', + 'text' => 'Full text bg', 'image' => [ 'src' => 'example_1_bg.jpeg', 'alt' => 'Alt bg', @@ -169,7 +178,7 @@ public function testTextWithMedia(): void { $this->container->get('entity_type.manager')->getAccessControlHandler('media')->resetCache(); $expected_values = [ - 'title' => 'Title', + 'title' => 'Heading', 'caption' => NULL, 'text' => 'Full text', 'image' => NULL, @@ -192,7 +201,7 @@ public function testTextWithMedia(): void { $html = $this->renderParagraph($paragraph); $expected_values = [ - 'title' => 'Title', + 'title' => 'Heading', 'caption' => 'Caption', 'text' => NULL, 'image' => [ @@ -203,7 +212,7 @@ public function testTextWithMedia(): void { $assert->assertPattern($expected_values, $html); $assert->assertVariant('left_simple', $html); - // Remove the title and assert the element is no longer rendered. + // Remove the heading and assert the element is no longer rendered. $paragraph->set('field_oe_title', ''); $paragraph->save(); @@ -212,6 +221,15 @@ public function testTextWithMedia(): void { $assert->assertPattern($expected_values, $html); $assert->assertVariant('left_simple', $html); + // Remove the title and assert the element is no longer rendered. + $paragraph->set('field_oe_text_title', ''); + $paragraph->save(); + + $html = $this->renderParagraph($paragraph); + $expected_values['text_title'] = NULL; + $assert->assertPattern($expected_values, $html); + $assert->assertVariant('left_simple', $html); + // Create a remote video and add it to the paragraph. $media = $media_storage->create([ 'bundle' => 'remote_video', diff --git a/tests/Kernel/fixtures/rendering.yml b/tests/Kernel/fixtures/rendering.yml index 6e738622a..b8f633083 100644 --- a/tests/Kernel/fixtures/rendering.yml +++ b/tests/Kernel/fixtures/rendering.yml @@ -2279,6 +2279,7 @@ '#variant': "left_simple" '#fields': title: "Heading" + text_title: "Title" image: src: "http://via.placeholder.com/150x150" caption: "Some caption text for the image" @@ -2290,6 +2291,7 @@ count: 'div.ecl-row': 1 'div.ecl-col-md-6.ecl-u-mb-m.ecl-u-mb-md-none.ecl-u-order-md-last': 1 + 'div.ecl-u-type-prolonged-m.ecl-u-type-bold.ecl-u-type-color-grey': 1 'figure.ecl-media-container': 1 'img.ecl-media-container__media[src="http://via.placeholder.com/150x150"]': 1 'div.ecl-media-container__media--ratio-16-9 iframe': 0 @@ -2297,6 +2299,7 @@ 'a.ecl-link.ecl-link--standalone[href="http://example.com"]': 1 equals: 'h2.ecl-u-type-heading-2': "Heading" + 'div.ecl-u-type-prolonged-m.ecl-u-type-bold.ecl-u-type-color-grey': "Title" 'figcaption.ecl-media-container__caption': "Some caption text for the image" 'div.ecl-col-md-6 div.ecl-editor': "Some more text" 'a.ecl-link span.ecl-link__label': "Call to action" @@ -2305,6 +2308,7 @@ '#id': text_featured_media '#variant': "right_simple" '#fields': + text_title: "Title" image: src: "http://via.placeholder.com/150x150" caption: "Some caption text for the image" @@ -2317,12 +2321,43 @@ 'h2.ecl-u-type-heading-2': 0 'div.ecl-row': 1 'div.ecl-col-md-6.ecl-u-mb-m.ecl-u-mb-md-none.ecl-u-order-md-last': 0 + 'div.ecl-u-type-prolonged-m.ecl-u-type-bold.ecl-u-type-color-grey': 1 'figure.ecl-media-container': 1 'img.ecl-media-container__media[src="http://via.placeholder.com/150x150"]': 1 'div.ecl-media-container__media--ratio-16-9 iframe': 0 'figcaption.ecl-media-container__caption': 1 'a.ecl-link.ecl-link--standalone[href="http://example.com"]': 1 equals: + 'div.ecl-u-type-prolonged-m.ecl-u-type-bold.ecl-u-type-color-grey': "Title" + 'figcaption.ecl-media-container__caption': "Some caption text for the image" + 'div.ecl-col-md-6 div.ecl-editor': "Some more text" + 'a.ecl-link span.ecl-link__label': "Call to action" +- array: + '#type': pattern + '#id': text_featured_media + '#variant': "right_simple" + '#fields': + title: "Heading" + image: + src: "http://via.placeholder.com/150x150" + caption: "Some caption text for the image" + text: "Some more text" + link: + label: "Call to action" + path: "http://example.com" + assertions: + count: + 'h2.ecl-u-type-heading-2': 1 + 'div.ecl-row': 1 + 'div.ecl-col-md-6.ecl-u-mb-m.ecl-u-mb-md-none.ecl-u-order-md-last': 0 + 'div.ecl-u-type-prolonged-m.ecl-u-type-bold.ecl-u-type-color-grey': 0 + 'figure.ecl-media-container': 1 + 'img.ecl-media-container__media[src="http://via.placeholder.com/150x150"]': 1 + 'div.ecl-media-container__media--ratio-16-9 iframe': 0 + 'figcaption.ecl-media-container__caption': 1 + 'a.ecl-link.ecl-link--standalone[href="http://example.com"]': 1 + equals: + 'h2.ecl-u-type-heading-2': "Heading" 'figcaption.ecl-media-container__caption': "Some caption text for the image" 'div.ecl-col-md-6 div.ecl-editor': "Some more text" 'a.ecl-link span.ecl-link__label': "Call to action" @@ -2331,12 +2366,14 @@ '#id': text_featured_media '#fields': title: "Heading" + text_title: "Title" caption: "Some caption text for the image" text: "Some more text" assertions: count: 'div.ecl-row': 1 'div.ecl-col-md-6.ecl-u-mb-m.ecl-u-mb-md-none': 0 + 'div.ecl-u-type-prolonged-m.ecl-u-type-bold.ecl-u-type-color-grey': 1 'figure.ecl-media-container': 0 'div.ecl-col-md-6.ecl-editor': 0 'img.ecl-media-container__media[src="http://via.placeholder.com/150x150"]': 0 @@ -2345,6 +2382,7 @@ 'a.ecl-link': 0 equals: 'h2.ecl-u-type-heading-2': "Heading" + 'div.ecl-u-type-prolonged-m.ecl-u-type-bold.ecl-u-type-color-grey': "Title" 'div.ecl-col-12 div.ecl-editor': "Some more text" - array: '#type': pattern @@ -2352,6 +2390,7 @@ '#variant': "right_featured" '#fields': title: "Heading" + text_title: "Title" image: src: "http://via.placeholder.com/150x150" text: "Some more text" @@ -2362,6 +2401,7 @@ count: 'div.ecl-row': 1 'div.ecl-col-md-6.ecl-u-mb-m.ecl-u-mb-md-none.ecl-u-order-md-last': 0 + 'div.ecl-u-type-prolonged-m.ecl-u-type-bold.ecl-u-type-color-grey': 1 'figure.ecl-media-container': 1 'img.ecl-media-container__media[src="http://via.placeholder.com/150x150"]': 1 'div.ecl-media-container__media--ratio-16-9 iframe': 0 @@ -2369,6 +2409,7 @@ 'a.ecl-link.ecl-link--cta[href="http://example.com"]': 1 equals: 'h2.ecl-u-type-heading-2': "Heading" + 'div.ecl-u-type-prolonged-m.ecl-u-type-bold.ecl-u-type-color-grey': "Title" 'div.ecl-col-md-6 div.ecl-editor': "Some more text" 'a.ecl-link span.ecl-link__label': "Call to action" - array: diff --git a/tests/PatternAssertions/TextFeaturedMediaAssert.php b/tests/PatternAssertions/TextFeaturedMediaAssert.php index 8943b4a50..add851391 100644 --- a/tests/PatternAssertions/TextFeaturedMediaAssert.php +++ b/tests/PatternAssertions/TextFeaturedMediaAssert.php @@ -23,6 +23,10 @@ protected function getAssertions($variant): array { [$this, 'assertElementText'], 'h2.ecl-u-type-heading-2.ecl-u-mt-2xl.ecl-u-mt-md-3xl.ecl-u-mb-l', ], + 'text_title' => [ + [$this, 'assertElementText'], + 'div.ecl-u-type-prolonged-m.ecl-u-type-bold.ecl-u-type-color-grey', + ], 'image' => [ [$this, 'assertImage'], 'div.ecl-row figure.ecl-media-container img', From e456e7d6c224dd2a72fb0b94840f0da2c8712564 Mon Sep 17 00:00:00 2001 From: Evgenii Nikitin Date: Thu, 15 Jul 2021 12:14:27 +0300 Subject: [PATCH 05/41] EWPP-1327: Rename field_oe_text_title to field_oe_feature_media_title. --- .../paragraphs/paragraph--oe-text-feature-media.html.twig | 2 +- tests/Kernel/Paragraphs/MediaParagraphsTest.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/templates/paragraphs/paragraph--oe-text-feature-media.html.twig b/templates/paragraphs/paragraph--oe-text-feature-media.html.twig index e6345ed2e..d319f6f0d 100644 --- a/templates/paragraphs/paragraph--oe-text-feature-media.html.twig +++ b/templates/paragraphs/paragraph--oe-text-feature-media.html.twig @@ -15,7 +15,7 @@ {{ pattern('text_featured_media', { 'variant': variant, 'title': not paragraph.field_oe_title.isEmpty ? content.field_oe_title, - 'text_title': not paragraph.field_oe_text_title.isEmpty ? content.field_oe_text_title, + 'text_title': not paragraph.field_oe_feature_media_title.isEmpty ? content.field_oe_feature_media_title, 'image': image, 'video': video, 'video_ratio': ratio, diff --git a/tests/Kernel/Paragraphs/MediaParagraphsTest.php b/tests/Kernel/Paragraphs/MediaParagraphsTest.php index 88cb68e58..92c77f7a7 100644 --- a/tests/Kernel/Paragraphs/MediaParagraphsTest.php +++ b/tests/Kernel/Paragraphs/MediaParagraphsTest.php @@ -72,7 +72,7 @@ public function testTextWithMedia(): void { ->getStorage('paragraph')->create([ 'type' => 'oe_text_feature_media', 'field_oe_title' => 'Heading', - 'field_oe_text_title' => 'Title', + 'field_oe_feature_media_title' => 'Title', 'field_oe_plain_text_long' => 'Caption', 'field_oe_text_long' => 'Full text', ]); @@ -136,7 +136,7 @@ public function testTextWithMedia(): void { // Add Bulgarian translation. $paragraph->addTranslation('bg', [ 'field_oe_title' => 'Heading bg', - 'field_oe_text_title' => 'Title bg', + 'field_oe_feature_media_title' => 'Title bg', 'field_oe_plain_text_long' => 'Caption bg', 'field_oe_text_long' => 'Full text bg', ])->save(); @@ -222,7 +222,7 @@ public function testTextWithMedia(): void { $assert->assertVariant('left_simple', $html); // Remove the title and assert the element is no longer rendered. - $paragraph->set('field_oe_text_title', ''); + $paragraph->set('field_oe_feature_media_title', ''); $paragraph->save(); $html = $this->renderParagraph($paragraph); From ad99ac7b4780ea7b2b906df355fbc3c03cc0cdd3 Mon Sep 17 00:00:00 2001 From: Evgenii Nikitin Date: Thu, 15 Jul 2021 18:42:38 +0300 Subject: [PATCH 06/41] EWPP-1327: Update default view display for Text with featured media paragraph. --- ...aragraph.oe_text_feature_media.default.yml | 71 +++++++++++++++++++ .../oe_theme_helper.post_update.php | 20 ++++++ 2 files changed, 91 insertions(+) create mode 100644 config/post_updates/20017_update_view_display_paragraph_text_media/core.entity_view_display.paragraph.oe_text_feature_media.default.yml diff --git a/config/post_updates/20017_update_view_display_paragraph_text_media/core.entity_view_display.paragraph.oe_text_feature_media.default.yml b/config/post_updates/20017_update_view_display_paragraph_text_media/core.entity_view_display.paragraph.oe_text_feature_media.default.yml new file mode 100644 index 000000000..e5d7b2f58 --- /dev/null +++ b/config/post_updates/20017_update_view_display_paragraph_text_media/core.entity_view_display.paragraph.oe_text_feature_media.default.yml @@ -0,0 +1,71 @@ +langcode: en +status: true +dependencies: + config: + - field.field.paragraph.oe_text_feature_media.field_oe_feature_media_title + - field.field.paragraph.oe_text_feature_media.field_oe_link + - field.field.paragraph.oe_text_feature_media.field_oe_media + - field.field.paragraph.oe_text_feature_media.field_oe_plain_text_long + - field.field.paragraph.oe_text_feature_media.field_oe_text_long + - field.field.paragraph.oe_text_feature_media.field_oe_title + - paragraphs.paragraphs_type.oe_text_feature_media + module: + - link + - text +id: paragraph.oe_text_feature_media.default +targetEntityType: paragraph +bundle: oe_text_feature_media +mode: default +content: + field_oe_feature_media_title: + type: string + weight: 1 + region: content + label: above + settings: + link_to_entity: false + third_party_settings: { } + field_oe_link: + type: link + weight: 5 + region: content + label: above + settings: + trim_length: 80 + url_only: false + url_plain: false + rel: '' + target: '' + third_party_settings: { } + field_oe_media: + type: entity_reference_entity_view + weight: 2 + label: above + settings: + view_mode: default + link: false + third_party_settings: { } + region: content + field_oe_plain_text_long: + weight: 3 + label: above + settings: { } + third_party_settings: { } + type: basic_string + region: content + field_oe_text_long: + weight: 4 + label: above + settings: { } + third_party_settings: { } + type: text_default + region: content + field_oe_title: + weight: 0 + label: above + settings: + link_to_entity: false + third_party_settings: { } + type: string + region: content +hidden: { } diff --git a/modules/oe_theme_helper/oe_theme_helper.post_update.php b/modules/oe_theme_helper/oe_theme_helper.post_update.php index 1ba8f0f92..6d3cb0d67 100644 --- a/modules/oe_theme_helper/oe_theme_helper.post_update.php +++ b/modules/oe_theme_helper/oe_theme_helper.post_update.php @@ -296,3 +296,23 @@ function oe_theme_helper_post_update_20016() { 'label' => 'OpenEuropa: Compact teaser', ])->save(); } + +/** + * Update default view display for Text with featured media paragraph. + */ +function oe_theme_helper_post_update_20017() { + if (!\Drupal::moduleHandler()->moduleExists('oe_paragraphs_media')) { + // Ensure that module for Text with featured media paragraph is enabled. + return t('Skipping since the oe_paragraphs_media module is not enabled.'); + } + + // Update existing default view display. + $storage = new FileStorage(drupal_get_path('theme', 'oe_theme') . '/config/post_updates/20017_update_view_display_paragraph_text_media'); + $display_values = $storage->read('core.entity_view_display.paragraph.oe_text_feature_media.default'); + $display_storage = \Drupal::entityTypeManager()->getStorage('entity_view_display'); + $display = $display_storage->load($display_values['id']); + if ($display) { + $display = $display_storage->updateFromStorageRecord($display, $display_values); + $display->save(); + } +} From 109613380f1c2ef5467435d0e1869b33eff69985 Mon Sep 17 00:00:00 2001 From: Sergii Pavlenko Date: Wed, 28 Jul 2021 14:16:18 +0300 Subject: [PATCH 07/41] EWPP-873: Adapt tests and fix some classes for text featured media pattern. --- .../text_featured_media/pattern-text-featured-media.html.twig | 4 ++-- tests/Kernel/Paragraphs/MediaParagraphsTest.php | 4 ++-- tests/PatternAssertions/TextFeaturedMediaAssert.php | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/templates/patterns/text_featured_media/pattern-text-featured-media.html.twig b/templates/patterns/text_featured_media/pattern-text-featured-media.html.twig index 875db2a9e..5233bbc5b 100644 --- a/templates/patterns/text_featured_media/pattern-text-featured-media.html.twig +++ b/templates/patterns/text_featured_media/pattern-text-featured-media.html.twig @@ -16,7 +16,7 @@ {% endif %} {% set text = text|render %} -{% set media_position_class = 'right' in variant ? '' : ' ecl-u-order-md-last' %} +{% set media_position_class = 'right' in variant ? '' : ' ecl-u-order-m-last' %} {% set call_to_action_link = '' %} {% if link %} @@ -30,7 +30,7 @@ path: link.path, icon_position: 'after' }, - extra_classes: 'ecl-u-mt-m ecl-u-mt-md-l ecl-u-type-bold', + extra_classes: 'ecl-u-mt-m ecl-u-mt-m-l ecl-u-type-bold', icon: get_link_icon(link.path) } %} {% endset %} diff --git a/tests/Kernel/Paragraphs/MediaParagraphsTest.php b/tests/Kernel/Paragraphs/MediaParagraphsTest.php index 92c77f7a7..2cfca34fb 100644 --- a/tests/Kernel/Paragraphs/MediaParagraphsTest.php +++ b/tests/Kernel/Paragraphs/MediaParagraphsTest.php @@ -349,7 +349,7 @@ public function testTextWithMedia(): void { // Assert "Text on the right, simple call to action" variant. $paragraph->set('oe_paragraphs_variant', 'right_simple')->save(); $html = $this->renderParagraph($paragraph); - $assert->assertVariant('right_simple', $html); + $assert->assertVariant('left_simple', $html); // Assert "Text on the left, featured call to action" variant. $paragraph->set('oe_paragraphs_variant', 'left_featured')->save(); @@ -359,7 +359,7 @@ public function testTextWithMedia(): void { // Assert "Text on the right, featured call to action" variant. $paragraph->set('oe_paragraphs_variant', 'right_featured')->save(); $html = $this->renderParagraph($paragraph); - $assert->assertVariant('right_featured', $html); + $assert->assertVariant('left_featured', $html); // Assert Link field without media. $paragraph->set('field_oe_media', [])->save(); diff --git a/tests/PatternAssertions/TextFeaturedMediaAssert.php b/tests/PatternAssertions/TextFeaturedMediaAssert.php index c340640d8..5e7d97025 100644 --- a/tests/PatternAssertions/TextFeaturedMediaAssert.php +++ b/tests/PatternAssertions/TextFeaturedMediaAssert.php @@ -91,14 +91,14 @@ protected function assertVideoRatio(string $expected_ratio, string $selector, Cr * The DomCrawler where to check the element. */ protected function assertLink(array $expected_link, Crawler $crawler): void { - $link_element = $crawler->filter('a.ecl-link.ecl-link--icon.ecl-link--icon-after.ecl-u-mt-m.ecl-u-mt-md-l.ecl-u-type-bold'); + $link_element = $crawler->filter('a.ecl-link.ecl-link--icon.ecl-link--icon-after.ecl-u-mt-m.ecl-u-mt-m-l.ecl-u-type-bold'); self::assertEquals($expected_link['path'], $link_element->attr('href')); $label_element = $link_element->filter('span.ecl-link__label'); self::assertEquals($expected_link['label'], $label_element->text()); $svg = $link_element->filter('svg.ecl-icon.ecl-icon--s.ecl-icon--primary.ecl-link__icon use'); - self::assertContains('icons.svg#ui--' . $expected_link['icon'], $svg->attr('xlink:href')); + self::assertContains('icons.svg#' . $expected_link['icon'], $svg->attr('xlink:href')); } /** From f2d0ededfb2e2fadfe3c93174e508763186c9fa6 Mon Sep 17 00:00:00 2001 From: Sergii Pavlenko Date: Wed, 28 Jul 2021 16:05:55 +0300 Subject: [PATCH 08/41] EWPP-1318: Finalize porting of 'text featured media' pattern to ECL3. --- tests/Kernel/Paragraphs/MediaParagraphsTest.php | 4 ++-- tests/PatternAssertions/TextFeaturedMediaAssert.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/Kernel/Paragraphs/MediaParagraphsTest.php b/tests/Kernel/Paragraphs/MediaParagraphsTest.php index 2cfca34fb..92c77f7a7 100644 --- a/tests/Kernel/Paragraphs/MediaParagraphsTest.php +++ b/tests/Kernel/Paragraphs/MediaParagraphsTest.php @@ -349,7 +349,7 @@ public function testTextWithMedia(): void { // Assert "Text on the right, simple call to action" variant. $paragraph->set('oe_paragraphs_variant', 'right_simple')->save(); $html = $this->renderParagraph($paragraph); - $assert->assertVariant('left_simple', $html); + $assert->assertVariant('right_simple', $html); // Assert "Text on the left, featured call to action" variant. $paragraph->set('oe_paragraphs_variant', 'left_featured')->save(); @@ -359,7 +359,7 @@ public function testTextWithMedia(): void { // Assert "Text on the right, featured call to action" variant. $paragraph->set('oe_paragraphs_variant', 'right_featured')->save(); $html = $this->renderParagraph($paragraph); - $assert->assertVariant('left_featured', $html); + $assert->assertVariant('right_featured', $html); // Assert Link field without media. $paragraph->set('field_oe_media', [])->save(); diff --git a/tests/PatternAssertions/TextFeaturedMediaAssert.php b/tests/PatternAssertions/TextFeaturedMediaAssert.php index 5e7d97025..311090374 100644 --- a/tests/PatternAssertions/TextFeaturedMediaAssert.php +++ b/tests/PatternAssertions/TextFeaturedMediaAssert.php @@ -116,8 +116,8 @@ protected function getPatternVariant(string $html): string { $crawler = new Crawler($html); $position_variant = 'left'; - $media_wrapper = $crawler->filter('.ecl-col-md-6.ecl-u-mb-m.ecl-u-mb-md-none'); - $media_position = $crawler->filter('.ecl-u-order-md-last'); + $media_wrapper = $crawler->filter('.ecl-col-m-6.ecl-u-mb-m.ecl-u-mb-m-none'); + $media_position = $crawler->filter('.ecl-u-order-m-last'); if ($media_wrapper->count() && !$media_position->count()) { // Media exists but media position class doesn't exist. $position_variant = 'right'; From c6c94b65c36c5fae2e7b86f1ab4d9303e0703895 Mon Sep 17 00:00:00 2001 From: Sergii Pavlenko Date: Fri, 30 Jul 2021 11:29:22 +0300 Subject: [PATCH 09/41] EWPP-1318: Adjust changes for text_featured_media pattern according to changes in oe_paragraph component. --- README.md | 2 -- composer.json | 2 +- oe_theme.theme | 5 ++++- tests/Kernel/Paragraphs/MediaParagraphsTest.php | 4 ++-- tests/PatternAssertions/TextFeaturedMediaAssert.php | 2 +- 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 036b67d44..65c30a0d9 100644 --- a/README.md +++ b/README.md @@ -171,8 +171,6 @@ templates/compositions/ec-component-content-item/content-item.html.twig Consider using the [List item](/templates/patterns/list_item/list_item.ui_patterns.yml) pattern and its variants instead. -### Upgrade to 2.21.0 - #### Text with Featured media pattern The pattern [Text with Featured media](/templates/patterns/text_featured_media/text_featured_media.ui_patterns.yml) now diff --git a/composer.json b/composer.json index fae555434..a4e5296ac 100644 --- a/composer.json +++ b/composer.json @@ -52,7 +52,7 @@ "openeuropa/oe_corporate_countries": "~2.0", "openeuropa/oe_media": "~1.12", "openeuropa/oe_multilingual": "~1.8", - "openeuropa/oe_paragraphs": "dev-EWPP-1326", + "openeuropa/oe_paragraphs": "dev-EWPP-1356", "openeuropa/oe_search": "~1.0", "openeuropa/oe_webtools": "~1.10", "openeuropa/oe_contact_forms": "~1.0", diff --git a/oe_theme.theme b/oe_theme.theme index ff14cb365..67a0e38a6 100644 --- a/oe_theme.theme +++ b/oe_theme.theme @@ -928,7 +928,10 @@ function oe_theme_preprocess_paragraph__oe_text_feature_media(array &$variables) // Set pattern variant. if (!$paragraph->get('oe_paragraphs_variant')->isEmpty()) { - $variables['variant'] = $paragraph->get('oe_paragraphs_variant')->first()->value; + $variant = $paragraph->get('oe_paragraphs_variant')->first()->value; + // The default variant of the paragraph is the 'Left simple' + // variant of pattern. + $variables['variant'] = $variant === 'default' ? 'left_simple' : $variant; } // Add link field. diff --git a/tests/Kernel/Paragraphs/MediaParagraphsTest.php b/tests/Kernel/Paragraphs/MediaParagraphsTest.php index 92c77f7a7..4f4fcc7bc 100644 --- a/tests/Kernel/Paragraphs/MediaParagraphsTest.php +++ b/tests/Kernel/Paragraphs/MediaParagraphsTest.php @@ -341,8 +341,8 @@ public function testTextWithMedia(): void { $assert->assertPattern($expected_values, $html); $assert->assertVariant('left_featured', $html); - // Assert "Text on the left, simple call to action" variant. - $paragraph->set('oe_paragraphs_variant', 'left_simple')->save(); + // Assert default ("Text on the left, simple call to action") variant. + $paragraph->set('oe_paragraphs_variant', 'default')->save(); $html = $this->renderParagraph($paragraph); $assert->assertVariant('left_simple', $html); diff --git a/tests/PatternAssertions/TextFeaturedMediaAssert.php b/tests/PatternAssertions/TextFeaturedMediaAssert.php index 311090374..b8b1a50fe 100644 --- a/tests/PatternAssertions/TextFeaturedMediaAssert.php +++ b/tests/PatternAssertions/TextFeaturedMediaAssert.php @@ -111,7 +111,7 @@ protected function getPatternVariant(string $html): string { // based on the media position. // If the media is not present then "left simple" or "left featured" // will be returned based on the link style. - // If neither media nor image are present then "left_simple? will be + // If neither media nor image are present then "left_simple" will be // returned. $crawler = new Crawler($html); From 5e807ce2a4a24da7e9887ac9e9d68710882c097c Mon Sep 17 00:00:00 2001 From: Evgenii Nikitin Date: Wed, 4 Aug 2021 16:34:38 +0300 Subject: [PATCH 10/41] EWPP-873: Use oe_paragraphs from the epic. --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index a4e5296ac..379242cb1 100644 --- a/composer.json +++ b/composer.json @@ -52,7 +52,7 @@ "openeuropa/oe_corporate_countries": "~2.0", "openeuropa/oe_media": "~1.12", "openeuropa/oe_multilingual": "~1.8", - "openeuropa/oe_paragraphs": "dev-EWPP-1356", + "openeuropa/oe_paragraphs": "dev-EPIC-EWPP-873-Text-media-2", "openeuropa/oe_search": "~1.0", "openeuropa/oe_webtools": "~1.10", "openeuropa/oe_contact_forms": "~1.0", From 7e6b3634ebe46c3f5ff4210785e24fc39041dcc0 Mon Sep 17 00:00:00 2001 From: Evgenii Nikitin Date: Tue, 10 Aug 2021 12:34:53 +0300 Subject: [PATCH 11/41] EWPP-1209: Ensure that Link field exist. --- oe_theme.theme | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/oe_theme.theme b/oe_theme.theme index a62900e31..e5e65d216 100644 --- a/oe_theme.theme +++ b/oe_theme.theme @@ -934,8 +934,8 @@ function oe_theme_preprocess_paragraph__oe_text_feature_media(array &$variables) $variables['variant'] = $variant === 'default' ? 'left_simple' : $variant; } - // Add link field. - if (!$paragraph->get('field_oe_link')->isEmpty()) { + // Link field doesn't exist in oe_paragraphs <= 1.8.0, so ensure it exists. + if ($paragraph->hasField('field_oe_link') && !$paragraph->get('field_oe_link')->isEmpty()) { $link_field = $paragraph->get('field_oe_link')->first(); $variables['link'] = [ 'path' => $link_field->getUrl()->toString(), From 6f3bafedcaa5d77f6cc62b292f8f186243e3b2b9 Mon Sep 17 00:00:00 2001 From: Evgenii Nikitin Date: Thu, 15 Jul 2021 12:22:06 +0300 Subject: [PATCH 12/41] EWPP-1046: Change label from "Open gallery" to "See all" in the gallery pattern. --- templates/patterns/gallery/pattern-gallery.html.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/patterns/gallery/pattern-gallery.html.twig b/templates/patterns/gallery/pattern-gallery.html.twig index 97c9c87ea..a388a7ff3 100644 --- a/templates/patterns/gallery/pattern-gallery.html.twig +++ b/templates/patterns/gallery/pattern-gallery.html.twig @@ -55,7 +55,7 @@ }, }, }, - 'view_all_label': "Open gallery"|t, + 'view_all_label': "See all"|t, 'counter_label': "media items"|t, 'items': _items } %} From e197e4436d7cbad1c387710e80731736d143f3da Mon Sep 17 00:00:00 2001 From: Evgenii Nikitin Date: Tue, 7 Sep 2021 12:53:20 +0300 Subject: [PATCH 13/41] EWPP-873: Fix test after merging. --- tests/Kernel/fixtures/rendering.yml | 8 ++++---- tests/PatternAssertions/TextFeaturedMediaAssert.php | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/Kernel/fixtures/rendering.yml b/tests/Kernel/fixtures/rendering.yml index 3d3082641..10f447c68 100644 --- a/tests/Kernel/fixtures/rendering.yml +++ b/tests/Kernel/fixtures/rendering.yml @@ -2297,7 +2297,7 @@ 'h2.ecl-u-type-heading-2': "Heading" 'div.ecl-u-type-prolonged-m.ecl-u-type-bold.ecl-u-type-color-grey': "Title" 'figcaption.ecl-media-container__caption': "Some caption text for the image" - 'div.ecl-col-m-6 div.ecl': "Some more text" + 'div.ecl-col-m-6 > div.ecl': "Some more text" 'a.ecl-link span.ecl-link__label': "Call to action" - array: '#type': pattern @@ -2326,7 +2326,7 @@ equals: 'div.ecl-u-type-prolonged-m.ecl-u-type-bold.ecl-u-type-color-grey': "Title" 'figcaption.ecl-media-container__caption': "Some caption text for the image" - 'div.ecl-col-m-6 div.ecl': "Some more text" + 'div.ecl-col-m-6 > div.ecl': "Some more text" 'a.ecl-link span.ecl-link__label': "Call to action" - array: '#type': pattern @@ -2355,7 +2355,7 @@ equals: 'h2.ecl-u-type-heading-2': "Heading" 'figcaption.ecl-media-container__caption': "Some caption text for the image" - 'div.ecl-col-m-6 div.ecl-editor': "Some more text" + 'div.ecl-col-m-6 > div.ecl': "Some more text" 'a.ecl-link span.ecl-link__label': "Call to action" - array: '#type': pattern @@ -2379,7 +2379,7 @@ equals: 'h2.ecl-u-type-heading-2': "Heading" 'div.ecl-u-type-prolonged-m.ecl-u-type-bold.ecl-u-type-color-grey': "Title" - 'div.ecl-col-12 div': "Some more text" + 'div.ecl-col-12 > div.ecl': "Some more text" - array: '#type': pattern '#id': text_featured_media diff --git a/tests/PatternAssertions/TextFeaturedMediaAssert.php b/tests/PatternAssertions/TextFeaturedMediaAssert.php index a443e98c7..b7543e676 100644 --- a/tests/PatternAssertions/TextFeaturedMediaAssert.php +++ b/tests/PatternAssertions/TextFeaturedMediaAssert.php @@ -41,7 +41,7 @@ protected function getAssertions($variant): array { ], 'text' => [ [$this, 'assertElementText'], - 'div.ecl-row div.ecl', + 'div.ecl-row div.ecl div.ecl', ], 'video_ratio' => [ [$this, 'assertVideoRatio'], From 973126209a1e4cc8b17021f557d04e7c9d55e788 Mon Sep 17 00:00:00 2001 From: Sergii Pavlenko Date: Thu, 15 Jul 2021 13:13:52 +0300 Subject: [PATCH 14/41] EWPP-1206: Fix UI issue by amending class in content-item-block composition. --- .../content-item-block.html.twig | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/templates/compositions/ec-component-content-item-block/content-item-block.html.twig b/templates/compositions/ec-component-content-item-block/content-item-block.html.twig index 9c0b409a2..070f0a825 100644 --- a/templates/compositions/ec-component-content-item-block/content-item-block.html.twig +++ b/templates/compositions/ec-component-content-item-block/content-item-block.html.twig @@ -43,13 +43,13 @@ {% set _extra_classes_item = 'ecl-col-12' %} {% if _type == 'two' %} - {% set _extra_classes_item = 'ecl-col-12 ecl-col-m-6' %} + {% set _extra_classes_item = 'ecl-col-12 ecl-col-l-6' %} {% elseif _type == 'three' %} - {% set _extra_classes_item = 'ecl-col-12 ecl-col-m-4' %} + {% set _extra_classes_item = 'ecl-col-12 ecl-col-l-4' %} {% elseif _type == 'four' %} - {% set _extra_classes_item = 'ecl-col-12 ecl-col-m-3' %} + {% set _extra_classes_item = 'ecl-col-12 ecl-col-l-3' %} {% elseif _type == 'six' %} - {% set _extra_classes_item = 'ecl-col-12 ecl-col-m-2' %} + {% set _extra_classes_item = 'ecl-col-12 ecl-col-l-2' %} {% endif %}
From 55f8cf4954a629e90f66b7dbc96f478356b614ef Mon Sep 17 00:00:00 2001 From: Sergii Pavlenko Date: Fri, 16 Jul 2021 13:28:27 +0300 Subject: [PATCH 15/41] EWPP-1206: Amend kernel tests for updated classes. --- tests/Kernel/Paragraphs/ParagraphsTest.php | 12 ++++---- tests/Kernel/fixtures/rendering.yml | 36 +++++++++++----------- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/tests/Kernel/Paragraphs/ParagraphsTest.php b/tests/Kernel/Paragraphs/ParagraphsTest.php index e0d7796b0..7050d302a 100644 --- a/tests/Kernel/Paragraphs/ParagraphsTest.php +++ b/tests/Kernel/Paragraphs/ParagraphsTest.php @@ -413,24 +413,24 @@ public function testListItemBlock() { // to this variant, so we check that neither the two or three columns class // modifiers are there. $this->assertCount(3, $crawler->filter('div.ecl-content-item-block__item.ecl-col-12 article.ecl-content-item')); - $this->assertCount(0, $crawler->filter('div.ecl-content-item-block__item.ecl-col-m-6 article.ecl-content-item')); - $this->assertCount(0, $crawler->filter('div.ecl-content-item-block__item.ecl-col-m-4 article.ecl-content-item')); + $this->assertCount(0, $crawler->filter('div.ecl-content-item-block__item.ecl-col-l-6 article.ecl-content-item')); + $this->assertCount(0, $crawler->filter('div.ecl-content-item-block__item.ecl-col-l-4 article.ecl-content-item')); // Change the variant to two columns. $paragraph->get('field_oe_list_item_block_layout')->setValue('two_columns'); $paragraph->save(); $crawler = new Crawler($this->renderParagraph($paragraph)); - $this->assertCount(3, $crawler->filter('div.ecl-content-item-block__item.ecl-col-m-6 article.ecl-content-item')); - $this->assertCount(0, $crawler->filter('div.ecl-content-item-block__item.ecl-col-m-4 article.ecl-content-item')); + $this->assertCount(3, $crawler->filter('div.ecl-content-item-block__item.ecl-col-l-6 article.ecl-content-item')); + $this->assertCount(0, $crawler->filter('div.ecl-content-item-block__item.ecl-col-l-4 article.ecl-content-item')); // Change the variant to three columns. $paragraph->get('field_oe_list_item_block_layout')->setValue('three_columns'); $paragraph->save(); $crawler = new Crawler($this->renderParagraph($paragraph)); - $this->assertCount(0, $crawler->filter('div.ecl-content-item-block__item.ecl-col-m-6 article.ecl-content-item')); - $this->assertCount(3, $crawler->filter('div.ecl-content-item-block__item.ecl-col-m-4 article.ecl-content-item')); + $this->assertCount(0, $crawler->filter('div.ecl-content-item-block__item.ecl-col-l-6 article.ecl-content-item')); + $this->assertCount(3, $crawler->filter('div.ecl-content-item-block__item.ecl-col-l-4 article.ecl-content-item')); } /** diff --git a/tests/Kernel/fixtures/rendering.yml b/tests/Kernel/fixtures/rendering.yml index 9a5fc0ac9..34d245b90 100644 --- a/tests/Kernel/fixtures/rendering.yml +++ b/tests/Kernel/fixtures/rendering.yml @@ -1382,10 +1382,10 @@ 'div.ecl-content-item-block__title': 0 'div.ecl-content-item-block__title h2.ecl-u-type-heading-2': 0 'div.ecl-content-item-block__item': 2 - 'div.ecl-content-item-block__item.ecl-col-m-6': 2 - 'div.ecl-content-item-block__item.ecl-col-m-4': 0 - 'div.ecl-content-item-block__item.ecl-col-m-6 article.ecl-content-item': 2 - 'div.ecl-content-item-block__item.ecl-col-m-4 article.ecl-content-item': 0 + 'div.ecl-content-item-block__item.ecl-col-l-6': 2 + 'div.ecl-content-item-block__item.ecl-col-l-4': 0 + 'div.ecl-content-item-block__item.ecl-col-l-6 article.ecl-content-item': 2 + 'div.ecl-content-item-block__item.ecl-col-l-4 article.ecl-content-item': 0 'div.ecl-content-item-block__button': 0 'div.ecl-content-item-block__button a.ecl-link[href="http://example.com"]': 0 equals: @@ -1418,10 +1418,10 @@ 'div.ecl-content-item-block__title': 0 'div.ecl-content-item-block__title h2.ecl-u-type-heading-2': 0 'div.ecl-content-item-block__item': 3 - 'div.ecl-content-item-block__item.ecl-col-m-6': 0 - 'div.ecl-content-item-block__item.ecl-col-m-4': 3 - 'div.ecl-content-item-block__item.ecl-col-m-6 article.ecl-content-item': 0 - 'div.ecl-content-item-block__item.ecl-col-m-4 article.ecl-content-item': 3 + 'div.ecl-content-item-block__item.ecl-col-l-6': 0 + 'div.ecl-content-item-block__item.ecl-col-l-4': 3 + 'div.ecl-content-item-block__item.ecl-col-l-6 article.ecl-content-item': 0 + 'div.ecl-content-item-block__item.ecl-col-l-4 article.ecl-content-item': 3 'div.ecl-content-item-block__button': 0 'div.ecl-content-item-block__button a.ecl-link[href="http://example.com"]': 0 equals: @@ -1442,10 +1442,10 @@ - { '#type': 'pattern', '#id': 'link', '#fields': { url: '#', text: 'A simple link 4' } } assertions: equals: - 'div.ecl-content-item-block__item.ecl-col-m-3:nth-child(1) a.ecl-link': 'A simple link 1' - 'div.ecl-content-item-block__item.ecl-col-m-3:nth-child(2) a.ecl-link': 'A simple link 2' - 'div.ecl-content-item-block__item.ecl-col-m-3:nth-child(3) a.ecl-link': 'A simple link 3' - 'div.ecl-content-item-block__item.ecl-col-m-3:nth-child(4) a.ecl-link': 'A simple link 4' + 'div.ecl-content-item-block__item.ecl-col-l-3:nth-child(1) a.ecl-link': 'A simple link 1' + 'div.ecl-content-item-block__item.ecl-col-l-3:nth-child(2) a.ecl-link': 'A simple link 2' + 'div.ecl-content-item-block__item.ecl-col-l-3:nth-child(3) a.ecl-link': 'A simple link 3' + 'div.ecl-content-item-block__item.ecl-col-l-3:nth-child(4) a.ecl-link': 'A simple link 4' - array: '#type': pattern '#id': list_item_block_six_columns @@ -1459,12 +1459,12 @@ - { '#type': 'pattern', '#id': 'link', '#fields': { url: '#', text: 'A simple link 6' } } assertions: equals: - 'div.ecl-content-item-block__item.ecl-col-m-2:nth-child(1) a.ecl-link': 'A simple link 1' - 'div.ecl-content-item-block__item.ecl-col-m-2:nth-child(2) a.ecl-link': 'A simple link 2' - 'div.ecl-content-item-block__item.ecl-col-m-2:nth-child(3) a.ecl-link': 'A simple link 3' - 'div.ecl-content-item-block__item.ecl-col-m-2:nth-child(4) a.ecl-link': 'A simple link 4' - 'div.ecl-content-item-block__item.ecl-col-m-2:nth-child(5) a.ecl-link': 'A simple link 5' - 'div.ecl-content-item-block__item.ecl-col-m-2:nth-child(6) a.ecl-link': 'A simple link 6' + 'div.ecl-content-item-block__item.ecl-col-l-2:nth-child(1) a.ecl-link': 'A simple link 1' + 'div.ecl-content-item-block__item.ecl-col-l-2:nth-child(2) a.ecl-link': 'A simple link 2' + 'div.ecl-content-item-block__item.ecl-col-l-2:nth-child(3) a.ecl-link': 'A simple link 3' + 'div.ecl-content-item-block__item.ecl-col-l-2:nth-child(4) a.ecl-link': 'A simple link 4' + 'div.ecl-content-item-block__item.ecl-col-l-2:nth-child(5) a.ecl-link': 'A simple link 5' + 'div.ecl-content-item-block__item.ecl-col-l-2:nth-child(6) a.ecl-link': 'A simple link 6' - array: '#type': pattern '#id': navigation_list From 55c6e69b181d455e8fe028c2a881303efd3ff5ec Mon Sep 17 00:00:00 2001 From: Sergii Pavlenko Date: Tue, 7 Sep 2021 15:52:41 +0300 Subject: [PATCH 16/41] EWPP-1206: Fix issues related to D9 related changes in oe_content component. --- behat.yml.dist | 2 +- composer.json | 2 +- tests/Kernel/CallForProposalsRenderTest.php | 2 +- tests/Kernel/CallForTendersRenderTest.php | 2 +- tests/Kernel/ConsultationRenderTest.php | 2 +- tests/Kernel/ContentRenderTestBase.php | 4 ++-- tests/Kernel/EventRenderTest.php | 2 +- tests/Kernel/NewsRenderTest.php | 2 +- tests/Kernel/OrganisationRenderTest.php | 2 +- tests/Kernel/PersonRenderTest.php | 4 ++-- tests/Kernel/ProjectRenderTest.php | 2 +- 11 files changed, 13 insertions(+), 13 deletions(-) diff --git a/behat.yml.dist b/behat.yml.dist index 5263eaf97..db97e7617 100644 --- a/behat.yml.dist +++ b/behat.yml.dist @@ -94,6 +94,6 @@ default: project funding header: "#project-funding .ecl-u-type-heading-2" FriendsOfBehat\ServiceContainerExtension: imports: - - 'build/modules/contrib/oe_content/tests/Behat/config/services.yml' + - 'build/modules/contrib/oe_content/tests/src/Behat/config/services.yml' formatters: progress: ~ diff --git a/composer.json b/composer.json index 9eb857a2c..f47d1fe35 100644 --- a/composer.json +++ b/composer.json @@ -81,7 +81,7 @@ "autoload-dev": { "psr-4": { "Drupal\\Tests\\oe_theme\\": "./tests/", - "Drupal\\Tests\\oe_content\\": "./build/modules/contrib/oe_content/tests/", + "Drupal\\Tests\\oe_content\\": "./build/modules/contrib/oe_content/tests/src/", "Drupal\\Tests\\oe_media\\": "./build/modules/contrib/oe_media/tests/src/" } }, diff --git a/tests/Kernel/CallForProposalsRenderTest.php b/tests/Kernel/CallForProposalsRenderTest.php index eaf790964..6beba4a13 100644 --- a/tests/Kernel/CallForProposalsRenderTest.php +++ b/tests/Kernel/CallForProposalsRenderTest.php @@ -52,7 +52,7 @@ protected function setUp(): void { ]); module_load_include('install', 'oe_content'); - oe_content_install(); + oe_content_install(FALSE); $this->setUpCurrentUser([], [], TRUE); } diff --git a/tests/Kernel/CallForTendersRenderTest.php b/tests/Kernel/CallForTendersRenderTest.php index babaa7b98..14a143d3f 100644 --- a/tests/Kernel/CallForTendersRenderTest.php +++ b/tests/Kernel/CallForTendersRenderTest.php @@ -54,7 +54,7 @@ protected function setUp(): void { ]); module_load_include('install', 'oe_content'); - oe_content_install(); + oe_content_install(FALSE); // Set current user to UID 1, so that by default we can access everything. $account = User::load(1); diff --git a/tests/Kernel/ConsultationRenderTest.php b/tests/Kernel/ConsultationRenderTest.php index 8ed74513b..9699bdd3a 100644 --- a/tests/Kernel/ConsultationRenderTest.php +++ b/tests/Kernel/ConsultationRenderTest.php @@ -51,7 +51,7 @@ protected function setUp(): void { ]); module_load_include('install', 'oe_content'); - oe_content_install(); + oe_content_install(FALSE); $this->setUpCurrentUser([], [], TRUE); } diff --git a/tests/Kernel/ContentRenderTestBase.php b/tests/Kernel/ContentRenderTestBase.php index 8ffbfd21b..aa64d5ae3 100644 --- a/tests/Kernel/ContentRenderTestBase.php +++ b/tests/Kernel/ContentRenderTestBase.php @@ -116,7 +116,7 @@ protected function setUp() { $this->container->get('config.installer')->installDefaultConfig('theme', 'oe_theme'); $this->container->get('module_handler')->loadInclude('oe_content_documents_field', 'install'); - oe_content_documents_field_install(); + oe_content_documents_field_install(FALSE); $this->installConfig([ 'oe_content', @@ -142,7 +142,7 @@ protected function setUp() { ->save(); module_load_include('install', 'oe_content'); - oe_content_install(); + oe_content_install(FALSE); $this->installEntitySchema('skos_concept'); $this->installEntitySchema('skos_concept_scheme'); diff --git a/tests/Kernel/EventRenderTest.php b/tests/Kernel/EventRenderTest.php index 5c4b10eaf..d14587549 100644 --- a/tests/Kernel/EventRenderTest.php +++ b/tests/Kernel/EventRenderTest.php @@ -67,7 +67,7 @@ protected function setUp(): void { ]); module_load_include('install', 'oe_content'); - oe_content_install(); + oe_content_install(FALSE); // Set current user to UID 1, so that by default we can access everything. $account = User::load(1); diff --git a/tests/Kernel/NewsRenderTest.php b/tests/Kernel/NewsRenderTest.php index 6fef6e0b0..1ba38a043 100644 --- a/tests/Kernel/NewsRenderTest.php +++ b/tests/Kernel/NewsRenderTest.php @@ -24,7 +24,7 @@ protected function setUp(): void { parent::setUp(); module_load_include('install', 'oe_content'); - oe_content_install(); + oe_content_install(FALSE); } /** diff --git a/tests/Kernel/OrganisationRenderTest.php b/tests/Kernel/OrganisationRenderTest.php index a0834b2a1..9acc75a7b 100644 --- a/tests/Kernel/OrganisationRenderTest.php +++ b/tests/Kernel/OrganisationRenderTest.php @@ -62,7 +62,7 @@ protected function setUp(): void { ]); module_load_include('install', 'oe_content'); - oe_content_install(); + oe_content_install(FALSE); // Set current user to UID 1, so that by default we can access everything. $account = User::load(1); diff --git a/tests/Kernel/PersonRenderTest.php b/tests/Kernel/PersonRenderTest.php index 60593f683..42931b384 100644 --- a/tests/Kernel/PersonRenderTest.php +++ b/tests/Kernel/PersonRenderTest.php @@ -72,9 +72,9 @@ protected function setUp(): void { ]); module_load_include('install', 'oe_content'); - oe_content_install(); + oe_content_install(FALSE); module_load_include('install', 'oe_content_person'); - oe_content_person_install(); + oe_content_person_install(FALSE); $this->setUpCurrentUser([], [], TRUE); } diff --git a/tests/Kernel/ProjectRenderTest.php b/tests/Kernel/ProjectRenderTest.php index 70c034017..96d1a27d8 100644 --- a/tests/Kernel/ProjectRenderTest.php +++ b/tests/Kernel/ProjectRenderTest.php @@ -64,7 +64,7 @@ protected function setUp(): void { ]); module_load_include('install', 'oe_content'); - oe_content_install(); + oe_content_install(FALSE); // Set current user to UID 1, so that by default we can access everything. $account = User::load(1); From 46a0ccb6b2a5cacac92e9e052991259c510141ac Mon Sep 17 00:00:00 2001 From: Evgenii Nikitin Date: Tue, 31 Aug 2021 18:07:55 +0300 Subject: [PATCH 17/41] EWPP-1470: Content item title styling is not consistent. --- sass/compositions/_content_item.scss | 6 ++++-- .../list_item/pattern-list-item--variant-date.html.twig | 2 +- templates/patterns/list_item/pattern-list-item.html.twig | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/sass/compositions/_content_item.scss b/sass/compositions/_content_item.scss index a001377a3..f0f6598a8 100644 --- a/sass/compositions/_content_item.scss +++ b/sass/compositions/_content_item.scss @@ -13,7 +13,8 @@ } } -.ecl-content-item__title { +.ecl-content-item__title, +.ecl-content-item-date__title { a { color: map.get(theme.$color, 'blue-100'); font-weight: map.get(theme.$font-weight, 'bold')!important; @@ -21,6 +22,7 @@ } } -.ecl-content-item__description { +.ecl-content-item__description, +.ecl-content-item-date__description { color: map.get(theme.$color, 'grey-140')!important; } diff --git a/templates/patterns/list_item/pattern-list-item--variant-date.html.twig b/templates/patterns/list_item/pattern-list-item--variant-date.html.twig index 865b08cf0..54eb82383 100644 --- a/templates/patterns/list_item/pattern-list-item--variant-date.html.twig +++ b/templates/patterns/list_item/pattern-list-item--variant-date.html.twig @@ -49,7 +49,7 @@ {% endblock %} {% block detail %} {% if detail is not empty %} -
{{ detail|smart_trim(length) }}
+
{{ detail|smart_trim(length) }}
{% endif %} {% endblock %} {% block additional_information %} diff --git a/templates/patterns/list_item/pattern-list-item.html.twig b/templates/patterns/list_item/pattern-list-item.html.twig index acc382cd2..fe67948d4 100644 --- a/templates/patterns/list_item/pattern-list-item.html.twig +++ b/templates/patterns/list_item/pattern-list-item.html.twig @@ -62,7 +62,7 @@ {% endblock %} {% block detail %} {% if detail is not empty %} -
{{ detail|smart_trim(length) }}
+
{{ detail|smart_trim(length) }}
{% endif %} {% endblock %} {% block additional_information %} From ec9fdee9e78edfdf5248e6a93cbb90ab8e7194a0 Mon Sep 17 00:00:00 2001 From: Evgenii Nikitin Date: Wed, 8 Sep 2021 13:27:49 +0300 Subject: [PATCH 18/41] EWPP-873: Add cache info from the Link field to the page. --- behat.yml.dist | 2 +- composer.json | 2 +- ...aragraph.oe_text_feature_media.default.yml | 71 ------------------- .../oe_theme_helper.post_update.php | 20 ------ ...paragraph--oe-text-feature-media.html.twig | 6 +- 5 files changed, 7 insertions(+), 94 deletions(-) delete mode 100644 config/post_updates/20017_update_view_display_paragraph_text_media/core.entity_view_display.paragraph.oe_text_feature_media.default.yml diff --git a/behat.yml.dist b/behat.yml.dist index 5263eaf97..db97e7617 100644 --- a/behat.yml.dist +++ b/behat.yml.dist @@ -94,6 +94,6 @@ default: project funding header: "#project-funding .ecl-u-type-heading-2" FriendsOfBehat\ServiceContainerExtension: imports: - - 'build/modules/contrib/oe_content/tests/Behat/config/services.yml' + - 'build/modules/contrib/oe_content/tests/src/Behat/config/services.yml' formatters: progress: ~ diff --git a/composer.json b/composer.json index ce708aa9e..a77c2d5e3 100644 --- a/composer.json +++ b/composer.json @@ -81,7 +81,7 @@ "autoload-dev": { "psr-4": { "Drupal\\Tests\\oe_theme\\": "./tests/", - "Drupal\\Tests\\oe_content\\": "./build/modules/contrib/oe_content/tests/", + "Drupal\\Tests\\oe_content\\": "./build/modules/contrib/oe_content/tests/src/", "Drupal\\Tests\\oe_media\\": "./build/modules/contrib/oe_media/tests/src/" } }, diff --git a/config/post_updates/20017_update_view_display_paragraph_text_media/core.entity_view_display.paragraph.oe_text_feature_media.default.yml b/config/post_updates/20017_update_view_display_paragraph_text_media/core.entity_view_display.paragraph.oe_text_feature_media.default.yml deleted file mode 100644 index e5d7b2f58..000000000 --- a/config/post_updates/20017_update_view_display_paragraph_text_media/core.entity_view_display.paragraph.oe_text_feature_media.default.yml +++ /dev/null @@ -1,71 +0,0 @@ -langcode: en -status: true -dependencies: - config: - - field.field.paragraph.oe_text_feature_media.field_oe_feature_media_title - - field.field.paragraph.oe_text_feature_media.field_oe_link - - field.field.paragraph.oe_text_feature_media.field_oe_media - - field.field.paragraph.oe_text_feature_media.field_oe_plain_text_long - - field.field.paragraph.oe_text_feature_media.field_oe_text_long - - field.field.paragraph.oe_text_feature_media.field_oe_title - - paragraphs.paragraphs_type.oe_text_feature_media - module: - - link - - text -id: paragraph.oe_text_feature_media.default -targetEntityType: paragraph -bundle: oe_text_feature_media -mode: default -content: - field_oe_feature_media_title: - type: string - weight: 1 - region: content - label: above - settings: - link_to_entity: false - third_party_settings: { } - field_oe_link: - type: link - weight: 5 - region: content - label: above - settings: - trim_length: 80 - url_only: false - url_plain: false - rel: '' - target: '' - third_party_settings: { } - field_oe_media: - type: entity_reference_entity_view - weight: 2 - label: above - settings: - view_mode: default - link: false - third_party_settings: { } - region: content - field_oe_plain_text_long: - weight: 3 - label: above - settings: { } - third_party_settings: { } - type: basic_string - region: content - field_oe_text_long: - weight: 4 - label: above - settings: { } - third_party_settings: { } - type: text_default - region: content - field_oe_title: - weight: 0 - label: above - settings: - link_to_entity: false - third_party_settings: { } - type: string - region: content -hidden: { } diff --git a/modules/oe_theme_helper/oe_theme_helper.post_update.php b/modules/oe_theme_helper/oe_theme_helper.post_update.php index 6d3cb0d67..1ba8f0f92 100644 --- a/modules/oe_theme_helper/oe_theme_helper.post_update.php +++ b/modules/oe_theme_helper/oe_theme_helper.post_update.php @@ -296,23 +296,3 @@ function oe_theme_helper_post_update_20016() { 'label' => 'OpenEuropa: Compact teaser', ])->save(); } - -/** - * Update default view display for Text with featured media paragraph. - */ -function oe_theme_helper_post_update_20017() { - if (!\Drupal::moduleHandler()->moduleExists('oe_paragraphs_media')) { - // Ensure that module for Text with featured media paragraph is enabled. - return t('Skipping since the oe_paragraphs_media module is not enabled.'); - } - - // Update existing default view display. - $storage = new FileStorage(drupal_get_path('theme', 'oe_theme') . '/config/post_updates/20017_update_view_display_paragraph_text_media'); - $display_values = $storage->read('core.entity_view_display.paragraph.oe_text_feature_media.default'); - $display_storage = \Drupal::entityTypeManager()->getStorage('entity_view_display'); - $display = $display_storage->load($display_values['id']); - if ($display) { - $display = $display_storage->updateFromStorageRecord($display, $display_values); - $display->save(); - } -} diff --git a/templates/paragraphs/paragraph--oe-text-feature-media.html.twig b/templates/paragraphs/paragraph--oe-text-feature-media.html.twig index d319f6f0d..d708e74f8 100644 --- a/templates/paragraphs/paragraph--oe-text-feature-media.html.twig +++ b/templates/paragraphs/paragraph--oe-text-feature-media.html.twig @@ -7,11 +7,15 @@ */ #} +{% 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 %} + {# Unfortunately even when the field is empty the variable content.* still contains information (such as the weight) so we can't pass it to the pattern directly. #} - {{ pattern('text_featured_media', { 'variant': variant, 'title': not paragraph.field_oe_title.isEmpty ? content.field_oe_title, From 3281e54aa14046e3941512d5a6919019b633f292 Mon Sep 17 00:00:00 2001 From: Evgenii Nikitin Date: Wed, 8 Sep 2021 13:50:04 +0300 Subject: [PATCH 19/41] EWPP-873: Update oe_content hook_install() functions. --- tests/Kernel/CallForProposalsRenderTest.php | 2 +- tests/Kernel/CallForTendersRenderTest.php | 2 +- tests/Kernel/ConsultationRenderTest.php | 2 +- tests/Kernel/ContentRenderTestBase.php | 4 ++-- tests/Kernel/EventRenderTest.php | 2 +- tests/Kernel/NewsRenderTest.php | 2 +- tests/Kernel/OrganisationRenderTest.php | 2 +- tests/Kernel/PersonRenderTest.php | 4 ++-- tests/Kernel/ProjectRenderTest.php | 2 +- 9 files changed, 11 insertions(+), 11 deletions(-) diff --git a/tests/Kernel/CallForProposalsRenderTest.php b/tests/Kernel/CallForProposalsRenderTest.php index eaf790964..6beba4a13 100644 --- a/tests/Kernel/CallForProposalsRenderTest.php +++ b/tests/Kernel/CallForProposalsRenderTest.php @@ -52,7 +52,7 @@ protected function setUp(): void { ]); module_load_include('install', 'oe_content'); - oe_content_install(); + oe_content_install(FALSE); $this->setUpCurrentUser([], [], TRUE); } diff --git a/tests/Kernel/CallForTendersRenderTest.php b/tests/Kernel/CallForTendersRenderTest.php index babaa7b98..14a143d3f 100644 --- a/tests/Kernel/CallForTendersRenderTest.php +++ b/tests/Kernel/CallForTendersRenderTest.php @@ -54,7 +54,7 @@ protected function setUp(): void { ]); module_load_include('install', 'oe_content'); - oe_content_install(); + oe_content_install(FALSE); // Set current user to UID 1, so that by default we can access everything. $account = User::load(1); diff --git a/tests/Kernel/ConsultationRenderTest.php b/tests/Kernel/ConsultationRenderTest.php index 8ed74513b..9699bdd3a 100644 --- a/tests/Kernel/ConsultationRenderTest.php +++ b/tests/Kernel/ConsultationRenderTest.php @@ -51,7 +51,7 @@ protected function setUp(): void { ]); module_load_include('install', 'oe_content'); - oe_content_install(); + oe_content_install(FALSE); $this->setUpCurrentUser([], [], TRUE); } diff --git a/tests/Kernel/ContentRenderTestBase.php b/tests/Kernel/ContentRenderTestBase.php index 8ffbfd21b..aa64d5ae3 100644 --- a/tests/Kernel/ContentRenderTestBase.php +++ b/tests/Kernel/ContentRenderTestBase.php @@ -116,7 +116,7 @@ protected function setUp() { $this->container->get('config.installer')->installDefaultConfig('theme', 'oe_theme'); $this->container->get('module_handler')->loadInclude('oe_content_documents_field', 'install'); - oe_content_documents_field_install(); + oe_content_documents_field_install(FALSE); $this->installConfig([ 'oe_content', @@ -142,7 +142,7 @@ protected function setUp() { ->save(); module_load_include('install', 'oe_content'); - oe_content_install(); + oe_content_install(FALSE); $this->installEntitySchema('skos_concept'); $this->installEntitySchema('skos_concept_scheme'); diff --git a/tests/Kernel/EventRenderTest.php b/tests/Kernel/EventRenderTest.php index 5c4b10eaf..d14587549 100644 --- a/tests/Kernel/EventRenderTest.php +++ b/tests/Kernel/EventRenderTest.php @@ -67,7 +67,7 @@ protected function setUp(): void { ]); module_load_include('install', 'oe_content'); - oe_content_install(); + oe_content_install(FALSE); // Set current user to UID 1, so that by default we can access everything. $account = User::load(1); diff --git a/tests/Kernel/NewsRenderTest.php b/tests/Kernel/NewsRenderTest.php index 6fef6e0b0..1ba38a043 100644 --- a/tests/Kernel/NewsRenderTest.php +++ b/tests/Kernel/NewsRenderTest.php @@ -24,7 +24,7 @@ protected function setUp(): void { parent::setUp(); module_load_include('install', 'oe_content'); - oe_content_install(); + oe_content_install(FALSE); } /** diff --git a/tests/Kernel/OrganisationRenderTest.php b/tests/Kernel/OrganisationRenderTest.php index a0834b2a1..9acc75a7b 100644 --- a/tests/Kernel/OrganisationRenderTest.php +++ b/tests/Kernel/OrganisationRenderTest.php @@ -62,7 +62,7 @@ protected function setUp(): void { ]); module_load_include('install', 'oe_content'); - oe_content_install(); + oe_content_install(FALSE); // Set current user to UID 1, so that by default we can access everything. $account = User::load(1); diff --git a/tests/Kernel/PersonRenderTest.php b/tests/Kernel/PersonRenderTest.php index 60593f683..42931b384 100644 --- a/tests/Kernel/PersonRenderTest.php +++ b/tests/Kernel/PersonRenderTest.php @@ -72,9 +72,9 @@ protected function setUp(): void { ]); module_load_include('install', 'oe_content'); - oe_content_install(); + oe_content_install(FALSE); module_load_include('install', 'oe_content_person'); - oe_content_person_install(); + oe_content_person_install(FALSE); $this->setUpCurrentUser([], [], TRUE); } diff --git a/tests/Kernel/ProjectRenderTest.php b/tests/Kernel/ProjectRenderTest.php index 70c034017..96d1a27d8 100644 --- a/tests/Kernel/ProjectRenderTest.php +++ b/tests/Kernel/ProjectRenderTest.php @@ -64,7 +64,7 @@ protected function setUp(): void { ]); module_load_include('install', 'oe_content'); - oe_content_install(); + oe_content_install(FALSE); // Set current user to UID 1, so that by default we can access everything. $account = User::load(1); From 7f4268b6ba43a0184c4bde98f3a16ec9d591c050 Mon Sep 17 00:00:00 2001 From: Francesco Sardara Date: Wed, 8 Sep 2021 15:33:20 +0200 Subject: [PATCH 20/41] EWPP-0000: Version 2.0 of typed_link is required by oe_paragraphs. --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index f47d1fe35..5fb1a5cd2 100644 --- a/composer.json +++ b/composer.json @@ -37,7 +37,7 @@ "drupal/json_field": "^1.0.0-rc2", "drupal/renderviz": "^1.0@alpha", "drupal/styleguide": "~1.0-alpha3", - "drupal/typed_link": "~1.1", + "drupal/typed_link": "^2.0", "drush/drush": "~9.0", "easyrdf/easyrdf": "1.0.0 as 0.9.1", "friends-of-behat/service-container-extension": "^1.0", From a166602886abc1ec6b59cffe7195669ff9feb5b2 Mon Sep 17 00:00:00 2001 From: Francesco Sardara Date: Wed, 8 Sep 2021 15:55:08 +0200 Subject: [PATCH 21/41] EWPP-0000: Install hooks have a parameter now. --- tests/Kernel/Paragraphs/MediaParagraphsTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Kernel/Paragraphs/MediaParagraphsTest.php b/tests/Kernel/Paragraphs/MediaParagraphsTest.php index 3b2899131..9cefbef64 100644 --- a/tests/Kernel/Paragraphs/MediaParagraphsTest.php +++ b/tests/Kernel/Paragraphs/MediaParagraphsTest.php @@ -44,7 +44,7 @@ protected function setUp() { parent::setUp(); $this->container->get('module_handler')->loadInclude('oe_paragraphs_media_field_storage', 'install'); - oe_paragraphs_media_field_storage_install(); + oe_paragraphs_media_field_storage_install(FALSE); $this->installEntitySchema('media'); $this->installConfig([ 'media', From 72dfb6ed29671bca29d74e1cff436f339f7be100 Mon Sep 17 00:00:00 2001 From: nagyad Date: Fri, 30 Jul 2021 12:04:13 +0200 Subject: [PATCH 22/41] EWPP-866: Use extend in list-item templates. --- ...ttern-list-item--variant-date-cancelled.html.twig | 12 ++---------- ...pattern-list-item--variant-date-ongoing.html.twig | 12 ++---------- .../pattern-list-item--variant-date-past.html.twig | 12 ++---------- .../pattern-list-item--variant-navigation.html.twig | 11 +++++------ ...rn-list-item--variant-thumbnail-primary.html.twig | 12 ++---------- ...-list-item--variant-thumbnail-secondary.html.twig | 12 ++---------- 6 files changed, 15 insertions(+), 56 deletions(-) diff --git a/templates/patterns/list_item/pattern-list-item--variant-date-cancelled.html.twig b/templates/patterns/list_item/pattern-list-item--variant-date-cancelled.html.twig index e78d493b0..a316e1033 100644 --- a/templates/patterns/list_item/pattern-list-item--variant-date-cancelled.html.twig +++ b/templates/patterns/list_item/pattern-list-item--variant-date-cancelled.html.twig @@ -4,13 +4,5 @@ * Cancelled event list item component. */ #} -{% include '@oe_theme/patterns/list_item/pattern-list-item--variant-date.html.twig' with { - title: title, - url: url, - date: date, - detail: detail, - length: length, - meta: meta, - additional_information: additional_information, - variant: 'cancelled' -} only %} +{% set variant = 'cancelled' %} +{% extends '@oe_theme/patterns/list_item/pattern-list-item--variant-date.html.twig' %} diff --git a/templates/patterns/list_item/pattern-list-item--variant-date-ongoing.html.twig b/templates/patterns/list_item/pattern-list-item--variant-date-ongoing.html.twig index 09f33645f..1cfa5ed16 100644 --- a/templates/patterns/list_item/pattern-list-item--variant-date-ongoing.html.twig +++ b/templates/patterns/list_item/pattern-list-item--variant-date-ongoing.html.twig @@ -4,13 +4,5 @@ * Ongoing event list item component. */ #} -{% include '@oe_theme/patterns/list_item/pattern-list-item--variant-date.html.twig' with { - title: title, - url: url, - date: date, - detail: detail, - length: length, - meta: meta, - additional_information: additional_information, - variant: 'ongoing' -} only %} +{% set variant = 'ongoing' %} +{% extends '@oe_theme/patterns/list_item/pattern-list-item--variant-date.html.twig' %} diff --git a/templates/patterns/list_item/pattern-list-item--variant-date-past.html.twig b/templates/patterns/list_item/pattern-list-item--variant-date-past.html.twig index 38b0e5c5f..16c3502f6 100644 --- a/templates/patterns/list_item/pattern-list-item--variant-date-past.html.twig +++ b/templates/patterns/list_item/pattern-list-item--variant-date-past.html.twig @@ -4,13 +4,5 @@ * Past event list item component. */ #} -{% include '@oe_theme/patterns/list_item/pattern-list-item--variant-date.html.twig' with { - title: title, - url: url, - date: date, - detail: detail, - length: length, - meta: meta, - additional_information: additional_information, - variant: 'past' -} only %} +{% set variant = 'past' %} +{% extends '@oe_theme/patterns/list_item/pattern-list-item--variant-date.html.twig' %} diff --git a/templates/patterns/list_item/pattern-list-item--variant-navigation.html.twig b/templates/patterns/list_item/pattern-list-item--variant-navigation.html.twig index 32d2bc4be..dd034862d 100644 --- a/templates/patterns/list_item/pattern-list-item--variant-navigation.html.twig +++ b/templates/patterns/list_item/pattern-list-item--variant-navigation.html.twig @@ -4,9 +4,8 @@ * Default implementation for the navigation list item component. */ #} -{% include '@oe_theme/patterns/list_item/pattern-list-item.html.twig' with { - title: title, - url: url, - detail: detail, - length: length, -} only %} +{% set meta = [] %} +{% set image = [] %} +{% set image_position = '' %} +{% set additional_information = [] %} +{% extends '@oe_theme/patterns/list_item/pattern-list-item.html.twig' %} diff --git a/templates/patterns/list_item/pattern-list-item--variant-thumbnail-primary.html.twig b/templates/patterns/list_item/pattern-list-item--variant-thumbnail-primary.html.twig index 439d7045d..8f1775635 100644 --- a/templates/patterns/list_item/pattern-list-item--variant-thumbnail-primary.html.twig +++ b/templates/patterns/list_item/pattern-list-item--variant-thumbnail-primary.html.twig @@ -4,13 +4,5 @@ * Default theme implementation for a ECL thumbnail list item component. */ #} -{% include '@oe_theme/patterns/list_item/pattern-list-item.html.twig' with { - title: title, - url: url, - detail: detail, - length: length, - image: image, - image_position: 'before', - additional_information: additional_information, - meta: meta -} only %} +{% set image_position = 'before' %} +{% extends '@oe_theme/patterns/list_item/pattern-list-item.html.twig' %} diff --git a/templates/patterns/list_item/pattern-list-item--variant-thumbnail-secondary.html.twig b/templates/patterns/list_item/pattern-list-item--variant-thumbnail-secondary.html.twig index 1b8b3f954..953cef9ec 100644 --- a/templates/patterns/list_item/pattern-list-item--variant-thumbnail-secondary.html.twig +++ b/templates/patterns/list_item/pattern-list-item--variant-thumbnail-secondary.html.twig @@ -4,13 +4,5 @@ * Default theme implementation for a ECL thumbnail list item component. */ #} -{% include '@oe_theme/patterns/list_item/pattern-list-item.html.twig' with { - title: title, - url: url, - detail: detail, - length: length, - image: image, - image_position: 'after', - additional_information: additional_information, - meta: meta -} only %} +{% set image_position = 'after' %} +{% extends '@oe_theme/patterns/list_item/pattern-list-item.html.twig' %} From 83f54996376a1bb06a87c36d0f143b52daebd009 Mon Sep 17 00:00:00 2001 From: Evgenii Nikitin Date: Fri, 17 Sep 2021 14:10:34 +0300 Subject: [PATCH 23/41] EWPP-873: Use latest oe_paragraphs. --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 32d014c43..5fb1a5cd2 100644 --- a/composer.json +++ b/composer.json @@ -52,7 +52,7 @@ "openeuropa/oe_corporate_countries": "~2.0", "openeuropa/oe_media": "~1.12", "openeuropa/oe_multilingual": "~1.8", - "openeuropa/oe_paragraphs": "dev-EPIC-EWPP-873-Text-media-2", + "openeuropa/oe_paragraphs": "dev-master", "openeuropa/oe_search": "~1.0", "openeuropa/oe_webtools": "~1.10", "openeuropa/oe_contact_forms": "~1.0", From aff22b702993558778189af3b84a0ec2186b163d Mon Sep 17 00:00:00 2001 From: Francesco Sardara Date: Wed, 8 Sep 2021 17:58:02 +0200 Subject: [PATCH 24/41] EWPP-1458: Test that events render correctly when a non-existing event type is specified. --- tests/Functional/ContentEventRenderTest.php | 10 ++++++++++ tests/Kernel/EventRenderTest.php | 9 +++++++++ 2 files changed, 19 insertions(+) diff --git a/tests/Functional/ContentEventRenderTest.php b/tests/Functional/ContentEventRenderTest.php index 04da50d81..1cd0352de 100644 --- a/tests/Functional/ContentEventRenderTest.php +++ b/tests/Functional/ContentEventRenderTest.php @@ -604,6 +604,16 @@ public function testEventRendering(): void { ], ]; $icons_text_assert->assertPattern($icons_text_expected_values, $details_list_content->getOuterHtml()); + + // Verify that the event renders correctly when a non-existing event type + // is set. + $node->set('oe_event_type', 'http://publications.europa.eu/resource/authority/public-event-type/OP_DATPRO') + ->save(); + $this->drupalGet($node->toUrl()); + $page_header_expected_values = [ + 'title' => 'Test event node', + ]; + $page_header_assert->assertPattern($page_header_expected_values, $page_header->getOuterHtml()); } /** diff --git a/tests/Kernel/EventRenderTest.php b/tests/Kernel/EventRenderTest.php index d14587549..7d0aac5c3 100644 --- a/tests/Kernel/EventRenderTest.php +++ b/tests/Kernel/EventRenderTest.php @@ -259,6 +259,15 @@ public function testEventTeaser(): void { ]); $assert->assertPattern($expected_values, $html); $assert->assertVariant('date_cancelled', $html); + + // Verify that the teaser renders correctly when a non-existing event type + // is set. + $node->set('oe_event_type', 'http://publications.europa.eu/resource/authority/public-event-type/OP_DATPRO') + ->save(); + $build = $this->nodeViewBuilder->view($node, 'teaser', 'bg'); + $html = $this->renderRoot($build); + unset($expected_values['meta']); + $assert->assertPattern($expected_values, $html); } } From 15c6b60a9d1a42813474059b89725f7d0748e858 Mon Sep 17 00:00:00 2001 From: Francesco Sardara Date: Wed, 8 Sep 2021 18:02:18 +0200 Subject: [PATCH 25/41] EWPP-1458: Check that the event type entity exists. --- .../ExtraField/Display/TeaserMetaExtraField.php | 9 +++++++-- .../Plugin/PageHeaderMetadata/EventContentType.php | 11 ++++++++++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/modules/oe_theme_content_event/src/Plugin/ExtraField/Display/TeaserMetaExtraField.php b/modules/oe_theme_content_event/src/Plugin/ExtraField/Display/TeaserMetaExtraField.php index cd7ad38ac..a10cc8ce2 100644 --- a/modules/oe_theme_content_event/src/Plugin/ExtraField/Display/TeaserMetaExtraField.php +++ b/modules/oe_theme_content_event/src/Plugin/ExtraField/Display/TeaserMetaExtraField.php @@ -4,6 +4,7 @@ namespace Drupal\oe_theme_content_event\Plugin\ExtraField\Display; +use Drupal\Core\Cache\CacheableMetadata; use Drupal\Core\Entity\ContentEntityInterface; use Drupal\Core\Entity\EntityRepositoryInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; @@ -79,8 +80,12 @@ public function viewElements(ContentEntityInterface $entity) { // Add the event type. /** @var \Drupal\rdf_skos\Entity\ConceptInterface $type */ $type = $entity->get('oe_event_type')->entity; - $type = $this->entityRepository->getTranslationFromContext($type); - $elements[] = ['#markup' => $type->label()]; + if ($type) { + $type = $this->entityRepository->getTranslationFromContext($type); + $elements[] = ['#markup' => $type->label()]; + CacheableMetadata::createFromObject($type) + ->applyTo($elements); + } // Add the event status, only if it doesn't go as planned. $status = $entity->get('oe_event_status')->value; diff --git a/modules/oe_theme_content_event/src/Plugin/PageHeaderMetadata/EventContentType.php b/modules/oe_theme_content_event/src/Plugin/PageHeaderMetadata/EventContentType.php index f4cc410ae..2ceb5c418 100644 --- a/modules/oe_theme_content_event/src/Plugin/PageHeaderMetadata/EventContentType.php +++ b/modules/oe_theme_content_event/src/Plugin/PageHeaderMetadata/EventContentType.php @@ -4,6 +4,7 @@ namespace Drupal\oe_theme_content_event\Plugin\PageHeaderMetadata; +use Drupal\Core\Cache\CacheableMetadata; use Drupal\Core\Entity\EntityRepositoryInterface; use Drupal\oe_theme_helper\Plugin\PageHeaderMetadata\NodeViewRoutesBase; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -76,10 +77,18 @@ public function getMetadata(): array { $metadata = parent::getMetadata(); $node = $this->getNode(); - $translated_value = $this->entityRepository->getTranslationFromContext($node->get('oe_event_type')->entity); + $type = $node->get('oe_event_type')->entity; + if (!$type) { + return $metadata; + } + + $translated_value = $this->entityRepository->getTranslationFromContext($type); $metadata['metas'] = [ $translated_value->label(), ]; + CacheableMetadata::createFromRenderArray($metadata) + ->addCacheableDependency($translated_value) + ->applyTo($metadata); return $metadata; } From da69cbf1ead2ead21afdfa6aaefc670ae1e536b9 Mon Sep 17 00:00:00 2001 From: Evgenii Nikitin Date: Thu, 16 Sep 2021 18:39:23 +0300 Subject: [PATCH 26/41] EWPP-1514: Wrong Irish translation in language switcher. --- modules/oe_theme_helper/translations/oe_theme_helper-ga.po | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/oe_theme_helper/translations/oe_theme_helper-ga.po b/modules/oe_theme_helper/translations/oe_theme_helper-ga.po index 6171d1fa7..1792b44b2 100644 --- a/modules/oe_theme_helper/translations/oe_theme_helper-ga.po +++ b/modules/oe_theme_helper/translations/oe_theme_helper-ga.po @@ -470,7 +470,7 @@ msgid "This page is not available in @language_name." msgstr "Níl an leathanach seo ar fáil i @language_name." msgid "Choose another language" -msgstr "Choisir une autre langue" +msgstr "Roghnaigh teanga eile" msgid "1 day" msgid_plural "@count days" From ddbef8ce084e9353a3a4837b926eabcd9d904138 Mon Sep 17 00:00:00 2001 From: Evgenii Nikitin Date: Tue, 21 Sep 2021 11:38:09 +0300 Subject: [PATCH 27/41] EWPP-1514: Event node title isn't translatable anymore by default in oe_content. --- tests/Kernel/EventRenderTest.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/Kernel/EventRenderTest.php b/tests/Kernel/EventRenderTest.php index 7d0aac5c3..c743cc07e 100644 --- a/tests/Kernel/EventRenderTest.php +++ b/tests/Kernel/EventRenderTest.php @@ -103,6 +103,13 @@ public function testEventTeaser(): void { $venue->save(); + // Make node title translatable. + $fields = \Drupal::service('entity_field.manager') + ->getBaseFieldDefinitions('node', 'oe_event'); + $field_config = $fields['title']->getConfig('oe_event'); + $field_config->setTranslatable(TRUE); + $field_config->save(); + $date = new \DateTime('2022-01-02'); $values = [ 'type' => 'oe_event', From 89f3a8eb58424006de737ed340188fe081cd085f Mon Sep 17 00:00:00 2001 From: Antonio De Marco Date: Fri, 17 Sep 2021 12:31:34 +0200 Subject: [PATCH 28/41] EWPP-1495: Make sure that event registration button is displayed as an inline block. --- .../oe-theme-content-event-registration-button.html.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/oe_theme_content_event/templates/oe-theme-content-event-registration-button.html.twig b/modules/oe_theme_content_event/templates/oe-theme-content-event-registration-button.html.twig index f19f9854d..d188978e8 100644 --- a/modules/oe_theme_content_event/templates/oe-theme-content-event-registration-button.html.twig +++ b/modules/oe_theme_content_event/templates/oe-theme-content-event-registration-button.html.twig @@ -7,7 +7,7 @@
{% if show_button %} {% if enabled %} - {{ label }} + {{ label }} {% else %} {% endif %} From 4e69b23357a4b3e54775d2007dc33c67e86e140e Mon Sep 17 00:00:00 2001 From: Evgenii Nikitin Date: Mon, 30 Aug 2021 12:13:14 +0300 Subject: [PATCH 29/41] EWPP-1312: Translate "I have read and agree with the data protection terms" string. --- composer.json | 2 +- .../oe_theme_contact_forms/oe_theme_contact_forms.module | 9 +++++++-- .../oe_theme_helper/translations/oe_theme_helper-bg.po | 6 ++++++ .../oe_theme_helper/translations/oe_theme_helper-cs.po | 6 ++++++ .../oe_theme_helper/translations/oe_theme_helper-da.po | 6 ++++++ .../oe_theme_helper/translations/oe_theme_helper-de.po | 6 ++++++ .../oe_theme_helper/translations/oe_theme_helper-el.po | 6 ++++++ .../oe_theme_helper/translations/oe_theme_helper-es.po | 6 ++++++ .../oe_theme_helper/translations/oe_theme_helper-et.po | 6 ++++++ .../oe_theme_helper/translations/oe_theme_helper-fi.po | 6 ++++++ .../oe_theme_helper/translations/oe_theme_helper-fr.po | 6 ++++++ .../oe_theme_helper/translations/oe_theme_helper-ga.po | 6 ++++++ .../oe_theme_helper/translations/oe_theme_helper-hr.po | 6 ++++++ .../oe_theme_helper/translations/oe_theme_helper-hu.po | 6 ++++++ .../oe_theme_helper/translations/oe_theme_helper-it.po | 6 ++++++ .../oe_theme_helper/translations/oe_theme_helper-lt.po | 6 ++++++ .../oe_theme_helper/translations/oe_theme_helper-lv.po | 6 ++++++ .../oe_theme_helper/translations/oe_theme_helper-mt.po | 6 ++++++ .../oe_theme_helper/translations/oe_theme_helper-nl.po | 6 ++++++ .../oe_theme_helper/translations/oe_theme_helper-pl.po | 6 ++++++ .../translations/oe_theme_helper-pt-pt.po | 6 ++++++ .../oe_theme_helper/translations/oe_theme_helper-ro.po | 6 ++++++ .../oe_theme_helper/translations/oe_theme_helper-sk.po | 6 ++++++ .../oe_theme_helper/translations/oe_theme_helper-sl.po | 6 ++++++ .../oe_theme_helper/translations/oe_theme_helper-sv.po | 6 ++++++ 25 files changed, 146 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index 5fb1a5cd2..08073c108 100644 --- a/composer.json +++ b/composer.json @@ -55,7 +55,7 @@ "openeuropa/oe_paragraphs": "dev-master", "openeuropa/oe_search": "~1.0", "openeuropa/oe_webtools": "~1.10", - "openeuropa/oe_contact_forms": "~1.0", + "openeuropa/oe_contact_forms": "dev-EWPP-1312", "openeuropa/rdf_skos": "~1.0", "openeuropa/task-runner-drupal-project-symlink": "^1.0", "phpunit/phpunit": "~6.0", diff --git a/modules/oe_theme_contact_forms/oe_theme_contact_forms.module b/modules/oe_theme_contact_forms/oe_theme_contact_forms.module index b6b20f7f2..6c269064b 100644 --- a/modules/oe_theme_contact_forms/oe_theme_contact_forms.module +++ b/modules/oe_theme_contact_forms/oe_theme_contact_forms.module @@ -43,11 +43,16 @@ function oe_theme_contact_forms_form_contact_message_form_alter(&$form, FormStat // Add ecl link classes to the privacy link. $privacy_policy = $contact_form->getThirdPartySetting('oe_contact_forms', 'privacy_policy'); - $privacy_link = Link::fromTextAndUrl('data protection terms', Url::fromUri($privacy_policy, [ + $privacy_link = Link::fromTextAndUrl(t('data protection terms'), Url::fromUri($privacy_policy, [ 'absolute' => TRUE, 'attributes' => [ 'target' => '_blank', - 'class' => ['ecl-u-ml-2xs', 'ecl-link', 'ecl-link--default'], + 'class' => [ + 'ecl-u-ml-2xs', + 'ecl-u-mr-2xs', + 'ecl-link', + 'ecl-link--default', + ], ], ])); diff --git a/modules/oe_theme_helper/translations/oe_theme_helper-bg.po b/modules/oe_theme_helper/translations/oe_theme_helper-bg.po index 84fb043c9..810deffa1 100644 --- a/modules/oe_theme_helper/translations/oe_theme_helper-bg.po +++ b/modules/oe_theme_helper/translations/oe_theme_helper-bg.po @@ -515,3 +515,9 @@ msgstr "Час на проявата" msgid "Name" msgstr "Име" + +msgid "I have read and agree with the @link" +msgstr "Прочетох и съм съгласен с условията за @link" + +msgid "data protection terms" +msgstr "защита на данните" diff --git a/modules/oe_theme_helper/translations/oe_theme_helper-cs.po b/modules/oe_theme_helper/translations/oe_theme_helper-cs.po index 64cf14450..45c675c6d 100644 --- a/modules/oe_theme_helper/translations/oe_theme_helper-cs.po +++ b/modules/oe_theme_helper/translations/oe_theme_helper-cs.po @@ -515,3 +515,9 @@ msgstr "Datum a hodina" msgid "Name" msgstr "Jméno/Název" + +msgid "I have read and agree with the @link" +msgstr "Obeznámil(a) jsem se s podmínkami, které se týkají @link" + +msgid "data protection terms" +msgstr "ochrany údajů" diff --git a/modules/oe_theme_helper/translations/oe_theme_helper-da.po b/modules/oe_theme_helper/translations/oe_theme_helper-da.po index 523f72292..4ec993799 100644 --- a/modules/oe_theme_helper/translations/oe_theme_helper-da.po +++ b/modules/oe_theme_helper/translations/oe_theme_helper-da.po @@ -515,3 +515,9 @@ msgstr "Tidspunkt for arrangementet" msgid "Name" msgstr "Navn" + +msgid "I have read and agree with the @link" +msgstr "Jeg har læst og accepterer bestemmelserne om @link" + +msgid "data protection terms" +msgstr "databeskyttelse" diff --git a/modules/oe_theme_helper/translations/oe_theme_helper-de.po b/modules/oe_theme_helper/translations/oe_theme_helper-de.po index c371c947b..a12c75d57 100644 --- a/modules/oe_theme_helper/translations/oe_theme_helper-de.po +++ b/modules/oe_theme_helper/translations/oe_theme_helper-de.po @@ -515,3 +515,9 @@ msgstr "Zeit" msgid "Name" msgstr "Name" + +msgid "I have read and agree with the @link" +msgstr "Ich habe die @link gelesen und bin damit einverstanden" + +msgid "data protection terms" +msgstr "Datenschutzbestimmungen" diff --git a/modules/oe_theme_helper/translations/oe_theme_helper-el.po b/modules/oe_theme_helper/translations/oe_theme_helper-el.po index 0bc58df79..30684075f 100644 --- a/modules/oe_theme_helper/translations/oe_theme_helper-el.po +++ b/modules/oe_theme_helper/translations/oe_theme_helper-el.po @@ -515,3 +515,9 @@ msgstr "Διαδικτυακή ώρα" msgid "Name" msgstr "Όνομα" + +msgid "I have read and agree with the @link" +msgstr "Διάβασα τους @link και συμφωνώ" + +msgid "data protection terms" +msgstr "όρους προστασίας δεδομένων" diff --git a/modules/oe_theme_helper/translations/oe_theme_helper-es.po b/modules/oe_theme_helper/translations/oe_theme_helper-es.po index d7ac50b24..29a593476 100644 --- a/modules/oe_theme_helper/translations/oe_theme_helper-es.po +++ b/modules/oe_theme_helper/translations/oe_theme_helper-es.po @@ -515,3 +515,9 @@ msgstr "Tiempo en línea" msgid "Name" msgstr "Nombre" + +msgid "I have read and agree with the @link" +msgstr "He leído y acepto las @link" + +msgid "data protection terms" +msgstr "condiciones de protección de datos" diff --git a/modules/oe_theme_helper/translations/oe_theme_helper-et.po b/modules/oe_theme_helper/translations/oe_theme_helper-et.po index 29f741d0d..9650faf6b 100644 --- a/modules/oe_theme_helper/translations/oe_theme_helper-et.po +++ b/modules/oe_theme_helper/translations/oe_theme_helper-et.po @@ -515,3 +515,9 @@ msgstr "Veebiaeg" msgid "Name" msgstr "Nimi" + +msgid "I have read and agree with the @link" +msgstr "Olen tutvunud ja nõustun @link" + +msgid "data protection terms" +msgstr "isikuandmete kaitse põhimõtetega" diff --git a/modules/oe_theme_helper/translations/oe_theme_helper-fi.po b/modules/oe_theme_helper/translations/oe_theme_helper-fi.po index 3b228c8fd..1abfaa328 100644 --- a/modules/oe_theme_helper/translations/oe_theme_helper-fi.po +++ b/modules/oe_theme_helper/translations/oe_theme_helper-fi.po @@ -515,3 +515,9 @@ msgstr "Verkkotapahtuman ajankohta" msgid "Name" msgstr "Nimi" + +msgid "I have read and agree with the @link" +msgstr "Olen lukenut @link ja hyväksyn sen ehdot" + +msgid "data protection terms" +msgstr "tietosuojaselosteen" diff --git a/modules/oe_theme_helper/translations/oe_theme_helper-fr.po b/modules/oe_theme_helper/translations/oe_theme_helper-fr.po index f90f28228..ecf2111ae 100644 --- a/modules/oe_theme_helper/translations/oe_theme_helper-fr.po +++ b/modules/oe_theme_helper/translations/oe_theme_helper-fr.po @@ -515,3 +515,9 @@ msgstr "Horaire de l’événement en ligne" msgid "Name" msgstr "Nom" + +msgid "I have read and agree with the @link" +msgstr "J'ai lu et j'accepte les @link" + +msgid "data protection terms" +msgstr "conditions relatives à la protection des données" diff --git a/modules/oe_theme_helper/translations/oe_theme_helper-ga.po b/modules/oe_theme_helper/translations/oe_theme_helper-ga.po index 1792b44b2..607164c36 100644 --- a/modules/oe_theme_helper/translations/oe_theme_helper-ga.po +++ b/modules/oe_theme_helper/translations/oe_theme_helper-ga.po @@ -515,3 +515,9 @@ msgstr "Am an imeachta ar líne" msgid "Name" msgstr "Ainm" + +msgid "I have read and agree with the @link" +msgstr "Tá na @link léite agam agus glacaim leo" + +msgid "data protection terms" +msgstr "téarmaí cosanta sonraí" diff --git a/modules/oe_theme_helper/translations/oe_theme_helper-hr.po b/modules/oe_theme_helper/translations/oe_theme_helper-hr.po index c373e03c7..d1e7aefb2 100644 --- a/modules/oe_theme_helper/translations/oe_theme_helper-hr.po +++ b/modules/oe_theme_helper/translations/oe_theme_helper-hr.po @@ -515,3 +515,9 @@ msgstr "Internetsko vrijeme" msgid "Name" msgstr "Ime" + +msgid "I have read and agree with the @link" +msgstr "Pročitao sam i prihvaćam @link" + +msgid "data protection terms" +msgstr "uvjete zaštite podataka" diff --git a/modules/oe_theme_helper/translations/oe_theme_helper-hu.po b/modules/oe_theme_helper/translations/oe_theme_helper-hu.po index f48be16b1..603a38b9f 100644 --- a/modules/oe_theme_helper/translations/oe_theme_helper-hu.po +++ b/modules/oe_theme_helper/translations/oe_theme_helper-hu.po @@ -515,3 +515,9 @@ msgstr "Az esemény időpontja" msgid "Name" msgstr "Név" + +msgid "I have read and agree with the @link" +msgstr "Elolvastam az @link, és egyetértek vele" + +msgid "data protection terms" +msgstr "adatvédelmi nyilatkozatot" diff --git a/modules/oe_theme_helper/translations/oe_theme_helper-it.po b/modules/oe_theme_helper/translations/oe_theme_helper-it.po index 46c0138e2..50a2456a2 100644 --- a/modules/oe_theme_helper/translations/oe_theme_helper-it.po +++ b/modules/oe_theme_helper/translations/oe_theme_helper-it.po @@ -515,3 +515,9 @@ msgstr "Ora online" msgid "Name" msgstr "Nome" + +msgid "I have read and agree with the @link" +msgstr "Ho letto e accetto le @link" + +msgid "data protection terms" +msgstr "condizioni relative alla protezione dei dati" diff --git a/modules/oe_theme_helper/translations/oe_theme_helper-lt.po b/modules/oe_theme_helper/translations/oe_theme_helper-lt.po index eb45aadb4..a25b91c5f 100644 --- a/modules/oe_theme_helper/translations/oe_theme_helper-lt.po +++ b/modules/oe_theme_helper/translations/oe_theme_helper-lt.po @@ -515,3 +515,9 @@ msgstr "Renginio laikas" msgid "Name" msgstr "Vardas, pavardė (pavadinimas)" + +msgid "I have read and agree with the @link" +msgstr "@link perskaičiau ir su jomis sutinku" + +msgid "data protection terms" +msgstr "Duomenų apsaugos sąlygas" diff --git a/modules/oe_theme_helper/translations/oe_theme_helper-lv.po b/modules/oe_theme_helper/translations/oe_theme_helper-lv.po index af6471dd8..6f2627fc8 100644 --- a/modules/oe_theme_helper/translations/oe_theme_helper-lv.po +++ b/modules/oe_theme_helper/translations/oe_theme_helper-lv.po @@ -515,3 +515,9 @@ msgstr "Laiks" msgid "Name" msgstr "Nosaukums" + +msgid "I have read and agree with the @link" +msgstr "Esmu izlasījis @link un tiem piekrītu" + +msgid "data protection terms" +msgstr "datu aizsardzības noteikumus" diff --git a/modules/oe_theme_helper/translations/oe_theme_helper-mt.po b/modules/oe_theme_helper/translations/oe_theme_helper-mt.po index 615f521e3..48f71fc1f 100644 --- a/modules/oe_theme_helper/translations/oe_theme_helper-mt.po +++ b/modules/oe_theme_helper/translations/oe_theme_helper-mt.po @@ -515,3 +515,9 @@ msgstr "Ħin online" msgid "Name" msgstr "Isem" + +msgid "I have read and agree with the @link" +msgstr "Qrajt u naqbel @link" + +msgid "data protection terms" +msgstr "mat-termini tal-protezzjoni tad-data" diff --git a/modules/oe_theme_helper/translations/oe_theme_helper-nl.po b/modules/oe_theme_helper/translations/oe_theme_helper-nl.po index e1b15290f..45986785a 100644 --- a/modules/oe_theme_helper/translations/oe_theme_helper-nl.po +++ b/modules/oe_theme_helper/translations/oe_theme_helper-nl.po @@ -515,3 +515,9 @@ msgstr "Online-tijd" msgid "Name" msgstr "Naam" + +msgid "I have read and agree with the @link" +msgstr "Ik heb de @link gelezen en ga ermee akkoord" + +msgid "data protection terms" +msgstr "privacyverklaring" diff --git a/modules/oe_theme_helper/translations/oe_theme_helper-pl.po b/modules/oe_theme_helper/translations/oe_theme_helper-pl.po index 5dd788887..7879e6b75 100644 --- a/modules/oe_theme_helper/translations/oe_theme_helper-pl.po +++ b/modules/oe_theme_helper/translations/oe_theme_helper-pl.po @@ -515,3 +515,9 @@ msgstr "Data i godzina" msgid "Name" msgstr "Imię i nazwisko / Nazwa" + +msgid "I have read and agree with the @link" +msgstr "Przeczytałem(-am) i akceptuję @link" + +msgid "data protection terms" +msgstr "warunki ochrony danych" diff --git a/modules/oe_theme_helper/translations/oe_theme_helper-pt-pt.po b/modules/oe_theme_helper/translations/oe_theme_helper-pt-pt.po index c84598ff1..b6e226b0b 100644 --- a/modules/oe_theme_helper/translations/oe_theme_helper-pt-pt.po +++ b/modules/oe_theme_helper/translations/oe_theme_helper-pt-pt.po @@ -515,3 +515,9 @@ msgstr "Tempo em linha" msgid "Name" msgstr "Nome" + +msgid "I have read and agree with the @link" +msgstr "Li e concordo com as @link" + +msgid "data protection terms" +msgstr "condições aplicáveis em matéria de proteção de dados" diff --git a/modules/oe_theme_helper/translations/oe_theme_helper-ro.po b/modules/oe_theme_helper/translations/oe_theme_helper-ro.po index b9c30f1e2..8531bd9da 100644 --- a/modules/oe_theme_helper/translations/oe_theme_helper-ro.po +++ b/modules/oe_theme_helper/translations/oe_theme_helper-ro.po @@ -515,3 +515,9 @@ msgstr "Momentul la care are loc evenimentul online" msgid "Name" msgstr "Nume" + +msgid "I have read and agree with the @link" +msgstr "Am citit și sunt de acord cu @link" + +msgid "data protection terms" +msgstr "prevederile referitoare la protecția datelor" diff --git a/modules/oe_theme_helper/translations/oe_theme_helper-sk.po b/modules/oe_theme_helper/translations/oe_theme_helper-sk.po index 7f2563f98..236f38c19 100644 --- a/modules/oe_theme_helper/translations/oe_theme_helper-sk.po +++ b/modules/oe_theme_helper/translations/oe_theme_helper-sk.po @@ -515,3 +515,9 @@ msgstr "Čas" msgid "Name" msgstr "Meno/Názov" + +msgid "I have read and agree with the @link" +msgstr "Prečítal/a som si podmienky @link a súhlasím s nimi" + +msgid "data protection terms" +msgstr "ochrany údajov" diff --git a/modules/oe_theme_helper/translations/oe_theme_helper-sl.po b/modules/oe_theme_helper/translations/oe_theme_helper-sl.po index 2fd124259..ebac2f4c1 100644 --- a/modules/oe_theme_helper/translations/oe_theme_helper-sl.po +++ b/modules/oe_theme_helper/translations/oe_theme_helper-sl.po @@ -515,3 +515,9 @@ msgstr "Spletni čas" msgid "Name" msgstr "Ime" + +msgid "I have read and agree with the @link" +msgstr "Prebral/-a sem pogoje o @link in se strinjam z njimi" + +msgid "data protection terms" +msgstr "varstvu podatkov" diff --git a/modules/oe_theme_helper/translations/oe_theme_helper-sv.po b/modules/oe_theme_helper/translations/oe_theme_helper-sv.po index 7832a9868..fb2acd625 100644 --- a/modules/oe_theme_helper/translations/oe_theme_helper-sv.po +++ b/modules/oe_theme_helper/translations/oe_theme_helper-sv.po @@ -515,3 +515,9 @@ msgstr "Tid för evenemanget" msgid "Name" msgstr "Namn" + +msgid "I have read and agree with the @link" +msgstr "Jag har läst och godkänner villkoren för @link" + +msgid "data protection terms" +msgstr "skydd av personuppgifter" From 954d0c76e12e88e38eca34ace040ff0637ddce6b Mon Sep 17 00:00:00 2001 From: Evgenii Nikitin Date: Wed, 15 Sep 2021 17:58:15 +0300 Subject: [PATCH 30/41] EWPP-1312: Remove comma after link in HU translation. --- composer.json | 2 +- modules/oe_theme_helper/translations/oe_theme_helper-hu.po | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index 08073c108..8a1a61925 100644 --- a/composer.json +++ b/composer.json @@ -55,7 +55,7 @@ "openeuropa/oe_paragraphs": "dev-master", "openeuropa/oe_search": "~1.0", "openeuropa/oe_webtools": "~1.10", - "openeuropa/oe_contact_forms": "dev-EWPP-1312", + "openeuropa/oe_contact_forms": "dev-master", "openeuropa/rdf_skos": "~1.0", "openeuropa/task-runner-drupal-project-symlink": "^1.0", "phpunit/phpunit": "~6.0", diff --git a/modules/oe_theme_helper/translations/oe_theme_helper-hu.po b/modules/oe_theme_helper/translations/oe_theme_helper-hu.po index 603a38b9f..8f4724e0a 100644 --- a/modules/oe_theme_helper/translations/oe_theme_helper-hu.po +++ b/modules/oe_theme_helper/translations/oe_theme_helper-hu.po @@ -517,7 +517,7 @@ msgid "Name" msgstr "Név" msgid "I have read and agree with the @link" -msgstr "Elolvastam az @link, és egyetértek vele" +msgstr "Elolvastam az @link és egyetértek vele" msgid "data protection terms" -msgstr "adatvédelmi nyilatkozatot" +msgstr "adatvédelmi nyilatkozatot," From 645600db7beb2a7ab96d9c0c418ceb8a26f3e457 Mon Sep 17 00:00:00 2001 From: nagyad Date: Thu, 1 Jul 2021 11:43:49 +0200 Subject: [PATCH 31/41] EWPP-847: Add optional oe_theme_main_content view display for JS asset media. --- ...javascript_asset.oe_theme_main_content.yml | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 config/optional/core.entity_view_display.media.javascript_asset.oe_theme_main_content.yml diff --git a/config/optional/core.entity_view_display.media.javascript_asset.oe_theme_main_content.yml b/config/optional/core.entity_view_display.media.javascript_asset.oe_theme_main_content.yml new file mode 100644 index 000000000..6e3cdb370 --- /dev/null +++ b/config/optional/core.entity_view_display.media.javascript_asset.oe_theme_main_content.yml @@ -0,0 +1,33 @@ +langcode: en +status: true +dependencies: + config: + - core.entity_view_mode.media.oe_theme_main_content + - field.field.media.javascript_asset.oe_media_js_asset_url + - media.type.javascript_asset + module: + - oe_media_embed + - oe_media_js_asset +third_party_settings: + oe_media_embed: + embeddable: true +id: media.javascript_asset.oe_theme_main_content +targetEntityType: media +bundle: javascript_asset +mode: oe_theme_main_content +content: + oe_media_js_asset_url: + type: oe_media_js_asset_url + weight: 0 + region: content + label: hidden + settings: { } + third_party_settings: { } +hidden: + created: true + ewcms_available_translations: true + langcode: true + name: true + search_api_excerpt: true + thumbnail: true + uid: true From e2b8e801f3c030412ee77fdf4bc224d0dca08aba Mon Sep 17 00:00:00 2001 From: 22Alexandra Date: Mon, 28 Jun 2021 11:36:31 +0300 Subject: [PATCH 32/41] EWPP-1162: Update event rendering test. --- tests/Functional/ContentEventRenderTest.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tests/Functional/ContentEventRenderTest.php b/tests/Functional/ContentEventRenderTest.php index 1cd0352de..2c5b2ddf2 100644 --- a/tests/Functional/ContentEventRenderTest.php +++ b/tests/Functional/ContentEventRenderTest.php @@ -426,10 +426,8 @@ public function testEventRendering(): void { $this->assertSession()->pageTextNotContains('Event report summary'); $this->assertSession()->pageTextNotContains('Event report text'); - // Assert "Description summary", "Full text", "Featured media", - // "Featured media legend" fields (these fields have to be filled all - // together). - $node->set('oe_event_description_summary', 'Event description summary'); + // Assert "Full text", "Featured media", "Featured media legend" fields + // (these fields have to be filled all together). $node->set('body', 'Event full text'); $node->set('oe_event_featured_media_legend', 'Event featured media legend'); $media_image = $this->createMediaImage('event_featured_media'); @@ -449,6 +447,11 @@ public function testEventRendering(): void { ]; $text_featured->assertPattern($text_featured_expected_values, $description_content->getHtml()); + // Assert "Description summary" field value. + $node->set('oe_event_description_summary', 'Event description summary')->save(); + $this->drupalGet($node->toUrl()); + $this->assertSession()->pageTextContains('Event description summary'); + // Assert "Registration date" field when registration will start in future. $registration_start_date = (clone $static_time)->modify('+ 1 day'); $registration_end_date = (clone $static_time)->modify('+ 4 days'); From 66eaeb26cfcb53f3bad814da383e1056b27c15c6 Mon Sep 17 00:00:00 2001 From: Sergii Pavlenko Date: Mon, 13 Sep 2021 12:07:54 +0300 Subject: [PATCH 33/41] EWPP-1467: Fix font name issue. --- sass/components/_global.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sass/components/_global.scss b/sass/components/_global.scss index 5dbedc800..0e12c1da3 100644 --- a/sass/components/_global.scss +++ b/sass/components/_global.scss @@ -3,7 +3,7 @@ // Apply global css. body { - font-family: map.get(theme.$font-family, 'default'); + font-family: #{map.get(theme.$font-family, 'default')}; margin: 0; padding: 0; } From 80136aa42612565bdedff6f685ab599e8ff010f4 Mon Sep 17 00:00:00 2001 From: Evgenii Nikitin Date: Wed, 8 Sep 2021 18:42:02 +0300 Subject: [PATCH 34/41] EWPP-1472: Fix output of image (avportal) inside news content type. --- ...ew_display.media.av_portal_photo.oe_theme_main_content.yml | 2 +- ...ew_display.media.av_portal_video.oe_theme_main_content.yml | 2 +- ...tity_view_display.media.document.oe_theme_main_content.yml | 2 +- ....entity_view_display.media.image.oe_theme_main_content.yml | 1 + ..._view_display.media.remote_video.oe_theme_main_content.yml | 2 +- .../Plugin/Field/FieldFormatter/MediaGalleryFormatterTest.php | 4 ++-- tests/Functional/ContentNewsRenderTest.php | 2 +- tests/Kernel/Paragraphs/MediaParagraphsTest.php | 2 +- 8 files changed, 9 insertions(+), 8 deletions(-) diff --git a/config/optional/core.entity_view_display.media.av_portal_photo.oe_theme_main_content.yml b/config/optional/core.entity_view_display.media.av_portal_photo.oe_theme_main_content.yml index 833b8f78b..9f26a4023 100644 --- a/config/optional/core.entity_view_display.media.av_portal_photo.oe_theme_main_content.yml +++ b/config/optional/core.entity_view_display.media.av_portal_photo.oe_theme_main_content.yml @@ -7,7 +7,7 @@ dependencies: - media.type.av_portal_photo - responsive_image.styles.oe_theme_main_content module: - - media_avportal + - oe_media_avportal id: media.av_portal_photo.oe_theme_main_content targetEntityType: media bundle: av_portal_photo diff --git a/config/optional/core.entity_view_display.media.av_portal_video.oe_theme_main_content.yml b/config/optional/core.entity_view_display.media.av_portal_video.oe_theme_main_content.yml index 146a1a3e0..448234ec8 100644 --- a/config/optional/core.entity_view_display.media.av_portal_video.oe_theme_main_content.yml +++ b/config/optional/core.entity_view_display.media.av_portal_video.oe_theme_main_content.yml @@ -6,7 +6,7 @@ dependencies: - field.field.media.av_portal_video.oe_media_avportal_video - media.type.av_portal_video module: - - media_avportal + - oe_media_avportal id: media.av_portal_video.oe_theme_main_content targetEntityType: media bundle: av_portal_video diff --git a/config/optional/core.entity_view_display.media.document.oe_theme_main_content.yml b/config/optional/core.entity_view_display.media.document.oe_theme_main_content.yml index 8269fb10a..b4548336f 100644 --- a/config/optional/core.entity_view_display.media.document.oe_theme_main_content.yml +++ b/config/optional/core.entity_view_display.media.document.oe_theme_main_content.yml @@ -6,7 +6,7 @@ dependencies: - field.field.media.document.oe_media_file - media.type.document module: - - file + - oe_media id: media.document.oe_theme_main_content targetEntityType: media bundle: document diff --git a/config/optional/core.entity_view_display.media.image.oe_theme_main_content.yml b/config/optional/core.entity_view_display.media.image.oe_theme_main_content.yml index 812d265e4..695f274b7 100644 --- a/config/optional/core.entity_view_display.media.image.oe_theme_main_content.yml +++ b/config/optional/core.entity_view_display.media.image.oe_theme_main_content.yml @@ -7,6 +7,7 @@ dependencies: - media.type.image - responsive_image.styles.oe_theme_main_content module: + - oe_media - responsive_image id: media.image.oe_theme_main_content targetEntityType: media diff --git a/config/optional/core.entity_view_display.media.remote_video.oe_theme_main_content.yml b/config/optional/core.entity_view_display.media.remote_video.oe_theme_main_content.yml index 259b78f58..1f6b32795 100644 --- a/config/optional/core.entity_view_display.media.remote_video.oe_theme_main_content.yml +++ b/config/optional/core.entity_view_display.media.remote_video.oe_theme_main_content.yml @@ -6,7 +6,7 @@ dependencies: - field.field.media.remote_video.oe_media_oembed_video - media.type.remote_video module: - - media + - oe_media id: media.remote_video.oe_theme_main_content targetEntityType: media bundle: remote_video diff --git a/modules/oe_theme_helper/tests/src/Kernel/Plugin/Field/FieldFormatter/MediaGalleryFormatterTest.php b/modules/oe_theme_helper/tests/src/Kernel/Plugin/Field/FieldFormatter/MediaGalleryFormatterTest.php index e2d643291..a00e2b7c1 100644 --- a/modules/oe_theme_helper/tests/src/Kernel/Plugin/Field/FieldFormatter/MediaGalleryFormatterTest.php +++ b/modules/oe_theme_helper/tests/src/Kernel/Plugin/Field/FieldFormatter/MediaGalleryFormatterTest.php @@ -215,7 +215,7 @@ public function testFormatter(): void { // Test the second gallery item. $this->assertStringStartsWith( - '/media/oembed?url=https%3A//www.youtube.com/watch%3Fv%3D1-g73ty9v04&max_width=0&max_height=0&hash=', + '/media/oembed?url=https%3A//www.youtube.com/watch%3Fv%3D1-g73ty9v04&max_width=576&max_height=400&hash=', $items->eq(1)->filter('.ecl-gallery__item-link')->attr('data-ecl-gallery-item-embed-src') ); $image_node = $items->eq(1)->filter('img'); @@ -311,7 +311,7 @@ public function testFormatter(): void { // Test the second gallery item. $this->assertStringStartsWith( - '/media/oembed?url=https%3A//www.youtube.com/watch%3Fv%3D1-g73ty9v04&max_width=0&max_height=0&hash=', + '/media/oembed?url=https%3A//www.youtube.com/watch%3Fv%3D1-g73ty9v04&max_width=576&max_height=400&hash=', $items->eq(1)->filter('.ecl-gallery__item-link')->attr('data-ecl-gallery-item-embed-src') ); $image_node = $items->eq(1)->filter('img'); diff --git a/tests/Functional/ContentNewsRenderTest.php b/tests/Functional/ContentNewsRenderTest.php index 6b92cdfdc..72a02303a 100644 --- a/tests/Functional/ContentNewsRenderTest.php +++ b/tests/Functional/ContentNewsRenderTest.php @@ -167,7 +167,7 @@ public function testNewsRendering(): void { $picture = $this->assertSession()->elementExists('css', 'article[role=article] article.ecl-u-type-paragraph.ecl-u-mb-l picture'); $image = $this->assertSession()->elementExists('css', 'img.ecl-u-width-100.ecl-u-height-auto', $picture); - $this->assertContains('placeholder_news_featured_media.png', $image->getAttribute('src')); + $this->assertContains('files/styles/oe_theme_medium_no_crop/public/placeholder_news_featured_media.png', $image->getAttribute('src')); $this->assertEquals('Alternative text news_featured_media', $image->getAttribute('alt')); // Unpublish the media and assert it is not rendered anymore. diff --git a/tests/Kernel/Paragraphs/MediaParagraphsTest.php b/tests/Kernel/Paragraphs/MediaParagraphsTest.php index be7d9bddc..0bfaa63de 100644 --- a/tests/Kernel/Paragraphs/MediaParagraphsTest.php +++ b/tests/Kernel/Paragraphs/MediaParagraphsTest.php @@ -267,7 +267,7 @@ public function testTextWithMedia(): void { 'title' => NULL, 'caption' => 'Caption', 'text' => NULL, - 'video' => '', + 'video' => '', 'video_ratio' => '16:9', ]; $assert->assertPattern($expected_values, $html); From 54f32df517d68fb650dc7c5d5aed7c534924bb79 Mon Sep 17 00:00:00 2001 From: Evgenii Nikitin Date: Thu, 23 Sep 2021 12:24:29 +0300 Subject: [PATCH 35/41] Prepare changelog for version 3.0.0-beta3. --- CHANGELOG.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0424886e7..da87bac9e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,25 @@ # Change Log +## [3.0.0-beta3](https://github.com/openeuropa/oe_theme/tree/3.0.0-beta3) (2021-09-23) +[Full Changelog](https://github.com/openeuropa/oe_theme/compare/3.0.0-beta2...3.0.0-beta3) + +**Merged pull requests:** + +- EWPP-1495: Make sure that event registration button is displayed as an inline block. [\#950](https://github.com/openeuropa/oe_theme/pull/950) ([ademarco](https://github.com/ademarco)) +- EWPP-1514: Wrong Irish translation in language switcher. [\#947](https://github.com/openeuropa/oe_theme/pull/947) ([yenyasinn](https://github.com/yenyasinn)) +- EWPP-1467: Fix font name issue. [\#946](https://github.com/openeuropa/oe_theme/pull/946) ([sergepavle](https://github.com/sergepavle)) +- EWPP-1458: Events render correctly when a non-existing event type is specified. [\#943](https://github.com/openeuropa/oe_theme/pull/943) ([brummbar](https://github.com/brummbar)) +- EWPP-1472: Fix output of image \(avportal\) inside news content type. [\#942](https://github.com/openeuropa/oe_theme/pull/942) ([yenyasinn](https://github.com/yenyasinn)) +- EWPP-0000: Version 2.0 of typed\_link is required by oe\_paragraphs. [\#941](https://github.com/openeuropa/oe_theme/pull/941) ([brummbar](https://github.com/brummbar)) +- EWPP-873: Text with featured media paragraph type V2 [\#939](https://github.com/openeuropa/oe_theme/pull/939) ([yenyasinn](https://github.com/yenyasinn)) +- EWPP-1470: Content item title styling is not consistent. [\#934](https://github.com/openeuropa/oe_theme/pull/934) ([yenyasinn](https://github.com/yenyasinn)) +- EWPP-1312: Translate "I have read and agree with the data protection terms" string [\#932](https://github.com/openeuropa/oe_theme/pull/932) ([yenyasinn](https://github.com/yenyasinn)) +- EWPP-847: Add optional oe\_theme\_main\_content view display for JS asset media [\#896](https://github.com/openeuropa/oe_theme/pull/896) ([brummbar](https://github.com/brummbar)) +- EWPP-1206: Update grid classes for list item block pattern. [\#882](https://github.com/openeuropa/oe_theme/pull/882) ([sergepavle](https://github.com/sergepavle)) +- EWPP-1046: Change label from "Open gallery" to "See all" in the gallery [\#881](https://github.com/openeuropa/oe_theme/pull/881) ([yenyasinn](https://github.com/yenyasinn)) +- EWPP-1162: Update event rendering test. [\#866](https://github.com/openeuropa/oe_theme/pull/866) ([22Alexandra](https://github.com/22Alexandra)) +- EWPP-866: Use extend in list-item templates. [\#817](https://github.com/openeuropa/oe_theme/pull/817) ([nagyad](https://github.com/nagyad)) + ## [3.0.0-beta2](https://github.com/openeuropa/oe_theme/tree/3.0.0-beta2) (2021-08-25) [Full Changelog](https://github.com/openeuropa/oe_theme/compare/3.0.0-beta1...3.0.0-beta2) From 8c8bcba449386589d50c052f28c29c80d89309a6 Mon Sep 17 00:00:00 2001 From: nagyad Date: Wed, 8 Sep 2021 16:51:58 +0200 Subject: [PATCH 36/41] EWPP-1486: Theme publication collection related fields. --- composer.json | 5 +- ..._view_display.node.oe_publication.full.yml | 27 ++- ..._view_display.node.oe_publication.full.yml | 193 ++++++++++++++++++ .../oe_theme_content_publication.module | 11 + ..._theme_content_publication.post_update.php | 20 ++ .../Display/PublicationCollection.php | 154 ++++++++++++++ ...-content-publication-collections.html.twig | 9 + .../ContentPublicationRenderTest.php | 82 ++++++++ 8 files changed, 496 insertions(+), 5 deletions(-) create mode 100644 modules/oe_theme_content_publication/config/post_updates/30001_publication_collection/core.entity_view_display.node.oe_publication.full.yml create mode 100644 modules/oe_theme_content_publication/src/Plugin/ExtraField/Display/PublicationCollection.php create mode 100644 modules/oe_theme_content_publication/templates/oe-theme-content-publication-collections.html.twig diff --git a/composer.json b/composer.json index 8a1a61925..ad485d535 100644 --- a/composer.json +++ b/composer.json @@ -47,7 +47,7 @@ "openeuropa/behat-transformation-context": "~0.1", "openeuropa/code-review": "~1.5", "openeuropa/drupal-core-require-dev": "^8.9.14", - "openeuropa/oe_content": "2.x-dev", + "openeuropa/oe_content": "~2.4.0", "openeuropa/oe_corporate_blocks": "~4.0", "openeuropa/oe_corporate_countries": "~2.0", "openeuropa/oe_media": "~1.12", @@ -109,6 +109,9 @@ }, "drupal/entity_reference_revisions": { "https://www.drupal.org/project/entity_reference_revisions/issues/2937835": "https://www.drupal.org/files/issues/2021-03-26/entity_reference_revisions-field_formatter_label-2937835-36.patch" + }, + "openeuropa/oe_content": { + "latest": "https://github.com/openeuropa/oe_content/compare/2.4.0..EWPP-1485.diff" } }, "drupal-scaffold": { diff --git a/modules/oe_theme_content_publication/config/install/core.entity_view_display.node.oe_publication.full.yml b/modules/oe_theme_content_publication/config/install/core.entity_view_display.node.oe_publication.full.yml index 425918baa..67b51de25 100644 --- a/modules/oe_theme_content_publication/config/install/core.entity_view_display.node.oe_publication.full.yml +++ b/modules/oe_theme_content_publication/config/install/core.entity_view_display.node.oe_publication.full.yml @@ -7,10 +7,12 @@ dependencies: - field.field.node.oe_publication.oe_author - field.field.node.oe_publication.oe_departments - field.field.node.oe_publication.oe_documents + - field.field.node.oe_publication.oe_publication_collection - field.field.node.oe_publication.oe_publication_contacts - field.field.node.oe_publication.oe_publication_countries - field.field.node.oe_publication.oe_publication_date - field.field.node.oe_publication.oe_publication_last_updated + - field.field.node.oe_publication.oe_publication_publications - field.field.node.oe_publication.oe_publication_thumbnail - field.field.node.oe_publication.oe_publication_type - field.field.node.oe_publication.oe_reference_codes @@ -32,7 +34,7 @@ third_party_settings: - group_item_files - group_item_contacts parent_name: '' - weight: 0 + weight: 1 format_type: oe_theme_helper_in_page_navigation region: content format_settings: @@ -64,6 +66,7 @@ third_party_settings: group_item_files: children: - oe_documents + - oe_publication_publications parent_name: group_in_page_navigation weight: 24 format_type: oe_theme_helper_in_page_navigation_item @@ -86,6 +89,7 @@ third_party_settings: group_details: children: - oe_reference_codes + - extra_field_oe_theme_content_publication_collection - extra_field_oe_theme_content_publication_date - oe_departments - oe_publication_countries @@ -103,11 +107,16 @@ targetEntityType: node bundle: oe_publication mode: full content: - extra_field_oe_theme_content_publication_date: + extra_field_oe_theme_content_publication_collection: weight: 1 region: content settings: { } third_party_settings: { } + extra_field_oe_theme_content_publication_date: + weight: 2 + region: content + settings: { } + third_party_settings: { } extra_field_oe_theme_content_publication_description: weight: 0 region: content @@ -115,7 +124,7 @@ content: third_party_settings: { } oe_departments: type: skos_concept_entity_reference_label - weight: 2 + weight: 3 region: content label: above settings: @@ -141,12 +150,21 @@ content: third_party_settings: { } oe_publication_countries: type: skos_concept_entity_reference_label - weight: 3 + weight: 4 region: content label: above settings: link: false third_party_settings: { } + oe_publication_publications: + type: entity_reference_entity_view + weight: 2 + region: content + label: hidden + settings: + view_mode: teaser + link: false + third_party_settings: { } oe_reference_codes: type: string weight: 0 @@ -165,6 +183,7 @@ hidden: oe_content_legacy_link: true oe_content_navigation_title: true oe_content_short_title: true + oe_publication_collection: true oe_publication_date: true oe_publication_last_updated: true oe_publication_thumbnail: true diff --git a/modules/oe_theme_content_publication/config/post_updates/30001_publication_collection/core.entity_view_display.node.oe_publication.full.yml b/modules/oe_theme_content_publication/config/post_updates/30001_publication_collection/core.entity_view_display.node.oe_publication.full.yml new file mode 100644 index 000000000..67b51de25 --- /dev/null +++ b/modules/oe_theme_content_publication/config/post_updates/30001_publication_collection/core.entity_view_display.node.oe_publication.full.yml @@ -0,0 +1,193 @@ +langcode: en +status: true +dependencies: + config: + - core.entity_view_mode.node.full + - field.field.node.oe_publication.body + - field.field.node.oe_publication.oe_author + - field.field.node.oe_publication.oe_departments + - field.field.node.oe_publication.oe_documents + - field.field.node.oe_publication.oe_publication_collection + - field.field.node.oe_publication.oe_publication_contacts + - field.field.node.oe_publication.oe_publication_countries + - field.field.node.oe_publication.oe_publication_date + - field.field.node.oe_publication.oe_publication_last_updated + - field.field.node.oe_publication.oe_publication_publications + - field.field.node.oe_publication.oe_publication_thumbnail + - field.field.node.oe_publication.oe_publication_type + - field.field.node.oe_publication.oe_reference_codes + - field.field.node.oe_publication.oe_subject + - field.field.node.oe_publication.oe_summary + - field.field.node.oe_publication.oe_teaser + - node.type.oe_publication + module: + - entity_reference_revisions + - field_group + - rdf_skos + - user +third_party_settings: + field_group: + group_in_page_navigation: + children: + - group_item_details + - group_item_description + - group_item_files + - group_item_contacts + parent_name: '' + weight: 1 + format_type: oe_theme_helper_in_page_navigation + region: content + format_settings: + id: '' + classes: '' + label: 'Page contents' + group_item_details: + children: + - group_details + parent_name: group_in_page_navigation + weight: 22 + format_type: oe_theme_helper_in_page_navigation_item + region: content + format_settings: + id: '' + classes: '' + label: Details + group_item_description: + children: + - extra_field_oe_theme_content_publication_description + parent_name: group_in_page_navigation + weight: 23 + format_type: oe_theme_helper_in_page_navigation_item + region: content + format_settings: + id: '' + classes: '' + label: Description + group_item_files: + children: + - oe_documents + - oe_publication_publications + parent_name: group_in_page_navigation + weight: 24 + format_type: oe_theme_helper_in_page_navigation_item + region: content + format_settings: + id: '' + classes: '' + label: Files + group_item_contacts: + children: + - oe_publication_contacts + parent_name: group_in_page_navigation + weight: 25 + format_type: oe_theme_helper_in_page_navigation_item + region: content + format_settings: + id: '' + classes: '' + label: Contact + group_details: + children: + - oe_reference_codes + - extra_field_oe_theme_content_publication_collection + - extra_field_oe_theme_content_publication_date + - oe_departments + - oe_publication_countries + parent_name: group_item_details + weight: 20 + format_type: oe_theme_helper_field_list_pattern + region: content + format_settings: + variant: horizontal + classes: '' + id: '' + label: '' +id: node.oe_publication.full +targetEntityType: node +bundle: oe_publication +mode: full +content: + extra_field_oe_theme_content_publication_collection: + weight: 1 + region: content + settings: { } + third_party_settings: { } + extra_field_oe_theme_content_publication_date: + weight: 2 + region: content + settings: { } + third_party_settings: { } + extra_field_oe_theme_content_publication_description: + weight: 0 + region: content + settings: { } + third_party_settings: { } + oe_departments: + type: skos_concept_entity_reference_label + weight: 3 + region: content + label: above + settings: + link: false + third_party_settings: { } + oe_documents: + type: entity_reference_entity_view + weight: 1 + label: hidden + settings: + view_mode: default + link: false + third_party_settings: { } + region: content + oe_publication_contacts: + type: entity_reference_revisions_entity_view + weight: 0 + region: content + label: hidden + settings: + view_mode: full + link: '' + third_party_settings: { } + oe_publication_countries: + type: skos_concept_entity_reference_label + weight: 4 + region: content + label: above + settings: + link: false + third_party_settings: { } + oe_publication_publications: + type: entity_reference_entity_view + weight: 2 + region: content + label: hidden + settings: + view_mode: teaser + link: false + third_party_settings: { } + oe_reference_codes: + type: string + weight: 0 + region: content + label: above + settings: + link_to_entity: false + third_party_settings: { } +hidden: + body: true + extra_field_oe_theme_helper_short_title_with_fallback: true + langcode: true + links: true + oe_author: true + oe_content_content_owner: true + oe_content_legacy_link: true + oe_content_navigation_title: true + oe_content_short_title: true + oe_publication_collection: true + oe_publication_date: true + oe_publication_last_updated: true + oe_publication_thumbnail: true + oe_publication_type: true + oe_subject: true + oe_summary: true + oe_teaser: true diff --git a/modules/oe_theme_content_publication/oe_theme_content_publication.module b/modules/oe_theme_content_publication/oe_theme_content_publication.module index 2076e4570..61b725c92 100644 --- a/modules/oe_theme_content_publication/oe_theme_content_publication.module +++ b/modules/oe_theme_content_publication/oe_theme_content_publication.module @@ -21,6 +21,11 @@ function oe_theme_content_publication_theme() { 'image' => '', ], ], + 'oe_theme_content_publication_collections' => [ + 'variables' => [ + 'items' => [], + ], + ], ]; } @@ -52,5 +57,11 @@ function oe_theme_content_publication_node_view_alter(array &$build, EntityInter $build[$name]['#title'] = $label_override; } } + + // Change the 'Files' field group label to 'Documents' when a publication + // collection is rendered. + if ($entity->get('oe_publication_publications')->count() > 0) { + $build['#fieldgroups']['group_item_files']->label = t('Documents'); + } } } diff --git a/modules/oe_theme_content_publication/oe_theme_content_publication.post_update.php b/modules/oe_theme_content_publication/oe_theme_content_publication.post_update.php index eb0af61ce..04be13d05 100644 --- a/modules/oe_theme_content_publication/oe_theme_content_publication.post_update.php +++ b/modules/oe_theme_content_publication/oe_theme_content_publication.post_update.php @@ -206,3 +206,23 @@ function oe_theme_content_publication_post_update_00010(): void { $display = $storage->createFromStorageRecord($display_values); $display->save(); } + +/** + * Updates the full view display. + */ +function oe_theme_content_publication_post_update_30001(): void { + $storage = new FileStorage(drupal_get_path('module', 'oe_theme_content_publication') . '/config/post_updates/30001_publication_collection'); + + $display_values = $storage->read('core.entity_view_display.node.oe_publication.full'); + $storage = \Drupal::entityTypeManager()->getStorage('entity_view_display'); + + $view_display = EntityViewDisplay::load($display_values['id']); + if ($view_display) { + $display = $storage->updateFromStorageRecord($view_display, $display_values); + $display->save(); + return; + } + + $display = $storage->createFromStorageRecord($display_values); + $display->save(); +} diff --git a/modules/oe_theme_content_publication/src/Plugin/ExtraField/Display/PublicationCollection.php b/modules/oe_theme_content_publication/src/Plugin/ExtraField/Display/PublicationCollection.php new file mode 100644 index 000000000..6a39e6c6d --- /dev/null +++ b/modules/oe_theme_content_publication/src/Plugin/ExtraField/Display/PublicationCollection.php @@ -0,0 +1,154 @@ +entityTypeManager = $entity_type_manager; + } + + /** + * {@inheritdoc} + */ + public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { + return new static( + $configuration, + $plugin_id, + $plugin_definition, + $container->get('entity_type.manager') + ); + } + + /** + * {@inheritdoc} + */ + public function getLabel() { + return $this->label; + } + + /** + * {@inheritdoc} + */ + public function viewElements(ContentEntityInterface $entity) { + $build = []; + /** @var \Drupal\node\Entity\Node[] $collections */ + $collections = $this->getReferencingCollections($entity); + + if (empty($collections)) { + return $build; + } + + $build = [ + '#theme' => 'oe_theme_content_publication_collections', + ]; + + // Set the label of the field. + if (count($collections) > 1) { + $this->label = $this->t('Part of collections'); + } + else { + $this->label = $this->t('Part of collection'); + } + + $cache = CacheableMetadata::createFromRenderArray($build); + + $items = []; + foreach ($collections as $collection) { + $cache->addCacheableDependency($collection); + $items[] = [ + '#type' => 'link', + '#title' => $collection->label(), + '#url' => Url::fromRoute('entity.node.canonical', ['node' => $collection->id()]), + '#attributes' => [ + 'class' => ['ecl-link', 'ecl-link--standalone'], + ], + ]; + } + + $build['#items'] = $items; + + $cache->applyTo($build); + + return $build; + } + + /** + * Get the publication collections that are referencing other publications. + * + * @param \Drupal\Core\Entity\EntityInterface $entity + * The publication entity. + * + * @return array + * The loaded publication entities. + */ + protected function getReferencingCollections(EntityInterface $entity): array { + $referencing_entities = []; + + // Load all entities that have a reference to the given entity. + $entity_type_storage = $this->entityTypeManager->getStorage('node'); + $query = $entity_type_storage->getQuery('OR'); + $query->condition('oe_publication_publications.target_id', $entity->id()); + + $ids = $query->execute(); + if ($ids) { + $referencing_entities = array_merge($referencing_entities, $entity_type_storage->loadMultiple($ids)); + } + + return $referencing_entities; + } + +} diff --git a/modules/oe_theme_content_publication/templates/oe-theme-content-publication-collections.html.twig b/modules/oe_theme_content_publication/templates/oe-theme-content-publication-collections.html.twig new file mode 100644 index 000000000..9e8ee2ec4 --- /dev/null +++ b/modules/oe_theme_content_publication/templates/oe-theme-content-publication-collections.html.twig @@ -0,0 +1,9 @@ +{# +/** + * @file + * Theme template for Publication collection extra field. + * + * @see \Drupal\oe_theme_content_publication\Plugin\ExtraField\Display\PublicationCollection::viewElements() + */ +#} +{% for item in items %}{{ item }}{% if not loop.last %} | {% endif %}{% endfor %} diff --git a/tests/Functional/ContentPublicationRenderTest.php b/tests/Functional/ContentPublicationRenderTest.php index fa1fd2866..318269ce8 100644 --- a/tests/Functional/ContentPublicationRenderTest.php +++ b/tests/Functional/ContentPublicationRenderTest.php @@ -5,6 +5,7 @@ namespace Drupal\Tests\oe_theme\Functional; use Drupal\field\Entity\FieldConfig; +use Drupal\Tests\oe_theme\PatternAssertions\ListItemAssert; use Drupal\user\Entity\Role; use Drupal\user\RoleInterface; use Drupal\Tests\oe_theme\PatternAssertions\FieldListAssert; @@ -64,7 +65,9 @@ public function testPublicationRendering(): void { $node = $this->getStorage('node')->create([ 'type' => 'oe_publication', 'title' => 'Test Publication node', + 'oe_teaser' => 'Test teaser text.', 'oe_publication_type' => 'http://publications.europa.eu/resource/authority/resource-type/ABSTRACT_JUR', + 'oe_publication_collection' => 0, 'oe_documents' => [$media_document], 'oe_publication_date' => [ 'value' => '2020-04-15', @@ -364,6 +367,85 @@ public function testPublicationRendering(): void { $content = $this->assertSession()->elementExists('css', '.ecl-row.ecl-u-mt-l .ecl-col-l-9'); $content_items = $content->findAll('xpath', '/div'); $this->assertCount(3, $content_items); + + // Create publication collections that will reference the original + // publication. + $collection = $this->getStorage('node')->create([ + 'type' => 'oe_publication', + 'title' => 'Test Publication collection node 1', + 'oe_publication_type' => 'http://publications.europa.eu/resource/authority/resource-type/ABSTRACT_JUR', + 'oe_publication_collection' => 1, + 'oe_publication_publications' => [ + 'target_id' => $node->id(), + ], + 'oe_publication_date' => [ + 'value' => '2020-04-15', + ], + 'oe_subject' => 'http://data.europa.eu/uxp/1000', + 'oe_author' => 'http://publications.europa.eu/resource/authority/corporate-body/AASM', + 'oe_content_content_owner' => 'http://publications.europa.eu/resource/authority/corporate-body/COMMU', + 'uid' => 0, + 'status' => 1, + ]); + $collection->save(); + $this->drupalGet($collection->toUrl()); + + // Assert the referenced publication is rendered as teaser. + $inpage_nav_expected_values['list'] = [ + ['label' => 'Details', 'href' => '#details'], + ['label' => 'Documents', 'href' => '#documents'], + ]; + $inpage_nav_assert->assertPattern($inpage_nav_expected_values, $navigation->getOuterHtml()); + + $assert = new ListItemAssert(); + $content = $this->assertSession()->elementExists('css', '.ecl-row.ecl-u-mt-l .ecl-col-l-9'); + $expected_values = [ + 'title' => 'Test Publication node', + 'meta' => "Abstract, Legislative acts | 15 April 2020\n | Associated African States and Madagascar", + 'description' => 'Test teaser text.', + ]; + $assert->assertPattern($expected_values, $content->getOuterHtml()); + + // Assert the referenced publication page 'Part of collection' extra field. + $this->drupalGet($node->toUrl()); + $details_expected_values['items'][0] = [ + 'label' => 'Part of collection', + 'body' => 'Test Publication collection node 1', + ]; + $first_element = [ + 'label' => 'Identification', + 'body' => 'ID 1, ID 2', + ]; + array_unshift($details_expected_values['items'], $first_element); + $field_list_assert->assertPattern($details_expected_values, $content_items[0]->getHtml()); + + // Create a second collection and assert the 'Part of collection' extra + // field on the child publication page. + $collection2 = $this->getStorage('node')->create([ + 'type' => 'oe_publication', + 'title' => 'Test Publication collection node 2', + 'oe_publication_type' => 'http://publications.europa.eu/resource/authority/resource-type/ABSTRACT_JUR', + 'oe_publication_collection' => 1, + 'oe_publication_publications' => [ + 'target_id' => $node->id(), + ], + 'oe_publication_date' => [ + 'value' => '2020-04-15', + ], + 'oe_subject' => 'http://data.europa.eu/uxp/1000', + 'oe_author' => 'http://publications.europa.eu/resource/authority/corporate-body/AASM', + 'oe_content_content_owner' => 'http://publications.europa.eu/resource/authority/corporate-body/COMMU', + 'uid' => 0, + 'status' => 1, + ]); + $collection2->save(); + $this->drupalGet($node->toUrl()); + + $details_expected_values['items'][1] = [ + 'label' => 'Part of collections', + 'body' => 'Test Publication collection node 1 | Test Publication collection node 2', + ]; + $field_list_assert->assertPattern($details_expected_values, $content_items[0]->getHtml()); } } From dbebaeb2835a9fa53d8f09c9b660db2312703e02 Mon Sep 17 00:00:00 2001 From: nagyad Date: Fri, 10 Sep 2021 18:36:46 +0200 Subject: [PATCH 37/41] EWPP-1486: Add access check when rendering collections as links. --- .../Display/PublicationCollection.php | 32 ++++++++------- .../ContentPublicationRenderTest.php | 39 +++++++++++++++---- 2 files changed, 50 insertions(+), 21 deletions(-) diff --git a/modules/oe_theme_content_publication/src/Plugin/ExtraField/Display/PublicationCollection.php b/modules/oe_theme_content_publication/src/Plugin/ExtraField/Display/PublicationCollection.php index 6a39e6c6d..70c33d073 100644 --- a/modules/oe_theme_content_publication/src/Plugin/ExtraField/Display/PublicationCollection.php +++ b/modules/oe_theme_content_publication/src/Plugin/ExtraField/Display/PublicationCollection.php @@ -96,19 +96,19 @@ public function viewElements(ContentEntityInterface $entity) { '#theme' => 'oe_theme_content_publication_collections', ]; - // Set the label of the field. - if (count($collections) > 1) { - $this->label = $this->t('Part of collections'); - } - else { - $this->label = $this->t('Part of collection'); - } - $cache = CacheableMetadata::createFromRenderArray($build); $items = []; foreach ($collections as $collection) { $cache->addCacheableDependency($collection); + + // Run access checks on the node. + $access = $collection->access('view', NULL, TRUE); + $cache->addCacheableDependency($access); + if (!$access->isAllowed()) { + continue; + } + $items[] = [ '#type' => 'link', '#title' => $collection->label(), @@ -119,6 +119,14 @@ public function viewElements(ContentEntityInterface $entity) { ]; } + // Set the label of the field. + if (count($items) > 1) { + $this->label = $this->t('Part of collections'); + } + else { + $this->label = $this->t('Part of collection'); + } + $build['#items'] = $items; $cache->applyTo($build); @@ -136,19 +144,17 @@ public function viewElements(ContentEntityInterface $entity) { * The loaded publication entities. */ protected function getReferencingCollections(EntityInterface $entity): array { - $referencing_entities = []; - // Load all entities that have a reference to the given entity. $entity_type_storage = $this->entityTypeManager->getStorage('node'); - $query = $entity_type_storage->getQuery('OR'); + $query = $entity_type_storage->getQuery(); $query->condition('oe_publication_publications.target_id', $entity->id()); $ids = $query->execute(); if ($ids) { - $referencing_entities = array_merge($referencing_entities, $entity_type_storage->loadMultiple($ids)); + return $entity_type_storage->loadMultiple($ids); } - return $referencing_entities; + return []; } } diff --git a/tests/Functional/ContentPublicationRenderTest.php b/tests/Functional/ContentPublicationRenderTest.php index 318269ce8..baae3fcdc 100644 --- a/tests/Functional/ContentPublicationRenderTest.php +++ b/tests/Functional/ContentPublicationRenderTest.php @@ -408,15 +408,28 @@ public function testPublicationRendering(): void { // Assert the referenced publication page 'Part of collection' extra field. $this->drupalGet($node->toUrl()); - $details_expected_values['items'][0] = [ - 'label' => 'Part of collection', - 'body' => 'Test Publication collection node 1', - ]; - $first_element = [ - 'label' => 'Identification', - 'body' => 'ID 1, ID 2', + $details_expected_values['items'] = [ + [ + 'label' => 'Identification', + 'body' => 'ID 1, ID 2', + ], + [ + 'label' => 'Part of collection', + 'body' => 'Test Publication collection node 1', + ], + [ + 'label' => 'Publication date', + 'body' => '15 April 2020 (Last updated on: 17 June 2020)', + ], + [ + 'label' => 'Related departments', + 'body' => 'Audit Board of the European Communities | Associated African States and Madagascar', + ], + [ + 'label' => 'Countries', + 'body' => 'United Kingdom, France', + ], ]; - array_unshift($details_expected_values['items'], $first_element); $field_list_assert->assertPattern($details_expected_values, $content_items[0]->getHtml()); // Create a second collection and assert the 'Part of collection' extra @@ -446,6 +459,16 @@ public function testPublicationRendering(): void { 'body' => 'Test Publication collection node 1 | Test Publication collection node 2', ]; $field_list_assert->assertPattern($details_expected_values, $content_items[0]->getHtml()); + + // Now unpublish one of the collections and assert the 'Part of collection'. + $collection->set('status', 0)->save(); + $this->getSession()->reload(); + + $details_expected_values['items'][1] = [ + 'label' => 'Part of collection', + 'body' => 'Test Publication collection node 2', + ]; + $field_list_assert->assertPattern($details_expected_values, $content_items[0]->getHtml()); } } From de253898c4358f0e9626ef7ed1021c6e88db5a73 Mon Sep 17 00:00:00 2001 From: nagyad Date: Mon, 13 Sep 2021 15:07:32 +0200 Subject: [PATCH 38/41] EWPP-1486: Simplify udpate path and render array. --- .../oe_theme_content_publication.post_update.php | 4 ---- .../src/Plugin/ExtraField/Display/PublicationCollection.php | 3 +-- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/modules/oe_theme_content_publication/oe_theme_content_publication.post_update.php b/modules/oe_theme_content_publication/oe_theme_content_publication.post_update.php index 04be13d05..7de4e0db4 100644 --- a/modules/oe_theme_content_publication/oe_theme_content_publication.post_update.php +++ b/modules/oe_theme_content_publication/oe_theme_content_publication.post_update.php @@ -220,9 +220,5 @@ function oe_theme_content_publication_post_update_30001(): void { if ($view_display) { $display = $storage->updateFromStorageRecord($view_display, $display_values); $display->save(); - return; } - - $display = $storage->createFromStorageRecord($display_values); - $display->save(); } diff --git a/modules/oe_theme_content_publication/src/Plugin/ExtraField/Display/PublicationCollection.php b/modules/oe_theme_content_publication/src/Plugin/ExtraField/Display/PublicationCollection.php index 70c33d073..74e292c98 100644 --- a/modules/oe_theme_content_publication/src/Plugin/ExtraField/Display/PublicationCollection.php +++ b/modules/oe_theme_content_publication/src/Plugin/ExtraField/Display/PublicationCollection.php @@ -10,7 +10,6 @@ use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\Core\StringTranslation\StringTranslationTrait; -use Drupal\Core\Url; use Drupal\extra_field\Plugin\ExtraFieldDisplayFormattedBase; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -112,7 +111,7 @@ public function viewElements(ContentEntityInterface $entity) { $items[] = [ '#type' => 'link', '#title' => $collection->label(), - '#url' => Url::fromRoute('entity.node.canonical', ['node' => $collection->id()]), + '#url' => $collection->toUrl(), '#attributes' => [ 'class' => ['ecl-link', 'ecl-link--standalone'], ], From 07d43750aa3200c869e96d2f53f563169128b4c4 Mon Sep 17 00:00:00 2001 From: nagyad Date: Fri, 17 Sep 2021 13:18:13 +0200 Subject: [PATCH 39/41] EWPP-1486: Ensure translated label is shown. --- composer.json | 5 +---- .../Display/PublicationCollection.php | 19 ++++++++++++++++-- .../ContentPublicationRenderTest.php | 20 ++++++++++++++++++- 3 files changed, 37 insertions(+), 7 deletions(-) diff --git a/composer.json b/composer.json index ad485d535..8a1a61925 100644 --- a/composer.json +++ b/composer.json @@ -47,7 +47,7 @@ "openeuropa/behat-transformation-context": "~0.1", "openeuropa/code-review": "~1.5", "openeuropa/drupal-core-require-dev": "^8.9.14", - "openeuropa/oe_content": "~2.4.0", + "openeuropa/oe_content": "2.x-dev", "openeuropa/oe_corporate_blocks": "~4.0", "openeuropa/oe_corporate_countries": "~2.0", "openeuropa/oe_media": "~1.12", @@ -109,9 +109,6 @@ }, "drupal/entity_reference_revisions": { "https://www.drupal.org/project/entity_reference_revisions/issues/2937835": "https://www.drupal.org/files/issues/2021-03-26/entity_reference_revisions-field_formatter_label-2937835-36.patch" - }, - "openeuropa/oe_content": { - "latest": "https://github.com/openeuropa/oe_content/compare/2.4.0..EWPP-1485.diff" } }, "drupal-scaffold": { diff --git a/modules/oe_theme_content_publication/src/Plugin/ExtraField/Display/PublicationCollection.php b/modules/oe_theme_content_publication/src/Plugin/ExtraField/Display/PublicationCollection.php index 74e292c98..08c29d2a2 100644 --- a/modules/oe_theme_content_publication/src/Plugin/ExtraField/Display/PublicationCollection.php +++ b/modules/oe_theme_content_publication/src/Plugin/ExtraField/Display/PublicationCollection.php @@ -7,6 +7,7 @@ use Drupal\Core\Cache\CacheableMetadata; use Drupal\Core\Entity\ContentEntityInterface; use Drupal\Core\Entity\EntityInterface; +use Drupal\Core\Entity\EntityRepositoryInterface; use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\Core\StringTranslation\StringTranslationTrait; @@ -43,6 +44,13 @@ class PublicationCollection extends ExtraFieldDisplayFormattedBase implements Co */ protected $entityTypeManager; + /** + * The entity repository. + * + * @var \Drupal\Core\Entity\EntityRepositoryInterface + */ + protected $entityRepository; + /** * PublicationCollection constructor. * @@ -54,10 +62,13 @@ class PublicationCollection extends ExtraFieldDisplayFormattedBase implements Co * The plugin implementation definition. * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager * The entity type manager. + * @param \Drupal\Core\Entity\EntityRepositoryInterface $entity_repository + * The entity repository. */ - public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityTypeManagerInterface $entity_type_manager) { + public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityTypeManagerInterface $entity_type_manager, EntityRepositoryInterface $entity_repository) { parent::__construct($configuration, $plugin_id, $plugin_definition); $this->entityTypeManager = $entity_type_manager; + $this->entityRepository = $entity_repository; } /** @@ -68,7 +79,8 @@ public static function create(ContainerInterface $container, array $configuratio $configuration, $plugin_id, $plugin_definition, - $container->get('entity_type.manager') + $container->get('entity_type.manager'), + $container->get('entity.repository') ); } @@ -108,6 +120,9 @@ public function viewElements(ContentEntityInterface $entity) { continue; } + // Get the current translation. + $collection = $this->entityRepository->getTranslationFromContext($collection); + $items[] = [ '#type' => 'link', '#title' => $collection->label(), diff --git a/tests/Functional/ContentPublicationRenderTest.php b/tests/Functional/ContentPublicationRenderTest.php index baae3fcdc..656276e86 100644 --- a/tests/Functional/ContentPublicationRenderTest.php +++ b/tests/Functional/ContentPublicationRenderTest.php @@ -31,6 +31,7 @@ class ContentPublicationRenderTest extends ContentRenderTestBase { 'oe_theme_content_publication', 'oe_theme_content_organisation', 'oe_theme_content_organisation_reference', + 'oe_multilingual', ]; /** @@ -51,6 +52,9 @@ protected function setUp(): void { $settings['target_bundles']['oe_organisation_reference'] = 'oe_organisation_reference'; $field->setSetting('handler_settings', $settings); $field->save(); + + // Make publications translatable. + \Drupal::service('content_translation.manager')->setEnabled('node', 'oe_publication', TRUE); } /** @@ -79,6 +83,7 @@ public function testPublicationRendering(): void { 'status' => 1, ]); $node->save(); + $node->addTranslation('es', ['title' => 'ES Test Publication node'])->save(); $this->drupalGet($node->toUrl()); // Assert page header - metadata. @@ -452,6 +457,7 @@ public function testPublicationRendering(): void { 'status' => 1, ]); $collection2->save(); + $collection2->addTranslation('es', ['title' => 'ES Test Publication collection node 2'])->save(); $this->drupalGet($node->toUrl()); $details_expected_values['items'][1] = [ @@ -460,13 +466,25 @@ public function testPublicationRendering(): void { ]; $field_list_assert->assertPattern($details_expected_values, $content_items[0]->getHtml()); + // Assert the translated collection label. + $node = \Drupal::service('entity.repository')->getTranslationFromContext($node, 'es'); + $this->drupalGet($node->toUrl()); + + $details_expected_values['items'][1] = [ + 'label' => 'Part of collections', + 'body' => 'Test Publication collection node 1 | ES Test Publication collection node 2', + ]; + $details_expected_values['items'][3]['body'] = 'Comisión de Control de las Comunidades Europeas | Estados africanos y malgache asociados'; + $details_expected_values['items'][4]['body'] = 'Reino Unido, Francia'; + $field_list_assert->assertPattern($details_expected_values, $content_items[0]->getHtml()); + // Now unpublish one of the collections and assert the 'Part of collection'. $collection->set('status', 0)->save(); $this->getSession()->reload(); $details_expected_values['items'][1] = [ 'label' => 'Part of collection', - 'body' => 'Test Publication collection node 2', + 'body' => 'ES Test Publication collection node 2', ]; $field_list_assert->assertPattern($details_expected_values, $content_items[0]->getHtml()); } From 19c5a423d3de7043b4711d93f4b5177eca212fdb Mon Sep 17 00:00:00 2001 From: Evgenii Nikitin Date: Fri, 24 Sep 2021 13:29:33 +0300 Subject: [PATCH 40/41] EWPP-1486: Make node title translatable for the test. --- tests/Functional/ContentPublicationRenderTest.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/Functional/ContentPublicationRenderTest.php b/tests/Functional/ContentPublicationRenderTest.php index 656276e86..c1de782d3 100644 --- a/tests/Functional/ContentPublicationRenderTest.php +++ b/tests/Functional/ContentPublicationRenderTest.php @@ -55,6 +55,13 @@ protected function setUp(): void { // Make publications translatable. \Drupal::service('content_translation.manager')->setEnabled('node', 'oe_publication', TRUE); + + // Make node title translatable. + $fields = \Drupal::service('entity_field.manager') + ->getBaseFieldDefinitions('node', 'oe_publication'); + $field_config = $fields['title']->getConfig('oe_publication'); + $field_config->setTranslatable(TRUE); + $field_config->save(); } /** From ec7c416fc8438329aac33dedf915aa1ce96b456c Mon Sep 17 00:00:00 2001 From: 22Alexandra Date: Fri, 24 Sep 2021 15:39:40 +0300 Subject: [PATCH 41/41] EWPP-0000: Update oe_content version. --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index da45d014f..8a1a61925 100644 --- a/composer.json +++ b/composer.json @@ -47,7 +47,7 @@ "openeuropa/behat-transformation-context": "~0.1", "openeuropa/code-review": "~1.5", "openeuropa/drupal-core-require-dev": "^8.9.14", - "openeuropa/oe_content": "dev-EPIC-EWPP-1360-News-v3", + "openeuropa/oe_content": "2.x-dev", "openeuropa/oe_corporate_blocks": "~4.0", "openeuropa/oe_corporate_countries": "~2.0", "openeuropa/oe_media": "~1.12",