Skip to content

Commit

Permalink
Merge pull request #1005 from openeuropa/EPIC-EWPP-755-Highlighted
Browse files Browse the repository at this point in the history
EPIC-EWPP-755-Highlighted
  • Loading branch information
22Alexandra authored Jan 11, 2022
2 parents 69dee2c + ed9d333 commit 4d2c9e5
Show file tree
Hide file tree
Showing 61 changed files with 583 additions and 76 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,21 @@ function oe_theme_content_call_proposals_node_view_alter(array &$build, EntityIn
}
}
}

/**
* Implements template_preprocess_node() for the CFP node type.
*/
function oe_theme_content_call_proposals_preprocess_node__oe_call_proposals__teaser(array &$variables): void {
if (!isset($variables['elements']['extra_field_oe_call_proposals_label_status'])) {
return;
}
$status = $variables['elements']['extra_field_oe_call_proposals_label_status'][0];
$variant = _oe_theme_helper_prepare_status_variant($status['#name']);
if (empty($variant)) {
return;
}
$variables['badges'][] = [
'label' => $status['#label']->render(),
'variant' => $variant,
];
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,21 @@ function _oe_theme_content_call_tenders_strike_deadline(array &$variables): void
$variables['attributes']['class'] = ['ecl-u-type-strike'];
}
}

/**
* Implements template_preprocess_node() for the CFT node type.
*/
function oe_theme_content_call_tenders_preprocess_node__oe_call_tenders__teaser(array &$variables): void {
if (!isset($variables['elements']['extra_field_oe_call_tenders_label_status'])) {
return;
}
$status = $variables['elements']['extra_field_oe_call_tenders_label_status'][0];
$variant = _oe_theme_helper_prepare_status_variant($status['#name']);
if (empty($variant)) {
return;
}
$variables['badges'][] = [
'label' => $status['#label']->render(),
'variant' => $variant,
];
}
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,21 @@ function oe_theme_content_consultation_preprocess_oe_theme_helper_in_page_naviga
}
}
}

/**
* Implements template_preprocess_node() for the Consultation node type.
*/
function oe_theme_content_consultation_preprocess_node__oe_consultation__teaser(array &$variables): void {
if (!isset($variables['elements']['extra_field_oe_consultation_label_status'])) {
return;
}
$status = $variables['elements']['extra_field_oe_consultation_label_status'][0];
$variant = _oe_theme_helper_prepare_status_variant($status['#name']);
if (empty($variant)) {
return;
}
$variables['badges'][] = [
'label' => $status['#label']->render(),
'variant' => $variant,
];
}
52 changes: 52 additions & 0 deletions modules/oe_theme_helper/oe_theme_helper.module
Original file line number Diff line number Diff line change
Expand Up @@ -412,3 +412,55 @@ function oe_theme_helper_form_entity_view_display_edit_form_alter(&$form, FormSt
}
}
}

/**
* Implements hook_preprocess_HOOK().
*/
function oe_theme_helper_preprocess_node(&$variables): void {
$node_bundles = [
'oe_call_proposals',
'oe_call_tenders',
'oe_consultation',
'oe_event',
'oe_news',
'oe_organisation',
'oe_page',
'oe_person',
'oe_policy',
'oe_project',
'oe_publication',
];
/** @var \Drupal\node\NodeInterface $node */
$node = $variables['node'];
if (in_array($node->bundle(), $node_bundles) && $node->isSticky()) {
$variables['badges'] = [
[
'label' => 'Highlighted',
'variant' => 'highlight',
],
];
}
}

/**
* Retrieves the variant for the status badge.
*
* @param string $status
* The status name.
*
* @return string
* The variant.
*/
function _oe_theme_helper_prepare_status_variant(string $status): string {
switch ($status) {
case 'open':
return 'high';

case 'upcoming':
return 'medium';

case 'closed':
return 'low';
}
return '';
}
3 changes: 3 additions & 0 deletions modules/oe_theme_helper/translations/oe_theme_helper-bg.po
Original file line number Diff line number Diff line change
Expand Up @@ -521,3 +521,6 @@ msgstr "Прочетох и съм съгласен с условията за @

msgid "data protection terms"
msgstr "защита на данните"

msgid "Highlighted"
msgstr "Акценти"
3 changes: 3 additions & 0 deletions modules/oe_theme_helper/translations/oe_theme_helper-cs.po
Original file line number Diff line number Diff line change
Expand Up @@ -521,3 +521,6 @@ msgstr "Obeznámil(a) jsem se s podmínkami, které se týkají @link"

msgid "data protection terms"
msgstr "ochrany údajů"

msgid "Highlighted"
msgstr "Důležité"
3 changes: 3 additions & 0 deletions modules/oe_theme_helper/translations/oe_theme_helper-da.po
Original file line number Diff line number Diff line change
Expand Up @@ -521,3 +521,6 @@ msgstr "Jeg har læst og accepterer bestemmelserne om @link"

msgid "data protection terms"
msgstr "databeskyttelse"

msgid "Highlighted"
msgstr "Fremhævet"
3 changes: 3 additions & 0 deletions modules/oe_theme_helper/translations/oe_theme_helper-de.po
Original file line number Diff line number Diff line change
Expand Up @@ -521,3 +521,6 @@ msgstr "Ich habe die @link gelesen und bin damit einverstanden"

msgid "data protection terms"
msgstr "Datenschutzbestimmungen"

msgid "Highlighted"
msgstr "Hervorgehoben"
3 changes: 3 additions & 0 deletions modules/oe_theme_helper/translations/oe_theme_helper-el.po
Original file line number Diff line number Diff line change
Expand Up @@ -521,3 +521,6 @@ msgstr "Διάβασα τους @link και συμφωνώ"

msgid "data protection terms"
msgstr "όρους προστασίας δεδομένων"

msgid "Highlighted"
msgstr "Με επισήμανση"
3 changes: 3 additions & 0 deletions modules/oe_theme_helper/translations/oe_theme_helper-es.po
Original file line number Diff line number Diff line change
Expand Up @@ -521,3 +521,6 @@ msgstr "He leído y acepto las @link"

msgid "data protection terms"
msgstr "condiciones de protección de datos"

msgid "Highlighted"
msgstr "Destacado"
3 changes: 3 additions & 0 deletions modules/oe_theme_helper/translations/oe_theme_helper-et.po
Original file line number Diff line number Diff line change
Expand Up @@ -521,3 +521,6 @@ msgstr "Olen tutvunud ja nõustun @link"

msgid "data protection terms"
msgstr "isikuandmete kaitse põhimõtetega"

msgid "Highlighted"
msgstr "Esiplaanil"
3 changes: 3 additions & 0 deletions modules/oe_theme_helper/translations/oe_theme_helper-fi.po
Original file line number Diff line number Diff line change
Expand Up @@ -521,3 +521,6 @@ msgstr "Olen lukenut @link ja hyväksyn sen ehdot"

msgid "data protection terms"
msgstr "tietosuojaselosteen"

msgid "Highlighted"
msgstr "Valokeilassa"
3 changes: 3 additions & 0 deletions modules/oe_theme_helper/translations/oe_theme_helper-fr.po
Original file line number Diff line number Diff line change
Expand Up @@ -521,3 +521,6 @@ msgstr "J'ai lu et j'accepte les @link"

msgid "data protection terms"
msgstr "conditions relatives à la protection des données"

msgid "Highlighted"
msgstr "Mis en évidence"
3 changes: 3 additions & 0 deletions modules/oe_theme_helper/translations/oe_theme_helper-ga.po
Original file line number Diff line number Diff line change
Expand Up @@ -521,3 +521,6 @@ msgstr "Tá na @link léite agam agus glacaim leo"

msgid "data protection terms"
msgstr "téarmaí cosanta sonraí"

msgid "Highlighted"
msgstr "Aibhsithe"
3 changes: 3 additions & 0 deletions modules/oe_theme_helper/translations/oe_theme_helper-hr.po
Original file line number Diff line number Diff line change
Expand Up @@ -521,3 +521,6 @@ msgstr "Pročitao sam i prihvaćam @link"

msgid "data protection terms"
msgstr "uvjete zaštite podataka"

msgid "Highlighted"
msgstr "Istaknuto"
3 changes: 3 additions & 0 deletions modules/oe_theme_helper/translations/oe_theme_helper-hu.po
Original file line number Diff line number Diff line change
Expand Up @@ -521,3 +521,6 @@ msgstr "Elolvastam az @link és egyetértek vele"

msgid "data protection terms"
msgstr "adatvédelmi nyilatkozatot,"

msgid "Highlighted"
msgstr "Előtérben"
3 changes: 3 additions & 0 deletions modules/oe_theme_helper/translations/oe_theme_helper-it.po
Original file line number Diff line number Diff line change
Expand Up @@ -521,3 +521,6 @@ msgstr "Ho letto e accetto le @link"

msgid "data protection terms"
msgstr "condizioni relative alla protezione dei dati"

msgid "Highlighted"
msgstr "Evidenziato"
3 changes: 3 additions & 0 deletions modules/oe_theme_helper/translations/oe_theme_helper-lt.po
Original file line number Diff line number Diff line change
Expand Up @@ -521,3 +521,6 @@ msgstr "@link perskaičiau ir su jomis sutinku"

msgid "data protection terms"
msgstr "Duomenų apsaugos sąlygas"

msgid "Highlighted"
msgstr "Paryškinta"
3 changes: 3 additions & 0 deletions modules/oe_theme_helper/translations/oe_theme_helper-lv.po
Original file line number Diff line number Diff line change
Expand Up @@ -521,3 +521,6 @@ msgstr "Esmu izlasījis @link un tiem piekrītu"

msgid "data protection terms"
msgstr "datu aizsardzības noteikumus"

msgid "Highlighted"
msgstr "Aktuāli"
3 changes: 3 additions & 0 deletions modules/oe_theme_helper/translations/oe_theme_helper-mt.po
Original file line number Diff line number Diff line change
Expand Up @@ -521,3 +521,6 @@ msgstr "Qrajt u naqbel @link"

msgid "data protection terms"
msgstr "mat-termini tal-protezzjoni tad-data"

msgid "Highlighted"
msgstr "Enfasizzat"
3 changes: 3 additions & 0 deletions modules/oe_theme_helper/translations/oe_theme_helper-nl.po
Original file line number Diff line number Diff line change
Expand Up @@ -521,3 +521,6 @@ msgstr "Ik heb de @link gelezen en ga ermee akkoord"

msgid "data protection terms"
msgstr "privacyverklaring"

msgid "Highlighted"
msgstr "Actueel"
3 changes: 3 additions & 0 deletions modules/oe_theme_helper/translations/oe_theme_helper-pl.po
Original file line number Diff line number Diff line change
Expand Up @@ -521,3 +521,6 @@ msgstr "Przeczytałem(-am) i akceptuję @link"

msgid "data protection terms"
msgstr "warunki ochrony danych"

msgid "Highlighted"
msgstr "Na pierwszym planie"
3 changes: 3 additions & 0 deletions modules/oe_theme_helper/translations/oe_theme_helper-pt-pt.po
Original file line number Diff line number Diff line change
Expand Up @@ -521,3 +521,6 @@ msgstr "Li e concordo com as @link"

msgid "data protection terms"
msgstr "condições aplicáveis em matéria de proteção de dados"

msgid "Highlighted"
msgstr "Em destaque"
3 changes: 3 additions & 0 deletions modules/oe_theme_helper/translations/oe_theme_helper-ro.po
Original file line number Diff line number Diff line change
Expand Up @@ -521,3 +521,6 @@ msgstr "Am citit și sunt de acord cu @link"

msgid "data protection terms"
msgstr "prevederile referitoare la protecția datelor"

msgid "Highlighted"
msgstr "În prim-plan"
3 changes: 3 additions & 0 deletions modules/oe_theme_helper/translations/oe_theme_helper-sk.po
Original file line number Diff line number Diff line change
Expand Up @@ -521,3 +521,6 @@ msgstr "Prečítal/a som si podmienky @link a súhlasím s nimi"

msgid "data protection terms"
msgstr "ochrany údajov"

msgid "Highlighted"
msgstr "Hlavné témy"
3 changes: 3 additions & 0 deletions modules/oe_theme_helper/translations/oe_theme_helper-sl.po
Original file line number Diff line number Diff line change
Expand Up @@ -521,3 +521,6 @@ msgstr "Prebral/-a sem pogoje o @link in se strinjam z njimi"

msgid "data protection terms"
msgstr "varstvu podatkov"

msgid "Highlighted"
msgstr "Izpostavljeno"
3 changes: 3 additions & 0 deletions modules/oe_theme_helper/translations/oe_theme_helper-sv.po
Original file line number Diff line number Diff line change
Expand Up @@ -521,3 +521,6 @@ msgstr "Jag har läst och godkänner villkoren för @link"

msgid "data protection terms"
msgstr "skydd av personuppgifter"

msgid "Highlighted"
msgstr "I fokus"
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"@ecl/twig-component-inpage-navigation": "3.1.2",
"@ecl/twig-component-language-list": "3.1.2",
"@ecl/twig-component-link": "3.1.2",
"@ecl/twig-component-label": "3.1.2",
"@ecl/twig-component-media-container": "3.1.2",
"@ecl/twig-component-menu": "3.1.2",
"@ecl/twig-component-message": "3.1.2",
Expand Down
7 changes: 3 additions & 4 deletions templates/content/node--oe-call-proposals--teaser.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,17 @@
* Teaser template implementation for "Call for proposals" content type.
*/
#}
{% set meta = [
content.extra_field_oe_call_proposals_label_status|field_value,
] %}
{% set additional_information = [
content.group_details,
] %}
{# Add cache info from status field. #}
{% set bubble_cache = content.extra_field_oe_call_proposals_label_status|render %}
{% block content %}
{{ pattern('list_item', {
'variant': 'default',
'url': url,
'title': content.extra_field_oe_theme_helper_short_title_with_fallback|field_value,
'meta': meta,
'additional_information': additional_information,
'badges': badges,
}) }}
{% endblock %}
7 changes: 3 additions & 4 deletions templates/content/node--oe-call-tenders--teaser.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,17 @@
* Teaser template implementtion for "Call for tenders" content type.
*/
#}
{% set meta = [
content.extra_field_oe_call_tenders_label_status|field_value,
] %}
{% set additional_information = [
content.group_details,
] %}
{# Add cache info from status field. #}
{% set bubble_cache = content.extra_field_oe_call_tenders_label_status|render %}
{% block content %}
{{ pattern('list_item', {
'variant': 'default',
'url': url,
'title': content.extra_field_oe_theme_helper_short_title_with_fallback|field_value,
'meta': meta,
'additional_information': additional_information,
'badges': badges,
}) }}
{% endblock %}
8 changes: 4 additions & 4 deletions templates/content/node--oe-consultation--teaser.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
{% set additional_information = [
content.group_details,
] %}
{# Add cache info from status field. #}
{% set bubble_cache = content.extra_field_oe_consultation_label_status|render %}
{% block content %}
{{ pattern('list_item', {
'variant': 'default',
'url': url,
'title': content.extra_field_oe_theme_helper_short_title_with_fallback|field_value,
'meta': [
content.extra_field_oe_consultation_label_status|field_value,
],
'additional_information': additional_information
'additional_information': additional_information,
'badges': badges,
}) }}
{% endblock %}
4 changes: 2 additions & 2 deletions templates/content/node--oe-event--teaser.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
{% if status == 'past' or status == 'cancelled' or status == 'ongoing' %}
{% set variant = 'date_' ~ status %}
{% endif %}
{% set meta = content.extra_field_oe_theme_content_event_teaser_meta|field_value %}
{% set detail = content.extra_field_oe_theme_content_event_teaser_details %}
{% set additional_information = [] %}
{% block content %}
Expand All @@ -18,8 +17,9 @@
'url': url,
'title': content.extra_field_oe_theme_helper_short_title_with_fallback|field_value,
'date': pattern_date,
'meta': meta,
'meta': content.extra_field_oe_theme_content_event_teaser_meta|field_value,
'detail': detail,
'additional_information': additional_information,
'badges': badges,
}) }}
{% endblock %}
1 change: 1 addition & 0 deletions templates/content/node--oe-news--teaser.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
'detail': detail,
'image': image_url ? { 'src': image_url },
'additional_information': additional_information,
'badges': badges,
}) }}
{% endblock %}
{% endspaceless %}
3 changes: 2 additions & 1 deletion templates/content/node--oe-organisation--teaser.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
'title': content.extra_field_oe_theme_helper_short_title_with_fallback|field_value,
'detail': content.oe_teaser|field_value,
'additional_information': additional_information,
'image': image_url ? { 'src': image_url }
'image': image_url ? { 'src': image_url },
'badges': badges,
}) }}
{% endblock %}
3 changes: 2 additions & 1 deletion templates/content/node--oe-page--teaser.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
'url': url,
'title': content.extra_field_oe_theme_helper_short_title_with_fallback|field_value,
'detail': content.oe_teaser|field_value,
'additional_information': additional_information|default([])
'additional_information': additional_information|default([]),
'badges': badges,
}) }}
{% endblock %}
Loading

0 comments on commit 4d2c9e5

Please sign in to comment.