Skip to content
This repository has been archived by the owner on Jul 27, 2022. It is now read-only.

Commit

Permalink
ISAICP-6765: “Highlighted Solution” will become “Highlighted Content”.
Browse files Browse the repository at this point in the history
  • Loading branch information
saidatom committed Oct 20, 2021
1 parent cc89103 commit b7bdcb4
Show file tree
Hide file tree
Showing 10 changed files with 219 additions and 21 deletions.
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ dependencies:
module:
- rdf_entity
id: highlighted_solution
label: 'Highlighted solution'
label: 'Highlighted content'
handler: simple
handler_configuration: { }
entity_settings:
target_type: rdf_entity
handler: 'default:rdf_entity'
handler_settings:
target_bundles:
collection: collection
solution: solution
sort:
field: _none
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/behat.yml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
4 changes: 2 additions & 2 deletions tests/features/homepage.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions tests/features/moderator/curated_content_listings.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand All @@ -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"
18 changes: 9 additions & 9 deletions tests/src/Context/SolutionContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -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() . '"]';
Expand All @@ -886,19 +886,19 @@ 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 */
$topic_element = array_shift($topic_elements);

// 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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
{% endif %}
{{ title_suffix }}
{% block content %}
<a href="{{ path('view.search.page_1', {}, {query: {f: ['type:solution']}}) }}" class="more-link">{{ 'More solutions'|t }}</a>
{{ related_content }}
{{ content }}
{% endblock %}
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{#
/**
* @file
* Themeing for rdf entities.
*/
#}
<article{{ attributes }}>
{{ content.field_ar_logo }}
{{ content.field_topic }}
{{ title_prefix }}
{% if not page and not is_label_hidden %}
<h2{{ title_attributes }}>
<a href="{{ url }}" rel="bookmark">{{ label }}</a>
</h2>
{% endif %}
{{ title_suffix }}
{{ content|without('field_ar_logo', 'field_topic') }}
</article>
31 changes: 31 additions & 0 deletions web/themes/ventuno/ventuno.theme
Original file line number Diff line number Diff line change
Expand Up @@ -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().
*
Expand Down

0 comments on commit b7bdcb4

Please sign in to comment.