diff --git a/src/site/stages/build/drupal/graphql/nodeEvent.graphql.js b/src/site/stages/build/drupal/graphql/nodeEvent.graphql.js index 4b4b1e50ab..a808613e1e 100644 --- a/src/site/stages/build/drupal/graphql/nodeEvent.graphql.js +++ b/src/site/stages/build/drupal/graphql/nodeEvent.graphql.js @@ -312,6 +312,32 @@ const nodeEventWithoutBreadcrumbs = ` } } } + fieldAdditionalListings { + entity { + entityBundle + entityId + entityType + ... on NodeEventListing { + fieldDescription + fieldIntroText + fieldOffice { + entity { + entityType + entityBundle + entityId + ... on NodeOffice { + fieldBody { + value + format + processed + } + fieldDescription + } + } + } + } + } + } fieldLocationHumanreadable fieldLocationType fieldMedia { diff --git a/src/site/stages/build/drupal/graphql/nodeEventListing.graphql.js b/src/site/stages/build/drupal/graphql/nodeEventListing.graphql.js index 5a7ecf6340..a675bc4660 100644 --- a/src/site/stages/build/drupal/graphql/nodeEventListing.graphql.js +++ b/src/site/stages/build/drupal/graphql/nodeEventListing.graphql.js @@ -21,6 +21,11 @@ const nodeEventListing = ` ... nodeEventWithoutBreadcrumbs } } + reverseFieldAdditionalListingsNode(limit: 5000, filter: { conditions: [{ field: "status", value: "1", operator: EQUAL, enabled: $onlyPublishedContent }, { field: "moderation_state", value: "archived", operator: NOT_EQUAL }, { field: "type", value: "event" }]}, sort: {field: "changed", direction: DESC}) { + entities { + ... nodeEventWithoutBreadcrumbs + } + } fieldOffice { entity { ...on NodeHealthCareRegionPage { diff --git a/src/site/stages/build/drupal/health-care-region.js b/src/site/stages/build/drupal/health-care-region.js index 6bb117eb6a..10b1870315 100644 --- a/src/site/stages/build/drupal/health-care-region.js +++ b/src/site/stages/build/drupal/health-care-region.js @@ -86,6 +86,29 @@ function createPastEventListPages(page, drupalPagePath, files) { ); } +/** + * Compiles fields for event listing pages. + * + * @param {page} page The page object. + * @return nothing + */ +function compileEventListingPage(page) { + const { cmsFeatureFlags } = global; + // Combine events from reverse entity reference queries, if additional + // listings data exists and feature flag is on. + if ( + cmsFeatureFlags.FEATURE_EVENT_OUTREACH_CHECKBOX && + page?.reverseFieldAdditionalListingsNode?.entities + ) { + page.reverseFieldListingNode.entities.push( + ...page.reverseFieldAdditionalListingsNode.entities, + ); + } + // Compile final template variables. + page.pastEventTeasers = page.pastEvents; + page.allEventTeasers = page.reverseFieldListingNode; +} + // Creates the facility pages function createHealthCareRegionListPages(page, drupalPagePath, files) { const sidebar = page.facilitySidebar; @@ -283,4 +306,5 @@ module.exports = { createPastEventListPages, addGetUpdatesFields, addPager, + compileEventListingPage, }; diff --git a/src/site/stages/build/drupal/metalsmith-drupal.js b/src/site/stages/build/drupal/metalsmith-drupal.js index bf8462c80c..5645e22d80 100644 --- a/src/site/stages/build/drupal/metalsmith-drupal.js +++ b/src/site/stages/build/drupal/metalsmith-drupal.js @@ -16,6 +16,7 @@ const { createPastEventListPages, addGetUpdatesFields, addPager, + compileEventListingPage, } = require('./health-care-region'); const createReactPages = require('../plugins/create-react-pages'); @@ -83,8 +84,7 @@ function pipeDrupalPagesIntoMetalsmith(contentData, files) { addGetUpdatesFields(pageCompiled, pages); break; case 'event_listing': - pageCompiled.pastEventTeasers = pageCompiled.pastEvents; - pageCompiled.allEventTeasers = pageCompiled.reverseFieldListingNode; + compileEventListingPage(pageCompiled); addPager( pageCompiled, files,