diff --git a/helfi_features/helfi_events/assets/js/eventList.js b/helfi_features/helfi_events/assets/js/eventList.js
deleted file mode 100644
index f42171d6e..000000000
--- a/helfi_features/helfi_events/assets/js/eventList.js
+++ /dev/null
@@ -1,182 +0,0 @@
-'use strict';
-
-(function ($) {
- Drupal.behaviors.events_list = {
- attach: function attach(context, settings) {
- if(settings.helfi_events.eventsUrl) {
- Drupal.behaviors.events_list.getEvents(settings.helfi_events.eventsUrl, true);
- }
- },
- listToHtml: function listToHtml(list) {
- const currentLanguage = drupalSettings.path.currentLanguage;
- const {
- at,
- events,
- eventKeywords,
- externalLink,
- seeAll
- } = drupalSettings.helfi_events.translations;
-
- // Bail if no current language
- if(!currentLanguage) {
- return;
- }
-
- return list.map(event => {
- // If event name is not in current language, return early
- if(!event.name[currentLanguage]) {
- return;
- }
-
- const startDate = new Date(event.start_time);
- const endDate = new Date(event.end_time);
-
- // Base element for event, wihout text elements from api
- const eventElement = $(`
-
-
-
-
-
-
-
- ${startDate.toLocaleDateString('fi-FI')}, ${at}
- ${startDate.toLocaleTimeString('fi-FI', {hour: '2-digit', minute: '2-digit'})}
- -
- ${endDate.toLocaleTimeString('fi-FI', {hour: '2-digit', minute: '2-digit'})}
-
-
-
-
-
- `);
-
- // Escape and append text content from Api response
- const keywords = event.keywords.map(keyword => {
- if(keyword.name[currentLanguage]) {
- const keywordName = keyword.name[currentLanguage];
- // Api return names sometimes in lowercase, capitalize it here instead of CSS for accessibility
- return $('').text(keywordName.charAt(0).toUpperCase() + keywordName.slice(1));
- }
- });
- if(keywords.length) {
- $(eventElement).find('.event-list__tags').append(keywords);
- }
-
- const eventName = document.createTextNode(event.name[currentLanguage]);
- $(eventElement).find('.event-list__event-link').append(eventName);
-
- // Use first image or fallback to placeholder if no images present
- const imageUrl = (event.images.length && event.images[0].url) ? event.images[0].url : null;
-
- let imageElement;
- if(imageUrl) {
- imageElement = $(``);
-
- // Get image alt text from response or use event name.
- const imageAlt = imageUrl && event.images[0].alt_text ? event.images[0].alt_text : eventName.textContent.trim();
- imageElement.attr('alt', imageAlt);
-
- // If image has photographer data, add it as data-attribute.
- if(event.images[0].photographer_name) {
- imageElement.attr('data-photographer', event.images[0].photographer_name);
- }
- }
- else {
- imageElement = $(drupalSettings.helfi_events.imagePlaceholder).addClass('event-list__event-image');
- }
- $(eventElement).find('.event-list__image-container').append(imageElement);
-
- const location = `${event.location.name[currentLanguage]}${event.location.street_address ? ', ' + event.location.street_address[currentLanguage] : ''}`;
- $(eventElement).find('.event__content--location').append(document.createTextNode(location))
-
- return eventElement;
- });
- },
- getEvents: function getEvents(url, initial = false) {
- const {
- emptyList,
- emptyListSubText,
- eventsCount,
- externalLink,
- loadMore,
- refineSearch,
- } = drupalSettings.helfi_events.translations;
-
- function get404() {
- return $(`
-
-
${emptyList}
-
${emptyListSubText}
-
- `).append(drupalSettings.helfi_events.seeAllButton);
- }
-
- function setLoading(state = false) {
- const progressElement = $('', {class: 'event-list-spinner'}).append($(Drupal.theme('ajaxProgressThrobber')));
-
- if(state === true) {
- $('.event-list__load-more-button').attr('disabled', true);
- $('.event-list__list-container').append(progressElement);
- }
- else {
- $('.event-list__load-more-button').removeAttr('disabled');
- $('.event-list-spinner').remove();
- }
- }
-
- setLoading(true);
-
- const events = fetch(url, {
- method: 'GET',
- headers: {
- 'Content-type': 'application/json'
- }
- })
- .then(res => res.json())
- .then(json => {
- if(json && json.meta.count > 0) {
- $('.event-list__count').html(`${json.meta.count} ${eventsCount}`);
- const listHtml = Drupal.behaviors.events_list.listToHtml(json.data);
- $('.event-list__list-container').append(listHtml);
-
- const next = json.meta.next ?? null;
-
- if(next) {
- if($('.event-list__load-more-button').length) {
- $('.event-list__load-more-button').attr('onClick', Drupal.behaviors.events_list.getEvents(next))
- }
- else if(drupalSettings.helfi_events.loadMore) {
- $('.event-list__load-more').append(`
-
- `
- )
- }
- if(!$('.event-list__refine-button').length) {
- $('.event-list__load-more').append(drupalSettings.helfi_events.refineSearchButton);
- }
- }
- else if($('.event-list__load-more-button').length) {
- $('.event-list__load-more-button').remove();
- }
- }
- else if(initial) {
- $('.event-list__list-container').append(get404());
- }
- })
- .catch(e => console.error(e))
- .finally(() => setLoading(false));
- },
- }
-})(jQuery);
diff --git a/helfi_features/helfi_events/config/install/core.entity_view_display.paragraph.event_list.default.yml b/helfi_features/helfi_events/config/install/core.entity_view_display.paragraph.event_list.default.yml
deleted file mode 100644
index 962395d77..000000000
--- a/helfi_features/helfi_events/config/install/core.entity_view_display.paragraph.event_list.default.yml
+++ /dev/null
@@ -1,35 +0,0 @@
-uuid: f4d6607c-e8dd-4c31-b4c7-1309356cdbf2
-langcode: en
-status: true
-dependencies:
- config:
- - field.field.paragraph.event_list.field_api_url
- - field.field.paragraph.event_list.field_event_list_description
- - field.field.paragraph.event_list.field_event_list_title
- - field.field.paragraph.event_list.field_load_more
- - paragraphs.paragraphs_type.event_list
-_core:
- default_config_hash: nGj1yREuVhXjkThRtA0yqFSF9Z8E6auVFz2kUVTlQgk
-id: paragraph.event_list.default
-targetEntityType: paragraph
-bundle: event_list
-mode: default
-content:
- field_event_list_description:
- type: text_default
- label: hidden
- settings: { }
- third_party_settings: { }
- weight: 1
- region: content
- field_event_list_title:
- type: string
- label: hidden
- settings:
- link_to_entity: false
- third_party_settings: { }
- weight: 0
- region: content
-hidden:
- field_api_url: true
- field_load_more: true
diff --git a/helfi_features/helfi_events/config/install/field.field.paragraph.event_list.field_load_more.yml b/helfi_features/helfi_events/config/install/field.field.paragraph.event_list.field_load_more.yml
deleted file mode 100644
index 9879b90a6..000000000
--- a/helfi_features/helfi_events/config/install/field.field.paragraph.event_list.field_load_more.yml
+++ /dev/null
@@ -1,25 +0,0 @@
-uuid: 25468e03-6f4c-4b5c-b619-f92681a7307e
-langcode: en
-status: true
-dependencies:
- config:
- - field.storage.paragraph.field_load_more
- - paragraphs.paragraphs_type.event_list
-_core:
- default_config_hash: 9sAb-CrCW0-Fv1WhF_uddTaYfoQoQdWp-mLi0Wyc4Zc
-id: paragraph.event_list.field_load_more
-field_name: field_load_more
-entity_type: paragraph
-bundle: event_list
-label: 'Load more'
-description: 'Show load more -button at the bottom of the list.'
-required: false
-translatable: false
-default_value:
- -
- value: 1
-default_value_callback: ''
-settings:
- on_label: Käytössä
- off_label: 'Pois päältä'
-field_type: boolean
diff --git a/helfi_features/helfi_events/config/language/fi/field.field.paragraph.event_list.field_load_more.yml b/helfi_features/helfi_events/config/language/fi/field.field.paragraph.event_list.field_load_more.yml
deleted file mode 100644
index 937a5d9b7..000000000
--- a/helfi_features/helfi_events/config/language/fi/field.field.paragraph.event_list.field_load_more.yml
+++ /dev/null
@@ -1,2 +0,0 @@
-label: 'Lataa lisää'
-description: 'Määrittää, näytetäänkö listauksen lopussa ''Lataa lisää'' -nappi.'
diff --git a/helfi_features/helfi_events/config/update/helfi_events_update_9001.yml b/helfi_features/helfi_events/config/update/helfi_events_update_9001.yml
deleted file mode 100644
index 759901a13..000000000
--- a/helfi_features/helfi_events/config/update/helfi_events_update_9001.yml
+++ /dev/null
@@ -1,36 +0,0 @@
-field.field.node.landing_page.field_content:
- expected_config: { }
- update_actions:
- add:
- settings:
- handler_settings:
- target_bundles:
- event_list: event_list
- target_bundles_drag_drop:
- event_list:
- enabled: true
- weight: 30
-field.field.node.page.field_content:
- expected_config: { }
- update_actions:
- add:
- settings:
- handler_settings:
- target_bundles:
- event_list: event_list
- target_bundles_drag_drop:
- event_list:
- enabled: true
- weight: 30
-field.field.node.page.field_lower_content:
- expected_config: { }
- update_actions:
- add:
- settings:
- handler_settings:
- target_bundles:
- event_list: event_list
- target_bundles_drag_drop:
- event_list:
- enabled: true
- weight: 30
\ No newline at end of file
diff --git a/helfi_features/helfi_events/helfi_events.info.yml b/helfi_features/helfi_events/helfi_events.info.yml
index d75de3326..a033b8a63 100644
--- a/helfi_features/helfi_events/helfi_events.info.yml
+++ b/helfi_features/helfi_events/helfi_events.info.yml
@@ -12,5 +12,3 @@ dependencies:
- 'paragraphs:paragraphs'
- 'update_helper:update_helper'
package: HELfi
-'interface translation project': helfi_events
-'interface translation server pattern': modules/contrib/helfi_platform_config/helfi_features/helfi_events/translations/%language.po
diff --git a/helfi_features/helfi_events/helfi_events.install b/helfi_features/helfi_events/helfi_events.install
index 82cc9420d..d819dc56a 100644
--- a/helfi_features/helfi_events/helfi_events.install
+++ b/helfi_features/helfi_events/helfi_events.install
@@ -46,3 +46,36 @@ function helfi_events_update_9001() {
// Output logged messages to related channel of update execution.
return $updateHelper->logger()->output();
}
+
+/**
+ * Implements hook_uninstall().
+ *
+ * Remove configs.
+ */
+function helfi_events_uninstall() {
+ /** @var \Drupal\Core\Config\ConfigFactoryInterface $configFactory */
+ $configFactory = \Drupal::configFactory();
+ $logger = \Drupal::logger('helfi_events');
+
+ $configNames = [
+ 'core.entity_form_display.paragraph.event_list.default',
+ 'core.entity_view_display.paragraph.event_list.default',
+ 'field.field.paragraph.event_list.field_api_url',
+ 'field.field.paragraph.event_list.field_event_list_description',
+ 'field.field.paragraph.event_list.field_event_list_title',
+ 'field.storage.paragraph.field_api_url',
+ 'field.storage.paragraph.field_event_list_description',
+ 'field.storage.paragraph.field_event_list_title',
+ 'paragraphs.paragraphs_type.event_list'
+ ];
+
+ foreach ($configNames as $configName) {
+ try {
+ $configFactory->getEditable($configName)->delete();
+ }
+ catch (\Exception $e) {
+ $logger->warning(sprintf('Unable to uninstall config: %s.', $configName));
+ }
+ }
+
+}
diff --git a/helfi_features/helfi_events/helfi_events.libraries.yml b/helfi_features/helfi_events/helfi_events.libraries.yml
deleted file mode 100644
index eebc25a1e..000000000
--- a/helfi_features/helfi_events/helfi_events.libraries.yml
+++ /dev/null
@@ -1,8 +0,0 @@
-events_list:
- version: 1.x
- js:
- assets/js/eventList.js: {}
- dependencies:
- - core/drupalSettings
- - core/jquery
- - core/drupal
diff --git a/helfi_features/helfi_events/helfi_events.module b/helfi_features/helfi_events/helfi_events.module
deleted file mode 100644
index 612e9a6f1..000000000
--- a/helfi_features/helfi_events/helfi_events.module
+++ /dev/null
@@ -1,83 +0,0 @@
-get('field_api_url')->isEmpty()) {
- $intialUrl = $paragraph->get('field_api_url')->first()->getUrl()->toString();
- $params = $linkedEvents->parseParams($intialUrl);
- $variables['#attached']['drupalSettings']['helfi_events']['eventsUrl'] = $linkedEvents->getEventsRequest($params);
-
- // Render link for refiging serach in events service for use in frontend
- $variables['#attached']['drupalSettings']['helfi_events']['refineSearchButton'] = twig_render_template(
- drupal_get_path('theme', 'hdbt') . '/templates/navigation/link-button.html.twig',
- [
- 'type' => 'secondary',
- 'label' => t('Refine search in tapahtumat.hel.fi'),
- 'class' => 'event-list__refine-button',
- 'url' => $intialUrl,
- 'theme_hook_original' => ''
- ]
- );
- }
-
- if ($loadMore = $paragraph->get('field_load_more')->value) {
- $variables['#attached']['drupalSettings']['helfi_events']['loadMore'] = $loadMore;
- }
- }
-
- // Render link to events service for use in frontend
- $variables['#attached']['drupalSettings']['helfi_events']['seeAllButton'] = twig_render_template(
- drupal_get_path('theme', 'hdbt') . '/templates/navigation/link-button.html.twig',
- [
- 'type' => 'primary',
- 'label' => t('See all events'),
- 'class' => 'event-list__see-all-button',
- 'url' => LinkedEvents::BASE_URL,
- 'theme_hook_original' => ''
- ]
- );
-
- //Render image placeholder for use in frontend
- $variables['#attached']['drupalSettings']['helfi_events']['imagePlaceholder'] = twig_render_template(
- drupal_get_path('theme', 'hdbt') . '/templates/misc/image-placeholder.twig',
- [
- 'image_placeholder' => 'calendar-clock',
- 'theme_hook_original' => ''
- ]
- );
-
- $variables['#attached']['library'][] = 'helfi_events/events_list';
- $variables['#attached']['drupalSettings']['helfi_events']['baseUrl'] = LinkedEvents::BASE_URL;
- $variables['#attached']['drupalSettings']['helfi_events']['translations'] = _helfi_events_translations();
-}
-
-/**
- * Returns string translations for frontend
- *
- * @return array
- * the translated strings
- */
-function _helfi_events_translations() : array {
- return [
- 'at' => t('at', [], ['context' => 'Indication that events take place in a certain timeframe']),
- 'emptyList' => t('This event list is empty.'),
- 'emptyListSubText' => t('No worries though, this city does not run out of things to do.'),
- 'eventKeywords' => t('Event keywords'),
- 'eventsCount' => t('events'),
- 'externalLink' => t(
- 'Link leads to external service',
- [],
- ['context' => 'Explanation for screen-reader software that the icon visible next to this link means that the link leads to an external service.']
- ),
- 'loadMore' => t('Load more events'),
- ];
-}
diff --git a/helfi_features/helfi_events/helfi_events.services.yml b/helfi_features/helfi_events/helfi_events.services.yml
deleted file mode 100644
index f7bf5a0dc..000000000
--- a/helfi_features/helfi_events/helfi_events.services.yml
+++ /dev/null
@@ -1,4 +0,0 @@
-services:
- helfi_events_linked_events:
- class: Drupal\helfi_events\LinkedEvents
- arguments: ['@http_client', '@cache.default']
diff --git a/helfi_features/helfi_events/src/LinkedEvents.php b/helfi_features/helfi_events/src/LinkedEvents.php
deleted file mode 100644
index b73b37ac4..000000000
--- a/helfi_features/helfi_events/src/LinkedEvents.php
+++ /dev/null
@@ -1,51 +0,0 @@
- 'General',
- 'format' => 'json',
- 'include' => 'keywords,location',
- 'page' => 1,
- 'page_size' => 12,
- 'sort' => 'end_time',
- 'start' => 'now',
- 'super_event_type' => 'umbrella,none',
- 'language' => \Drupal::languageManager()->getCurrentLanguage()->getId(),
- ];
-
- $options = array_merge($defaultOptions, $options);
-
- if (!isset($options['all_ongoing_AND'])) {
- $options['all_ongoing'] = 'true';
- }
-
- $url->setOption('query', $options);
-
- return $url->toString();
- }
-
-}
diff --git a/helfi_features/helfi_events/translations/fi.po b/helfi_features/helfi_events/translations/fi.po
deleted file mode 100644
index 780694b0c..000000000
--- a/helfi_features/helfi_events/translations/fi.po
+++ /dev/null
@@ -1,27 +0,0 @@
-msgid ""
-msgstr ""
-
-msgid "at"
-msgctxt "Indication that events take place in a certain timeframe"
-msgstr "klo"
-
-msgid "events"
-msgstr "tapahtumaa"
-
-msgid "This event list is empty."
-msgstr "Tämä tapahtumakalenteri on tyhjä."
-
-msgid "No worries though, this city does not run out of things to do."
-msgstr "Ei hätää, nimittäin tästä kaupungista ei tekeminen lopu."
-
-msgid "See all events"
-msgstr "Katso kaikki tapahtumat"
-
-msgid "Load more events"
-msgstr "Lataa lisää tapahtumia"
-
-msgid "Refine search in tapahtumat.hel.fi"
-msgstr "Tarkenna hakua tapahtumat.hel.fi:ssä"
-
-msgid "Event keywords"
-msgstr "Tapahtuman avainsanat"
diff --git a/helfi_features/helfi_events/translations/sv.po b/helfi_features/helfi_events/translations/sv.po
deleted file mode 100644
index d468e177c..000000000
--- a/helfi_features/helfi_events/translations/sv.po
+++ /dev/null
@@ -1,27 +0,0 @@
-msgid ""
-msgstr ""
-
-msgid "at"
-msgctxt "Indication that events take place in a certain timeframe"
-msgstr "klockan"
-
-msgid "events"
-msgstr "evenemang"
-
-msgid "This event list is empty."
-msgstr "Den här händelselistan är tom."
-
-msgid "No worries though, this city does not run out of things to do."
-msgstr "Inga bekymmer, den här staden har inte slut på saker att göra."
-
-msgid "See all events"
-msgstr "Se alla evenemang"
-
-msgid "Load more events"
-msgstr "Ladda fler händelser"
-
-msgid "Refine search in tapahtumat.hel.fi"
-msgstr "Förfina sökningen i tapahtumat.hel.fi"
-
-msgid "Event keywords"
-msgstr "Händelse nyckelord"
diff --git a/helfi_features/helfi_events/config/install/core.entity_form_display.paragraph.event_list.default.yml b/helfi_features/helfi_react_search/config/install/core.entity_form_display.paragraph.event_list.default.yml
similarity index 53%
rename from helfi_features/helfi_events/config/install/core.entity_form_display.paragraph.event_list.default.yml
rename to helfi_features/helfi_react_search/config/install/core.entity_form_display.paragraph.event_list.default.yml
index a77943729..6389e75b2 100644
--- a/helfi_features/helfi_events/config/install/core.entity_form_display.paragraph.event_list.default.yml
+++ b/helfi_features/helfi_react_search/config/install/core.entity_form_display.paragraph.event_list.default.yml
@@ -1,17 +1,19 @@
-uuid: e478d84e-0e63-4c35-ba22-4db0f1f2fe54
langcode: en
status: true
dependencies:
config:
- field.field.paragraph.event_list.field_api_url
+ - field.field.paragraph.event_list.field_event_count
- field.field.paragraph.event_list.field_event_list_description
- field.field.paragraph.event_list.field_event_list_title
- - field.field.paragraph.event_list.field_load_more
+ - field.field.paragraph.event_list.field_event_location
+ - field.field.paragraph.event_list.field_event_time
+ - field.field.paragraph.event_list.field_free_events
+ - field.field.paragraph.event_list.field_remote_events
- paragraphs.paragraphs_type.event_list
module:
- link
-_core:
- default_config_hash: fi3ARI4tFWq7YIeTEOsXVXkhwXFDyPL0QrPZJOmfRf4
+ - text
id: paragraph.event_list.default
targetEntityType: paragraph
bundle: event_list
@@ -25,6 +27,12 @@ content:
placeholder_url: ''
placeholder_title: ''
third_party_settings: { }
+ field_event_count:
+ type: options_select
+ weight: 4
+ region: content
+ settings: { }
+ third_party_settings: { }
field_event_list_description:
type: text_textarea
weight: 1
@@ -41,9 +49,30 @@ content:
size: 60
placeholder: ''
third_party_settings: { }
- field_load_more:
+ field_event_location:
+ type: boolean_checkbox
+ weight: 4
+ region: content
+ settings:
+ display_label: true
+ third_party_settings: { }
+ field_event_time:
+ type: boolean_checkbox
+ weight: 5
+ region: content
+ settings:
+ display_label: true
+ third_party_settings: { }
+ field_free_events:
+ type: boolean_checkbox
+ weight: 7
+ region: content
+ settings:
+ display_label: true
+ third_party_settings: { }
+ field_remote_events:
type: boolean_checkbox
- weight: 3
+ weight: 6
region: content
settings:
display_label: true
diff --git a/helfi_features/helfi_react_search/config/install/core.entity_view_display.paragraph.event_list.default.yml b/helfi_features/helfi_react_search/config/install/core.entity_view_display.paragraph.event_list.default.yml
new file mode 100644
index 000000000..89c03e081
--- /dev/null
+++ b/helfi_features/helfi_react_search/config/install/core.entity_view_display.paragraph.event_list.default.yml
@@ -0,0 +1,85 @@
+langcode: en
+status: true
+dependencies:
+ config:
+ - field.field.paragraph.event_list.field_api_url
+ - field.field.paragraph.event_list.field_event_count
+ - field.field.paragraph.event_list.field_event_list_description
+ - field.field.paragraph.event_list.field_event_list_title
+ - field.field.paragraph.event_list.field_event_location
+ - field.field.paragraph.event_list.field_event_time
+ - field.field.paragraph.event_list.field_free_events
+ - field.field.paragraph.event_list.field_remote_events
+ - paragraphs.paragraphs_type.event_list
+ module:
+ - options
+ - text
+id: paragraph.event_list.default
+targetEntityType: paragraph
+bundle: event_list
+mode: default
+content:
+ field_event_count:
+ type: list_default
+ label: above
+ settings: { }
+ third_party_settings: { }
+ weight: 2
+ region: content
+ field_event_list_description:
+ type: text_default
+ label: hidden
+ settings: { }
+ third_party_settings: { }
+ weight: 1
+ region: content
+ field_event_list_title:
+ type: string
+ label: hidden
+ settings:
+ link_to_entity: false
+ third_party_settings: { }
+ weight: 0
+ region: content
+ field_event_location:
+ type: boolean
+ label: above
+ settings:
+ format: default
+ format_custom_false: ''
+ format_custom_true: ''
+ third_party_settings: { }
+ weight: 2
+ region: content
+ field_event_time:
+ type: boolean
+ label: above
+ settings:
+ format: default
+ format_custom_false: ''
+ format_custom_true: ''
+ third_party_settings: { }
+ weight: 3
+ region: content
+ field_free_events:
+ type: boolean
+ label: above
+ settings:
+ format: default
+ format_custom_false: ''
+ format_custom_true: ''
+ third_party_settings: { }
+ weight: 5
+ region: content
+ field_remote_events:
+ type: boolean
+ label: above
+ settings:
+ format: default
+ format_custom_false: ''
+ format_custom_true: ''
+ third_party_settings: { }
+ weight: 4
+ region: content
+hidden:
+ field_api_url: true
diff --git a/helfi_features/helfi_events/config/install/field.field.paragraph.event_list.field_api_url.yml b/helfi_features/helfi_react_search/config/install/field.field.paragraph.event_list.field_api_url.yml
similarity index 88%
rename from helfi_features/helfi_events/config/install/field.field.paragraph.event_list.field_api_url.yml
rename to helfi_features/helfi_react_search/config/install/field.field.paragraph.event_list.field_api_url.yml
index c42e67782..70d0f5c76 100644
--- a/helfi_features/helfi_events/config/install/field.field.paragraph.event_list.field_api_url.yml
+++ b/helfi_features/helfi_react_search/config/install/field.field.paragraph.event_list.field_api_url.yml
@@ -14,7 +14,7 @@ field_name: field_api_url
entity_type: paragraph
bundle: event_list
label: 'Api URL'
-description: 'Add URL from tapahtumat.hel.fi to form a list of events'
+description: 'Add URL from tapahtumat.hel.fi to form a list of events. Example URL: https://tapahtumat.hel.fi/fi/events?categories=museum'
required: false
translatable: false
default_value: { }
diff --git a/helfi_features/helfi_react_search/config/install/field.field.paragraph.event_list.field_event_count.yml b/helfi_features/helfi_react_search/config/install/field.field.paragraph.event_list.field_event_count.yml
new file mode 100644
index 000000000..739c95fa4
--- /dev/null
+++ b/helfi_features/helfi_react_search/config/install/field.field.paragraph.event_list.field_event_count.yml
@@ -0,0 +1,24 @@
+langcode: en
+status: true
+dependencies:
+ config:
+ - field.storage.paragraph.field_event_count
+ - paragraphs.paragraphs_type.event_list
+ module:
+ - options
+id: paragraph.event_list.field_event_count
+field_name: field_event_count
+entity_type: paragraph
+bundle: event_list
+label: 'Event count'
+description: ''
+required: false
+translatable: false
+default_value:
+ -
+ value: 3
+default_value_callback: ''
+settings:
+ allowed_values: { }
+ allowed_values_function: 'helfi_react_search_event_list_allowed_values_function'
+field_type: list_integer
diff --git a/helfi_features/helfi_events/config/install/field.field.paragraph.event_list.field_event_list_description.yml b/helfi_features/helfi_react_search/config/install/field.field.paragraph.event_list.field_event_list_description.yml
similarity index 100%
rename from helfi_features/helfi_events/config/install/field.field.paragraph.event_list.field_event_list_description.yml
rename to helfi_features/helfi_react_search/config/install/field.field.paragraph.event_list.field_event_list_description.yml
diff --git a/helfi_features/helfi_events/config/install/field.field.paragraph.event_list.field_event_list_title.yml b/helfi_features/helfi_react_search/config/install/field.field.paragraph.event_list.field_event_list_title.yml
similarity index 100%
rename from helfi_features/helfi_events/config/install/field.field.paragraph.event_list.field_event_list_title.yml
rename to helfi_features/helfi_react_search/config/install/field.field.paragraph.event_list.field_event_list_title.yml
diff --git a/helfi_features/helfi_react_search/config/install/field.field.paragraph.event_list.field_event_location.yml b/helfi_features/helfi_react_search/config/install/field.field.paragraph.event_list.field_event_location.yml
new file mode 100644
index 000000000..33e7cb6fe
--- /dev/null
+++ b/helfi_features/helfi_react_search/config/install/field.field.paragraph.event_list.field_event_location.yml
@@ -0,0 +1,22 @@
+langcode: en
+status: true
+dependencies:
+ config:
+ - field.storage.paragraph.field_event_location
+ - paragraphs.paragraphs_type.event_list
+id: paragraph.event_list.field_event_location
+field_name: field_event_location
+entity_type: paragraph
+bundle: event_list
+label: 'Event location'
+description: 'Show "event location" filter. Do not use at the same time with the "Remote events" filter.'
+required: false
+translatable: false
+default_value:
+ -
+ value: 0
+default_value_callback: ''
+settings:
+ on_label: 'Yes'
+ off_label: 'No'
+field_type: boolean
diff --git a/helfi_features/helfi_react_search/config/install/field.field.paragraph.event_list.field_event_time.yml b/helfi_features/helfi_react_search/config/install/field.field.paragraph.event_list.field_event_time.yml
new file mode 100644
index 000000000..e850ec326
--- /dev/null
+++ b/helfi_features/helfi_react_search/config/install/field.field.paragraph.event_list.field_event_time.yml
@@ -0,0 +1,22 @@
+langcode: en
+status: true
+dependencies:
+ config:
+ - field.storage.paragraph.field_event_time
+ - paragraphs.paragraphs_type.event_list
+id: paragraph.event_list.field_event_time
+field_name: field_event_time
+entity_type: paragraph
+bundle: event_list
+label: 'Event time'
+description: 'Show "event time" filter.'
+required: false
+translatable: false
+default_value:
+ -
+ value: 0
+default_value_callback: ''
+settings:
+ on_label: 'Yes'
+ off_label: 'No'
+field_type: boolean
diff --git a/helfi_features/helfi_react_search/config/install/field.field.paragraph.event_list.field_free_events.yml b/helfi_features/helfi_react_search/config/install/field.field.paragraph.event_list.field_free_events.yml
new file mode 100644
index 000000000..365d63852
--- /dev/null
+++ b/helfi_features/helfi_react_search/config/install/field.field.paragraph.event_list.field_free_events.yml
@@ -0,0 +1,22 @@
+langcode: en
+status: true
+dependencies:
+ config:
+ - field.storage.paragraph.field_free_events
+ - paragraphs.paragraphs_type.event_list
+id: paragraph.event_list.field_free_events
+field_name: field_free_events
+entity_type: paragraph
+bundle: event_list
+label: 'Free events'
+description: 'Show "list only free events" filter.'
+required: false
+translatable: false
+default_value:
+ -
+ value: 0
+default_value_callback: ''
+settings:
+ on_label: 'Yes'
+ off_label: 'No'
+field_type: boolean
diff --git a/helfi_features/helfi_react_search/config/install/field.field.paragraph.event_list.field_remote_events.yml b/helfi_features/helfi_react_search/config/install/field.field.paragraph.event_list.field_remote_events.yml
new file mode 100644
index 000000000..79084bab7
--- /dev/null
+++ b/helfi_features/helfi_react_search/config/install/field.field.paragraph.event_list.field_remote_events.yml
@@ -0,0 +1,22 @@
+langcode: en
+status: true
+dependencies:
+ config:
+ - field.storage.paragraph.field_remote_events
+ - paragraphs.paragraphs_type.event_list
+id: paragraph.event_list.field_remote_events
+field_name: field_remote_events
+entity_type: paragraph
+bundle: event_list
+label: 'Remote events'
+description: 'Show "list only remote events" filter. Do not use at the same time with the "Event location" filter.'
+required: false
+translatable: false
+default_value:
+ -
+ value: 0
+default_value_callback: ''
+settings:
+ on_label: 'Yes'
+ off_label: 'No'
+field_type: boolean
diff --git a/helfi_features/helfi_events/config/install/field.storage.paragraph.field_api_url.yml b/helfi_features/helfi_react_search/config/install/field.storage.paragraph.field_api_url.yml
similarity index 100%
rename from helfi_features/helfi_events/config/install/field.storage.paragraph.field_api_url.yml
rename to helfi_features/helfi_react_search/config/install/field.storage.paragraph.field_api_url.yml
diff --git a/helfi_features/helfi_react_search/config/install/field.storage.paragraph.field_event_count.yml b/helfi_features/helfi_react_search/config/install/field.storage.paragraph.field_event_count.yml
new file mode 100644
index 000000000..418dd76ae
--- /dev/null
+++ b/helfi_features/helfi_react_search/config/install/field.storage.paragraph.field_event_count.yml
@@ -0,0 +1,20 @@
+langcode: en
+status: true
+dependencies:
+ module:
+ - options
+ - paragraphs
+id: paragraph.field_event_count
+field_name: field_event_count
+entity_type: paragraph
+type: list_integer
+settings:
+ allowed_values: { }
+ allowed_values_function: 'helfi_react_search_event_list_allowed_values_function'
+module: options
+locked: false
+cardinality: 1
+translatable: true
+indexes: { }
+persist_with_no_fields: false
+custom_storage: false
diff --git a/helfi_features/helfi_events/config/install/field.storage.paragraph.field_event_list_description.yml b/helfi_features/helfi_react_search/config/install/field.storage.paragraph.field_event_list_description.yml
similarity index 100%
rename from helfi_features/helfi_events/config/install/field.storage.paragraph.field_event_list_description.yml
rename to helfi_features/helfi_react_search/config/install/field.storage.paragraph.field_event_list_description.yml
diff --git a/helfi_features/helfi_events/config/install/field.storage.paragraph.field_event_list_title.yml b/helfi_features/helfi_react_search/config/install/field.storage.paragraph.field_event_list_title.yml
similarity index 100%
rename from helfi_features/helfi_events/config/install/field.storage.paragraph.field_event_list_title.yml
rename to helfi_features/helfi_react_search/config/install/field.storage.paragraph.field_event_list_title.yml
diff --git a/helfi_features/helfi_events/config/install/field.storage.paragraph.field_load_more.yml b/helfi_features/helfi_react_search/config/install/field.storage.paragraph.field_event_location.yml
similarity index 58%
rename from helfi_features/helfi_events/config/install/field.storage.paragraph.field_load_more.yml
rename to helfi_features/helfi_react_search/config/install/field.storage.paragraph.field_event_location.yml
index 028ab4973..5afe94293 100644
--- a/helfi_features/helfi_events/config/install/field.storage.paragraph.field_load_more.yml
+++ b/helfi_features/helfi_react_search/config/install/field.storage.paragraph.field_event_location.yml
@@ -1,13 +1,10 @@
-uuid: 776fafd9-c109-451b-8237-419c378e7a5a
langcode: en
status: true
dependencies:
module:
- paragraphs
-_core:
- default_config_hash: ZhUgtRcKcDHF_w9mzjd7qeu79oxePLBhAD4JQVk4zD0
-id: paragraph.field_load_more
-field_name: field_load_more
+id: paragraph.field_event_location
+field_name: field_event_location
entity_type: paragraph
type: boolean
settings: { }
diff --git a/helfi_features/helfi_react_search/config/install/field.storage.paragraph.field_event_time.yml b/helfi_features/helfi_react_search/config/install/field.storage.paragraph.field_event_time.yml
new file mode 100644
index 000000000..4a6391490
--- /dev/null
+++ b/helfi_features/helfi_react_search/config/install/field.storage.paragraph.field_event_time.yml
@@ -0,0 +1,17 @@
+langcode: en
+status: true
+dependencies:
+ module:
+ - paragraphs
+id: paragraph.field_event_time
+field_name: field_event_time
+entity_type: paragraph
+type: boolean
+settings: { }
+module: core
+locked: false
+cardinality: 1
+translatable: true
+indexes: { }
+persist_with_no_fields: false
+custom_storage: false
diff --git a/helfi_features/helfi_react_search/config/install/field.storage.paragraph.field_free_events.yml b/helfi_features/helfi_react_search/config/install/field.storage.paragraph.field_free_events.yml
new file mode 100644
index 000000000..c01dcc7f0
--- /dev/null
+++ b/helfi_features/helfi_react_search/config/install/field.storage.paragraph.field_free_events.yml
@@ -0,0 +1,17 @@
+langcode: en
+status: true
+dependencies:
+ module:
+ - paragraphs
+id: paragraph.field_free_events
+field_name: field_free_events
+entity_type: paragraph
+type: boolean
+settings: { }
+module: core
+locked: false
+cardinality: 1
+translatable: true
+indexes: { }
+persist_with_no_fields: false
+custom_storage: false
diff --git a/helfi_features/helfi_react_search/config/install/field.storage.paragraph.field_remote_events.yml b/helfi_features/helfi_react_search/config/install/field.storage.paragraph.field_remote_events.yml
new file mode 100644
index 000000000..60a588c4e
--- /dev/null
+++ b/helfi_features/helfi_react_search/config/install/field.storage.paragraph.field_remote_events.yml
@@ -0,0 +1,17 @@
+langcode: en
+status: true
+dependencies:
+ module:
+ - paragraphs
+id: paragraph.field_remote_events
+field_name: field_remote_events
+entity_type: paragraph
+type: boolean
+settings: { }
+module: core
+locked: false
+cardinality: 1
+translatable: true
+indexes: { }
+persist_with_no_fields: false
+custom_storage: false
diff --git a/helfi_features/helfi_events/config/install/paragraphs.paragraphs_type.event_list.yml b/helfi_features/helfi_react_search/config/install/paragraphs.paragraphs_type.event_list.yml
similarity index 100%
rename from helfi_features/helfi_events/config/install/paragraphs.paragraphs_type.event_list.yml
rename to helfi_features/helfi_react_search/config/install/paragraphs.paragraphs_type.event_list.yml
diff --git a/helfi_features/helfi_events/config/language/fi/field.field.paragraph.event_list.field_api_url.yml b/helfi_features/helfi_react_search/config/language/fi/field.field.paragraph.event_list.field_api_url.yml
similarity index 100%
rename from helfi_features/helfi_events/config/language/fi/field.field.paragraph.event_list.field_api_url.yml
rename to helfi_features/helfi_react_search/config/language/fi/field.field.paragraph.event_list.field_api_url.yml
diff --git a/helfi_features/helfi_react_search/config/language/fi/field.field.paragraph.event_list.field_event_count.yml b/helfi_features/helfi_react_search/config/language/fi/field.field.paragraph.event_list.field_event_count.yml
new file mode 100644
index 000000000..5d14d22c9
--- /dev/null
+++ b/helfi_features/helfi_react_search/config/language/fi/field.field.paragraph.event_list.field_event_count.yml
@@ -0,0 +1 @@
+label: 'Tapahtumien lukumäärä'
diff --git a/helfi_features/helfi_events/config/language/fi/field.field.paragraph.event_list.field_event_list_description.yml b/helfi_features/helfi_react_search/config/language/fi/field.field.paragraph.event_list.field_event_list_description.yml
similarity index 100%
rename from helfi_features/helfi_events/config/language/fi/field.field.paragraph.event_list.field_event_list_description.yml
rename to helfi_features/helfi_react_search/config/language/fi/field.field.paragraph.event_list.field_event_list_description.yml
diff --git a/helfi_features/helfi_events/config/language/fi/field.field.paragraph.event_list.field_event_list_title.yml b/helfi_features/helfi_react_search/config/language/fi/field.field.paragraph.event_list.field_event_list_title.yml
similarity index 100%
rename from helfi_features/helfi_events/config/language/fi/field.field.paragraph.event_list.field_event_list_title.yml
rename to helfi_features/helfi_react_search/config/language/fi/field.field.paragraph.event_list.field_event_list_title.yml
diff --git a/helfi_features/helfi_react_search/config/language/fi/field.field.paragraph.event_list.field_event_location.yml b/helfi_features/helfi_react_search/config/language/fi/field.field.paragraph.event_list.field_event_location.yml
new file mode 100644
index 000000000..e61dab35f
--- /dev/null
+++ b/helfi_features/helfi_react_search/config/language/fi/field.field.paragraph.event_list.field_event_location.yml
@@ -0,0 +1,2 @@
+label: 'Tapahtumapaikka'
+description: 'Näytä "tapahtumapaikka" -suodatin. Älä käytä yhtä aikaa "Etätapahtumat" -suodattimen kanssa.'
diff --git a/helfi_features/helfi_react_search/config/language/fi/field.field.paragraph.event_list.field_event_time.yml b/helfi_features/helfi_react_search/config/language/fi/field.field.paragraph.event_list.field_event_time.yml
new file mode 100644
index 000000000..241a6771d
--- /dev/null
+++ b/helfi_features/helfi_react_search/config/language/fi/field.field.paragraph.event_list.field_event_time.yml
@@ -0,0 +1,2 @@
+label: 'Ajankohta'
+description: 'Näytä "ajankohta" -suodatin.'
diff --git a/helfi_features/helfi_react_search/config/language/fi/field.field.paragraph.event_list.field_free_events.yml b/helfi_features/helfi_react_search/config/language/fi/field.field.paragraph.event_list.field_free_events.yml
new file mode 100644
index 000000000..d0e4ed973
--- /dev/null
+++ b/helfi_features/helfi_react_search/config/language/fi/field.field.paragraph.event_list.field_free_events.yml
@@ -0,0 +1,2 @@
+label: 'Maksuttomat tapahtumat'
+description: 'Näytä "näytä vain maksuttomat tapahtumat" -suodatin.'
diff --git a/helfi_features/helfi_react_search/config/language/fi/field.field.paragraph.event_list.field_remote_events.yml b/helfi_features/helfi_react_search/config/language/fi/field.field.paragraph.event_list.field_remote_events.yml
new file mode 100644
index 000000000..5fc2b399e
--- /dev/null
+++ b/helfi_features/helfi_react_search/config/language/fi/field.field.paragraph.event_list.field_remote_events.yml
@@ -0,0 +1,2 @@
+label: 'Etätapahtumat'
+description: 'Näytä "näytä vain etätapahtumat" -suodatin. Älä käytä yhtä aikaa "Tapahtumapaikka" -suodattimen kanssa.'
diff --git a/helfi_features/helfi_events/config/language/fi/paragraphs.paragraphs_type.event_list.yml b/helfi_features/helfi_react_search/config/language/fi/paragraphs.paragraphs_type.event_list.yml
similarity index 100%
rename from helfi_features/helfi_events/config/language/fi/paragraphs.paragraphs_type.event_list.yml
rename to helfi_features/helfi_react_search/config/language/fi/paragraphs.paragraphs_type.event_list.yml
diff --git a/helfi_features/helfi_react_search/helfi_react_search.info.yml b/helfi_features/helfi_react_search/helfi_react_search.info.yml
new file mode 100644
index 000000000..5034c45a7
--- /dev/null
+++ b/helfi_features/helfi_react_search/helfi_react_search.info.yml
@@ -0,0 +1,16 @@
+name: 'HELfi react search'
+type: module
+description: 'Add react search related backend features'
+core_version_requirement: '^9 || ^10'
+dependencies:
+ - 'drupal:ckeditor'
+ - 'drupal:content_translation'
+ - 'drupal:editor'
+ - 'drupal:language'
+ - 'drupal:link'
+ - 'drupal:text'
+ - 'helfi_platform_config:helfi_platform_config'
+ - 'paragraphs:paragraphs'
+package: HELfi
+'interface translation project': helfi_react_search
+'interface translation server pattern': modules/contrib/helfi_platform_config/helfi_features/helfi_react_search/translations/%language.po
diff --git a/helfi_features/helfi_react_search/helfi_react_search.install b/helfi_features/helfi_react_search/helfi_react_search.install
new file mode 100644
index 000000000..ec6813590
--- /dev/null
+++ b/helfi_features/helfi_react_search/helfi_react_search.install
@@ -0,0 +1,100 @@
+getEditable($configName)->delete();
+ }
+ catch (\Exception $e) {
+ $logger->warning(sprintf('Unable to uninstall config: %s.', $configName));
+ }
+ }
+
+}
+
+/**
+ * Adds new fields to the Events paragraph.
+ */
+function helfi_react_search_update_9001() {
+ drupal_flush_all_caches();
+
+ $config_location = dirname(__FILE__) . '/config/install/';
+ $config_translation_location = dirname(__FILE__) . '/config/language/';
+
+ // Add new config.
+ $new_config = [
+ 'field.storage.paragraph.field_event_location' => 'field.field.paragraph.event_list.field_event_location',
+ 'field.storage.paragraph.field_event_time' => 'field.field.paragraph.event_list.field_event_time',
+ 'field.storage.paragraph.field_free_events' => 'field.field.paragraph.event_list.field_free_events',
+ 'field.storage.paragraph.field_remote_events' => 'field.field.paragraph.event_list.field_remote_events',
+ ];
+
+ foreach ($new_config as $field_storage => $field_config) {
+ ConfigHelper::installNewField($config_location, $field_storage, $field_config);
+ ConfigHelper::installNewConfigTranslation($config_translation_location, $field_config);
+ }
+
+ // Update existing config.
+ $update_config = [
+ 'core.entity_form_display.paragraph.event_list.default',
+ 'core.entity_view_display.paragraph.event_list.default',
+ ];
+
+ foreach ($update_config as $config_item) {
+ ConfigHelper::updateExistingConfig($config_location, $config_item);
+ }
+}
+
+/**
+ * Remove the show more button and add int list field.
+ */
+function helfi_react_search_update_9002() {
+ // Install new configurations
+ $configLocation = dirname(__FILE__) . '/config/install/';
+ ConfigHelper::installNewField($configLocation, 'field.storage.paragraph.field_event_count', 'field.field.paragraph.event_list.field_event_count');
+ ConfigHelper::installNewConfigTranslation('/config/language/', 'field.field.paragraph.event_list.field_event_count');
+
+ // Update old configurations
+ ConfigHelper::updateExistingConfig($configLocation, 'core.entity_form_display.paragraph.event_list.default');
+ ConfigHelper::updateExistingConfig($configLocation, 'core.entity_view_display.paragraph.event_list.default');
+}
diff --git a/helfi_features/helfi_react_search/helfi_react_search.module b/helfi_features/helfi_react_search/helfi_react_search.module
new file mode 100644
index 000000000..f5855dfdc
--- /dev/null
+++ b/helfi_features/helfi_react_search/helfi_react_search.module
@@ -0,0 +1,16 @@
+ 3,
+ 5 => 5,
+ ];
+}
diff --git a/helfi_features/helfi_react_search/helfi_react_search.services.yml b/helfi_features/helfi_react_search/helfi_react_search.services.yml
new file mode 100644
index 000000000..a7c2dfbda
--- /dev/null
+++ b/helfi_features/helfi_react_search/helfi_react_search.services.yml
@@ -0,0 +1,11 @@
+services:
+ logger.channel.helfi_react_search:
+ parent: logger.channel_base
+ arguments:
+ - 'helfi_react_search'
+ helfi_react_search_linked_events:
+ class: Drupal\helfi_react_search\LinkedEvents
+ arguments:
+ - '@cache.default'
+ - '@http_client'
+ - '@logger.channel.helfi_react_search'
diff --git a/helfi_features/helfi_events/src/Enum/CategoryKeywords.php b/helfi_features/helfi_react_search/src/Enum/CategoryKeywords.php
similarity index 98%
rename from helfi_features/helfi_events/src/Enum/CategoryKeywords.php
rename to helfi_features/helfi_react_search/src/Enum/CategoryKeywords.php
index 8217c6255..19c808ec1 100644
--- a/helfi_features/helfi_events/src/Enum/CategoryKeywords.php
+++ b/helfi_features/helfi_react_search/src/Enum/CategoryKeywords.php
@@ -2,7 +2,7 @@
declare(strict_types = 1);
-namespace Drupal\helfi_events\Enum;
+namespace Drupal\helfi_react_search\Enum;
/**
* Enum class CategoryKeywords.
diff --git a/helfi_features/helfi_events/src/EventsApiBase.php b/helfi_features/helfi_react_search/src/EventsApiBase.php
similarity index 74%
rename from helfi_features/helfi_events/src/EventsApiBase.php
rename to helfi_features/helfi_react_search/src/EventsApiBase.php
index baff1124b..5c37cf417 100644
--- a/helfi_features/helfi_events/src/EventsApiBase.php
+++ b/helfi_features/helfi_react_search/src/EventsApiBase.php
@@ -2,66 +2,15 @@
declare(strict_types = 1);
-namespace Drupal\helfi_events;
+namespace Drupal\helfi_react_search;
use Drupal\Component\Utility\UrlHelper;
-use Drupal\Core\Cache\CacheBackendInterface;
-use Drupal\helfi_events\Enum\CategoryKeywords;
-use GuzzleHttp\ClientInterface;
+use Drupal\helfi_react_search\Enum\CategoryKeywords;
/**
* Base class for retrieving events data.
*/
-class EventsApiBase {
-
- /**
- * The constructor.
- *
- * @param \GuzzleHttp\ClientInterface $httpClient
- * HTTP Client.
- * @param \Drupal\Core\Cache\CacheBackendInterface $dataCache
- * Data Cache.
- */
- public function __construct(
- protected ClientInterface $httpClient,
- protected CacheBackendInterface $dataCache
- ) {}
-
- /**
- * Sets cache.
- *
- * @param string $id
- * Cache id.
- * @param mixed $data
- * The data.
- */
- protected function setCache(string $id, $data) : void {
- $key = $this->getCacheKey($id);
- $this->dataCache->set($key, $data, $this->getCacheMaxAge(), []);
- }
-
- /**
- * Get cached data for given id.
- *
- * @param string $id
- * The id.
- *
- * @return mixed|null
- * Cached data or null
- */
- protected function getFromCache(string $id) : mixed {
- $key = $this->getCacheKey($id);
-
- if (isset($this->data[$key])) {
- return $this->data[$key];
- }
-
- if ($data = $this->dataCache->get($key)) {
- return $data->data;
- }
-
- return NULL;
- }
+abstract class EventsApiBase {
/**
* Parse query params from request url.
@@ -103,7 +52,6 @@ public function parseParams(string $url) : array {
case 'dateTypes':
$dateTypes = explode(',', $param);
- $dateParams = '';
foreach ($dateTypes as $dataType) {
switch ($param) {
case 'today':
diff --git a/helfi_features/helfi_react_search/src/LinkedEvents.php b/helfi_features/helfi_react_search/src/LinkedEvents.php
new file mode 100644
index 000000000..be5adf87a
--- /dev/null
+++ b/helfi_features/helfi_react_search/src/LinkedEvents.php
@@ -0,0 +1,188 @@
+getCacheKey($id);
+
+ if ($data = $this->dataCache->get($key)) {
+ return $data->data;
+ }
+ return NULL;
+ }
+
+ /**
+ * Sets the cache.
+ *
+ * @param string $id
+ * The id.
+ * @param mixed $data
+ * The data.
+ */
+ protected function setCache(string $id, $data) : void {
+ $key = $this->getCacheKey($id);
+ $this->dataCache->set($key, $data, $this->getCacheMaxAge(), []);
+ }
+
+ /**
+ * Form url for getting events from api.
+ *
+ * @param array $options
+ * Filters as key = value array.
+ * @param string $pageSize
+ * How many events to load in a page.
+ *
+ * @return string
+ * Resulting api url with params a query string
+ */
+ public function getEventsRequest(array $options = [], string $pageSize = '3') : string {
+ $url = Url::fromUri(self::API_URL . 'event');
+
+ $defaultOptions = [
+ 'event_type' => 'General',
+ 'format' => 'json',
+ 'include' => 'keywords,location',
+ 'page' => 1,
+ 'page_size' => $pageSize,
+ 'sort' => 'end_time',
+ 'start' => 'now',
+ 'super_event_type' => 'umbrella,none',
+ 'language' => \Drupal::languageManager()->getCurrentLanguage()->getId(),
+ ];
+
+ $options = array_merge($defaultOptions, $options);
+
+ if (!isset($options['all_ongoing_AND'])) {
+ $options['all_ongoing'] = 'true';
+ }
+
+ $url->setOption('query', $options);
+
+ return $url->toString();
+ }
+
+ /**
+ * Return places from cache or generate list of them.
+ *
+ * @param string $url
+ * The Api url for events.
+ *
+ * @return array
+ * Array of all possible places.
+ *
+ * @throws \GuzzleHttp\Exception\GuzzleException
+ */
+ public function getPlacesList($url) : array {
+ if ($data = $this->getFromCache($url)) {
+ return $data;
+ }
+
+ $result = [];
+
+ // Set max page size to reduce amount of requests.
+ $transformedUrl = Url::fromUri($url);
+ $transformedUrl->setOption('query', ['page_size' => '100']);
+ $transformedUrl = $transformedUrl->toString();
+
+ try {
+ $response = $this->httpClient->request('GET', $transformedUrl);
+ $body = json_decode($response->getBody()->getContents());
+ $next = $body->meta->next;
+ $data = $body->data;
+
+ do {
+ foreach ($data as $item) {
+ // Bail if no location data.
+ if (!isset($item->location) || !isset($item->location->id)) {
+ continue;
+ }
+
+ if (!array_key_exists($item->location->id, $result)) {
+ $result[$item->location->id] = $item->location;
+ }
+ }
+
+ if ($next) {
+ $response = $this->httpClient->request('GET', $next);
+ $body = json_decode($response->getBody()->getContents());
+ $next = $body->meta->next;
+ $data = $body->data;
+ }
+ else {
+ $data = NULL;
+ }
+ } while ($data && count($data) > 0);
+
+ $this->setCache($url, $result);
+ }
+ catch (GuzzleException $e) {
+ $this->logger->error('Request failed with error: ' . $e->getMessage());
+ }
+
+ return $result;
+ }
+
+}
diff --git a/helfi_features/helfi_react_search/translations/fi.po b/helfi_features/helfi_react_search/translations/fi.po
new file mode 100644
index 000000000..5162e5576
--- /dev/null
+++ b/helfi_features/helfi_react_search/translations/fi.po
@@ -0,0 +1,76 @@
+msgid ""
+msgstr ""
+
+msgctxt "React search"
+msgid "Search"
+msgstr "Hae"
+
+msgid "at"
+msgctxt "Indication that events take place in a certain timeframe"
+msgstr "klo"
+
+msgid "events"
+msgstr "tapahtumaa"
+
+msgid "This event list is empty."
+msgstr "Tämä tapahtumakalenteri on tyhjä."
+
+msgid "No worries though, this city does not run out of things to do."
+msgstr "Ei hätää, nimittäin tästä kaupungista ei tekeminen lopu."
+
+msgid "Refine search in tapahtumat.hel.fi"
+msgstr "Tarkenna hakua tapahtumat.hel.fi:ssä"
+
+msgid "Event keywords"
+msgstr "Tapahtuman avainsanat"
+
+msgctxt "Event search: search form title"
+msgid "Filter events"
+msgstr "Etsi tapahtumia"
+
+msgctxt "Event search: all available options"
+msgid "All"
+msgstr "Kaikki"
+
+msgid "If you want to search for remote events, select only the option 'Internet (remote events)'"
+msgstr "Jos haluat etsiä etätapahtumia, valitse vaihtoehto 'Internet (etätapahtumat)'"
+
+msgid "Select a venue"
+msgstr "Valitse tapahtumapaikka"
+
+msgctxt "Event search: remove item aria label"
+msgid "Remove item"
+msgstr "Poista valinta"
+
+msgctxt "Event search: clear button aria label"
+msgid "Clear selections"
+msgstr "Tyhjennä kaikki valinnat"
+
+msgid "Use the format D.M.YYYY"
+msgstr "Käytä muotoa P.K.VVVV"
+
+msgctxt "Event search: date selection label"
+msgid "Date"
+msgstr "Ajankohta"
+
+msgid "Select a time period in which in which the event takes place"
+msgstr "Valitse ajankohta, johon tapahtuma sijoittuu"
+
+msgid "First day of the time period"
+msgstr "Alkaen"
+
+msgid "The last day of the time period is the same as the first day"
+msgstr "Aikavälin viimeinen päivä on sama kuin ensimmäinen"
+
+msgid "Last day of the time period"
+msgstr "Asti"
+
+msgctxt "Event search: event type prefix"
+msgid "Show only"
+msgstr "Näytä vain"
+
+msgid "Free-of-charge events"
+msgstr "Maksuttomat tapahtumat"
+
+msgid "Remote events"
+msgstr "Etätapahtumat"
diff --git a/helfi_features/helfi_react_search/translations/sv.po b/helfi_features/helfi_react_search/translations/sv.po
new file mode 100644
index 000000000..63c50243f
--- /dev/null
+++ b/helfi_features/helfi_react_search/translations/sv.po
@@ -0,0 +1,82 @@
+msgid ""
+msgstr ""
+
+msgctxt "React search"
+msgid "Search"
+msgstr "Sök"
+
+msgid "at"
+msgctxt "Indication that events take place in a certain timeframe"
+msgstr "klockan"
+
+msgid "events"
+msgstr "evenemang"
+
+msgid "This event list is empty."
+msgstr "Den här händelselistan är tom."
+
+msgid "No worries though, this city does not run out of things to do."
+msgstr "Inga bekymmer, den här staden har inte slut på saker att göra."
+
+msgid "See all events"
+msgstr "Se alla evenemang"
+
+msgid "Load more events"
+msgstr "Ladda fler händelser"
+
+msgid "Refine search in tapahtumat.hel.fi"
+msgstr "Förfina sökningen i tapahtumat.hel.fi"
+
+msgid "Event keywords"
+msgstr "Händelse nyckelord"
+
+msgctxt "Event search: search form title"
+msgid "Filter events"
+msgstr "Filtrera evenemang"
+
+msgctxt "Event search: all available options"
+msgid "All"
+msgstr "Alla"
+
+msgid "If you want to search for remote events, select only the option 'Internet (remote events)'"
+msgstr "Om du vill söka evenemang på distans, välj endast alternativet 'Internet (evenemang på distans)'"
+
+msgid "Select a venue"
+msgstr "Välj tidpunkt"
+
+msgctxt "Event search: remove item aria label"
+msgid "Remove item"
+msgstr "Töm valda"
+
+msgctxt "Event search: clear button aria label"
+msgid "Clear selections"
+msgstr "Rensa alla"
+
+msgid "Use the format D.M.YYYY"
+msgstr "Ange i formen D.M.ÅÅÅÅ"
+
+msgctxt "Event search: date selection label"
+msgid "Date"
+msgstr "Tidsperiod"
+
+msgid "Select a time period in which in which the event takes place"
+msgstr "Välj tidsperiod då evenemanget äger rum"
+
+msgid "First day of the time period"
+msgstr "Tidsperiodens första dag"
+
+msgid "The last day of the time period is the same as the first day"
+msgstr "Tidsperiodens sista dag är samma som första"
+
+msgid "Last day of the time period"
+msgstr "Tidsperiodens sista dag"
+
+msgctxt "Event search: event type prefix"
+msgid "Show only"
+msgstr "Visa endast"
+
+msgid "Free-of-charge events"
+msgstr "Kostnadsfria evenemang"
+
+msgid "Remote events"
+msgstr "Evenemang på distans"
diff --git a/helfi_platform_config.install b/helfi_platform_config.install
index 593226486..091cdb197 100644
--- a/helfi_platform_config.install
+++ b/helfi_platform_config.install
@@ -286,3 +286,20 @@ function helfi_platform_config_update_9012() : void {
$config->set('ignored_config_entities', $ignored)
->save();
}
+
+/**
+ * Replace helfi_events module with helfi_react_search module
+ */
+function helfi_platform_config_update_9013() : void {
+ if (Drupal::moduleHandler()->moduleExists('helfi_events')) {
+ Drupal::service('module_installer')->uninstall([
+ 'helfi_events',
+ ]);
+ }
+
+ if (!Drupal::moduleHandler()->moduleExists('helfi_react_search')) {
+ Drupal::service('module_installer')->install([
+ 'helfi_react_search',
+ ]);
+ }
+}