From a6621efc8c85d4151ed16881deb03fbe39aa3430 Mon Sep 17 00:00:00 2001 From: LasseStaus Date: Thu, 21 Dec 2023 15:24:24 +0100 Subject: [PATCH 01/76] Added Search_api module along with dependencies. Created view for events. This commit installs and enables the drupal_search_api module, creates a server, and creates an index over the events based on their date. Creats a view called 'events' that uses this index to search for events. The only filter that should be enabled is filtering by end_date. DDFFORM-59 --- composer.json | 1 + composer.lock | 72 ++++++ ...ntity_view_display.media.image.default.yml | 1 + ...ity_view_display.media.image.hero_wide.yml | 1 + ...view_display.media.image.media_library.yml | 1 + ..._display.media.image.paragraph_squared.yml | 1 + ...iew_display.media.image.paragraph_wide.yml | 1 + ...tity_view_display.node.article.default.yml | 1 + ....entity_view_display.node.article.full.yml | 1 + ...ntity_view_display.node.article.teaser.yml | 1 + ...ity_view_display.node.campaign.default.yml | 1 + ...tity_view_display.node.campaign.teaser.yml | 1 + ...entity_view_display.node.event.default.yml | 1 + ...re.entity_view_display.node.event.full.yml | 1 + ....entity_view_display.node.event.teaser.yml | 1 + ...isplay.paragraph.campaign_rule.default.yml | 3 +- ...aragraph.event_ticket_category.default.yml | 3 +- ...y_view_display.paragraph.links.default.yml | 3 +- ...w_display.paragraph.medias.alternative.yml | 3 +- ..._view_display.paragraph.medias.default.yml | 3 +- ..._view_display.paragraph.medias.preview.yml | 3 +- ...ew_display.paragraph.text_body.default.yml | 3 +- ...ew_display.paragraph.text_body.preview.yml | 3 +- config/sync/core.extension.yml | 2 + config/sync/search_api.index.events.yml | 47 ++++ config/sync/search_api.server.db_search.yml | 15 ++ config/sync/search_api.settings.yml | 28 +++ config/sync/search_api_db.settings.yml | 3 + config/sync/views.view.events.yml | 229 ++++++++++++++++++ 29 files changed, 426 insertions(+), 8 deletions(-) create mode 100644 config/sync/search_api.index.events.yml create mode 100644 config/sync/search_api.server.db_search.yml create mode 100644 config/sync/search_api.settings.yml create mode 100644 config/sync/search_api_db.settings.yml create mode 100644 config/sync/views.view.events.yml diff --git a/composer.json b/composer.json index 6fad8f5a3..5fd101959 100644 --- a/composer.json +++ b/composer.json @@ -110,6 +110,7 @@ "drupal/purge": "^3.2", "drupal/redis": "^1.7", "drupal/restui": "^1.21", + "drupal/search_api": "^1.31", "drupal/twig_tweak": "^3.2.1", "drupal/upgrade_status": "^4.0", "drupal/varnish_purge": "^2.2", diff --git a/composer.lock b/composer.lock index b7c24f70c..ab9edffe1 100644 --- a/composer.lock +++ b/composer.lock @@ -4808,6 +4808,78 @@ "source": "https://git.drupalcode.org/project/schemata" } }, + { + "name": "drupal/search_api", + "version": "1.31.0", + "source": { + "type": "git", + "url": "https://git.drupalcode.org/project/search_api.git", + "reference": "8.x-1.31" + }, + "dist": { + "type": "zip", + "url": "https://ftp.drupal.org/files/projects/search_api-8.x-1.31.zip", + "reference": "8.x-1.31", + "shasum": "ec8436744c34de2ede6370d4dd26875489e761bc" + }, + "require": { + "drupal/core": "^10.0" + }, + "conflict": { + "drupal/search_api_solr": "2.* || 3.0 || 3.1" + }, + "require-dev": { + "drupal/language_fallback_fix": "@dev", + "drupal/search_api_autocomplete": "@dev", + "drupal/search_api_db": "*" + }, + "suggest": { + "drupal/facets": "Adds the ability to create faceted searches.", + "drupal/search_api_autocomplete": "Allows adding autocomplete suggestions to search fields.", + "drupal/search_api_solr": "Adds support for using Apache Solr as a backend." + }, + "type": "drupal-module", + "extra": { + "drupal": { + "version": "8.x-1.31", + "datestamp": "1700926323", + "security-coverage": { + "status": "covered", + "message": "Covered by Drupal's security advisory policy" + } + }, + "drush": { + "services": { + "drush.services.yml": "^9 || ^10 || ^11" + } + } + }, + "notification-url": "https://packages.drupal.org/8/downloads", + "license": [ + "GPL-2.0-or-later" + ], + "authors": [ + { + "name": "Thomas Seidl", + "homepage": "https://www.drupal.org/u/drunken-monkey" + }, + { + "name": "Nick Veenhof", + "homepage": "https://www.drupal.org/u/nick_vh" + }, + { + "name": "See other contributors", + "homepage": "https://www.drupal.org/node/790418/committers" + } + ], + "description": "Provides a generic framework for modules offering search capabilities.", + "homepage": "https://www.drupal.org/project/search_api", + "support": { + "source": "https://git.drupalcode.org/project/search_api", + "issues": "https://www.drupal.org/project/issues/search_api", + "irc": "irc://irc.freenode.org/drupal-search-api" + } + }, { "name": "drupal/token", "version": "1.13.0", diff --git a/config/sync/core.entity_view_display.media.image.default.yml b/config/sync/core.entity_view_display.media.image.default.yml index 843d43c6c..727baaa9d 100644 --- a/config/sync/core.entity_view_display.media.image.default.yml +++ b/config/sync/core.entity_view_display.media.image.default.yml @@ -37,5 +37,6 @@ hidden: created: true langcode: true name: true + search_api_excerpt: true thumbnail: true uid: true diff --git a/config/sync/core.entity_view_display.media.image.hero_wide.yml b/config/sync/core.entity_view_display.media.image.hero_wide.yml index a53018311..5f7af2cf6 100644 --- a/config/sync/core.entity_view_display.media.image.hero_wide.yml +++ b/config/sync/core.entity_view_display.media.image.hero_wide.yml @@ -30,5 +30,6 @@ hidden: field_byline: true langcode: true name: true + search_api_excerpt: true thumbnail: true uid: true diff --git a/config/sync/core.entity_view_display.media.image.media_library.yml b/config/sync/core.entity_view_display.media.image.media_library.yml index 66d720b21..22ab01be4 100644 --- a/config/sync/core.entity_view_display.media.image.media_library.yml +++ b/config/sync/core.entity_view_display.media.image.media_library.yml @@ -38,5 +38,6 @@ hidden: created: true langcode: true name: true + search_api_excerpt: true thumbnail: true uid: true diff --git a/config/sync/core.entity_view_display.media.image.paragraph_squared.yml b/config/sync/core.entity_view_display.media.image.paragraph_squared.yml index d28355885..221178013 100644 --- a/config/sync/core.entity_view_display.media.image.paragraph_squared.yml +++ b/config/sync/core.entity_view_display.media.image.paragraph_squared.yml @@ -38,5 +38,6 @@ hidden: created: true langcode: true name: true + search_api_excerpt: true thumbnail: true uid: true diff --git a/config/sync/core.entity_view_display.media.image.paragraph_wide.yml b/config/sync/core.entity_view_display.media.image.paragraph_wide.yml index b399bb5d8..af48dc46f 100644 --- a/config/sync/core.entity_view_display.media.image.paragraph_wide.yml +++ b/config/sync/core.entity_view_display.media.image.paragraph_wide.yml @@ -38,5 +38,6 @@ hidden: created: true langcode: true name: true + search_api_excerpt: true thumbnail: true uid: true diff --git a/config/sync/core.entity_view_display.node.article.default.yml b/config/sync/core.entity_view_display.node.article.default.yml index b32d1250b..5f496696e 100644 --- a/config/sync/core.entity_view_display.node.article.default.yml +++ b/config/sync/core.entity_view_display.node.article.default.yml @@ -48,3 +48,4 @@ hidden: field_canonical_url: true field_paragraphs: true langcode: true + search_api_excerpt: true diff --git a/config/sync/core.entity_view_display.node.article.full.yml b/config/sync/core.entity_view_display.node.article.full.yml index 53345933b..6bad59a74 100644 --- a/config/sync/core.entity_view_display.node.article.full.yml +++ b/config/sync/core.entity_view_display.node.article.full.yml @@ -44,3 +44,4 @@ hidden: field_show_override_author: true langcode: true links: true + search_api_excerpt: true diff --git a/config/sync/core.entity_view_display.node.article.teaser.yml b/config/sync/core.entity_view_display.node.article.teaser.yml index 3b4dd6f93..38dd8b7e4 100644 --- a/config/sync/core.entity_view_display.node.article.teaser.yml +++ b/config/sync/core.entity_view_display.node.article.teaser.yml @@ -27,3 +27,4 @@ hidden: field_show_override_author: true field_subtitle: true langcode: true + search_api_excerpt: true diff --git a/config/sync/core.entity_view_display.node.campaign.default.yml b/config/sync/core.entity_view_display.node.campaign.default.yml index a6ea65130..1aa1e987d 100644 --- a/config/sync/core.entity_view_display.node.campaign.default.yml +++ b/config/sync/core.entity_view_display.node.campaign.default.yml @@ -73,3 +73,4 @@ content: region: content hidden: langcode: true + search_api_excerpt: true diff --git a/config/sync/core.entity_view_display.node.campaign.teaser.yml b/config/sync/core.entity_view_display.node.campaign.teaser.yml index 5d5078922..03a90aada 100644 --- a/config/sync/core.entity_view_display.node.campaign.teaser.yml +++ b/config/sync/core.entity_view_display.node.campaign.teaser.yml @@ -29,3 +29,4 @@ hidden: field_campaign_rules_logic: true field_campaign_text: true langcode: true + search_api_excerpt: true diff --git a/config/sync/core.entity_view_display.node.event.default.yml b/config/sync/core.entity_view_display.node.event.default.yml index 6b0686f9f..c77add38d 100644 --- a/config/sync/core.entity_view_display.node.event.default.yml +++ b/config/sync/core.entity_view_display.node.event.default.yml @@ -84,3 +84,4 @@ hidden: field_event_date: true field_event_state: true langcode: true + search_api_excerpt: true diff --git a/config/sync/core.entity_view_display.node.event.full.yml b/config/sync/core.entity_view_display.node.event.full.yml index 88c9287c4..dd103bf3c 100644 --- a/config/sync/core.entity_view_display.node.event.full.yml +++ b/config/sync/core.entity_view_display.node.event.full.yml @@ -90,3 +90,4 @@ hidden: field_event_state: true langcode: true links: true + search_api_excerpt: true diff --git a/config/sync/core.entity_view_display.node.event.teaser.yml b/config/sync/core.entity_view_display.node.event.teaser.yml index 17d9decc1..4656641cc 100644 --- a/config/sync/core.entity_view_display.node.event.teaser.yml +++ b/config/sync/core.entity_view_display.node.event.teaser.yml @@ -35,3 +35,4 @@ hidden: field_event_state: true field_ticket_categories: true langcode: true + search_api_excerpt: true diff --git a/config/sync/core.entity_view_display.paragraph.campaign_rule.default.yml b/config/sync/core.entity_view_display.paragraph.campaign_rule.default.yml index 32ed5285f..58a3aa535 100644 --- a/config/sync/core.entity_view_display.paragraph.campaign_rule.default.yml +++ b/config/sync/core.entity_view_display.paragraph.campaign_rule.default.yml @@ -38,4 +38,5 @@ content: third_party_settings: { } weight: 5 region: content -hidden: { } +hidden: + search_api_excerpt: true diff --git a/config/sync/core.entity_view_display.paragraph.event_ticket_category.default.yml b/config/sync/core.entity_view_display.paragraph.event_ticket_category.default.yml index 4f3f83c94..d24849b0a 100644 --- a/config/sync/core.entity_view_display.paragraph.event_ticket_category.default.yml +++ b/config/sync/core.entity_view_display.paragraph.event_ticket_category.default.yml @@ -30,4 +30,5 @@ content: third_party_settings: { } weight: 1 region: content -hidden: { } +hidden: + search_api_excerpt: true diff --git a/config/sync/core.entity_view_display.paragraph.links.default.yml b/config/sync/core.entity_view_display.paragraph.links.default.yml index 7dfc1657a..d1723cac7 100644 --- a/config/sync/core.entity_view_display.paragraph.links.default.yml +++ b/config/sync/core.entity_view_display.paragraph.links.default.yml @@ -24,4 +24,5 @@ content: third_party_settings: { } weight: 0 region: content -hidden: { } +hidden: + search_api_excerpt: true diff --git a/config/sync/core.entity_view_display.paragraph.medias.alternative.yml b/config/sync/core.entity_view_display.paragraph.medias.alternative.yml index 00eb109a6..f584a781a 100644 --- a/config/sync/core.entity_view_display.paragraph.medias.alternative.yml +++ b/config/sync/core.entity_view_display.paragraph.medias.alternative.yml @@ -20,4 +20,5 @@ content: third_party_settings: { } weight: 0 region: content -hidden: { } +hidden: + search_api_excerpt: true diff --git a/config/sync/core.entity_view_display.paragraph.medias.default.yml b/config/sync/core.entity_view_display.paragraph.medias.default.yml index 37b767da5..575e8971d 100644 --- a/config/sync/core.entity_view_display.paragraph.medias.default.yml +++ b/config/sync/core.entity_view_display.paragraph.medias.default.yml @@ -19,4 +19,5 @@ content: third_party_settings: { } weight: 0 region: content -hidden: { } +hidden: + search_api_excerpt: true diff --git a/config/sync/core.entity_view_display.paragraph.medias.preview.yml b/config/sync/core.entity_view_display.paragraph.medias.preview.yml index b65d380f0..304e18d24 100644 --- a/config/sync/core.entity_view_display.paragraph.medias.preview.yml +++ b/config/sync/core.entity_view_display.paragraph.medias.preview.yml @@ -20,4 +20,5 @@ content: third_party_settings: { } weight: 0 region: content -hidden: { } +hidden: + search_api_excerpt: true diff --git a/config/sync/core.entity_view_display.paragraph.text_body.default.yml b/config/sync/core.entity_view_display.paragraph.text_body.default.yml index 147c7318e..54edf5777 100644 --- a/config/sync/core.entity_view_display.paragraph.text_body.default.yml +++ b/config/sync/core.entity_view_display.paragraph.text_body.default.yml @@ -19,4 +19,5 @@ content: third_party_settings: { } weight: 0 region: content -hidden: { } +hidden: + search_api_excerpt: true diff --git a/config/sync/core.entity_view_display.paragraph.text_body.preview.yml b/config/sync/core.entity_view_display.paragraph.text_body.preview.yml index cf9ffa57e..74bd752b3 100644 --- a/config/sync/core.entity_view_display.paragraph.text_body.preview.yml +++ b/config/sync/core.entity_view_display.paragraph.text_body.preview.yml @@ -21,4 +21,5 @@ content: third_party_settings: { } weight: 0 region: content -hidden: { } +hidden: + search_api_excerpt: true diff --git a/config/sync/core.extension.yml b/config/sync/core.extension.yml index 4dc1f6de4..37cc30209 100644 --- a/config/sync/core.extension.yml +++ b/config/sync/core.extension.yml @@ -80,6 +80,8 @@ module: rest: 0 schemata: 0 schemata_json_schema: 0 + search_api: 0 + search_api_db: 0 serialization: 0 system: 0 text: 0 diff --git a/config/sync/search_api.index.events.yml b/config/sync/search_api.index.events.yml new file mode 100644 index 000000000..da076f292 --- /dev/null +++ b/config/sync/search_api.index.events.yml @@ -0,0 +1,47 @@ +uuid: 6476ceb4-e4f9-4dbc-b13a-755c12251ab2 +langcode: en +status: true +dependencies: + config: + - field.storage.node.field_event_date + - search_api.server.db_search + module: + - search_api + - node +id: events +name: Events +description: '' +read_only: false +field_settings: + end_value: + label: 'Date » End date value' + datasource_id: 'entity:node' + property_path: 'field_event_date:end_value' + type: date + dependencies: + config: + - field.storage.node.field_event_date +datasource_settings: + 'entity:node': + bundles: + default: false + selected: + - event + languages: + default: true + selected: { } +processor_settings: + add_url: { } + aggregated_field: { } + custom_value: { } + entity_type: { } + language_with_fallback: { } + rendered_item: { } +tracker_settings: + default: + indexing_order: fifo +options: + cron_limit: 50 + index_directly: true + track_changes_in_references: true +server: db_search diff --git a/config/sync/search_api.server.db_search.yml b/config/sync/search_api.server.db_search.yml new file mode 100644 index 000000000..7e4c09f00 --- /dev/null +++ b/config/sync/search_api.server.db_search.yml @@ -0,0 +1,15 @@ +uuid: 0d2716a3-9481-4f7a-90b6-eb5d42a61185 +langcode: en +status: true +dependencies: + module: + - search_api_db +id: db_search +name: 'DB Search' +description: '' +backend: search_api_db +backend_config: + database: 'default:default' + min_chars: 1 + matching: words + phrase: bigram diff --git a/config/sync/search_api.settings.yml b/config/sync/search_api.settings.yml new file mode 100644 index 000000000..510a3e528 --- /dev/null +++ b/config/sync/search_api.settings.yml @@ -0,0 +1,28 @@ +_core: + default_config_hash: b2zIRm9Jv3SB60NYdZkZHxH8-KdEa-Xa48-4NsIi4lg +default_cron_limit: 50 +cron_worker_runtime: 15 +default_tracker: default +tracking_page_size: 100 +boost_factors: + - 0.0 + - 0.1 + - 0.2 + - 0.3 + - 0.5 + - 0.6 + - 0.7 + - 0.8 + - 0.9 + - 1.0 + - 1.1 + - 1.2 + - 1.3 + - 1.4 + - 1.5 + - 2.0 + - 3.0 + - 5.0 + - 8.0 + - 13.0 + - 21.0 diff --git a/config/sync/search_api_db.settings.yml b/config/sync/search_api_db.settings.yml new file mode 100644 index 000000000..32ffc9406 --- /dev/null +++ b/config/sync/search_api_db.settings.yml @@ -0,0 +1,3 @@ +_core: + default_config_hash: fEmluJPpUL5dVqkWi0Fw89OlZYLhjQqyZIl6HWCDE1s +autocomplete_max_occurrences: 0.9 diff --git a/config/sync/views.view.events.yml b/config/sync/views.view.events.yml new file mode 100644 index 000000000..158b81c90 --- /dev/null +++ b/config/sync/views.view.events.yml @@ -0,0 +1,229 @@ +uuid: 64c2acda-1c36-4843-a6ae-35b06b00c172 +langcode: en +status: true +dependencies: + config: + - field.storage.node.field_event_date + - search_api.index.events + module: + - datetime_range + - search_api +id: events +label: Events +module: views +description: '' +tag: '' +base_table: search_api_index_events +base_field: search_api_id +display: + default: + id: default + display_title: Default + display_plugin: default + position: 0 + display_options: + title: Events + fields: + field_event_date: + id: field_event_date + table: search_api_index_events + field: field_event_date + relationship: none + group_type: group + admin_label: '' + entity_type: null + entity_field: null + plugin_id: search_api_field + label: '' + exclude: false + alter: + alter_text: false + text: '' + make_link: false + path: '' + absolute: false + external: false + replace_spaces: false + path_case: none + trim_whitespace: false + alt: '' + rel: '' + link_class: '' + prefix: '' + suffix: '' + target: '' + nl2br: false + max_length: 0 + word_boundary: true + ellipsis: true + more_link: false + more_link_text: '' + more_link_path: '' + strip_tags: false + trim: false + preserve_tags: '' + html: false + element_type: '' + element_class: '' + element_label_type: '' + element_label_class: '' + element_label_colon: true + element_wrapper_type: '' + element_wrapper_class: '' + element_default_classes: true + empty: '' + hide_empty: false + empty_zero: false + hide_alter_empty: true + click_sort_column: value + type: daterange_default + settings: { } + group_column: value + group_columns: { } + group_rows: true + delta_limit: 0 + delta_offset: 0 + delta_reversed: false + delta_first_last: false + multi_type: separator + separator: ', ' + field_api_classes: false + field_rendering: true + fallback_handler: search_api + fallback_options: + link_to_item: false + use_highlighting: false + multi_type: separator + multi_separator: ', ' + pager: + type: mini + options: + offset: 0 + items_per_page: 10 + total_pages: null + id: 0 + tags: + next: ›› + previous: ‹‹ + expose: + items_per_page: false + items_per_page_label: 'Items per page' + items_per_page_options: '5, 10, 25, 50' + items_per_page_options_all: false + items_per_page_options_all_label: '- All -' + offset: false + offset_label: Offset + exposed_form: + type: basic + options: + submit_button: Apply + reset_button: false + reset_button_label: Reset + exposed_sorts_label: 'Sort by' + expose_sort_order: true + sort_asc_label: Asc + sort_desc_label: Desc + access: + type: none + options: { } + cache: + type: none + options: { } + empty: { } + sorts: { } + arguments: { } + filters: + end_value: + id: end_value + table: search_api_index_events + field: end_value + relationship: none + group_type: group + admin_label: '' + plugin_id: search_api_date + operator: '>=' + value: + min: '' + max: '' + value: today + type: offset + group: 1 + exposed: false + expose: + operator_id: '' + label: '' + description: '' + use_operator: false + operator: '' + operator_limit_selection: false + operator_list: { } + identifier: '' + required: false + remember: false + multiple: false + remember_roles: + authenticated: authenticated + min_placeholder: '' + max_placeholder: '' + placeholder: '' + is_grouped: false + group_info: + label: '' + description: '' + identifier: '' + optional: true + widget: select + multiple: false + remember: false + default_group: All + default_group_multiple: { } + group_items: { } + style: + type: default + row: + type: search_api + options: + view_modes: + 'entity:node': + event: event_list_teaser + query: + type: search_api_query + options: + bypass_access: false + skip_access: false + preserve_facet_query_args: false + query_tags: { } + relationships: { } + header: { } + footer: { } + display_extenders: { } + cache_metadata: + max-age: -1 + contexts: + - 'languages:language_content' + - 'languages:language_interface' + - url.query_args + - 'user.node_grants:view' + tags: + - 'config:field.storage.node.field_event_date' + - 'config:search_api.index.events' + - 'search_api_list:events' + page_1: + id: page_1 + display_title: Page + display_plugin: page + position: 1 + display_options: + display_extenders: { } + path: Arrangementer + cache_metadata: + max-age: -1 + contexts: + - 'languages:language_content' + - 'languages:language_interface' + - url.query_args + - 'user.node_grants:view' + tags: + - 'config:field.storage.node.field_event_date' + - 'config:search_api.index.events' + - 'search_api_list:events' From 95a2f2e9df1ed7918051ab2733da4d66f9105b31 Mon Sep 17 00:00:00 2001 From: LasseStaus Date: Thu, 21 Dec 2023 15:30:49 +0100 Subject: [PATCH 02/76] Added module date_range_formatter. DDFFORM-59 --- composer.json | 1 + composer.lock | 50 +++++++++++++++++++++++++++++++++- config/sync/core.extension.yml | 1 + 3 files changed, 51 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 5fd101959..1a12381c5 100644 --- a/composer.json +++ b/composer.json @@ -86,6 +86,7 @@ "drupal/core-project-message": "~10.0.11", "drupal/core-recommended": "~10.0.11", "drupal/customerror": "^1.0@beta", + "drupal/date_range_formatter": "^4.0", "drupal/default_content": "^2.0@alpha", "drupal/devel": "~5.0.2", "drupal/enum_field": "^1.0", diff --git a/composer.lock b/composer.lock index ab9edffe1..b929da8a2 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "c10e7b6bd90d5c05829a062bd704795e", + "content-hash": "d7234e58819b45100d4098b66822842f", "packages": [ { "name": "amazeeio/drupal_integrations", @@ -2938,6 +2938,54 @@ "source": "https://git.drupalcode.org/project/customerror" } }, + { + "name": "drupal/date_range_formatter", + "version": "4.0.1", + "source": { + "type": "git", + "url": "https://git.drupalcode.org/project/date_range_formatter.git", + "reference": "4.0.1" + }, + "dist": { + "type": "zip", + "url": "https://ftp.drupal.org/files/projects/date_range_formatter-4.0.1.zip", + "reference": "4.0.1", + "shasum": "d218f325c9a1e144ede86d34b87002330a4e8709" + }, + "require": { + "drupal/core": "^8 || ^9 || ^10" + }, + "type": "drupal-module", + "extra": { + "drupal": { + "version": "4.0.1", + "datestamp": "1661752209", + "security-coverage": { + "status": "covered", + "message": "Covered by Drupal's security advisory policy" + } + } + }, + "notification-url": "https://packages.drupal.org/8/downloads", + "license": [ + "GPL-2.0-or-later" + ], + "authors": [ + { + "name": "maximpodorov", + "homepage": "https://www.drupal.org/user/515310" + }, + { + "name": "sudishth", + "homepage": "https://www.drupal.org/user/1440562" + } + ], + "description": "Formats date ranges.", + "homepage": "https://www.drupal.org/project/date_range_formatter", + "support": { + "source": "https://git.drupalcode.org/project/date_range_formatter" + } + }, { "name": "drupal/default_content", "version": "2.0.0-alpha2", diff --git a/config/sync/core.extension.yml b/config/sync/core.extension.yml index 37cc30209..146899a81 100644 --- a/config/sync/core.extension.yml +++ b/config/sync/core.extension.yml @@ -9,6 +9,7 @@ module: config_filter: 0 crop: 0 customerror: 0 + date_range_formatter: 0 datetime: 0 datetime_range: 0 dpl_admin: 0 From 2aa3add6f990f6efce87a5f4dd3f1c30e6732df8 Mon Sep 17 00:00:00 2001 From: LasseStaus Date: Thu, 21 Dec 2023 15:33:39 +0100 Subject: [PATCH 03/76] Added event-list-teaser view template & preprocess Added view mode for event-list-teaser and its' template. Added a preprocess on __node to prepare the ticket prices for the event-list-teaser view mode. DDFFORM-59 --- ...w_display.node.event.event_list_teaser.yml | 102 ++++++++++++++++++ ...ntity_view_mode.node.event_list_teaser.yml | 10 ++ web/themes/custom/novel/novel.theme | 70 +++++++++++- .../views/node--event-list-teaser.html.twig | 31 ++++++ 4 files changed, 212 insertions(+), 1 deletion(-) create mode 100644 config/sync/core.entity_view_display.node.event.event_list_teaser.yml create mode 100644 config/sync/core.entity_view_mode.node.event_list_teaser.yml create mode 100644 web/themes/custom/novel/templates/views/node--event-list-teaser.html.twig diff --git a/config/sync/core.entity_view_display.node.event.event_list_teaser.yml b/config/sync/core.entity_view_display.node.event.event_list_teaser.yml new file mode 100644 index 000000000..97aa9e100 --- /dev/null +++ b/config/sync/core.entity_view_display.node.event.event_list_teaser.yml @@ -0,0 +1,102 @@ +uuid: ada8a99f-6c6b-40e3-886a-519af92e33e6 +langcode: en +status: true +dependencies: + config: + - core.entity_view_mode.node.event_list_teaser + - field.field.node.event.field_event_address + - field.field.node.event.field_event_date + - field.field.node.event.field_event_description + - field.field.node.event.field_event_image + - field.field.node.event.field_event_link + - field.field.node.event.field_event_place + - field.field.node.event.field_event_state + - field.field.node.event.field_ticket_categories + - node.type.event + module: + - address + - date_range_formatter + - entity_reference_revisions + - link + - text + - user +id: node.event.event_list_teaser +targetEntityType: node +bundle: event +mode: event_list_teaser +content: + field_event_address: + type: address_default + label: hidden + settings: { } + third_party_settings: { } + weight: 4 + region: content + field_event_date: + type: date_range_without_time + label: hidden + settings: + timezone_override: '' + date_format: 'Y-m-d\TH:i:s' + separator: '-' + one_day: 'd. M Y' + one_month: 'd. - {d}. M Y' + several_months: 'd. M - {d}. {M} Y' + several_years: 'd. M Y - {d}. {M} {Y}' + third_party_settings: { } + weight: 7 + region: content + field_event_description: + type: text_default + label: hidden + settings: { } + third_party_settings: { } + weight: 1 + region: content + field_event_image: + type: entity_reference_entity_view + label: hidden + settings: + view_mode: default + link: false + third_party_settings: { } + weight: 6 + region: content + field_event_link: + type: link + label: hidden + settings: + trim_length: 80 + url_only: false + url_plain: false + rel: '' + target: '' + third_party_settings: { } + weight: 3 + region: content + field_event_place: + type: string + label: hidden + settings: + link_to_entity: false + third_party_settings: { } + weight: 5 + region: content + field_ticket_categories: + type: entity_reference_revisions_entity_view + label: hidden + settings: + view_mode: default + link: '' + third_party_settings: { } + weight: 2 + region: content + links: + settings: { } + third_party_settings: { } + weight: 0 + region: content +hidden: + field_event_state: true + langcode: true + search_api_excerpt: true diff --git a/config/sync/core.entity_view_mode.node.event_list_teaser.yml b/config/sync/core.entity_view_mode.node.event_list_teaser.yml new file mode 100644 index 000000000..2217538ff --- /dev/null +++ b/config/sync/core.entity_view_mode.node.event_list_teaser.yml @@ -0,0 +1,10 @@ +uuid: 8c2b4ca5-9c0e-4734-a4a3-b03b6c7252b0 +langcode: en +status: true +dependencies: + module: + - node +id: node.event_list_teaser +label: 'Event list teaser' +targetEntityType: node +cache: true diff --git a/web/themes/custom/novel/novel.theme b/web/themes/custom/novel/novel.theme index 55af5a9f4..60ccad9dd 100644 --- a/web/themes/custom/novel/novel.theme +++ b/web/themes/custom/novel/novel.theme @@ -6,8 +6,8 @@ */ use Drupal\Core\StringTranslation\TranslatableMarkup; - use function Safe\file_get_contents; +use function Safe\sort; use function Safe\sprintf; /** @@ -86,3 +86,71 @@ function novel_preprocess_dpl_react_app__search_result(array &$variables): void // That enables us to vary the "searching" title line. $variables['#cache']['contexts'][] = "url.query_args:q"; } + +/** + * Implements hook_preprocess_HOOK() for node templates. + * + * Preprocesses variables for node templates. + * + * Includes generating ticket pricing display in 'event_list_teaser' view mode. + * + * @param mixed[] $variables + * The variables array for the node template. + * + * @throws \Safe\Exceptions\ArrayException + */ +function novel_preprocess_node(array &$variables):void { + if ($variables['node']->hasField('field_ticket_categories')) { + $ticket_categories = $variables['node']->get('field_ticket_categories')->referencedEntities(); + $prices = []; + + // Collect prices from ticket categories. + foreach ($ticket_categories as $category) { + if ($category->hasField('field_ticket_category_price') && !$category->get('field_ticket_category_price')->isEmpty()) { + $price = $category->get('field_ticket_category_price')->value; + $prices[] = (floatval($price) == intval($price)) ? intval($price) : floatval($price); + } + } + + $variables['ticket_price_display'] = novel_get_ticket_price_display($prices); + } +} + +/** + * Helper function to format the price display string. + * + * @param float[] $prices + * Array of price values from ticket categories. + * + * @return string + * Formatted price display string. + * + * @throws \Safe\Exceptions\ArrayException + */ +function novel_get_ticket_price_display(array $prices): string { + sort($prices); + $price_display = ''; + + if (empty($prices) || (count($prices) === 1 && $prices[0] == 0)) { + $price_display = 'Gratis'; + } + else { + $has_free_price = in_array(0, $prices); + $filtered_prices = array_filter($prices, fn($price) => $price > 0); + + if ($has_free_price && !empty($filtered_prices)) { + $highest_price = max($filtered_prices); + $price_display = 'Gratis - ' . $highest_price . ' KR'; + } + elseif ($has_free_price) { + $price_display = 'Gratis'; + } + else { + $lowest_price = min($filtered_prices); + $highest_price = max($filtered_prices); + $price_display = $lowest_price . ($lowest_price != $highest_price ? ' - ' . $highest_price : '') . ' KR'; + } + } + + return $price_display; +} diff --git a/web/themes/custom/novel/templates/views/node--event-list-teaser.html.twig b/web/themes/custom/novel/templates/views/node--event-list-teaser.html.twig new file mode 100644 index 000000000..73e8f1e83 --- /dev/null +++ b/web/themes/custom/novel/templates/views/node--event-list-teaser.html.twig @@ -0,0 +1,31 @@ + +
+ {% if content.field_event_image['#items'] is not empty %} + {% set image_uri = content.field_event_image['#items'].entity.field_media_image.entity.fileuri %} + {% set image_url = file_url(image_uri) %} + {{ content.label }} + {% endif %} +
+
+
foredrag
+

{{ content.field_event_date|render|striptags }}

+

{{ label }}

+

{{ content.field_event_description|render|striptags|trim }}

+
+ {% for item in content.field_event_place['#items'] %} +

{{ item.value }}

+ {% endfor %} +
+
+ + {% if ticket_price_display is defined %} +

{{ ticket_price_display }}

+ {% endif %} +
+
+ {{ source(directory ~ '/assets/dpl-design-system/icons/arrow-ui/icon-arrow-ui-small-right.svg') }} +
From 12bd57ae92cbf22c19bd20b28caa444cfc2d1e4b Mon Sep 17 00:00:00 2001 From: LasseStaus Date: Thu, 21 Dec 2023 15:35:32 +0100 Subject: [PATCH 04/76] Added templates for the unformatted list view mode. Added template for the events view page. Correspondes to eventList and eventListPage in the design system DDFFORM-59 --- .../views/views-view--events.html.twig | 40 +++++++++++++++++++ .../views-view-unformatted--events.html.twig | 7 ++++ 2 files changed, 47 insertions(+) create mode 100644 web/themes/custom/novel/templates/views/views-view--events.html.twig create mode 100644 web/themes/custom/novel/templates/views/views-view-unformatted--events.html.twig diff --git a/web/themes/custom/novel/templates/views/views-view--events.html.twig b/web/themes/custom/novel/templates/views/views-view--events.html.twig new file mode 100644 index 000000000..5b66c0411 --- /dev/null +++ b/web/themes/custom/novel/templates/views/views-view--events.html.twig @@ -0,0 +1,40 @@ +{% + set classes = [ + dom_id ? 'js-view-dom-id-' ~ dom_id, + 'event-list-page' +] +%} + + {{ title_prefix }} + {{ title }} + {{ title_suffix }} + +

Arrangementer

+ + {% if header %} +
+ {{ header }} +
+ {% endif %} + + {{ exposed }} + {{ attachment_before }} + + {% if rows -%} + {{ rows }} + {% elseif empty -%} + {{ empty }} + {% endif %} + {{ pager }} + + {{ attachment_after }} + {{ more }} + + {% if footer %} +
+ {{ footer }} +
+ {% endif %} + + {{ feed_icons }} + diff --git a/web/themes/custom/novel/templates/views/views-view-unformatted--events.html.twig b/web/themes/custom/novel/templates/views/views-view-unformatted--events.html.twig new file mode 100644 index 000000000..8b4f74bb6 --- /dev/null +++ b/web/themes/custom/novel/templates/views/views-view-unformatted--events.html.twig @@ -0,0 +1,7 @@ +
    + {% for row in rows %} +
  • + {{ row.content }} +
  • + {% endfor %} +
From 8811059746d352c82fea0a90a45cc59a18e2960d Mon Sep 17 00:00:00 2001 From: LasseStaus Date: Thu, 21 Dec 2023 15:37:36 +0100 Subject: [PATCH 05/76] Refactor the way dates were shown on the page for a single event. By adding the module date_range_formatter it is no longer necessary to create twig-logic for handling the dates. I configured the display with the new module to match the event-list-teaser, and updated the html, including deleting field--node--field-event-date.html.twig template. DDFFORM-59 --- ...entity_view_display.node.event.default.yml | 12 ++++++++- ...re.entity_view_display.node.event.full.yml | 9 +++++-- .../field--node--field-event-date.html.twig | 27 ------------------- .../layout/node--event--full.html.twig | 8 +++--- 4 files changed, 23 insertions(+), 33 deletions(-) delete mode 100644 web/themes/custom/novel/templates/fields/field--node--field-event-date.html.twig diff --git a/config/sync/core.entity_view_display.node.event.default.yml b/config/sync/core.entity_view_display.node.event.default.yml index c77add38d..a1c73d0ce 100644 --- a/config/sync/core.entity_view_display.node.event.default.yml +++ b/config/sync/core.entity_view_display.node.event.default.yml @@ -14,6 +14,7 @@ dependencies: - node.type.event module: - address + - datetime_range - entity_reference_revisions - link - text @@ -30,6 +31,16 @@ content: third_party_settings: { } weight: 4 region: content + field_event_date: + type: daterange_default + label: above + settings: + timezone_override: '' + format_type: medium + separator: '-' + third_party_settings: { } + weight: 7 + region: content field_event_description: type: text_default label: above @@ -81,7 +92,6 @@ content: weight: 0 region: content hidden: - field_event_date: true field_event_state: true langcode: true search_api_excerpt: true diff --git a/config/sync/core.entity_view_display.node.event.full.yml b/config/sync/core.entity_view_display.node.event.full.yml index dd103bf3c..948801bcc 100644 --- a/config/sync/core.entity_view_display.node.event.full.yml +++ b/config/sync/core.entity_view_display.node.event.full.yml @@ -15,7 +15,7 @@ dependencies: - node.type.event module: - address - - datetime_range + - date_range_formatter - entity_reference_revisions - link - text @@ -33,11 +33,16 @@ content: weight: 3 region: content field_event_date: - type: daterange_plain + type: date_range_without_time label: hidden settings: timezone_override: '' + date_format: 'Y-m-d\TH:i:s' separator: '-' + one_day: 'd. M Y' + one_month: 'd. - {d}. M Y' + several_months: 'd. M - {d}. {M} Y' + several_years: 'd. M Y - {d}. {M} {Y}' third_party_settings: { } weight: 0 region: content diff --git a/web/themes/custom/novel/templates/fields/field--node--field-event-date.html.twig b/web/themes/custom/novel/templates/fields/field--node--field-event-date.html.twig deleted file mode 100644 index aca3a6170..000000000 --- a/web/themes/custom/novel/templates/fields/field--node--field-event-date.html.twig +++ /dev/null @@ -1,27 +0,0 @@ -{% for item in items %} - {% set start_date = item.content.start_date["#markup"]|date("U") %} - {% set end_date = item.content.end_date["#markup"]|date("U") %} - - {% set start_day = start_date|date("j.") %} - {% set start_month = start_date|date("M") %} - {% set start_year = start_date|date("Y") %} - {% set end_day = end_date|date("j.") %} - {% set end_month = end_date|date("M") %} - {% set end_year = end_date|date("Y") %} - - - {% if start_day == end_day and start_month == end_month and start_year == end_year %} - {# Same day #} - {{ start_day ~ ' ' ~ start_month ~ ' ' ~ start_year }} - {% elseif start_month == end_month and start_year == end_year %} - {# Same month #} - {{ start_day ~ ' - ' ~ end_day ~ ' ' ~ start_month ~ ' ' ~ start_year }} - {% elseif start_year == end_year %} - {# Different months, same year #} - {{ start_day ~ ' ' ~ start_month ~ ' - ' ~ end_day ~ ' ' ~ end_month ~ ' ' ~ start_year }} - {% else %} - {# Different years #} - {{ start_date|date("j. M Y") ~ ' - ' ~ end_date|date("j. M Y") }} - {% endif %} - -{% endfor %} diff --git a/web/themes/custom/novel/templates/layout/node--event--full.html.twig b/web/themes/custom/novel/templates/layout/node--event--full.html.twig index 53113a1e5..c484530b2 100644 --- a/web/themes/custom/novel/templates/layout/node--event--full.html.twig +++ b/web/themes/custom/novel/templates/layout/node--event--full.html.twig @@ -2,7 +2,9 @@
+

{{ label }}

{{ content.field_event_link }}
@@ -28,9 +30,9 @@
{{ "Time"|trans }}
- {{ content.field_event_date.0.start_date["#markup"]|date("H:i") }} - - - {{ content.field_event_date.0.end_date["#markup"]|date("H:i") }} + {{ content.field_event_date['#items'].0.start_date|date("H:i") }} + - + {{ content.field_event_date['#items'].0.end_date|date("H:i") }}
{% endif %} From f80ecc0b28fb18f4ac05b92285bbb3a189cefb7b Mon Sep 17 00:00:00 2001 From: LasseStaus Date: Fri, 5 Jan 2024 08:52:19 +0100 Subject: [PATCH 06/76] Added datetime attribute for list teaser Added a datetime attribute for