Skip to content

Commit

Permalink
Merge pull request #712 from City-of-Helsinki/UHF-8442_hearing_paragraph
Browse files Browse the repository at this point in the history
UHF-8442 Hearing paragraph
  • Loading branch information
rpnykanen authored Aug 30, 2023
2 parents 7e26c93 + d1a168e commit 8c2b38e
Show file tree
Hide file tree
Showing 9 changed files with 293 additions and 3 deletions.
2 changes: 1 addition & 1 deletion dist/css/styles.min.css

Large diffs are not rendered by default.

35 changes: 35 additions & 0 deletions hdbt.theme
Original file line number Diff line number Diff line change
Expand Up @@ -1696,3 +1696,38 @@ function hdbt_preprocess_paragraph__job_search(array &$variables) {

$variables['#attached']['library'][] = 'hdbt/job-search';
}

/**
* Implements hook_preprocess_HOOK().
*/
function hdbt_preprocess_external_entity__helfi_hearings(array &$variables) {
$language = \Drupal::languageManager()
->getCurrentLanguage(LanguageInterface::TYPE_CONTENT)
->getId();
$entity = $variables['external_entity'];
$hearingLangcode = $entity->get('langcode')->value;
if ($hearingLangcode && $hearingLangcode == $language) {
return;
}
$existingLanguages = explode(',', $entity->get('existing_translations')->value);

if (in_array("fi", $existingLanguages) && in_array("en", $existingLanguages) && count($existingLanguages) === 2) {
$variables['available_in_languages'] = t('Hearing only available in Finnish and English', [], ['context' => 'Hearing available in languages']);
}
if (in_array("fi", $existingLanguages) && in_array("sv", $existingLanguages) && count($existingLanguages) === 2) {
$variables['available_in_languages'] = t('Hearing only available in Finnish and Swedish', [], ['context' => 'Hearing available in languages']);
}
if (in_array("en", $existingLanguages) && in_array("sv", $existingLanguages) && count($existingLanguages) === 2) {
$variables['available_in_languages'] = t('Hearing only available in English and Swedish', [], ['context' => 'Hearing available in languages']);
}
if (in_array("fi", $existingLanguages) && count($existingLanguages) === 1) {
$variables['available_in_languages'] = t('Hearing only available in Finnish', [], ['context' => 'Hearing available in languages']);
}
if (in_array("en", $existingLanguages) && count($existingLanguages) === 1) {
$variables['available_in_languages'] = t('Hearing only available in English', [], ['context' => 'Hearing available in languages']);
}
if (in_array("sv", $existingLanguages) && count($existingLanguages) === 1) {
$variables['available_in_languages'] = t('Hearing only available in Swedish', [], ['context' => 'Hearing available in languages']);
}

}
1 change: 1 addition & 0 deletions src/scss/06_components/paragraphs/__index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
@import 'content-liftup';
@import 'district-and-project-search';
@import 'event-list';
@import 'hearings';
@import 'hero';
@import 'image';
@import 'liftup-with-image';
Expand Down
26 changes: 26 additions & 0 deletions src/scss/06_components/paragraphs/_hearings.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
.component--hearings {
background: $color-silver-light;
}

.component--hearings .component__container {
padding-bottom: $spacing-double;
padding-top: $spacing-double;

@include breakpoint($breakpoint-m) {
padding-bottom: $spacing-quadruple;
padding-top: $spacing-quadruple;
}
}

.hearings__count-container {
@include font('small');
margin-bottom: $spacing;

.hearings__count {
font-weight: $font-weight-bold;
}
}

.hearings__results {
margin-bottom: $spacing-double;
}
5 changes: 3 additions & 2 deletions templates/component/card.twig
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
card_modifier_class: 'card--cardtype',
card_image: card_image,
card_title_level: 'h3',
card_title_lang: 'fi',
card_title: 'Otsikko',
card_url: 'https://www.hel.fi/fi/',
card_url_external: false,
Expand Down Expand Up @@ -49,8 +50,8 @@
{% endif %}

<div class="card__text">
<{{ card_title_level|default('h3') }} class="card__title">
{{ link(card_title, card_url, { 'class':['card__link'], 'rel':'bookmark' }) }}
<{{ card_title_level|default('h3') }} class="card__title" {% if card_title_lang %}lang="{{ card_title_lang }}"{% endif %}>
{{ link(card_title, card_url, { 'class':['card__link'], 'rel':'bookmark' }) }}
</{{ card_title_level|default('h3') }}>

{% if card_category_tag %}
Expand Down
80 changes: 80 additions & 0 deletions templates/content/external-entity--helfi-hearings.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
{% set card_hearing_classes = ['card--hearing'] %}

{% if content.comments[0]['#context'].value == '1' %}
{% set card_hearing_comments = content.comments[0]['#context'].value ~ ' ' ~ 'comment'|t({}, {'context': 'Hearing activity suffix singular'}) %}
{% else %}
{% set card_hearing_comments = content.comments[0]['#context'].value ~ ' ' ~ 'comments'|t({}, {'context': 'Hearing activity suffix plural'}) %}
{% endif %}

{% if content.open_at[0]['#context'].value is not empty %}
{% set card_published_on = content.open_at[0]['#context'].value|date('j.n.Y') %}
{% else %}
{% set card_published_on = '-' %}
{% endif %}

{% if content.close_at[0]['#context'].value is not empty %}
{% set card_unpublished_on = content.close_at[0]['#context'].value|date('j.n.Y') ~ ' ' ~ 'at'|t({}, {'context': 'Word in between hearing unpublished date and time'}) ~ ' ' ~ node.unpublish_on.value|date('H:i') %}
{% else %}
{% set card_unpublished_on = '-' %}
{% endif %}

{% if available_in_languages %}
{% embed '@hdbt/component/card.twig' with {
card_modifier_class: card_hearing_classes|join(' '),
card_title: content.title[0]['#context'].value,
card_title_lang: content.langcode[0]['#context'].value,
card_image: content.main_image,
card_url: content.url[0]['#context'].value,
card_url_external: true,
card_metas: [
{
icon: 'clock',
label: 'Opened'|t({}, {'context': 'Label for hearing opened date'}),
content: card_published_on,
},
{
icon: 'clock',
label: 'Closes'|t({}, {'context': 'Label for hearing closes date'}),
content: card_unpublished_on,
},
{
icon: 'speechbubble-text',
label: 'Activity'|t({}, {'context': 'Label for hearing activity row'}),
content: card_hearing_comments,
},
],
card_tags: [
{
tag: available_in_languages,
color: 'alert',
}
],
} %}
{% endembed %}
{% else %}
{% embed '@hdbt/component/card.twig' with {
card_modifier_class: card_hearing_classes|join(' '),
card_title: content.title[0]['#context'].value,
card_image: content.main_image,
card_url: content.url[0]['#context'].value,
card_url_external: true,
card_metas: [
{
icon: 'clock',
label: 'Opened'|t({}, {'context': 'Label for hearing opened date'}),
content: card_published_on,
},
{
icon: 'clock',
label: 'Closes'|t({}, {'context': 'Label for hearing closes date'}),
content: card_unpublished_on,
},
{
icon: 'speechbubble-text',
label: 'Activity'|t({}, {'context': 'Label for hearing activity row'}),
content: card_hearing_comments,
},
]
} %}
{% endembed %}
{% endif %}
47 changes: 47 additions & 0 deletions templates/paragraphs/paragraph--hearings.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{% block paragraph %}

{% embed "@hdbt/misc/component.twig" with
{
component_classes: [
'component--hearings',
],
component_title_level: 'h2',
component_title: content.field_hearings_title,
component_description: content.field_hearings_description,
component_content_class: 'hearings',
}
%}
{% block component_content %}
{% if content.list %}
{% set hearings_count = content.list[0]['#helfi_hearings'].get('count')[0].value %}
<section class="hearings__results">
<div class="hearings__count-container">
<span class="hearings__count">{{ hearings_count }}</span>
{% trans with {'context': 'Hearings count'}%}plan open for commenting{% plural hearings_count %}plans open for commenting{% endtrans %}
</div>
{{ content.list }}
</section>
{% include '@hdbt/navigation/link-button.html.twig' with {
type: 'primary',
label: 'See all plans'|t({},{'context': 'See all plans link text'}),
url: 'https://kerrokantasi.hel.fi/hearings/list?lang=' ~ current_langcode,
class: 'hearings__link',
is_external: true,
open_in_a_new_window: true,
} %}
{% else %}
<section class="hearings__results">
<p>{{ "At the moment there is no open hearings for commenting."|t }}</p>
</section>
{% include '@hdbt/navigation/link-button.html.twig' with {
type: 'primary',
label: 'See all already closed plans'|t({},{'context': 'See closed plans link text'}),
url: 'https://kerrokantasi.hel.fi/hearings/list?lang=' ~ current_langcode,
class: 'hearings__link',
is_external: true,
open_in_a_new_window: true,
} %}
{% endif %}
{% endblock component_content %}
{% endembed %}
{% endblock paragraph %}
53 changes: 53 additions & 0 deletions translations/fi.po
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,56 @@ msgctxt "District and project search"
msgid "Our website currently shows only some of the projects and residential areas of Helsinki. You can try again by removing some of the limiting search terms or by starting over."
msgstr "Sivuillamme esitetään toistaiseksi vain osa Helsingin hankkeista ja asuinalueista. Voit kokeilla uudestaan poistamalla jonkin rajausehdoista tai aloittamalla alusta."

msgctxt "Hearing activity suffix singular"
msgid "comment"
msgstr "kommentti"

msgctxt "Hearing activity suffix plural"
msgid "comments"
msgstr "kommenttia"

msgctxt "Word in between hearing unpublished date and time"
msgid "at"
msgstr "klo"

msgctxt "Label for hearing opened date"
msgid "Opened"
msgstr "Avautui"

msgctxt "Label for hearing closes date"
msgid "Closes"
msgstr "Sulkeutuu"

msgctxt "Label for hearing activity row"
msgid "Activity"
msgstr "Aktiivisuus"

msgctxt "Hearings count"
msgid "plan open for commenting"
msgid_plural "plans open for commenting"
msgstr[0] "suunnitelma avoinna kommentoitavaksi"
msgstr[1] "suunnitelmaa avoinna kommentoitavaksi"

msgctxt "See all plans link text"
msgid "See all plans"
msgstr "Katso kaikki suunnitelmat"

msgctxt "See closed plans link text"
msgid "See all already closed plans"
msgstr "Katso jo sulkeutuneet suunnitelmat"

msgctxt "Hearing available in languages"
msgid "Hearing only available in English"
msgstr "Kommentoitavissa vain englanniksi"

msgctxt "Hearing available in languages"
msgid "Hearing only available in Swedish"
msgstr "Kommentoitavissa vain ruotsiksi"

msgctxt "Hearing available in languages"
msgid "Hearing only available in English and Swedish"
msgstr "Kommentoitavissa vain englanniksi ja ruotsiksi"

msgctxt "News archive filter results heading"
msgid "Filter news items"
msgstr "Suodata uutisia"
Expand Down Expand Up @@ -632,6 +682,9 @@ msgctxt "News RSS feed subscribe link"
msgid "Subscribe to RSS feed of news based on your choices"
msgstr "Tilaa uutisten RSS-syöte valintojesi perusteella"

msgid "At the moment there is no open hearings for commenting."
msgstr "Tällä hetkellä ei ole avoimia suunnitelmia kommentoitavaksi."

msgctxt "React search clear selection label"
msgid "Clear @label selection"
msgstr "Tyhjennä @label valinnat"
47 changes: 47 additions & 0 deletions translations/sv.po
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,50 @@ msgctxt "District and project search"
msgid "Our website currently shows only some of the projects and residential areas of Helsinki. You can try again by removing some of the limiting search terms or by starting over."
msgstr "På vår webbplats finns för närvarande endast en del av Helsingfors projekt och bostadsområden. Du kan försöka på nytt genom att ta bort något av avgränsningsvillkoren eller genom att börja om från början."

msgctxt "Hearing activity suffix singular"
msgid "comment"
msgstr "kommentar"

msgctxt "Hearing activity suffix plural"
msgid "comments"
msgstr "kommentar"

msgctxt "Word in between hearing unpublished date and time"
msgid "at"
msgstr "på"

msgctxt "Label for hearing opened date"
msgid "Opened"
msgstr "Öppnades"

msgctxt "Label for hearing closes date"
msgid "Closes"
msgstr "Stängs"

msgctxt "Label for hearing activity row"
msgid "Activity"
msgstr "Aktivitet"

msgctxt "See all plans link text"
msgid "See all plans"
msgstr "Se alla planer"

msgctxt "See closed plans link text"
msgid "See all already closed plans"
msgstr "Se alla redan stängda planer"

msgctxt "Hearing available in languages"
msgid "Hearing only available in English"
msgstr "Hörandet finns endast på engelska"

msgctxt "Hearing available in languages"
msgid "Hearing only available in Finnish"
msgstr "Hörandet finns endast på finska"

msgctxt "Hearing available in languages"
msgid "Hearing only available in English and Finnish"
msgstr "Hörandet finns endast på engelska och finska"

msgctxt "News archive filter results heading"
msgid "Filter news items"
msgstr "Filtera nyheter"
Expand Down Expand Up @@ -630,6 +674,9 @@ msgctxt "News RSS feed subscribe link"
msgid "Subscribe to RSS feed of news based on your choices"
msgstr "Prenumerera på RSS-flöde med nyheter baserat på dina val"

msgid "At the moment there is no open hearings for commenting."
msgstr "För närvarande finns det inga öppna planer för kommentarer."

msgctxt "React search clear selection label"
msgid "Clear @label selection"
msgstr "Rensa alla @label"

0 comments on commit 8c2b38e

Please sign in to comment.