diff --git a/config/sync/core.entity_view_display.node.stanford_event.stanford_card.yml b/config/sync/core.entity_view_display.node.stanford_event.stanford_card.yml index 7eff3f11e..72a441209 100644 --- a/config/sync/core.entity_view_display.node.stanford_event.stanford_card.yml +++ b/config/sync/core.entity_view_display.node.stanford_event.stanford_card.yml @@ -48,13 +48,13 @@ third_party_settings: field_templates: only_content regions: start_month: - - 'dynamic_token_field:node-event_start_month' + - 'display_field_copy:node-event_date_time_1' start_date: - - 'dynamic_token_field:node-event_start_day' + - 'display_field_copy:node-event_date_time_2' end_month: - - 'dynamic_token_field:node-date_end_month' + - 'display_field_copy:node-event_date_time_3' end_date: - - 'dynamic_token_field:node-date_end_day' + - 'display_field_copy:node-event_date_time_4' event_type: - su_event_type headline: @@ -70,29 +70,97 @@ third_party_settings: address: - su_event_location fields: - 'dynamic_token_field:node-date_end_day': - plugin_id: 'dynamic_token_field:node-date_end_day' - weight: 3 + 'display_field_copy:node-event_date_time_1': + plugin_id: 'display_field_copy:node-event_date_time_1' + weight: 0 label: hidden - formatter: default - 'dynamic_token_field:node-date_end_month': - plugin_id: 'dynamic_token_field:node-date_end_month' - weight: 2 + formatter: smartdate_default + settings: + formatter: + parts: + start: start + end: 0 + duration: 0 + timezone_override: '' + format: short_month + duration: + separator: ' | ' + unit: '' + decimals: '2' + suffix: h + time_wrapper: '1' + force_chronological: 0 + add_classes: 0 + localize: 0 + 'display_field_copy:node-event_date_time_2': + plugin_id: 'display_field_copy:node-event_date_time_2' + weight: 0 label: hidden - formatter: default - 'dynamic_token_field:node-event_start_day': - plugin_id: 'dynamic_token_field:node-event_start_day' - weight: 1 + formatter: smartdate_default + settings: + formatter: + parts: + start: start + end: 0 + duration: 0 + timezone_override: '' + format: day + duration: + separator: ' | ' + unit: '' + decimals: '2' + suffix: h + time_wrapper: '1' + force_chronological: 0 + add_classes: 0 + localize: 0 + 'display_field_copy:node-event_date_time_3': + plugin_id: 'display_field_copy:node-event_date_time_3' + weight: 0 label: hidden - formatter: default - 'dynamic_token_field:node-event_start_month': - plugin_id: 'dynamic_token_field:node-event_start_month' + formatter: smartdate_default + settings: + formatter: + parts: + end: end + start: 0 + duration: 0 + timezone_override: '' + format: short_month + duration: + separator: ' | ' + unit: '' + decimals: '2' + suffix: h + time_wrapper: '1' + force_chronological: 0 + add_classes: 0 + localize: 0 + 'display_field_copy:node-event_date_time_4': + plugin_id: 'display_field_copy:node-event_date_time_4' weight: 0 label: hidden - formatter: default + formatter: smartdate_default + settings: + formatter: + parts: + end: end + start: 0 + duration: 0 + timezone_override: '' + format: day + duration: + separator: ' | ' + unit: '' + decimals: '2' + suffix: h + time_wrapper: '1' + force_chronological: 0 + add_classes: 0 + localize: 0 node_title: plugin_id: node_title - weight: 5 + weight: 6 label: hidden formatter: default settings: @@ -110,7 +178,7 @@ content: settings: link_to_entity: false third_party_settings: { } - weight: 9 + weight: 10 region: location su_event_date_time: type: smartdate_default @@ -122,17 +190,26 @@ content: force_chronological: false add_classes: false time_wrapper: true + localize: false + parts: + - start + - end + duration: + separator: ' | ' + unit: '' + decimals: 2 + suffix: h third_party_settings: field_formatter_class: class: '' - weight: 8 + weight: 9 region: date_time su_event_location: type: address_default label: hidden settings: { } third_party_settings: { } - weight: 10 + weight: 11 region: address su_event_source: type: link @@ -146,7 +223,7 @@ content: third_party_settings: field_formatter_class: class: '' - weight: 7 + weight: 8 region: url su_event_subheadline: type: string @@ -154,7 +231,7 @@ content: settings: link_to_entity: false third_party_settings: { } - weight: 6 + weight: 7 region: subheadline su_event_type: type: entity_reference_label @@ -166,7 +243,7 @@ content: class: '' ds: ds_limit: '1' - weight: 4 + weight: 5 region: event_type hidden: body: true diff --git a/config/sync/core.entity_view_display.node.stanford_event.teaser.yml b/config/sync/core.entity_view_display.node.stanford_event.teaser.yml index c371e07e6..5556aed26 100644 --- a/config/sync/core.entity_view_display.node.stanford_event.teaser.yml +++ b/config/sync/core.entity_view_display.node.stanford_event.teaser.yml @@ -49,13 +49,13 @@ third_party_settings: field_templates: only_content regions: start_month: - - 'dynamic_token_field:node-event_start_month' + - 'display_field_copy:node-event_date_time_1' start_date: - - 'dynamic_token_field:node-event_start_day' + - 'display_field_copy:node-event_date_time_2' end_month: - - 'dynamic_token_field:node-date_end_month' + - 'display_field_copy:node-event_date_time_3' end_date: - - 'dynamic_token_field:node-date_end_day' + - 'display_field_copy:node-event_date_time_4' event_type: - su_event_type headline: @@ -69,29 +69,97 @@ third_party_settings: date_time: - su_event_date_time location: - - su_event_location - su_event_alt_loc + - su_event_location fields: - 'dynamic_token_field:node-date_end_day': - plugin_id: 'dynamic_token_field:node-date_end_day' - weight: 3 + 'display_field_copy:node-event_date_time_1': + plugin_id: 'display_field_copy:node-event_date_time_1' + weight: 0 label: hidden - formatter: default - 'dynamic_token_field:node-date_end_month': - plugin_id: 'dynamic_token_field:node-date_end_month' - weight: 2 + formatter: smartdate_default + settings: + formatter: + parts: + start: start + end: 0 + duration: 0 + timezone_override: '' + format: short_month + duration: + separator: ' | ' + unit: '' + decimals: '2' + suffix: h + time_wrapper: '1' + force_chronological: 0 + add_classes: 0 + localize: 0 + 'display_field_copy:node-event_date_time_2': + plugin_id: 'display_field_copy:node-event_date_time_2' + weight: 0 label: hidden - formatter: default - 'dynamic_token_field:node-event_start_day': - plugin_id: 'dynamic_token_field:node-event_start_day' - weight: 1 + formatter: smartdate_default + settings: + formatter: + parts: + start: start + end: 0 + duration: 0 + timezone_override: '' + format: day + duration: + separator: ' | ' + unit: '' + decimals: '2' + suffix: h + time_wrapper: '1' + force_chronological: 0 + add_classes: 0 + localize: 0 + 'display_field_copy:node-event_date_time_3': + plugin_id: 'display_field_copy:node-event_date_time_3' + weight: 0 label: hidden - formatter: default - 'dynamic_token_field:node-event_start_month': - plugin_id: 'dynamic_token_field:node-event_start_month' + formatter: smartdate_default + settings: + formatter: + parts: + end: end + start: 0 + duration: 0 + timezone_override: '' + format: short_month + duration: + separator: ' | ' + unit: '' + decimals: '2' + suffix: h + time_wrapper: '1' + force_chronological: 0 + add_classes: 0 + localize: 0 + 'display_field_copy:node-event_date_time_4': + plugin_id: 'display_field_copy:node-event_date_time_4' weight: 0 label: hidden - formatter: default + formatter: smartdate_default + settings: + formatter: + parts: + end: end + start: 0 + duration: 0 + timezone_override: '' + format: day + duration: + separator: ' | ' + unit: '' + decimals: '2' + suffix: h + time_wrapper: '1' + force_chronological: 0 + add_classes: 0 + localize: 0 node_title: plugin_id: node_title weight: 5 @@ -122,6 +190,17 @@ content: format_type: medium format: stanford_events_long force_chronological: false + add_classes: false + time_wrapper: true + localize: false + parts: + - start + - end + duration: + separator: ' | ' + unit: '' + decimals: 2 + suffix: h third_party_settings: field_formatter_class: class: '' @@ -141,7 +220,7 @@ content: settings: { } third_party_settings: { } weight: 11 - region: address + region: location su_event_source: type: link label: hidden diff --git a/config/sync/ds.field.basic_page_type_content_url.yml b/config/sync/ds.field.basic_page_type_content_url.yml deleted file mode 100644 index 06b37d519..000000000 --- a/config/sync/ds.field.basic_page_type_content_url.yml +++ /dev/null @@ -1,11 +0,0 @@ -id: basic_page_type_content_url -label: 'Basic Page Type Content URL' -ui_limit: 'stanford_page|*' -type: token -type_label: 'Token field' -entities: - node: node -properties: - content: - value: "

[node:url]

\r\n" - format: stanford_minimal_html diff --git a/config/sync/ds.field.date_end_day.yml b/config/sync/ds.field.date_end_day.yml deleted file mode 100644 index 3156c33d0..000000000 --- a/config/sync/ds.field.date_end_day.yml +++ /dev/null @@ -1,11 +0,0 @@ -id: date_end_day -label: 'Date - End Day' -ui_limit: 'stanford_event|*' -type: token -type_label: 'Token field' -entities: - node: node -properties: - content: - value: '[node:su_event_date_time:end_value-custom:d]' - format: plain_text diff --git a/config/sync/ds.field.date_end_month.yml b/config/sync/ds.field.date_end_month.yml deleted file mode 100644 index 1f0bf0fd1..000000000 --- a/config/sync/ds.field.date_end_month.yml +++ /dev/null @@ -1,11 +0,0 @@ -id: date_end_month -label: 'Date - End Month' -ui_limit: 'stanford_event|*' -type: token -type_label: 'Token field' -entities: - node: node -properties: - content: - value: '[node:su_event_date_time:end_value-custom:M]' - format: plain_text diff --git a/config/sync/ds.field.event_date_time_1.yml b/config/sync/ds.field.event_date_time_1.yml new file mode 100644 index 000000000..4cd7619ea --- /dev/null +++ b/config/sync/ds.field.event_date_time_1.yml @@ -0,0 +1,9 @@ +id: event_date_time_1 +label: 'Date Time 1' +ui_limit: 'stanford_event|*' +type: display_field_copy +type_label: 'Copy field' +entities: + node: node +properties: + field_id: node.stanford_event.su_event_date_time diff --git a/config/sync/ds.field.event_date_time_2.yml b/config/sync/ds.field.event_date_time_2.yml new file mode 100644 index 000000000..1a0c75ccd --- /dev/null +++ b/config/sync/ds.field.event_date_time_2.yml @@ -0,0 +1,9 @@ +id: event_date_time_2 +label: 'Date Time 2' +ui_limit: 'stanford_event|*' +type: display_field_copy +type_label: 'Copy field' +entities: + node: node +properties: + field_id: node.stanford_event.su_event_date_time diff --git a/config/sync/ds.field.event_date_time_3.yml b/config/sync/ds.field.event_date_time_3.yml new file mode 100644 index 000000000..7975773f0 --- /dev/null +++ b/config/sync/ds.field.event_date_time_3.yml @@ -0,0 +1,9 @@ +id: event_date_time_3 +label: 'Date Time 3' +ui_limit: 'stanford_event|*' +type: display_field_copy +type_label: 'Copy field' +entities: + node: node +properties: + field_id: node.stanford_event.su_event_date_time diff --git a/config/sync/ds.field.event_date_time_4.yml b/config/sync/ds.field.event_date_time_4.yml new file mode 100644 index 000000000..1b2d0b145 --- /dev/null +++ b/config/sync/ds.field.event_date_time_4.yml @@ -0,0 +1,9 @@ +id: event_date_time_4 +label: 'Date Time 4' +ui_limit: 'stanford_event|*' +type: display_field_copy +type_label: 'Copy field' +entities: + node: node +properties: + field_id: node.stanford_event.su_event_date_time diff --git a/config/sync/ds.field.event_start_day.yml b/config/sync/ds.field.event_start_day.yml deleted file mode 100644 index b6d66454f..000000000 --- a/config/sync/ds.field.event_start_day.yml +++ /dev/null @@ -1,11 +0,0 @@ -id: event_start_day -label: 'Date - Start Day' -ui_limit: 'stanford_event|*' -type: token -type_label: 'Token field' -entities: - node: node -properties: - content: - value: '[node:su_event_date_time:value-custom:d]' - format: plain_text diff --git a/config/sync/ds.field.event_start_month.yml b/config/sync/ds.field.event_start_month.yml deleted file mode 100644 index ad194450c..000000000 --- a/config/sync/ds.field.event_start_month.yml +++ /dev/null @@ -1,11 +0,0 @@ -id: event_start_month -label: 'Date - Start Month' -ui_limit: 'stanford_event|*' -type: token -type_label: 'Token field' -entities: - node: node -properties: - content: - value: '[node:su_event_date_time:value-custom:M]' - format: plain_text diff --git a/config/sync/smart_date.smart_date_format.day.yml b/config/sync/smart_date.smart_date_format.day.yml new file mode 100644 index 000000000..eb88f8fa0 --- /dev/null +++ b/config/sync/smart_date.smart_date_format.day.yml @@ -0,0 +1,15 @@ +uuid: 8a731073-7673-4349-84d9-710af9c3cf32 +langcode: en +status: true +dependencies: { } +id: day +label: Day +date_format: j +time_format: '' +time_hour_format: '' +allday_label: '' +separator: ' - ' +join: ', ' +ampm_reduce: '1' +date_first: '1' +site_time_toggle: '1' diff --git a/config/sync/smart_date.smart_date_format.short_month.yml b/config/sync/smart_date.smart_date_format.short_month.yml new file mode 100644 index 000000000..7dc793d69 --- /dev/null +++ b/config/sync/smart_date.smart_date_format.short_month.yml @@ -0,0 +1,15 @@ +uuid: dadcc509-5bbe-4f59-8a3a-7b18f054d510 +langcode: en +status: true +dependencies: { } +id: short_month +label: 'Short Month' +date_format: M +time_format: '' +time_hour_format: '' +allday_label: '' +separator: ' - ' +join: ', ' +ampm_reduce: '1' +date_first: '1' +site_time_toggle: '1' diff --git a/tests/codeception/acceptance/Content/EventsCest.php b/tests/codeception/acceptance/Content/EventsCest.php index 14ae51730..38b84e94b 100644 --- a/tests/codeception/acceptance/Content/EventsCest.php +++ b/tests/codeception/acceptance/Content/EventsCest.php @@ -341,6 +341,37 @@ public function testClone(AcceptanceTester $I) { $I->assertEquals(6, round($diff / (60 * 60 * 24 * 30.5))); } + /** + * Test event card markup. + */ + public function testEventCard(AcceptanceTester $I) { + $event = $this->createEventNode($I); + $view_builder = \Drupal::entityTypeManager()->getViewBuilder('node'); + $pre_render = $view_builder->view($event, 'stanford_card'); + $render_output = \Drupal::service('renderer')->renderPlain($pre_render); + + libxml_use_internal_errors(TRUE); + $dom = new DOMDocument(); + $dom->loadHTML($render_output); + $xpath = new DOMXPath($dom); + + $month = $xpath->query('//span[@class="su-event-start-month"]'); + $I->assertNotEmpty($month); + $I->assertEquals(date('M', time()), $month->item(0)->nodeValue, 'Start Month does not match'); + + $day = $xpath->query('//span[@class="su-event-start-date"]'); + $I->assertNotEmpty($day); + $I->assertEquals(date('j', time()), $day->item(0)->nodeValue, 'Start Date does not match'); + + $month = $xpath->query('//span[@class="su-event-end-month"]'); + $I->assertNotEmpty($month); + $I->assertEquals(date('M', time() + (60 * 60 * 24)), $month->item(0)->nodeValue, 'End Month does not match'); + + $day = $xpath->query('//span[@class="su-event-end-date"]'); + $I->assertNotEmpty($day); + $I->assertEquals(date('j', time() + (60 * 60 * 24)), $day->item(0)->nodeValue, 'End Date does not match'); + } + /** * Create an Event Node. *