diff --git a/modules/oe_theme_content_entity_contact/config/install/core.entity_view_display.oe_contact.oe_general.full.yml b/modules/oe_theme_content_entity_contact/config/install/core.entity_view_display.oe_contact.oe_general.full.yml index ee614d106..cebf40083 100644 --- a/modules/oe_theme_content_entity_contact/config/install/core.entity_view_display.oe_contact.oe_general.full.yml +++ b/modules/oe_theme_content_entity_contact/config/install/core.entity_view_display.oe_contact.oe_general.full.yml @@ -35,15 +35,15 @@ third_party_settings: - oe_address - oe_office - oe_social_media + label: 'Contact information' parent_name: '' + region: content weight: 2 format_type: oe_theme_helper_field_list_pattern format_settings: - variant: horizontal classes: '' id: '' - label: 'Contact information' - region: content + variant: horizontal id: oe_contact.oe_general.full targetEntityType: oe_contact bundle: oe_general @@ -51,54 +51,51 @@ mode: full content: name: type: string - weight: 0 - region: content label: hidden settings: link_to_entity: false third_party_settings: { } + weight: 0 + region: content oe_address: - weight: 17 + type: oe_theme_helper_address_commission label: hidden - settings: - delimiter: ', ' + settings: { } third_party_settings: { } - type: oe_theme_helper_address_inline + weight: 17 region: content oe_body: type: text_default - weight: 1 - region: content label: hidden settings: { } third_party_settings: { } + weight: 1 + region: content oe_email: - weight: 13 + type: email_mailto label: hidden settings: { } third_party_settings: { } - type: email_mailto + weight: 13 region: content oe_fax: type: string - weight: 16 - region: content label: hidden settings: link_to_entity: false third_party_settings: { } + weight: 16 + region: content oe_image: type: oe_theme_helper_featured_media_formatter - weight: 5 - region: content label: hidden settings: image_style: '' third_party_settings: { } + weight: 5 + region: content oe_link: type: link - weight: 4 - region: content label: hidden settings: trim_length: 80 @@ -107,42 +104,42 @@ content: rel: '' target: '' third_party_settings: { } + weight: 4 + region: content oe_mobile: type: string - weight: 15 - region: content label: hidden settings: link_to_entity: false third_party_settings: { } + weight: 15 + region: content oe_office: type: string - weight: 18 - region: content label: hidden settings: link_to_entity: false third_party_settings: { } + weight: 18 + region: content oe_organisation: type: string - weight: 11 - region: content label: hidden settings: link_to_entity: false third_party_settings: { } + weight: 11 + region: content oe_phone: - weight: 14 + type: string label: hidden settings: link_to_entity: false third_party_settings: { } - type: string + weight: 14 region: content oe_press_contact_url: type: link - weight: 3 - region: content label: hidden settings: trim_length: 80 @@ -151,10 +148,10 @@ content: rel: '' target: '' third_party_settings: { } + weight: 3 + region: content oe_social_media: type: oe_theme_helper_social_media_icons_list_formatter - weight: 19 - region: content label: hidden settings: trim_length: 80 @@ -163,10 +160,10 @@ content: rel: nofollow target: _blank third_party_settings: { } + weight: 19 + region: content oe_website: type: link - weight: 12 - region: content label: hidden settings: trim_length: 80 @@ -175,6 +172,8 @@ content: rel: '' target: '' third_party_settings: { } + weight: 12 + region: content hidden: created: true langcode: true diff --git a/modules/oe_theme_content_entity_contact/config/install/core.entity_view_display.oe_contact.oe_general.oe_details.yml b/modules/oe_theme_content_entity_contact/config/install/core.entity_view_display.oe_contact.oe_general.oe_details.yml index 4df9e20b8..2e83ac171 100644 --- a/modules/oe_theme_content_entity_contact/config/install/core.entity_view_display.oe_contact.oe_general.oe_details.yml +++ b/modules/oe_theme_content_entity_contact/config/install/core.entity_view_display.oe_contact.oe_general.oe_details.yml @@ -28,15 +28,15 @@ third_party_settings: - oe_email - oe_phone - oe_address + label: 'Contact information' parent_name: '' + region: content weight: 0 format_type: oe_theme_helper_field_list_pattern format_settings: - variant: horizontal classes: '' id: '' - label: 'Contact information' - region: content + variant: horizontal id: oe_contact.oe_general.oe_details targetEntityType: oe_contact bundle: oe_general @@ -44,49 +44,48 @@ mode: oe_details content: name: type: string - weight: 0 - region: content label: above settings: link_to_entity: false third_party_settings: { } + weight: 0 + region: content oe_address: - weight: 3 + type: oe_theme_helper_address_commission label: above - settings: - delimiter: ', ' + settings: { } third_party_settings: { } - type: oe_theme_helper_address_inline + weight: 3 region: content oe_email: - weight: 1 + type: basic_string label: above settings: { } third_party_settings: { } - type: basic_string + weight: 1 region: content oe_phone: - weight: 2 + type: string label: above settings: link_to_entity: false third_party_settings: { } - type: string + weight: 2 region: content oe_social_media: type: oe_theme_helper_social_media_links_formatter - weight: 5 - region: content label: hidden settings: trim_length: 80 + url_only: false + url_plain: false rel: nofollow target: _blank title: 'Social media' variant: horizontal - url_only: false - url_plain: false third_party_settings: { } + weight: 5 + region: content hidden: created: true langcode: true diff --git a/modules/oe_theme_content_entity_contact/config/install/core.entity_view_display.oe_contact.oe_press.full.yml b/modules/oe_theme_content_entity_contact/config/install/core.entity_view_display.oe_contact.oe_press.full.yml index fb054efca..f21ff65d4 100644 --- a/modules/oe_theme_content_entity_contact/config/install/core.entity_view_display.oe_contact.oe_press.full.yml +++ b/modules/oe_theme_content_entity_contact/config/install/core.entity_view_display.oe_contact.oe_press.full.yml @@ -35,15 +35,15 @@ third_party_settings: - oe_address - oe_office - oe_social_media + label: 'Contact information' parent_name: '' + region: content weight: 2 format_type: oe_theme_helper_field_list_pattern format_settings: - variant: horizontal classes: '' id: '' - label: 'Contact information' - region: content + variant: horizontal id: oe_contact.oe_press.full targetEntityType: oe_contact bundle: oe_press @@ -51,54 +51,51 @@ mode: full content: name: type: string - weight: 0 - region: content label: hidden settings: link_to_entity: false third_party_settings: { } + weight: 0 + region: content oe_address: - weight: 7 + type: oe_theme_helper_address_commission label: hidden - settings: - delimiter: ', ' + settings: { } third_party_settings: { } - type: oe_theme_helper_address_inline + weight: 7 region: content oe_body: type: text_default - weight: 1 - region: content label: hidden settings: { } third_party_settings: { } + weight: 1 + region: content oe_email: - weight: 3 + type: basic_string label: hidden settings: { } third_party_settings: { } - type: basic_string + weight: 3 region: content oe_fax: type: string - weight: 6 - region: content label: hidden settings: link_to_entity: false third_party_settings: { } + weight: 6 + region: content oe_image: type: oe_theme_helper_featured_media_formatter - weight: 5 - region: content label: hidden settings: image_style: '' third_party_settings: { } + weight: 5 + region: content oe_link: type: link - weight: 4 - region: content label: hidden settings: trim_length: 80 @@ -107,42 +104,42 @@ content: rel: '' target: '' third_party_settings: { } + weight: 4 + region: content oe_mobile: type: string - weight: 5 - region: content label: hidden settings: link_to_entity: false third_party_settings: { } + weight: 5 + region: content oe_office: type: string - weight: 8 - region: content label: hidden settings: link_to_entity: false third_party_settings: { } + weight: 8 + region: content oe_organisation: type: string - weight: 1 - region: content label: hidden settings: link_to_entity: false third_party_settings: { } + weight: 1 + region: content oe_phone: - weight: 4 + type: string label: hidden settings: link_to_entity: false third_party_settings: { } - type: string + weight: 4 region: content oe_press_contact_url: type: link - weight: 3 - region: content label: hidden settings: trim_length: 80 @@ -151,22 +148,22 @@ content: rel: '' target: '' third_party_settings: { } + weight: 3 + region: content oe_social_media: type: oe_theme_helper_social_media_icons_list_formatter - weight: 9 - region: content label: hidden settings: trim_length: 80 - rel: nofollow - target: _blank url_only: false url_plain: false + rel: nofollow + target: _blank third_party_settings: { } + weight: 9 + region: content oe_website: type: link - weight: 2 - region: content label: hidden settings: trim_length: 80 @@ -175,6 +172,8 @@ content: rel: '' target: '' third_party_settings: { } + weight: 2 + region: content hidden: created: true langcode: true diff --git a/modules/oe_theme_content_entity_contact/config/install/core.entity_view_display.oe_contact.oe_press.oe_details.yml b/modules/oe_theme_content_entity_contact/config/install/core.entity_view_display.oe_contact.oe_press.oe_details.yml index fc5c5e352..5ceff9c4e 100644 --- a/modules/oe_theme_content_entity_contact/config/install/core.entity_view_display.oe_contact.oe_press.oe_details.yml +++ b/modules/oe_theme_content_entity_contact/config/install/core.entity_view_display.oe_contact.oe_press.oe_details.yml @@ -28,65 +28,64 @@ third_party_settings: - oe_email - oe_phone - oe_address + label: 'Contact information' parent_name: '' + region: content weight: 0 format_type: oe_theme_helper_field_list_pattern format_settings: - variant: horizontal classes: '' id: '' - label: 'Contact information' - region: content + variant: horizontal id: oe_contact.oe_press.oe_details targetEntityType: oe_contact bundle: oe_press mode: oe_details content: name: - label: above type: string - weight: 1 - region: content + label: above settings: link_to_entity: false third_party_settings: { } + weight: 1 + region: content oe_address: - weight: 4 + type: oe_theme_helper_address_commission label: above - settings: - delimiter: ', ' + settings: { } third_party_settings: { } - type: oe_theme_helper_address_inline + weight: 4 region: content oe_email: - weight: 2 + type: basic_string label: above settings: { } third_party_settings: { } - type: basic_string + weight: 2 region: content oe_phone: - weight: 3 + type: string label: above settings: link_to_entity: false third_party_settings: { } - type: string + weight: 3 region: content oe_social_media: type: oe_theme_helper_social_media_links_formatter - weight: 4 - region: content label: hidden settings: trim_length: 80 + url_only: false + url_plain: false rel: nofollow target: _blank title: 'Social media' variant: horizontal - url_only: false - url_plain: false third_party_settings: { } + weight: 4 + region: content hidden: created: true langcode: true diff --git a/modules/oe_theme_content_organisation/src/Plugin/ExtraField/Display/TeaserDetailsExtraField.php b/modules/oe_theme_content_organisation/src/Plugin/ExtraField/Display/TeaserDetailsExtraField.php index 5a37bdb43..7b482445f 100644 --- a/modules/oe_theme_content_organisation/src/Plugin/ExtraField/Display/TeaserDetailsExtraField.php +++ b/modules/oe_theme_content_organisation/src/Plugin/ExtraField/Display/TeaserDetailsExtraField.php @@ -112,8 +112,7 @@ public function viewElements(ContentEntityInterface $entity) { 'oe_email' => ['type' => 'email_mailto'], 'oe_phone' => [], 'oe_address' => [ - 'type' => 'oe_theme_helper_address_inline', - 'settings' => ['delimiter' => ', '], + 'type' => 'oe_theme_helper_address_commission', ], ]; foreach ($fields as $field_name => $display_options) { diff --git a/modules/oe_theme_content_person/config/install/core.entity_view_display.oe_contact.oe_general.oe_person.yml b/modules/oe_theme_content_person/config/install/core.entity_view_display.oe_contact.oe_general.oe_person.yml index 47d367ee0..207e7d34a 100644 --- a/modules/oe_theme_content_person/config/install/core.entity_view_display.oe_contact.oe_general.oe_person.yml +++ b/modules/oe_theme_content_person/config/install/core.entity_view_display.oe_contact.oe_general.oe_person.yml @@ -8,6 +8,7 @@ dependencies: - field.field.oe_contact.oe_general.oe_email - field.field.oe_contact.oe_general.oe_fax - field.field.oe_contact.oe_general.oe_image + - field.field.oe_contact.oe_general.oe_link - field.field.oe_contact.oe_general.oe_mobile - field.field.oe_contact.oe_general.oe_office - field.field.oe_contact.oe_general.oe_organisation @@ -30,71 +31,68 @@ third_party_settings: - oe_address - oe_office - oe_social_media + label: 'Contact information' parent_name: '' + region: content weight: 0 format_type: oe_theme_helper_field_list_pattern - region: content format_settings: - variant: horizontal classes: '' id: '' - label: 'Contact information' + variant: horizontal id: oe_contact.oe_general.oe_person targetEntityType: oe_contact bundle: oe_general mode: oe_person content: oe_address: - weight: 8 + type: oe_theme_helper_address_commission label: hidden - settings: - delimiter: ', ' + settings: { } third_party_settings: { } - type: oe_theme_helper_address_inline + weight: 8 region: content oe_email: - weight: 4 + type: email_mailto label: hidden settings: { } third_party_settings: { } - type: email_mailto + weight: 4 region: content oe_fax: type: string - weight: 7 - region: content label: hidden settings: link_to_entity: false third_party_settings: { } + weight: 7 + region: content oe_mobile: type: string - weight: 6 - region: content label: hidden settings: link_to_entity: false third_party_settings: { } + weight: 6 + region: content oe_office: type: string - weight: 9 - region: content label: hidden settings: link_to_entity: false third_party_settings: { } + weight: 9 + region: content oe_phone: - weight: 5 + type: string label: hidden settings: link_to_entity: false third_party_settings: { } - type: string + weight: 5 region: content oe_social_media: type: oe_theme_helper_social_media_icons_list_formatter - weight: 10 - region: content label: hidden settings: trim_length: 80 @@ -103,12 +101,15 @@ content: rel: '' target: '' third_party_settings: { } + weight: 10 + region: content hidden: created: true langcode: true name: true oe_body: true oe_image: true + oe_link: true oe_organisation: true oe_press_contact_url: true oe_website: true diff --git a/modules/oe_theme_helper/src/Plugin/Field/FieldFormatter/AddressCommissionFormatter.php b/modules/oe_theme_helper/src/Plugin/Field/FieldFormatter/AddressCommissionFormatter.php new file mode 100644 index 000000000..ad9935a9e --- /dev/null +++ b/modules/oe_theme_helper/src/Plugin/Field/FieldFormatter/AddressCommissionFormatter.php @@ -0,0 +1,116 @@ + [], + 'city' => [], + ]; + // Group address parts to address related and city with postal code. + foreach ($devided_lines as $line) { + if (in_array($line, ['locality', 'administrativeArea', 'postalCode'])) { + $reformatted_lines['city'][] = '%' . $line; + } + else { + $reformatted_lines['address'][] = '%' . $line; + } + } + + $address = implode(" ", $reformatted_lines['address']); + $city = implode(" ", $reformatted_lines['city']); + $string = $address . "\n" . $city; + + return $string; + } + + /** + * Inserts the rendered elements into the format string. + * + * @param string $content + * The rendered element. + * @param array $element + * An associative array containing the properties and children of the + * element. + * + * @return string + * The new rendered element. + */ + public static function postRender($content, array $element) { + /** @var \CommerceGuys\Addressing\AddressFormat\AddressFormat $address_format */ + $address_format = $element['#address_format']; + $locale = $element['#locale']; + // Add the country to the bottom or the top of the format string, + // depending on whether the format is minor-to-major or major-to-minor. + if (Locale::matchCandidates($address_format->getLocale(), $locale)) { + $format_string = $address_format->getLocalFormat(); + self::updateFormat($format_string); + $format_string = '%country' . "\n" . $format_string; + } + else { + $format_string = $address_format->getFormat(); + self::updateFormat($format_string); + $format_string = $format_string . "\n" . '%country'; + } + + $replacements = []; + foreach (Element::getVisibleChildren($element) as $key) { + $child = $element[$key]; + if (isset($child['#placeholder'])) { + $replacements[$child['#placeholder']] = $child['#value'] ? $child['#markup'] : ''; + } + } + $content = self::replacePlaceholders($format_string, $replacements); + $content = nl2br($content, FALSE); + + return $content; + } + +} diff --git a/sass/components/_global.scss b/sass/components/_global.scss index f66601341..bfbb36e9c 100644 --- a/sass/components/_global.scss +++ b/sass/components/_global.scss @@ -31,3 +31,8 @@ a { .ecl-u-shadow-none { box-shadow: none!important; } + +p.address { + margin-bottom: 0px; + margin-top: 0px; +} diff --git a/tests/src/Functional/ContentRenderTestBase.php b/tests/src/Functional/ContentRenderTestBase.php index 96036a631..8da915403 100644 --- a/tests/src/Functional/ContentRenderTestBase.php +++ b/tests/src/Functional/ContentRenderTestBase.php @@ -297,7 +297,7 @@ protected function assertContactDefaultRender(NodeElement $element, string $name 'body' => "Fax number $name", ], [ 'label' => 'Postal address', - 'body' => "Address $name, 1001 Brussels, Belgium", + 'body' => "Address $name 1001 Brussels Belgium", ], [ 'label' => 'Office', 'body' => "Office $name", @@ -345,7 +345,7 @@ protected function assertContactDetailsRender(NodeElement $element, string $name 'body' => "Phone number $name", ], [ 'label' => 'Address', - 'body' => "Address $name, 1001 Brussels, Belgium", + 'body' => "Address $name 1001 Brussels Belgium", ], ], ]; diff --git a/tests/src/Kernel/ContactRenderTest.php b/tests/src/Kernel/ContactRenderTest.php index 28218b5dc..822704fa9 100644 --- a/tests/src/Kernel/ContactRenderTest.php +++ b/tests/src/Kernel/ContactRenderTest.php @@ -176,7 +176,7 @@ public function testFullView(): void { $build = $this->contactViewBuilder->view($contact, 'full'); $expected_values['items'][] = [ 'label' => 'Postal address', - 'body' => "Address $name, 1001 Brussels, Belgium", + 'body' => "Address $name 1001 Brussels Belgium", ]; $field_list_assert->assertPattern($expected_values, $this->renderRoot($build)); diff --git a/tests/src/Kernel/OrganisationRenderTest.php b/tests/src/Kernel/OrganisationRenderTest.php index 2ca7d809a..f49566679 100644 --- a/tests/src/Kernel/OrganisationRenderTest.php +++ b/tests/src/Kernel/OrganisationRenderTest.php @@ -133,7 +133,7 @@ public function testOrganisationTeaser(): void { ], [ 'label' => 'Address', - 'body' => 'Address first_contact, 1001 Brussels, Belgium', + 'body' => 'Address first_contact 1001 Brussels Belgium', ], ], 'variant' => 'vertical', @@ -184,7 +184,7 @@ public function testOrganisationTeaser(): void { ], [ 'label' => 'Address', - 'body' => 'Address second_contact, 1001 Brussels, Belgium', + 'body' => 'Address second_contact 1001 Brussels Belgium', ], ], ]; diff --git a/tests/src/Kernel/Paragraphs/ContactParagraphTest.php b/tests/src/Kernel/Paragraphs/ContactParagraphTest.php index 75825eb67..c2965e544 100644 --- a/tests/src/Kernel/Paragraphs/ContactParagraphTest.php +++ b/tests/src/Kernel/Paragraphs/ContactParagraphTest.php @@ -140,7 +140,7 @@ public function testContact(): void { $this->assertEquals('
General contact body text
', trim($crawler->filter('div.ecl-col-m-6 div.ecl-u-mb-l:nth-child(1) div.ecl')->html())); $this->assertEquals('General contact Organisation', trim($crawler->filter('dl.ecl-description-list.ecl-description-list--horizontal:nth-child(2) dd.ecl-description-list__definition:nth-child(2) div')->html())); $this->assertEquals('general@example.com', trim($crawler->filter('dl.ecl-description-list.ecl-description-list--horizontal:nth-child(2) dd.ecl-description-list__definition:nth-child(4) div a')->html())); - $this->assertEquals('Address of General contact, 1001 Brussels, Belgium', trim($crawler->filter('dl.ecl-description-list.ecl-description-list--horizontal:nth-child(2) dd.ecl-description-list__definition:nth-child(6) div span')->html())); + $this->assertEquals('Address of General contact