Skip to content

Commit

Permalink
Merge pull request #844 from City-of-Helsinki/UHF-11235
Browse files Browse the repository at this point in the history
UHF-11235: Events near you page
  • Loading branch information
jeremysteerio authored Feb 10, 2025
2 parents e701749 + 86a37be commit 5e5a931
Show file tree
Hide file tree
Showing 15 changed files with 288 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
uuid: e100646b-2af9-4b0d-ae6e-d2b74498f2fc
langcode: en
status: true
dependencies:
module:
- helfi_etusivu
- system
theme:
- hdbt_subtheme
id: hdbt_subtheme_helsinkinearyoueventsheroblock
theme: hdbt_subtheme
region: before_content
weight: 0
provider: null
plugin: helsinki_near_you_events_hero_block
settings:
id: helsinki_near_you_events_hero_block
label: 'Helsinki near you events hero block'
label_display: '0'
provider: helfi_etusivu
visibility:
request_path:
id: request_path
negate: false
pages: "/helsinki-near-you/events\r\n/helsinki-lahellasi/tapahtumat\r\n/helsingfors-nara-dig/utbildningar"
21 changes: 21 additions & 0 deletions public/modules/custom/helfi_etusivu/helfi_etusivu.install
Original file line number Diff line number Diff line change
Expand Up @@ -314,3 +314,24 @@ function helfi_etusivu_update_9013(): void {
}
}
}

/**
* UHF-11235: Add events landing page to helsinki-near-you.
*/
function helfi_etusivu_update_9014(): void {
$paths = [
[
'path' => '/helsinki-near-you/events',
'alias' => '/helsinki-lahellasi/tapahtumat',
'langcode' => 'fi',
],
[
'path' => '/helsinki-near-you/events',
'alias' => '/helsingfors-nara-dig/utbildningar',
'langcode' => 'sv',
],
];
foreach ($paths as $path) {
PathAlias::create($path)->save();
}
}
27 changes: 24 additions & 3 deletions public/modules/custom/helfi_etusivu/helfi_etusivu.module
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,13 @@ function helfi_etusivu_helfi_hero_design_alter(array &$designs, FieldStorageDefi
function helfi_etusivu_preprocess_html(&$variables): void {
$route = \Drupal::routeMatch()->getRouteName();

// Set the theme color to suomenlinna on Helsinki near you landing page.
if ($route === 'helfi_etusivu.helsinki_near_you') {
// Set the theme color to suomenlinna on Helsinki near you landing pages.
$near_you_pages = [
'helfi_etusivu.helsinki_near_you',
'helfi_etusivu.helsinki_near_you_events',
];

if (in_array($route, $near_you_pages)) {
$variables['theme_color'] = 'suomenlinna';
}
}
Expand All @@ -256,9 +261,14 @@ function helfi_etusivu_preprocess_html(&$variables): void {
function helfi_etusivu_preprocess_page(&$variables): void {
$route = \Drupal::routeMatch()->getRouteName();

$near_you_pages = [
'helfi_etusivu.helsinki_near_you',
'helfi_etusivu.helsinki_near_you_events',
];

// There is hero block on Helsinki near you landing page but
// since it isn't a paragraph we must set this variable manually.
if ($route === 'helfi_etusivu.helsinki_near_you') {
if (in_array($route, $near_you_pages)) {
$variables['has_hero'] = TRUE;
}

Expand Down Expand Up @@ -347,6 +357,17 @@ function helfi_etusivu_theme() : array {
],
'template' => 'helsinki-near-you-hero-block',
],
'helsinki_near_you_events' => [
'variables' => [],
'template' => 'helsinki-near-you-events',
],
'helsinki_near_you_events_hero_block' => [
'variables' => [
'hero_title' => NULL,
'hero_description' => NULL,
],
'template' => 'helsinki-near-you-events-hero-block',
],
];
}

Expand Down
8 changes: 8 additions & 0 deletions public/modules/custom/helfi_etusivu/helfi_etusivu.routing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,11 @@ helfi_etusivu.helsinki_near_you_autocomplete:
_controller: '\Drupal\helfi_etusivu\Controller\HelsinkiNearYouResultsController::addressSuggestions'
requirements:
_role: 'authenticated'

helfi_etusivu.helsinki_near_you_events:
path: '/helsinki-near-you/events'
defaults:
_controller: '\Drupal\helfi_etusivu\Controller\HelsinkiNearYouEventsController::content'
_title: 'Events near you'
requirements:
_role: 'authenticated'
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?php

declare(strict_types=1);

namespace Drupal\helfi_etusivu\Controller;

use Drupal\Core\Controller\ControllerBase;
use Drupal\helfi_react_search\LinkedEvents;

/**
* Events near you landing page controller.
*/
class HelsinkiNearYouEventsController extends ControllerBase {

/**
* Constructs a new instance.
*/
public function __construct(protected readonly LinkedEvents $linkedEvents) {
}

/**
* Returns a renderable array.
*/
public function content() : array {
$events_url = $this->linkedEvents->getEventsRequest();

return [
'#attached' => [
'drupalSettings' => [
'helfi_events' => [
'baseUrl' => LinkedEvents::BASE_URL,
'data' => [
'helfi-coordinates-based-event-list' => [
'events_api_url' => $events_url,
'field_event_count' => 10,
'field_event_location' => TRUE,
'field_event_time' => TRUE,
'field_free_events' => TRUE,
'field_remote_events' => TRUE,
'places' => $this->linkedEvents->getPlacesList($events_url),
'hideHeading' => TRUE,
'useFullLocationFilter' => TRUE,
'useFullTopicsFilter' => TRUE,
'useLocationSearch' => TRUE,
],
],
'seeAllButtonOverride' => $this->t(
'Search for more events on the Events website',
[],
['context' => 'Helsinki near you events search']
),
'useExperimentalGhosts' => TRUE,
],
],
],
'#theme' => 'helsinki_near_you_events',
'#title' => $this->t('Events near you', [], ['context' => 'Helsinki near you']),
];
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ public function content(Request $request) : array|RedirectResponse {
];
$newsArchiveUrl = $this->getInternalSearchLink(InternalSearchLink::NEWS_ARCHIVE, $newsQuery);

$eventsNearYouRoute = Url::fromRoute('helfi_etusivu.helsinki_near_you_events', [], [
'query' => [
'address' => $addressName,
],
]);

return [
'#attached' => [
'drupalSettings' => [
Expand All @@ -87,9 +93,10 @@ public function content(Request $request) : array|RedirectResponse {
'dwithin_metres' => 2000,
]),
'field_event_count' => 3,
'hidePagination' => TRUE,
],
],
'seeAllButtonOverride' => $this->t('See all events', [], ['context' => 'Helsinki near you']),
'seeAllNearYouLink' => $eventsNearYouRoute->toString(),
'useExperimentalGhosts' => TRUE,
],
'helfi_news_archive' => [
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

declare(strict_types=1);

namespace Drupal\helfi_etusivu\Plugin\Block;

use Drupal\Core\Block\Attribute\Block;
use Drupal\Core\Block\BlockBase;
use Drupal\Core\StringTranslation\TranslatableMarkup;

/**
* Provides a 'HelsinkiNearYouEventsHeroBlock' block.
*/
#[Block(
id: "helsinki_near_you_events_hero_block",
admin_label: new TranslatableMarkup("Helsinki near you events hero block"),
)]
final class HelsinkiNearYouEventsHeroBlock extends BlockBase {

/**
* {@inheritdoc}
*/
public function build() : array {
$build['helsinki_near_you_hero_block'] = [
'#theme' => 'helsinki_near_you_events_hero_block',
'#hero_title' => $this->t('Events near you', [], ['context' => 'Helsinki near you']),
'#hero_description' => $this->t('Find events in your neighbourhood that interest you.', [], ['context' => 'Helsinki near you events search']),
];
return $build;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{% embed '@hdbt/component/hero.twig' with {
design: 'with-helsinki-near-you',
title: hero_title,
description: hero_description,
} %}
{% endembed %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<article>
<div class="components components--computed components--helsinki-near-you-events">
{% embed "@hdbt/misc/component.twig" with
{
component_classes: [
'component--react-search',
'component--event-list',
'component--full-width',
],
component_title: 'Find events near you'|t({}, {'context': 'Helsinki near you events search'}),
component_description: 'Browse events near you or search for events by theme, location or date.'|t({}, {'context': 'Helsinki near you events search'}),
}
%}
{% block component_content %}
{# Hook React app to this div #}
{{ attach_library('hdbt/event-list') }}
<div
id="helfi-events-search"
data-paragraph-id="helfi-coordinates-based-event-list"
>
</div>
{# Indicate JS not enabled #}
<noscript>
<div class="event-list__javascript-disabled">
{{ 'You must enable JavaScript in your browser for event list to work'|t }}
</div>
</noscript>
{% endblock %}
{% endembed %}
</div>
</article>
31 changes: 31 additions & 0 deletions public/modules/custom/helfi_etusivu/translations/fi.po
Original file line number Diff line number Diff line change
Expand Up @@ -200,3 +200,34 @@ msgstr "Katu- ja puistohankkeet lähellä osoitetta @address"
msgctxt "Helsinki near you address label"
msgid "Plans under preparation near the address @address"
msgstr "Valmisteilla olevat kaavat lähellä osoitetta @address"

msgctxt "Helsinki near you events search"
msgid "For example, Kotikatu 1"
msgstr "Esim. Kotikatu 1"

msgctxt "Helsinki near you events search"
msgid "Find events near you"
msgstr "Etsi tapahtumia lähelläsi"

msgctxt "Helsinki near you events search"
msgid "Browse events near you or search for events by theme, location or date."
msgstr "Voit selata lähialueesi tapahtumia tai etsiä tapahtumia aiheen, tapahtumapaikan tai ajankohdan mukaan."

msgctxt "Helsinki near you events search"
msgid "Find events in your neighbourhood that interest you."
msgstr "Löydä sinua kiinnostavat tapahtumat lähialueeltasi."

msgctxt "Helsinki near you events search"
msgid "Search for more events on the Events website"
msgstr "Etsi lisää tapahtumia Tapahtumat-sivustolta"

msgctxt "Helsinki near you events search"
msgid "See all events near you"
msgstr "Katso kaikki tapahtumat lähelläsi"

msgctxt "Helsinki near you events search"
msgid "Start by searching with your address."
msgstr "Aloita kirjoittamalla osoitteesi."

msgid "Events near you"
msgstr "Tapahtumat lähelläsi"
31 changes: 31 additions & 0 deletions public/modules/custom/helfi_etusivu/translations/sv.po
Original file line number Diff line number Diff line change
Expand Up @@ -189,3 +189,34 @@ msgstr "Gatu- och parkprojekt nära adressen @address"
msgctxt "Helsinki near you address label"
msgid "Plans under preparation near the address @address"
msgstr "Detaljplaner under beredning nära adressen @address"

msgctxt "Helsinki near you events search"
msgid "For example, Kotikatu 1"
msgstr "T.ex. Hemgatan 1"

msgctxt "Helsinki near you events search"
msgid "Find events near you"
msgstr "Sök evenemang nära dig"

msgctxt "Helsinki near you events search"
msgid "Browse events near you or search for events by theme, location or date."
msgstr "Du kan bläddra i evenemang nära dig eller söka evenemang enligt tema, plats eller tidpunkt."

msgctxt "Helsinki near you events search"
msgid "Find events in your neighbourhood that interest you."
msgstr "Hitta intressanta evenemang nära dig."

msgctxt "Helsinki near you events search"
msgid "Search for more events on the Events website"
msgstr "Sök fler evenemang på webbplatsen Evenemang"

msgctxt "Helsinki near you events search"
msgid "See all events near you"
msgstr "Se alla evenemang nära dig"

msgctxt "Helsinki near you events search"
msgid "Start by searching with your address."
msgstr "Börja med att söka med din adress."

msgid "Events near you"
msgstr "Evenemang nära dig"

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ a11y_autocomplete:
helfi_etusivu_autocomplete:
js:
dist/js/autocomplete.min.js: {}
version: 1.0.1
version: 1.0.2
dependencies:
- hdbt_subtheme/a11y_autocomplete
- core/drupal
Expand Down
12 changes: 6 additions & 6 deletions public/themes/custom/hdbt_subtheme/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions public/themes/custom/hdbt_subtheme/src/js/autocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
} = drupalSettings.helsinki_near_you_form;

A11yAutocomplete(element, {
allowRepeatValues: true,
classes: {
wrapper: 'helfi-etusivu-autocomplete'
},
Expand All @@ -54,6 +55,7 @@
inputAssistiveHint,
noResultsAssistiveHint,
someResultsAssistiveHint,
sort: false,
oneResultAssistiveHint,
highlightedAssistiveHint,
});
Expand Down

0 comments on commit 5e5a931

Please sign in to comment.