From b7bdcb48f5a0299e8189cc6147afc375fd026812 Mon Sep 17 00:00:00 2001 From: Alexandre Dias Date: Wed, 20 Oct 2021 10:32:21 +0100 Subject: [PATCH] =?UTF-8?q?ISAICP-6765:=20=E2=80=9CHighlighted=20Solution?= =?UTF-8?q?=E2=80=9D=20will=20become=20=E2=80=9CHighlighted=20Content?= =?UTF-8?q?=E2=80=9D.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...play.rdf_entity.collection.highlighted.yml | 148 ++++++++++++++++++ ...ueue.entity_queue.highlighted_solution.yml | 3 +- ...page_variant.homepage-layout_builder-0.yml | 2 +- tests/behat.yml.dist | 2 +- tests/features/homepage.feature | 4 +- .../curated_content_listings.feature | 12 +- tests/src/Context/SolutionContext.php | 18 +-- ...ueue-block--highlighted-solution.html.twig | 2 +- ...-entity--collection--highlighted.html.twig | 18 +++ web/themes/ventuno/ventuno.theme | 31 ++++ 10 files changed, 219 insertions(+), 21 deletions(-) create mode 100644 config/sync/core.entity_view_display.rdf_entity.collection.highlighted.yml create mode 100644 web/themes/ventuno/templates/rdf-entity/rdf-entity--collection--highlighted.html.twig diff --git a/config/sync/core.entity_view_display.rdf_entity.collection.highlighted.yml b/config/sync/core.entity_view_display.rdf_entity.collection.highlighted.yml new file mode 100644 index 0000000000..ab1bdc1e71 --- /dev/null +++ b/config/sync/core.entity_view_display.rdf_entity.collection.highlighted.yml @@ -0,0 +1,148 @@ +uuid: 651f0d88-0d69-41c1-a40c-908655d164bc +langcode: en +status: true +dependencies: + config: + - core.entity_view_mode.rdf_entity.highlighted + - field.field.rdf_entity.collection.field_ar_abstract + - field.field.rdf_entity.collection.field_ar_access_url + - field.field.rdf_entity.collection.field_ar_affiliates + - field.field.rdf_entity.collection.field_ar_banner + - field.field.rdf_entity.collection.field_ar_closed + - field.field.rdf_entity.collection.field_ar_contact_information + - field.field.rdf_entity.collection.field_ar_content_creation + - field.field.rdf_entity.collection.field_ar_description + - field.field.rdf_entity.collection.field_ar_logo + - field.field.rdf_entity.collection.field_ar_moderation + - field.field.rdf_entity.collection.field_ar_owner + - field.field.rdf_entity.collection.field_ar_state + - field.field.rdf_entity.collection.field_collection_content + - field.field.rdf_entity.collection.field_keywords + - field.field.rdf_entity.collection.field_newsletter + - field.field.rdf_entity.collection.field_short_id + - field.field.rdf_entity.collection.field_site_featured + - field.field.rdf_entity.collection.field_spatial_coverage + - field.field.rdf_entity.collection.field_topic + - rdf_entity.rdfentity.collection + - responsive_image.styles.highlighted_solution + module: + - field_delimiter + - field_formatter_range + - field_group + - layout_builder + - responsive_image + - smart_trim + - template_suggestion + - user +third_party_settings: + field_group: + group_abstract_wrapper: + children: + - field_ar_abstract + - read_more + parent_name: '' + weight: 4 + format_type: html_element + format_settings: + element: div + show_label: false + label_element: h3 + attributes: '' + effect: none + speed: fast + id: '' + classes: '' + label: 'Abstract wrapper' + region: hidden + layout_builder: + allow_custom: false + enabled: false +id: rdf_entity.collection.highlighted +targetEntityType: rdf_entity +bundle: collection +mode: highlighted +content: + field_ar_description: + type: smart_trim + weight: 3 + region: content + label: hidden + settings: + trim_length: 200 + trim_type: chars + trim_suffix: … + wrap_class: trimmed + more_text: More + more_class: more-link + trim_options: + text: true + trim_zero: false + wrap_output: false + more_link: false + summary_handler: full + third_party_settings: + template_suggestion: + template_suggestion: '' + field_ar_logo: + type: responsive_image + weight: 0 + region: content + label: hidden + settings: + responsive_image_style: highlighted_solution + image_link: content + third_party_settings: + template_suggestion: + template_suggestion: '' + field_topic: + type: entity_reference_label + weight: 1 + region: content + label: hidden + settings: + link: true + third_party_settings: + field_delimiter: + delimiter: '' + field_formatter_range: + order: 0 + limit: 2 + offset: 0 + template_suggestion: + template_suggestion: '' + label: + label: hidden + type: string + weight: 2 + settings: + link_to_entity: false + third_party_settings: { } + region: content +hidden: + changed: true + created: true + field_ar_abstract: true + field_ar_access_url: true + field_ar_affiliates: true + field_ar_banner: true + field_ar_closed: true + field_ar_contact_information: true + field_ar_content_creation: true + field_ar_moderation: true + field_ar_owner: true + field_ar_state: true + field_collection_content: true + field_keywords: true + field_newsletter: true + field_short_id: true + field_site_featured: true + field_spatial_coverage: true + join_collection: true + langcode: true + last_update: true + members: true + og_group: true + rdf_entity_field_collection_content_inline_facets: true + rdf_entity_field_collection_content_top: true + read_more: true + solutions: true diff --git a/config/sync/entityqueue.entity_queue.highlighted_solution.yml b/config/sync/entityqueue.entity_queue.highlighted_solution.yml index 3b3a5d60f6..2a3d23b081 100644 --- a/config/sync/entityqueue.entity_queue.highlighted_solution.yml +++ b/config/sync/entityqueue.entity_queue.highlighted_solution.yml @@ -5,7 +5,7 @@ dependencies: module: - rdf_entity id: highlighted_solution -label: 'Highlighted solution' +label: 'Highlighted content' handler: simple handler_configuration: { } entity_settings: @@ -13,6 +13,7 @@ entity_settings: handler: 'default:rdf_entity' handler_settings: target_bundles: + collection: collection solution: solution sort: field: _none diff --git a/config/sync/page_manager.page_variant.homepage-layout_builder-0.yml b/config/sync/page_manager.page_variant.homepage-layout_builder-0.yml index 4a422cc7f2..39b2ffe9c7 100644 --- a/config/sync/page_manager.page_variant.homepage-layout_builder-0.yml +++ b/config/sync/page_manager.page_variant.homepage-layout_builder-0.yml @@ -36,7 +36,7 @@ variant_settings: region: second configuration: id: 'entityqueue_block:highlighted_solution' - label: 'Highlighted solution' + label: 'Highlighted content' provider: entityqueue_block label_display: visible view_mode: highlighted diff --git a/tests/behat.yml.dist b/tests/behat.yml.dist index edaab95926..3f3d20e746 100644 --- a/tests/behat.yml.dist +++ b/tests/behat.yml.dist @@ -113,7 +113,7 @@ default: Header menu: '#block-joinup-theme-main-menu' Header: '.section--featured, .section-header' Highlighted event: '.block-entityqueue--highlighted-event' - Highlighted solution: '.block-entityqueue--highlighted-solution' + Highlighted content: '.block-entityqueue--highlighted-solution' In the spotlight: '.block-views-blockin-the-spotlight-block' Left sidebar: '.section--sidebar-left' Main solution vertical tab: '#edit-group-main' diff --git a/tests/features/homepage.feature b/tests/features/homepage.feature index a489c49ee2..b97dc74512 100644 --- a/tests/features/homepage.feature +++ b/tests/features/homepage.feature @@ -99,12 +99,12 @@ Feature: Homepage | solution type | Interoperability Specification, Networking Service | | topic | Demography, EU and European Policies, HR | | state | validated | - And the "Highlighted solution" content listing contains: + And the "Highlighted content" content listing contains: | type | label | | solution | Mercury poisoning | When I am on the homepage - Then I should see "Mercury poisoning" as the highlighted solution + Then I should see "Mercury poisoning" as the Highlighted content And I should see the link "More solutions" When I click "More solutions" Then I should be on the advanced search page diff --git a/tests/features/moderator/curated_content_listings.feature b/tests/features/moderator/curated_content_listings.feature index 15fdf64faf..4049d76319 100644 --- a/tests/features/moderator/curated_content_listings.feature +++ b/tests/features/moderator/curated_content_listings.feature @@ -12,7 +12,7 @@ Feature: Curated content listings And I should see the following links: | Discover topics | | Highlighted event | - | Highlighted solution | + | Highlighted content | | In the spotlight | When I click "Discover topics" Then I should see the heading "Update curated content listing Discover topics" @@ -27,19 +27,19 @@ Feature: Curated content listings And I am on the homepage Then I should not see any contextual links in the "In the spotlight" region And I should not see any contextual links in the "Highlighted event" region - And I should not see any contextual links in the "Highlighted solution" region + And I should not see any contextual links in the "Highlighted content" region Given I am logged in as an "authenticated user" And I am on the homepage Then I should not see any contextual links in the "In the spotlight" region And I should not see any contextual links in the "Highlighted event" region - And I should not see any contextual links in the "Highlighted solution" region + And I should not see any contextual links in the "Highlighted content" region Given I am logged in as a "moderator" And I am on the homepage Then I should see the contextual link "Update curated content" in the "In the spotlight" region And I should see the contextual link "Update curated content" in the "Highlighted event" region - And I should see the contextual link "Update curated content" in the "Highlighted solution" region + And I should see the contextual link "Update curated content" in the "Highlighted content" region Given I am on the homepage When I click the contextual link "Update curated content" in the "In the spotlight" region @@ -50,5 +50,5 @@ Feature: Curated content listings Then I should see the heading "Update curated content listing Highlighted event" Given I am on the homepage - When I click the contextual link "Update curated content" in the "Highlighted solution" region - Then I should see the heading "Update curated content listing Highlighted solution" + When I click the contextual link "Update curated content" in the "Highlighted content" region + Then I should see the heading "Update curated content listing Highlighted content" diff --git a/tests/src/Context/SolutionContext.php b/tests/src/Context/SolutionContext.php index d5da167644..e026ed1d42 100644 --- a/tests/src/Context/SolutionContext.php +++ b/tests/src/Context/SolutionContext.php @@ -847,34 +847,34 @@ public function setDownloadCountForEntity(string $type, string $target_entity_la } /** - * Checks the contents of the "Highlighted solution" block. + * Checks the contents of the "Highlighted content" block. * * This is shown on the homepage. * * @param string $label * The label of the solution that is highlighted on the homepage. * - * @Then I should see :label as the highlighted solution + * @Then I should see :label as the Highlighted content */ public function assertHighlightedSolution(string $label): void { $solution = self::getSolutionByName($label); - $block_element = $this->getSession()->getPage()->find('css', '.block-entityqueue--highlighted-solution'); + $block_element = $this->getSession()->getPage()->find('css', '.block-entityqueue--highlighted-content'); // Check block title. $actual_block_title = $block_element->find('css', 'h2')->getText(); - Assert::assertEquals('Highlighted solution', $actual_block_title, sprintf('Expected the highlighted solution block to have the title "Highlighted solution" but instead found "%s".', $actual_block_title)); + Assert::assertEquals('Highlighted content', $actual_block_title, sprintf('Expected the Highlighted content block to have the title "Highlighted content" but instead found "%s".', $actual_block_title)); // Check that the logo is present. if ($logo = $solution->getLogoAsFile()) { $filename = $logo->getFilename(); $logo_is_present = self::hasImage($filename, $block_element); - Assert::assertTrue($logo_is_present, sprintf('Image with filename "%s" has been found in the highlighted solution block.', $filename)); + Assert::assertTrue($logo_is_present, sprintf('Image with filename "%s" has been found in the Highlighted content block.', $filename)); } // Check title text. $actual_title = $block_element->find('css', 'article h2')->getText(); - Assert::assertEquals($solution->label(), $actual_title, sprintf('Expected the highlighted solution to have the title "%s" but instead found "%s".', $solution->label(), $actual_title)); + Assert::assertEquals($solution->label(), $actual_title, sprintf('Expected the Highlighted content to have the title "%s" but instead found "%s".', $solution->label(), $actual_title)); // Check that title links to the canonical page of the solution. $xpath = '//h2/a[@href = "' . $solution->toUrl()->toString() . '"]'; @@ -886,7 +886,7 @@ public function assertHighlightedSolution(string $label): void { // Check that the correct number of topics are present. $topic_elements = $block_element->findAll('css', '.field--name-field-topic .field__item'); - Assert::assertEquals(count($topics), count($topic_elements), sprintf('Expected %d topics in the "Highlighted solution" section but found %d topics.', count($topics), count($topic_elements))); + Assert::assertEquals(count($topics), count($topic_elements), sprintf('Expected %d topics in the "Highlighted content" section but found %d topics.', count($topics), count($topic_elements))); foreach ($topics as $j => $topic) { /** @var \Behat\Mink\Element\NodeElement $topic_element */ @@ -894,11 +894,11 @@ public function assertHighlightedSolution(string $label): void { // Check the title of each topic. $actual_topic_title = $topic_element->getText(); - Assert::assertEquals($topic->label(), $actual_topic_title, sprintf('Expected topic #%d to be "%s" in the "Highlighted solution" section but instead found "%s".', $j + 1, $topic->label(), $actual_topic_title)); + Assert::assertEquals($topic->label(), $actual_topic_title, sprintf('Expected topic #%d to be "%s" in the "Highlighted content" section but instead found "%s".', $j + 1, $topic->label(), $actual_topic_title)); // Check that each topic links to their canonical page. $xpath = '/a[@href = "' . $topic->toUrl()->toString() . '"]'; - Assert::assertNotEmpty($topic_element->find('xpath', $xpath), sprintf('Topic "%s" in the "Highlighted solution" section does not link to the canonical topic page.', $actual_topic_title)); + Assert::assertNotEmpty($topic_element->find('xpath', $xpath), sprintf('Topic "%s" in the "Highlighted content" section does not link to the canonical topic page.', $actual_topic_title)); } // Check that the description is present. diff --git a/web/themes/ventuno/templates/block/block--entityqueue-block--highlighted-solution.html.twig b/web/themes/ventuno/templates/block/block--entityqueue-block--highlighted-solution.html.twig index 2ecd30c2e2..7a1557127e 100644 --- a/web/themes/ventuno/templates/block/block--entityqueue-block--highlighted-solution.html.twig +++ b/web/themes/ventuno/templates/block/block--entityqueue-block--highlighted-solution.html.twig @@ -41,7 +41,7 @@ {% endif %} {{ title_suffix }} {% block content %} - {{ 'More solutions'|t }} + {{ related_content }} {{ content }} {% endblock %} diff --git a/web/themes/ventuno/templates/rdf-entity/rdf-entity--collection--highlighted.html.twig b/web/themes/ventuno/templates/rdf-entity/rdf-entity--collection--highlighted.html.twig new file mode 100644 index 0000000000..fbf1ed495b --- /dev/null +++ b/web/themes/ventuno/templates/rdf-entity/rdf-entity--collection--highlighted.html.twig @@ -0,0 +1,18 @@ +{# +/** + * @file + * Themeing for rdf entities. + */ +#} + + {{ content.field_ar_logo }} + {{ content.field_topic }} + {{ title_prefix }} + {% if not page and not is_label_hidden %} + + {{ label }} + + {% endif %} + {{ title_suffix }} + {{ content|without('field_ar_logo', 'field_topic') }} + diff --git a/web/themes/ventuno/ventuno.theme b/web/themes/ventuno/ventuno.theme index 9728db6ac0..9c4bd88093 100644 --- a/web/themes/ventuno/ventuno.theme +++ b/web/themes/ventuno/ventuno.theme @@ -138,6 +138,37 @@ function ventuno_preprocess_page(&$variables) { $variables['anonymous_links'] = $anonymous_links; } +/** + * Implements hook_preprocess_block(). + */ +function ventuno_preprocess_block(&$variables) { + if ($variables['derivative_plugin_id'] == 'highlighted_solution') { + /** @var \Drupal\rdf_entity\RdfInterface $entity */ + $entity = $variables['elements']['content']['entities'][0]['#rdf_entity']; + + $topics = $entity->get('field_topic')->getValue(); + + $options = [ + 'query' => + [ + 'f' => + [ + 'type:' . $entity->bundle(), + 'topic:' . reset($topics)["target_id"], + ], + ], + ]; + $variables['related_content'] = [ + '#type' => 'link', + '#title' => t('Related content'), + '#url' => Url::fromRoute('view.search.page_1', [], $options), + '#attributes' => [ + 'class' => ['more-link'], + ], + ]; + } +} + /** * Implements hook_preprocess_HOOK(). *