Code development platform for open source projects from the European Union institutions

Skip to content
Snippets Groups Projects
Unverified Commit 75dbbe5a authored by Andreas Hennings's avatar Andreas Hennings Committed by GitHub
Browse files

Merge pull request #159 from openeuropa/OEL-1662

OEL-1662: Add registration URL field to the full content view
parents ed153708 1bd25c39
No related branches found
No related tags found
No related merge requests found
Showing
with 289 additions and 1 deletion
......@@ -94,6 +94,9 @@
"patches": {
"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_starter_content": {
"latest": "https://github.com/openeuropa/oe_starter_content/compare/1.0.0-beta1..OEL-1662.diff"
}
},
"drupal-scaffold": {
......
......@@ -8,6 +8,7 @@ dependencies:
- field.field.node.oe_sc_event.oe_featured_media
- field.field.node.oe_sc_event.oe_sc_event_dates
- field.field.node.oe_sc_event.oe_sc_event_location
- field.field.node.oe_sc_event.oe_sc_event_registration_url
- field.field.node.oe_sc_event.oe_summary
- node.type.oe_sc_event
module:
......@@ -64,5 +65,6 @@ hidden:
oe_content_navigation_title: true
oe_content_short_title: true
oe_featured_media: true
oe_sc_event_registration_url: true
oe_summary: true
search_api_excerpt: true
......@@ -8,9 +8,11 @@ dependencies:
- field.field.node.oe_sc_event.oe_featured_media
- field.field.node.oe_sc_event.oe_sc_event_dates
- field.field.node.oe_sc_event.oe_sc_event_location
- field.field.node.oe_sc_event.oe_sc_event_registration_url
- field.field.node.oe_sc_event.oe_summary
- node.type.oe_sc_event
module:
- link
- oe_content_featured_media_field
- text
- user
......@@ -27,6 +29,18 @@ content:
third_party_settings: { }
weight: 1
region: content
oe_sc_event_registration_url:
type: link
label: above
settings:
trim_length: 80
url_only: false
url_plain: false
rel: ''
target: ''
third_party_settings: { }
weight: 2
region: content
oe_summary:
type: text_default
label: hidden
......@@ -45,3 +59,4 @@ hidden:
oe_documents: true
oe_sc_event_dates: true
oe_sc_event_location: true
search_api_excerpt: true
......@@ -8,6 +8,7 @@ dependencies:
- field.field.node.oe_sc_event.oe_featured_media
- field.field.node.oe_sc_event.oe_sc_event_dates
- field.field.node.oe_sc_event.oe_sc_event_location
- field.field.node.oe_sc_event.oe_sc_event_registration_url
- field.field.node.oe_sc_event.oe_summary
- node.type.oe_sc_event
module:
......@@ -52,4 +53,5 @@ hidden:
oe_content_short_title: true
oe_documents: true
oe_featured_media: true
oe_sc_event_registration_url: true
search_api_excerpt: true
langcode: en
status: true
dependencies:
config:
- core.entity_view_mode.node.full
- field.field.node.oe_sc_event.body
- field.field.node.oe_sc_event.oe_documents
- field.field.node.oe_sc_event.oe_featured_media
- field.field.node.oe_sc_event.oe_sc_event_dates
- field.field.node.oe_sc_event.oe_sc_event_location
- field.field.node.oe_sc_event.oe_sc_event_registration_url
- field.field.node.oe_sc_event.oe_summary
- node.type.oe_sc_event
module:
- daterange_compact
- oe_whitelabel_helper
- text
- user
id: node.oe_sc_event.full
targetEntityType: node
bundle: oe_sc_event
mode: full
content:
body:
type: text_default
label: above
settings: { }
third_party_settings: { }
weight: 0
region: content
links:
settings: { }
third_party_settings: { }
weight: 4
region: content
oe_documents:
type: entity_reference_entity_view
label: above
settings:
view_mode: default
link: true
third_party_settings: { }
weight: 3
region: content
oe_sc_event_dates:
type: daterange_compact
label: inline
settings:
daterange_compact_format: oe_whitelabel_date_time_long
third_party_settings: { }
weight: 1
region: content
oe_sc_event_location:
type: oe_whitelabel_helper_address_inline
label: inline
settings:
delimiter: ', '
third_party_settings: { }
weight: 2
region: content
hidden:
langcode: true
oe_content_content_owner: true
oe_content_legacy_link: true
oe_content_navigation_title: true
oe_content_short_title: true
oe_featured_media: true
oe_sc_event_registration_url: true
oe_summary: true
search_api_excerpt: true
langcode: en
status: true
dependencies:
config:
- core.entity_view_mode.node.oe_w_content_banner
- field.field.node.oe_sc_event.body
- field.field.node.oe_sc_event.oe_documents
- field.field.node.oe_sc_event.oe_featured_media
- field.field.node.oe_sc_event.oe_sc_event_dates
- field.field.node.oe_sc_event.oe_sc_event_location
- field.field.node.oe_sc_event.oe_sc_event_registration_url
- field.field.node.oe_sc_event.oe_summary
- node.type.oe_sc_event
module:
- link
- oe_content_featured_media_field
- text
- user
id: node.oe_sc_event.oe_w_content_banner
targetEntityType: node
bundle: oe_sc_event
mode: oe_w_content_banner
content:
oe_featured_media:
type: oe_featured_media_label
label: hidden
settings:
link: true
third_party_settings: { }
weight: 1
region: content
oe_sc_event_registration_url:
type: link
label: above
settings:
trim_length: 80
url_only: false
url_plain: false
rel: ''
target: ''
third_party_settings: { }
weight: 2
region: content
oe_summary:
type: text_default
label: hidden
settings: { }
third_party_settings: { }
weight: 0
region: content
hidden:
body: true
langcode: true
links: true
oe_content_content_owner: true
oe_content_legacy_link: true
oe_content_navigation_title: true
oe_content_short_title: true
oe_documents: true
oe_sc_event_dates: true
oe_sc_event_location: true
search_api_excerpt: true
langcode: en
status: true
dependencies:
config:
- core.entity_view_mode.node.teaser
- field.field.node.oe_sc_event.body
- field.field.node.oe_sc_event.oe_documents
- field.field.node.oe_sc_event.oe_featured_media
- field.field.node.oe_sc_event.oe_sc_event_dates
- field.field.node.oe_sc_event.oe_sc_event_location
- field.field.node.oe_sc_event.oe_sc_event_registration_url
- field.field.node.oe_sc_event.oe_summary
- node.type.oe_sc_event
module:
- address
- daterange_compact
- text
- user
id: node.oe_sc_event.teaser
targetEntityType: node
bundle: oe_sc_event
mode: teaser
content:
oe_sc_event_dates:
type: daterange_compact
label: hidden
settings:
daterange_compact_format: oe_whitelabel_date_only_short_month
third_party_settings: { }
weight: 4
region: content
oe_sc_event_location:
type: address_default
label: hidden
settings: { }
third_party_settings: { }
weight: 5
region: content
oe_summary:
type: text_default
label: hidden
settings: { }
third_party_settings: { }
weight: 2
region: content
hidden:
body: true
langcode: true
links: true
oe_content_content_owner: true
oe_content_legacy_link: true
oe_content_navigation_title: true
oe_content_short_title: true
oe_documents: true
oe_featured_media: true
oe_sc_event_registration_url: true
search_api_excerpt: true
......@@ -125,3 +125,14 @@ function _oe_whitelabel_starter_event_preprocess_inpage_nav(array &$variables):
}
}
/**
* Implements hook_preprocess_HOOK().
*/
function oe_whitelabel_starter_event_preprocess_field__node__oe_sc_event_registration_url(&$variables) {
foreach ($variables['items'] as &$item) {
if ($item['content']['#url']->isExternal()) {
$item['content']['attributes']['target'] = '_blank';
}
}
}
......@@ -31,3 +31,21 @@ function oe_whitelabel_starter_event_post_update_00002(): void {
];
ConfigImporter::importMultiple('module', 'oe_whitelabel_starter_event', '/config/post_updates/00002_event_date_show_time', $configs);
}
/**
* Add registration URL field to event content_banner view.
*/
function oe_whitelabel_starter_event_post_update_00003(): void {
$configs = [
'core.entity_view_display.node.oe_sc_event.full',
'core.entity_view_display.node.oe_sc_event.oe_w_content_banner',
'core.entity_view_display.node.oe_sc_event.teaser',
];
ConfigImporter::importMultiple(
'module',
'oe_whitelabel_starter_event',
'/config/post_updates/00003_add_registration_url_field',
$configs,
TRUE
);
}
{#
/**
* @file
* Event registration button display.
*/
#}
{% for item in items %}
<div class="mt-4">
{% set button %}
{{ pattern('button', {
'label': 'Register'|t,
'icon': 'calendar-check',
'icon_position': 'before',
}) }}
{% endset %}
{{ pattern('link', {
'label': button,
'path': item['content']['#url'].toString(),
'attributes': item['content']['attributes']
}) }}
</div>
{% endfor %}
......@@ -8,7 +8,10 @@
{{ pattern('content_banner', {
background: 'gray',
title: label,
content: content.oe_summary,
content: [
content.oe_summary,
content.oe_sc_event_registration_url,
],
image: image,
}) }}
</div>
......@@ -80,6 +80,28 @@ class ContentEventRenderTest extends WhitelabelBrowserTestBase {
trim($content_banner->filter('.oe-sc-event__oe-summary')->text())
);
// Assert registration button.
$link = $crawler->filter('.bcl-content-banner a[target="_blank"]');
$this->assertCount(1, $link);
$this->assertEquals('https://europa.eu', $link->attr('href'));
$button = $link->filter('button');
$this->assertStringContainsString('Register', $button->text());
$this->assertStringContainsString('calendar-check', $button->html());
// Assert registration button with internal route.
$node->set('oe_sc_event_registration_url', 'entity:node/' . $node->id());
$node->save();
$this->drupalGet('node/' . $node->id());
$crawler = $client->getCrawler();
$link = $crawler->filter('.bcl-content-banner a[href="/build/node/' . $node->id() . '"]');
$this->assertCount(1, $link);
$this->assertObjectNotHasAttribute('target', $link);
$button = $link->filter('button');
$this->assertStringContainsString('Register', $button->text());
$this->assertStringContainsString('calendar-check', $button->html());
$date = $crawler->filter('dl > dd');
// Assert event dates starting and ending same day.
......@@ -237,6 +259,7 @@ class ContentEventRenderTest extends WhitelabelBrowserTestBase {
]);
$node->set('oe_documents', [$media_document]);
$node->set('oe_featured_media', [$media_image]);
$node->set('oe_sc_event_registration_url', 'https://europa.eu');
$node->save();
return $node;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment