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

Commit

Permalink
Merge pull request #1265 from ec-europa/ISAICP-4582
Browse files Browse the repository at this point in the history
ISAICP-4582
  • Loading branch information
brummbar authored Jul 3, 2018
2 parents 27f20fe + 0fe64d1 commit b9e09fe
Show file tree
Hide file tree
Showing 11 changed files with 139 additions and 14 deletions.
3 changes: 3 additions & 0 deletions tests/features/collection/collection_overview.feature
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,11 @@ Feature: Collections Overview
# Check that later chunks of text in the abstract are not rendered.
But I should not see the text "purus. Integer nec enim facilisis mi fermentum mollis sed vitae lacus"
And I should not see the text "This collection is intended to show ways of being fit while working"

# The 'Read more' link leads to the About page.
When I click "Read more" in the "Content" region
Then I should see the heading "About Fitness at work"

And I should see the text "Fit while working is dope"
And I should see the text "This collection is intended to show ways of being fit while working"
And I should see the text "Tamsin Irwin"
Expand Down
5 changes: 3 additions & 2 deletions tests/features/solution/add_solution.feature
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,10 @@ Feature: "Add solution" visibility options.
And I press "Publish"
# The name of the solution should exist in the block of the relative content in a collection.
Then I should see the heading "Espresso is the solution"
# The solution fields will be shown in the "about" page.
# The description is shown in the overview.
And I should see the text "This is a test text"
# Most solution fields are not shown in the overview but in the "about" page.
# @see https://webgate.ec.europa.eu/CITnet/jira/browse/ISAICP-3224
And I should not see the text "This is a test text"
And I should not see the link "Demography"
And I should not see the link "Belgium"
And I should not see the link "Flemish"
Expand Down
20 changes: 20 additions & 0 deletions tests/features/solution/homepage.feature
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,26 @@ Feature: Solution homepage
As a user of the website
I need to be able see an introduction of the solution on its homepage

Scenario: The solution homepage shows basic information about the solution
Given the following solution:
| title | Petri net |
| description | "<p>A <b>Petri net</b>, also known as a <b>place/transition (PT) net</b>, is one of several <a href=\"#mathematical\">mathematical</a> modeling languages for the description of distributed systems. It is a class of discrete event dynamic system. A Petri net is a directed bipartite graph, in which the nodes represent transitions (i.e. events that may occur, represented by bars) and places (i.e. conditions, represented by circles). The directed arcs describe which places are pre- and/or postconditions for which transitions (signified by arrows). Some sources state that Petri nets were invented in August 1939 by Carl Adam Petriat the age of 13for the purpose of describing chemical processes.</p>" |
| logo | logo.png |
| banner | banner.jpg |
| state | validated |
When I go to the homepage of the "Petri net" solution
# Checking for HTML text ensures that any HTML elements in the abstract are correctly stripped.
Then the page should contain the html text "A Petri net, also known as a place/transition (PT) net, is one of several mathematical modeling languages for the description of distributed systems."
# The text should be split on a word boundary after 500 characters, followed by an ellipsis.
And the page should contain the html text "(signified by arrows)…"
# There should be a link to the about page.
And I should see the link "Read more"
# The abstract itself should be stripped of unsightly links.
But I should not see the link "mathematical"
# The 'Read more' link leads to the About page.
When I click "Read more"
Then I should see the heading "About Petri net"

# This is a regression test for the entities that include a hashmark on their Uri.
# @see https://webgate.ec.europa.eu/CITnet/jira/browse/ISAICP-3225
Scenario: Regression test for Uris that include a '#'.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ dependencies:
- field.field.rdf_entity.solution.field_is_metrics_page
- field.field.rdf_entity.solution.field_is_moderation
- field.field.rdf_entity.solution.field_is_owner
- field.field.rdf_entity.solution.field_is_pinned_in
- field.field.rdf_entity.solution.field_is_product_type
- field.field.rdf_entity.solution.field_is_related_solutions
- field.field.rdf_entity.solution.field_is_solution_type
Expand Down Expand Up @@ -453,6 +454,7 @@ hidden:
field_is_included_asset: true
field_is_issue_tracker: true
field_is_logo: true
field_is_pinned_in: true
field_is_related_solutions: true
field_is_source_code_repository: true
field_is_state: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,32 +42,87 @@ dependencies:
- field.field.rdf_entity.solution.field_status
- rdf_entity.rdfentity.solution
module:
- ds
- field_group
- search_api_field
- smart_trim
- user
third_party_settings:
field_group:
group_solution_abstract_wrapper:
children:
- field_is_description
- read_more
parent_name: ''
weight: 0
format_type: html_element
format_settings:
id: ''
classes: ''
element: div
show_label: false
label_element: h3
attributes: ''
effect: none
speed: fast
label: 'Abstract wrapper'
id: rdf_entity.solution.default
targetEntityType: rdf_entity
bundle: solution
mode: default
content:
field_is_content:
weight: 2
weight: 3
label: above
settings: { }
third_party_settings: { }
type: search_api_field
region: content
field_is_description:
type: smart_trim
weight: 37
region: content
label: hidden
settings:
trim_length: 500
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:
ds:
ft:
id: default
settings:
lb: ''
lb-col: false
classes: { }
joinup:
template_suggestion: p_wrapper
rdf_entity_field_is_content_inline_facets:
weight: 1
weight: 2
region: content
settings: { }
third_party_settings: { }
rdf_entity_field_is_content_top:
weight: 0
weight: 1
region: content
settings: { }
third_party_settings: { }
read_more:
weight: 38
region: content
settings: { }
third_party_settings: { }
related_solutions:
weight: 3
weight: 4
region: content
settings: { }
third_party_settings: { }
Expand All @@ -81,7 +136,6 @@ hidden:
field_is_banner: true
field_is_business_process: true
field_is_contact_information: true
field_is_description: true
field_is_distribution: true
field_is_documentation: true
field_is_elibrary_creation: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ dependencies:
- field.field.rdf_entity.solution.field_is_metrics_page
- field.field.rdf_entity.solution.field_is_moderation
- field.field.rdf_entity.solution.field_is_owner
- field.field.rdf_entity.solution.field_is_pinned_in
- field.field.rdf_entity.solution.field_is_product_type
- field.field.rdf_entity.solution.field_is_related_solutions
- field.field.rdf_entity.solution.field_is_solution_type
Expand Down Expand Up @@ -138,6 +139,7 @@ hidden:
field_is_metrics_page: true
field_is_moderation: true
field_is_owner: true
field_is_pinned_in: true
field_is_product_type: true
field_is_related_solutions: true
field_is_solution_type: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ dependencies:
- field.field.rdf_entity.solution.field_is_metrics_page
- field.field.rdf_entity.solution.field_is_moderation
- field.field.rdf_entity.solution.field_is_owner
- field.field.rdf_entity.solution.field_is_pinned_in
- field.field.rdf_entity.solution.field_is_product_type
- field.field.rdf_entity.solution.field_is_related_solutions
- field.field.rdf_entity.solution.field_is_solution_type
Expand Down Expand Up @@ -313,6 +314,7 @@ hidden:
field_is_distribution: true
field_is_has_version: true
field_is_logo: true
field_is_pinned_in: true
field_is_related_solutions: true
field_is_state: true
field_site_featured: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ dependencies:
- field.field.rdf_entity.solution.field_is_metrics_page
- field.field.rdf_entity.solution.field_is_moderation
- field.field.rdf_entity.solution.field_is_owner
- field.field.rdf_entity.solution.field_is_pinned_in
- field.field.rdf_entity.solution.field_is_product_type
- field.field.rdf_entity.solution.field_is_related_solutions
- field.field.rdf_entity.solution.field_is_solution_type
Expand Down Expand Up @@ -134,6 +135,7 @@ hidden:
field_is_metrics_page: true
field_is_moderation: true
field_is_owner: true
field_is_pinned_in: true
field_is_product_type: true
field_is_related_solutions: true
field_is_solution_type: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ dependencies:
- field.field.rdf_entity.solution.field_is_metrics_page
- field.field.rdf_entity.solution.field_is_moderation
- field.field.rdf_entity.solution.field_is_owner
- field.field.rdf_entity.solution.field_is_pinned_in
- field.field.rdf_entity.solution.field_is_product_type
- field.field.rdf_entity.solution.field_is_related_solutions
- field.field.rdf_entity.solution.field_is_solution_type
Expand Down Expand Up @@ -134,6 +135,7 @@ hidden:
field_is_metrics_page: true
field_is_moderation: true
field_is_owner: true
field_is_pinned_in: true
field_is_product_type: true
field_is_related_solutions: true
field_is_solution_type: true
Expand Down
39 changes: 32 additions & 7 deletions web/modules/custom/solution/solution.module
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@
* Contains hooks regarding the solution rdf entity bundle.
*/

declare(strict_types = 1);

use Drupal\Core\Access\AccessResult;
use Drupal\Core\Cache\Cache;
use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityMalformedException;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Field\BaseFieldDefinition;
use Drupal\Core\Form\FormBuilderInterface;
Expand Down Expand Up @@ -274,35 +277,42 @@ function solution_rdf_entity_access(EntityInterface $entity, $operation, Account
/**
* Implements hook_entity_extra_field_info().
*/
function solution_entity_extra_field_info() {
function solution_entity_extra_field_info(): array {
$fields = [];

$solution = RdfEntityType::load('solution');
if ($solution) {
$display = &$fields['rdf_entity'][$solution->id()]['display'];
// Append some additional fields to the solution entity display containing
// related information.
// @see solution_rdf_entity_view()
$fields['rdf_entity'][$solution->id()]['display']['releases_overview'] = [
$display['releases_overview'] = [
'label' => t('Releases overview'),
'description' => t('A link to the releases overview page'),
'description' => t('A link to the releases overview page.'),
'visible' => FALSE,
];
$fields['rdf_entity'][$solution->id()]['display']['related_solutions'] = [
$display['related_solutions'] = [
'label' => t('Related solutions: explicit + EIRA'),
'description' => t('Solutions either explicitly or referenced through EIRA.'),
'visible' => FALSE,
];
$fields['rdf_entity'][$solution->id()]['display']['download_total'] = [
$display['download_total'] = [
'label' => t('Total distribution downloads'),
'description' => t('The total downloads of all distributions in this collection.'),
'visible' => FALSE,
];
$fields['rdf_entity'][$solution->id()]['display']['collections'] = [
$display['collections'] = [
'label' => t('Collections'),
'description' => t('The collections this solution is affiliated to.'),
'visible' => FALSE,
];
$display['read_more'] = [
'label' => t('Read more'),
'description' => t('Shows a link to the about page of the solution.'),
'visible' => FALSE,
];
}

return $fields;
}

Expand Down Expand Up @@ -337,7 +347,7 @@ function solution_rdf_entity_load($entities) {
/**
* Implements hook_ENTITY_TYPE_view().
*/
function solution_rdf_entity_view(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display, $view_mode) {
function solution_rdf_entity_view(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display, $view_mode): void {
if ($entity->bundle() != 'solution') {
return;
}
Expand Down Expand Up @@ -405,6 +415,21 @@ function solution_rdf_entity_view(array &$build, EntityInterface $entity, Entity
'link' => $collection->toLink($collection->label())->toRenderable(),
];
}

// Read more link to the about page.
if ($display->getComponent('read_more')) {
try {
$link = $entity->toLink(t('Read more'), 'about-page', [
'attributes' => [
'class' => ['about-page', 'read-more', 'fieldset__read-more'],
],
]);
$build['read_more'] = $link->toRenderable();
}
catch (EntityMalformedException $e) {
// Don't include a read more link that leads to a malformed entity.
}
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{#
/**
* @file
* Theme override for a fieldgroup html element.
*
* This template is needed to "reset" the styling as the default template for
* fieldgroup html element adds classes with particular styling.
*
* @ingroup themeable
*/
#}
{% extends "field-group-html-element--group-abstract-wrapper.html.twig" %}

0 comments on commit b9e09fe

Please sign in to comment.