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 #1272 from ec-europa/ISAICP-4618
Browse files Browse the repository at this point in the history
ISAICP-4618: Allow tallinn report tiles to display a 'Last update' property.
  • Loading branch information
brummbar authored Jul 4, 2018
2 parents 28a64ef + 16246b0 commit 2a15bd5
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 4 deletions.
28 changes: 28 additions & 0 deletions tests/features/communities/tallinn/last_update.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
@api @tallinn
Feature:
As a moderator of Joinup
I want to be able to be aware when was the last update time of a tallinn report.

Background:
Given users:
| Username | Roles |
| karma | moderator |

Scenario: Tallinn reports that have never been updated should not show last update date.
Given tallinn_report content:
| title | collection | created | changed |
| Romania Report | Tallinn Ministerial Declaration | 02-07-2018 | 02-07-2018 |
When I am logged in as "karma"
And I go to the "Tallinn Ministerial Declaration" collection
And I click "Tallinn initiative" in the "Left sidebar" region
Then I should see the text "Last update: -" in the "Romania Report" tile
And I should not see the text "02/07/2018" in the "Romania Report" tile

Scenario: Tallinn reports that have been updated should show last update date.
Given tallinn_report content:
| title | collection | created | changed |
| Romania Report | Tallinn Ministerial Declaration | 01-07-2018 | 02-07-2018 |
When I am logged in as "karma"
And I go to the "Tallinn Ministerial Declaration" collection
And I click "Tallinn initiative" in the "Left sidebar" region
Then I should see the text "Last update: 02/07/2018" in the "Romania Report" tile
13 changes: 13 additions & 0 deletions web/themes/joinup/joinup_theme.theme
Original file line number Diff line number Diff line change
Expand Up @@ -1525,6 +1525,19 @@ function joinup_theme_preprocess_node__event__listing_item(&$variables) {
}
}

/**
* Implements hook_preprocess_HOOK() for node--tallinn-report--listing-item.html.twig.
*/
function joinup_theme_preprocess_node__tallinn_report__listing_item(&$variables) {
/** @var \Drupal\node\NodeInterface $node */
$node = $variables['node'];
$variables['last_update']['#markup'] = '-';
if (!$node->get('created')->equals($node->get('changed'))) {
$date = \Drupal::service('date.formatter')->format($node->getChangedTime(), 'custom', 'd/m/Y');
$variables['last_update'] = $date;
}
}

/**
* Implements hook_form_FORM_ID_alter().
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,11 @@
<h2 class="listing__title"><a href="{{ url }}">{{ label }}</a></h2>
{{ title_suffix }}
<h5 class="listing__subtitle listing__author">{{ author_name|striptags }}</h5>
<h5 class="listing__subtitle listing__date">{{ created }}</h5>
<h5 class="listing__subtitle listing__date">{{ "Last update"|t }}: {{ last_update }}</h5>
</div>
<div class="listing__field">
<p class="listing__teaser">{{ content.body|render|striptags('<a>')|raw }}</p>
</div>
{% if content.field_keywords|render %}
<div class="listing__field listing__tags">{{ content.field_keywords }}</div>
{% endif %}
<div class="listing__field listing__stats mdl-card__actions">
<div class="listing__stat">
<span class="listing__text">{{ node.type.entity.label|lower }}</span>
Expand Down

0 comments on commit 2a15bd5

Please sign in to comment.