From 385e8e3655b7d6d87e7ec7251f5f4bd16f92508b Mon Sep 17 00:00:00 2001 From: Francesco Sardara Date: Thu, 23 Feb 2023 18:26:11 +0100 Subject: [PATCH 01/27] OEL-2115: Drop lower dependencies tests, tests targeted core versions. --- .drone.yml | 41 ++++++++++++----------------------------- 1 file changed, 12 insertions(+), 29 deletions(-) diff --git a/.drone.yml b/.drone.yml index bc123a89b..7383a9257 100644 --- a/.drone.yml +++ b/.drone.yml @@ -48,31 +48,14 @@ pipeline: - npm install --unsafe-perm - NODE_ENV=production npm run production - composer-install-highest: - group: post-prepare - image: registry.fpfis.eu/fpfis/httpd-php:${PHP_VERSION}-ci - volumes: - - /cache:/cache - commands: - - composer self-update --2 - - composer install --ansi --no-progress - when: - matrix: - COMPOSER_BOUNDARY: highest - - composer-update-lowest: - group: post-prepare + composer-install: + group: prepare image: registry.fpfis.eu/fpfis/httpd-php:${PHP_VERSION}-ci volumes: - - /cache:/cache + - /cache/${DRONE_REPO_NAME}:/cache commands: - composer self-update --2 - - composer update --prefer-lowest --prefer-stable --ansi --no-progress - when: - event: - exclude: tag - matrix: - COMPOSER_BOUNDARY: lowest + - composer require drupal/core:~${CORE_VERSION} drupal/core-composer-scaffold:~${CORE_VERSION} drupal/core-dev:~${CORE_VERSION} --update-with-all-dependencies --ansi --no-progress --no-interaction site-install: image: registry.fpfis.eu/fpfis/httpd-php:${PHP_VERSION}-ci @@ -112,8 +95,8 @@ pipeline: when: event: tag matrix: - COMPOSER_BOUNDARY: highest - PHP_VERSION: 7.4 + CORE_VERSION: "9.4.0" + PHP_VERSION: "8.0" github-release: image: registry.fpfis.eu/drone-plugins/github-release @@ -124,13 +107,13 @@ pipeline: when: event: tag matrix: - COMPOSER_BOUNDARY: highest - PHP_VERSION: 7.4 + CORE_VERSION: "9.4.0" + PHP_VERSION: "8.0" matrix: - COMPOSER_BOUNDARY: - - lowest - - highest + CORE_VERSION: + - 9.4.0 + - 9.5.0 PHP_VERSION: - - 7.4 - 8.0 + - 8.1 From c2f3d8899876c5abb9b32bc59420c54bb35553e8 Mon Sep 17 00:00:00 2001 From: Francesco Sardara Date: Thu, 23 Feb 2023 18:26:49 +0100 Subject: [PATCH 02/27] OEL-2115: Raise dependencies and drop the ones added for lower dependency tests. --- .drone.yml | 2 +- composer.json | 29 +++++++---------------------- 2 files changed, 8 insertions(+), 23 deletions(-) diff --git a/.drone.yml b/.drone.yml index 7383a9257..c013abb8e 100644 --- a/.drone.yml +++ b/.drone.yml @@ -55,7 +55,7 @@ pipeline: - /cache/${DRONE_REPO_NAME}:/cache commands: - composer self-update --2 - - composer require drupal/core:~${CORE_VERSION} drupal/core-composer-scaffold:~${CORE_VERSION} drupal/core-dev:~${CORE_VERSION} --update-with-all-dependencies --ansi --no-progress --no-interaction + - composer require drupal/core:~${CORE_VERSION} drupal/core-composer-scaffold:~${CORE_VERSION} --update-with-all-dependencies --ansi --no-progress --no-interaction site-install: image: registry.fpfis.eu/fpfis/httpd-php:${PHP_VERSION}-ci diff --git a/composer.json b/composer.json index 9811d1377..59fcf405e 100644 --- a/composer.json +++ b/composer.json @@ -6,9 +6,9 @@ "minimum-stability": "dev", "prefer-stable": true, "require": { - "php": ">=7.4", + "php": ">=8.0", "cweagans/composer-patches": "^1.7", - "drupal/core": "^9.3", + "drupal/core": "^9.4", "drupal/daterange_compact": "^2.0", "drupal/twig_field_value": "^2.0", "openeuropa/composer-artifacts": "^1.0.0-alpha1", @@ -19,24 +19,17 @@ "drupal/better_exposed_filters": "^5.0", "drupal/composite_reference": "^2.1", "drupal/config_devel": "~1.2", - "drupal/core-composer-scaffold": "^9.3", - "drupal/core-dev": "^9.3", - "drupal/ctools": "^3.7", + "drupal/core-composer-scaffold": "^9.4", "drupal/description_list_field": "^1.0@alpha", - "drupal/drupal-extension": "~4.1", + "drupal/drupal-extension": "^5.0.0alpha1", "drupal/entity_reference_revisions": "^1.9", "drupal/extra_field": "^2.1", "drupal/facets_form": "1.0.0-alpha3", "drupal/field_group": "^3.2", - "drupal/inline_entity_form": "^1.0-rc12", "drupal/search_api": "^1.21", "drupal/search_api_autocomplete": "^1.5", - "drupal/token": "^1.10", "drupal/typed_link": "^2.0", - "drush/drush": "^10.3", - "easyrdf/easyrdf": "1.0.0 as 0.9.1", - "league/csv": "^9.1", - "nikic/php-parser": "^4.13", + "drush/drush": "^11.1", "openeuropa/code-review": "^2.0", "openeuropa/oe_authentication": "^1.8", "openeuropa/oe_contact_forms": "~1.5", @@ -47,9 +40,8 @@ "openeuropa/oe_multilingual": "^1.11", "openeuropa/oe_paragraphs": "^1.17", "openeuropa/oe_starter_content": "^1.0.0", - "openeuropa/task-runner-drupal-project-symlink": "^1.0-beta5", - "phpspec/prophecy-phpunit": "^2", - "symfony/dom-crawler": "^4.4.12" + "openeuropa/task-runner-drupal-project-symlink": "^1.0-beta6", + "phpspec/prophecy-phpunit": "^2" }, "scripts": { "post-install-cmd": "./vendor/bin/run drupal:site-setup", @@ -97,13 +89,6 @@ "web-root": "./build" } }, - "_readme": [ - "Explicit minimum version requirement of drupal/ctools module due to D9.3 compatibility.", - "Explicit requirement for league/csv due to PHP 8.0 compatibility", - "Explicit minimum version requirement for symfony/dom-crawler due to its lower versions using the deprecated function libxml_disable_entity_loader() in PHP8.", - "Explicit requirement of token module due to PHP 8 compatbility.", - "Explicit minimum version requirement of drupal/inline_entity_form due to failing patch in lower versions. To be removed once oe_media required the same minimum version." - ], "installer-paths": { "build/core": [ "type:drupal-core" From 834a030e2bb2448a17489e626f7d981d684cc68d Mon Sep 17 00:00:00 2001 From: Francesco Sardara Date: Thu, 23 Feb 2023 18:27:16 +0100 Subject: [PATCH 03/27] OEL-2115: Develop on 8.1 by default. --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 1b7cab0b7..75e5a6f5e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,7 +1,7 @@ version: '2' services: web: - image: fpfis/httpd-php-dev:8.0 + image: fpfis/httpd-php-dev:8.1 working_dir: /var/www/html ports: - 8080:8080 From 78cc3ace5f8948f6b2894dd2604048007996740b Mon Sep 17 00:00:00 2001 From: Francesco Sardara Date: Thu, 23 Feb 2023 18:44:04 +0100 Subject: [PATCH 04/27] OEL-2115: Add missing dependencies. --- composer.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 59fcf405e..8290f20f1 100644 --- a/composer.json +++ b/composer.json @@ -30,6 +30,7 @@ "drupal/search_api_autocomplete": "^1.5", "drupal/typed_link": "^2.0", "drush/drush": "^11.1", + "mikey179/vfsstream": "^1.6.10", "openeuropa/code-review": "^2.0", "openeuropa/oe_authentication": "^1.8", "openeuropa/oe_contact_forms": "~1.5", @@ -41,7 +42,8 @@ "openeuropa/oe_paragraphs": "^1.17", "openeuropa/oe_starter_content": "^1.0.0", "openeuropa/task-runner-drupal-project-symlink": "^1.0-beta6", - "phpspec/prophecy-phpunit": "^2" + "phpspec/prophecy-phpunit": "^2", + "symfony/phpunit-bridge": "^6.0" }, "scripts": { "post-install-cmd": "./vendor/bin/run drupal:site-setup", From 6adc690f6ffeaf8483a016f3ae74bf5f3029ba83 Mon Sep 17 00:00:00 2001 From: drishu Date: Mon, 6 Mar 2023 17:20:31 +0200 Subject: [PATCH 05/27] OEL-2115: Replace deprecated assertObjectNotHasAttribute(). --- tests/src/Functional/ContentEventRenderTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/src/Functional/ContentEventRenderTest.php b/tests/src/Functional/ContentEventRenderTest.php index 65d897cb1..e1c415265 100644 --- a/tests/src/Functional/ContentEventRenderTest.php +++ b/tests/src/Functional/ContentEventRenderTest.php @@ -96,7 +96,7 @@ public function testEventPage(): void { $link = $crawler->filter('.bcl-content-banner a[href="/build/node/' . $node->id() . '"]'); $this->assertCount(1, $link); - $this->assertObjectNotHasAttribute('target', $link); + $this->assertFalse(property_exists($link, 'target')); $this->assertStringContainsString('Register', $link->text()); $this->assertStringContainsString('calendar-check', $link->html()); From 9e63e79a98a2ae040c067da6406fb8380e7f1328 Mon Sep 17 00:00:00 2001 From: drishu Date: Thu, 16 Mar 2023 17:59:22 +0200 Subject: [PATCH 06/27] OEL-2115: Bump up oebt version. --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 8290f20f1..9f6417573 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,7 @@ "drupal/daterange_compact": "^2.0", "drupal/twig_field_value": "^2.0", "openeuropa/composer-artifacts": "^1.0.0-alpha1", - "openeuropa/oe_bootstrap_theme": "^1.1.0" + "openeuropa/oe_bootstrap_theme": "^1.3.0" }, "require-dev": { "composer/installers": "^1.11", @@ -38,7 +38,7 @@ "openeuropa/oe_content_extra": "^1.0.0-beta2", "openeuropa/oe_corporate_blocks": "^4.8", "openeuropa/oe_list_pages": "^0.20", - "openeuropa/oe_multilingual": "^1.11", + "openeuropa/oe_multilingual": "^1.12", "openeuropa/oe_paragraphs": "^1.17", "openeuropa/oe_starter_content": "^1.0.0", "openeuropa/task-runner-drupal-project-symlink": "^1.0-beta6", From 5575cd8e8d204a68808eaef91a584e5bd18ad08b Mon Sep 17 00:00:00 2001 From: drishu Date: Wed, 22 Mar 2023 12:23:37 +0200 Subject: [PATCH 07/27] OEL-2115: Bump up oe_multilingual. --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 9f6417573..b6cc9eecb 100644 --- a/composer.json +++ b/composer.json @@ -38,7 +38,7 @@ "openeuropa/oe_content_extra": "^1.0.0-beta2", "openeuropa/oe_corporate_blocks": "^4.8", "openeuropa/oe_list_pages": "^0.20", - "openeuropa/oe_multilingual": "^1.12", + "openeuropa/oe_multilingual": "^1.14", "openeuropa/oe_paragraphs": "^1.17", "openeuropa/oe_starter_content": "^1.0.0", "openeuropa/task-runner-drupal-project-symlink": "^1.0-beta6", From 4907a53ae40631be0216fb180597749d27ff0538 Mon Sep 17 00:00:00 2001 From: drishu Date: Wed, 29 Mar 2023 19:10:24 +0300 Subject: [PATCH 08/27] OEL-2115: Replace deprecated module_load_include. --- tests/src/Kernel/ContentLanguageSwitcherTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/src/Kernel/ContentLanguageSwitcherTest.php b/tests/src/Kernel/ContentLanguageSwitcherTest.php index 797bdaac9..ece1d4106 100644 --- a/tests/src/Kernel/ContentLanguageSwitcherTest.php +++ b/tests/src/Kernel/ContentLanguageSwitcherTest.php @@ -72,7 +72,7 @@ protected function setUp(): void { // in places like route enhancers. // @see CurrentUserContext::getRuntimeContexts(). // @see EntityConverter::convert(). - module_load_include('install', 'user'); + $this->container->get('module_handler')->loadInclude('oe_multilingual', 'install'); user_install(); \Drupal::service('kernel')->rebuildContainer(); From 149c2d4bc702e49066e2485a5d79e577ede31817 Mon Sep 17 00:00:00 2001 From: drishu Date: Wed, 29 Mar 2023 19:10:52 +0300 Subject: [PATCH 09/27] OEL-2115: Fix permission issue. --- tests/src/Kernel/ContentLanguageSwitcherTest.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/src/Kernel/ContentLanguageSwitcherTest.php b/tests/src/Kernel/ContentLanguageSwitcherTest.php index ece1d4106..c178122bc 100644 --- a/tests/src/Kernel/ContentLanguageSwitcherTest.php +++ b/tests/src/Kernel/ContentLanguageSwitcherTest.php @@ -6,6 +6,7 @@ use Drupal\node\Entity\Node; use Drupal\KernelTests\KernelTestBase; +use Drupal\user\Entity\User; use Symfony\Component\DomCrawler\Crawler; use Symfony\Component\HttpFoundation\Request; @@ -74,6 +75,7 @@ protected function setUp(): void { // @see EntityConverter::convert(). $this->container->get('module_handler')->loadInclude('oe_multilingual', 'install'); user_install(); + \Drupal::currentUser()->setAccount(User::load(1)); \Drupal::service('kernel')->rebuildContainer(); } From f4b0e2a21a6321bc9dd41055eac0ea0610b00ae6 Mon Sep 17 00:00:00 2001 From: drishu Date: Thu, 30 Mar 2023 09:47:35 +0300 Subject: [PATCH 10/27] OEL-2115: Adapt multilingual block test. --- tests/src/Kernel/MultilingualBlockTest.php | 48 +++++++++++----------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/tests/src/Kernel/MultilingualBlockTest.php b/tests/src/Kernel/MultilingualBlockTest.php index a87ba42d9..b441d9560 100644 --- a/tests/src/Kernel/MultilingualBlockTest.php +++ b/tests/src/Kernel/MultilingualBlockTest.php @@ -92,76 +92,76 @@ public function testBlockRendering(): void { $button_header = $crawler->filter('button.btn-close'); $this->assertSame('modal', $button_header->attr('data-bs-dismiss')); $link_language = $crawler->filter('a#link_bg'); - $this->assertSame('http://localhost/bg/%3Cnone%3E', $link_language->attr('href')); + $this->assertEmpty($link_language->attr('href')); $this->assertSame('български', $link_language->text()); $link_language = $crawler->filter('a#link_cs'); - $this->assertSame('http://localhost/cs/%3Cnone%3E', $link_language->attr('href')); + $this->assertEmpty($link_language->attr('href')); $this->assertSame('čeština', $link_language->text()); $link_language = $crawler->filter('a#link_da'); - $this->assertSame('http://localhost/da/%3Cnone%3E', $link_language->attr('href')); + $this->assertEmpty($link_language->attr('href')); $this->assertSame('dansk', $link_language->text()); $link_language = $crawler->filter('a#link_de'); - $this->assertSame('http://localhost/de/%3Cnone%3E', $link_language->attr('href')); + $this->assertEmpty($link_language->attr('href')); $this->assertSame('Deutsch', $link_language->text()); $link_language = $crawler->filter('a#link_et'); - $this->assertSame('http://localhost/et/%3Cnone%3E', $link_language->attr('href')); + $this->assertEmpty($link_language->attr('href')); $this->assertSame('eesti', $link_language->text()); $link_language = $crawler->filter('a#link_el'); - $this->assertSame('http://localhost/el/%3Cnone%3E', $link_language->attr('href')); + $this->assertEmpty($link_language->attr('href')); $this->assertSame('ελληνικά', $link_language->text()); $link_language = $crawler->filter('a#link_en'); - $this->assertSame('http://localhost/en/%3Cnone%3E', $link_language->attr('href')); + $this->assertEmpty($link_language->attr('href')); $this->assertSame('English', $link_language->text()); $link_language = $crawler->filter('a#link_es'); - $this->assertSame('http://localhost/es/%3Cnone%3E', $link_language->attr('href')); + $this->assertEmpty($link_language->attr('href')); $this->assertSame('español', $link_language->text()); $link_language = $crawler->filter('a#link_fr'); - $this->assertSame('http://localhost/fr/%3Cnone%3E', $link_language->attr('href')); + $this->assertEmpty($link_language->attr('href')); $this->assertSame('français', $link_language->text()); $link_language = $crawler->filter('a#link_ga'); - $this->assertSame('http://localhost/ga/%3Cnone%3E', $link_language->attr('href')); + $this->assertEmpty($link_language->attr('href')); $this->assertSame('Gaeilge', $link_language->text()); $link_language = $crawler->filter('a#link_hr'); - $this->assertSame('http://localhost/hr/%3Cnone%3E', $link_language->attr('href')); + $this->assertEmpty($link_language->attr('href')); $this->assertSame('hrvatski', $link_language->text()); $link_language = $crawler->filter('a#link_it'); - $this->assertSame('http://localhost/it/%3Cnone%3E', $link_language->attr('href')); + $this->assertEmpty($link_language->attr('href')); $this->assertSame('italiano', $link_language->text()); $link_language = $crawler->filter('a#link_lt'); - $this->assertSame('http://localhost/lt/%3Cnone%3E', $link_language->attr('href')); + $this->assertEmpty($link_language->attr('href')); $this->assertSame('lietuvių', $link_language->text()); $link_language = $crawler->filter('a#link_lv'); - $this->assertSame('http://localhost/lv/%3Cnone%3E', $link_language->attr('href')); + $this->assertEmpty($link_language->attr('href')); $this->assertSame('latviešu', $link_language->text()); $link_language = $crawler->filter('a#link_hu'); - $this->assertSame('http://localhost/hu/%3Cnone%3E', $link_language->attr('href')); + $this->assertEmpty($link_language->attr('href')); $this->assertSame('magyar', $link_language->text()); $link_language = $crawler->filter('a#link_mt'); - $this->assertSame('http://localhost/mt/%3Cnone%3E', $link_language->attr('href')); + $this->assertEmpty($link_language->attr('href')); $this->assertSame('Malti', $link_language->text()); $link_language = $crawler->filter('a#link_nl'); - $this->assertSame('http://localhost/nl/%3Cnone%3E', $link_language->attr('href')); + $this->assertEmpty($link_language->attr('href')); $this->assertSame('Nederlands', $link_language->text()); $link_language = $crawler->filter('a#link_pl'); - $this->assertSame('http://localhost/pl/%3Cnone%3E', $link_language->attr('href')); + $this->assertEmpty($link_language->attr('href')); $this->assertSame('polski', $link_language->text()); $link_language = $crawler->filter('a#link_pt-pt'); - $this->assertSame('http://localhost/pt/%3Cnone%3E', $link_language->attr('href')); + $this->assertEmpty($link_language->attr('href')); $this->assertSame('português', $link_language->text()); $link_language = $crawler->filter('a#link_ro'); - $this->assertSame('http://localhost/ro/%3Cnone%3E', $link_language->attr('href')); + $this->assertEmpty($link_language->attr('href')); $this->assertSame('română', $link_language->text()); $link_language = $crawler->filter('a#link_sk'); - $this->assertSame('http://localhost/sk/%3Cnone%3E', $link_language->attr('href')); + $this->assertEmpty($link_language->attr('href')); $this->assertSame('slovenčina', $link_language->text()); $link_language = $crawler->filter('a#link_sl'); - $this->assertSame('http://localhost/sl/%3Cnone%3E', $link_language->attr('href')); + $this->assertEmpty($link_language->attr('href')); $this->assertSame('slovenščina', $link_language->text()); $link_language = $crawler->filter('a#link_fi'); - $this->assertSame('http://localhost/fi/%3Cnone%3E', $link_language->attr('href')); + $this->assertEmpty($link_language->attr('href')); $this->assertSame('suomi', $link_language->text()); $link_language = $crawler->filter('a#link_sv'); - $this->assertSame('http://localhost/sv/%3Cnone%3E', $link_language->attr('href')); + $this->assertEmpty($link_language->attr('href')); $this->assertSame('svenska', $link_language->text()); } From 9227f0689ba8ebbeda5185424d155d869ad7f79b Mon Sep 17 00:00:00 2001 From: drishu Date: Wed, 22 Mar 2023 18:00:19 +0200 Subject: [PATCH 11/27] OEL-2267: Add new budget fields to config. --- ...tity_view_display.node.oe_project.full.yml | 4 +++ ...ay.node.oe_project.oe_w_content_banner.yml | 4 +++ ...ty_view_display.node.oe_project.teaser.yml | 4 +++ ...y_form_display.node.oe_project.default.yml | 36 ++++++++++--------- 4 files changed, 32 insertions(+), 16 deletions(-) diff --git a/modules/oe_whitelabel_extra_project/config/install/core.entity_view_display.node.oe_project.full.yml b/modules/oe_whitelabel_extra_project/config/install/core.entity_view_display.node.oe_project.full.yml index 8088900d9..82f6b74b5 100644 --- a/modules/oe_whitelabel_extra_project/config/install/core.entity_view_display.node.oe_project.full.yml +++ b/modules/oe_whitelabel_extra_project/config/install/core.entity_view_display.node.oe_project.full.yml @@ -18,6 +18,8 @@ dependencies: - field.field.node.oe_project.oe_project_contact - field.field.node.oe_project.oe_project_coordinators - field.field.node.oe_project.oe_project_dates + - field.field.node.oe_project.oe_project_eu_budget + - field.field.node.oe_project.oe_project_eu_contrib - field.field.node.oe_project.oe_project_funding_programme - field.field.node.oe_project.oe_project_locations - field.field.node.oe_project.oe_project_participants @@ -232,6 +234,8 @@ hidden: oe_featured_media: true oe_project_calls: true oe_project_contact: true + oe_project_eu_budget: true + oe_project_eu_contrib: true oe_project_locations: true oe_project_result_files: true oe_project_results: true diff --git a/modules/oe_whitelabel_extra_project/config/install/core.entity_view_display.node.oe_project.oe_w_content_banner.yml b/modules/oe_whitelabel_extra_project/config/install/core.entity_view_display.node.oe_project.oe_w_content_banner.yml index d55324162..3461df553 100644 --- a/modules/oe_whitelabel_extra_project/config/install/core.entity_view_display.node.oe_project.oe_w_content_banner.yml +++ b/modules/oe_whitelabel_extra_project/config/install/core.entity_view_display.node.oe_project.oe_w_content_banner.yml @@ -18,6 +18,8 @@ dependencies: - field.field.node.oe_project.oe_project_contact - field.field.node.oe_project.oe_project_coordinators - field.field.node.oe_project.oe_project_dates + - field.field.node.oe_project.oe_project_eu_budget + - field.field.node.oe_project.oe_project_eu_contrib - field.field.node.oe_project.oe_project_funding_programme - field.field.node.oe_project.oe_project_locations - field.field.node.oe_project.oe_project_participants @@ -75,6 +77,8 @@ hidden: oe_project_contact: true oe_project_coordinators: true oe_project_dates: true + oe_project_eu_budget: true + oe_project_eu_contrib: true oe_project_funding_programme: true oe_project_locations: true oe_project_participants: true diff --git a/modules/oe_whitelabel_extra_project/config/install/core.entity_view_display.node.oe_project.teaser.yml b/modules/oe_whitelabel_extra_project/config/install/core.entity_view_display.node.oe_project.teaser.yml index acf603362..a7e02d283 100644 --- a/modules/oe_whitelabel_extra_project/config/install/core.entity_view_display.node.oe_project.teaser.yml +++ b/modules/oe_whitelabel_extra_project/config/install/core.entity_view_display.node.oe_project.teaser.yml @@ -18,6 +18,8 @@ dependencies: - field.field.node.oe_project.oe_project_contact - field.field.node.oe_project.oe_project_coordinators - field.field.node.oe_project.oe_project_dates + - field.field.node.oe_project.oe_project_eu_budget + - field.field.node.oe_project.oe_project_eu_contrib - field.field.node.oe_project.oe_project_funding_programme - field.field.node.oe_project.oe_project_locations - field.field.node.oe_project.oe_project_participants @@ -114,6 +116,8 @@ hidden: oe_project_calls: true oe_project_contact: true oe_project_coordinators: true + oe_project_eu_budget: true + oe_project_eu_contrib: true oe_project_funding_programme: true oe_project_locations: true oe_project_participants: true diff --git a/modules/oe_whitelabel_extra_project/config/overrides/core.entity_form_display.node.oe_project.default.yml b/modules/oe_whitelabel_extra_project/config/overrides/core.entity_form_display.node.oe_project.default.yml index cf518277a..194926ee2 100644 --- a/modules/oe_whitelabel_extra_project/config/overrides/core.entity_form_display.node.oe_project.default.yml +++ b/modules/oe_whitelabel_extra_project/config/overrides/core.entity_form_display.node.oe_project.default.yml @@ -17,6 +17,8 @@ dependencies: - field.field.node.oe_project.oe_project_contact - field.field.node.oe_project.oe_project_coordinators - field.field.node.oe_project.oe_project_dates + - field.field.node.oe_project.oe_project_eu_budget + - field.field.node.oe_project.oe_project_eu_contrib - field.field.node.oe_project.oe_project_funding_programme - field.field.node.oe_project.oe_project_locations - field.field.node.oe_project.oe_project_participants @@ -55,8 +57,8 @@ third_party_settings: required_fields: true group_budget: children: - - oe_project_budget - - oe_project_budget_eu + - oe_project_eu_budget + - oe_project_eu_contrib label: Budget region: content parent_name: group_details @@ -170,20 +172,6 @@ content: size: 60 placeholder: '' third_party_settings: { } - oe_project_budget: - type: number - weight: 9 - region: content - settings: - placeholder: '' - third_party_settings: { } - oe_project_budget_eu: - type: number - weight: 10 - region: content - settings: - placeholder: '' - third_party_settings: { } oe_project_coordinators: type: inline_entity_form_complex weight: 10 @@ -211,6 +199,20 @@ content: date_order: DMY time_type: none third_party_settings: { } + oe_project_eu_budget: + type: number + weight: 0 + region: content + settings: + placeholder: '' + third_party_settings: { } + oe_project_eu_contrib: + type: number + weight: 2 + region: content + settings: + placeholder: '' + third_party_settings: { } oe_project_funding_programme: type: skos_concept_entity_reference_autocomplete weight: 8 @@ -328,6 +330,8 @@ hidden: oe_content_navigation_title: true oe_content_short_title: true oe_departments: true + oe_project_budget: true + oe_project_budget_eu: true oe_project_calls: true oe_project_contact: true oe_project_locations: true From 9e452fade218baa2b3e0551ccbeccbff53ef2b5e Mon Sep 17 00:00:00 2001 From: drishu Date: Fri, 24 Mar 2023 08:39:59 +0200 Subject: [PATCH 12/27] OEL-2267: Add budget pseudo field. --- ...tity_view_display.node.oe_project.full.yml | 22 ++-- .../Display/OverallBudgetExtraField.php | 104 ++++++++++++++++++ 2 files changed, 113 insertions(+), 13 deletions(-) create mode 100644 modules/oe_whitelabel_extra_project/src/Plugin/ExtraField/Display/OverallBudgetExtraField.php diff --git a/modules/oe_whitelabel_extra_project/config/install/core.entity_view_display.node.oe_project.full.yml b/modules/oe_whitelabel_extra_project/config/install/core.entity_view_display.node.oe_project.full.yml index 82f6b74b5..68b9eddce 100644 --- a/modules/oe_whitelabel_extra_project/config/install/core.entity_view_display.node.oe_project.full.yml +++ b/modules/oe_whitelabel_extra_project/config/install/core.entity_view_display.node.oe_project.full.yml @@ -72,7 +72,7 @@ third_party_settings: format_settings: { } group_budget: children: - - oe_project_budget + - extra_field_oe_whitelabel_extra_project_project_budget - oe_project_budget_eu label: Budget parent_name: '' @@ -106,6 +106,11 @@ targetEntityType: node bundle: oe_project mode: full content: + extra_field_oe_whitelabel_extra_project_project_budget: + settings: { } + third_party_settings: { } + weight: 0 + region: content oe_cx_achievements_and_milestone: type: text_default label: hidden @@ -136,17 +141,6 @@ content: third_party_settings: { } weight: 4 region: content - oe_project_budget: - type: number_decimal - label: hidden - settings: - thousand_separator: . - decimal_separator: ',' - scale: 2 - prefix_suffix: true - third_party_settings: { } - weight: 2 - region: content oe_project_budget_eu: type: number_decimal label: hidden @@ -156,7 +150,7 @@ content: scale: 2 prefix_suffix: true third_party_settings: { } - weight: 3 + weight: 2 region: content oe_project_coordinators: type: entity_reference_revisions_label @@ -232,6 +226,7 @@ hidden: oe_departments: true oe_documents: true oe_featured_media: true + oe_project_budget: true oe_project_calls: true oe_project_contact: true oe_project_eu_budget: true @@ -241,3 +236,4 @@ hidden: oe_project_results: true oe_subject: true oe_teaser: true + search_api_excerpt: true diff --git a/modules/oe_whitelabel_extra_project/src/Plugin/ExtraField/Display/OverallBudgetExtraField.php b/modules/oe_whitelabel_extra_project/src/Plugin/ExtraField/Display/OverallBudgetExtraField.php new file mode 100644 index 000000000..b7b182155 --- /dev/null +++ b/modules/oe_whitelabel_extra_project/src/Plugin/ExtraField/Display/OverallBudgetExtraField.php @@ -0,0 +1,104 @@ +viewBuilder = $entity_type_manager->getViewBuilder('node'); + } + + /** + * {@inheritdoc} + */ + public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { + return new static( + $configuration, + $plugin_id, + $plugin_definition, + $container->get('entity_type.manager') + ); + } + + /** + * {@inheritdoc} + */ + public function getLabel() { + return $this->t('Overall budget'); + } + + /** + * {@inheritdoc} + */ + public function viewElements(ContentEntityInterface $entity) { + if ($entity->get('oe_project_budget')->isEmpty() && $entity->get('oe_project_eu_budget')->isEmpty()) { + return []; + } + $build = []; + + $display_options = [ + 'label' => 'hidden', + 'type' => 'number_decimal', + 'settings' => [ + 'thousand_separator' => '.', + 'decimal_separator' => ',', + 'scale' => 2, + 'prefix_suffix' => TRUE, + ], + ]; + if ($entity->get('oe_project_eu_budget')->isEmpty()) { + // Fallback to old field. + $build[] = $this->viewBuilder->viewField($entity->get('oe_project_budget'), $display_options); + } + else { + // Render new field value. + $build[] = $this->viewBuilder->viewField($entity->get('oe_project_eu_budget'), $display_options); + } + + return $build; + } + +} From fddbeb1c7c7188c0c4f0fd3317f01a84f731afa2 Mon Sep 17 00:00:00 2001 From: drishu Date: Fri, 24 Mar 2023 10:31:55 +0200 Subject: [PATCH 13/27] OEL-2267: Add eu contribution pseudo field. --- ...tity_view_display.node.oe_project.full.yml | 27 ++--- .../Display/EuContributionExtraField.php | 104 ++++++++++++++++++ 2 files changed, 115 insertions(+), 16 deletions(-) create mode 100644 modules/oe_whitelabel_extra_project/src/Plugin/ExtraField/Display/EuContributionExtraField.php diff --git a/modules/oe_whitelabel_extra_project/config/install/core.entity_view_display.node.oe_project.full.yml b/modules/oe_whitelabel_extra_project/config/install/core.entity_view_display.node.oe_project.full.yml index 68b9eddce..4ec06b28d 100644 --- a/modules/oe_whitelabel_extra_project/config/install/core.entity_view_display.node.oe_project.full.yml +++ b/modules/oe_whitelabel_extra_project/config/install/core.entity_view_display.node.oe_project.full.yml @@ -67,13 +67,13 @@ third_party_settings: label: Coordinators parent_name: group_project_details region: content - weight: 3 + weight: 11 format_type: oe_whitelabel_helper_description_list_pattern format_settings: { } group_budget: children: - extra_field_oe_whitelabel_extra_project_project_budget - - oe_project_budget_eu + - extra_field_oe_whitelabel_extra_project_eu_contrib label: Budget parent_name: '' region: content @@ -98,7 +98,7 @@ third_party_settings: label: Website parent_name: group_project_details region: content - weight: 2 + weight: 10 format_type: oe_whitelabel_helper_description_list_pattern format_settings: { } id: node.oe_project.full @@ -106,10 +106,15 @@ targetEntityType: node bundle: oe_project mode: full content: + extra_field_oe_whitelabel_extra_project_eu_contrib: + settings: { } + third_party_settings: { } + weight: 6 + region: content extra_field_oe_whitelabel_extra_project_project_budget: settings: { } third_party_settings: { } - weight: 0 + weight: 5 region: content oe_cx_achievements_and_milestone: type: text_default @@ -141,17 +146,6 @@ content: third_party_settings: { } weight: 4 region: content - oe_project_budget_eu: - type: number_decimal - label: hidden - settings: - thousand_separator: . - decimal_separator: ',' - scale: 2 - prefix_suffix: true - third_party_settings: { } - weight: 2 - region: content oe_project_coordinators: type: entity_reference_revisions_label label: hidden @@ -205,7 +199,7 @@ content: settings: link_to_entity: false third_party_settings: { } - weight: 5 + weight: 6 region: content oe_summary: type: text_default @@ -227,6 +221,7 @@ hidden: oe_documents: true oe_featured_media: true oe_project_budget: true + oe_project_budget_eu: true oe_project_calls: true oe_project_contact: true oe_project_eu_budget: true diff --git a/modules/oe_whitelabel_extra_project/src/Plugin/ExtraField/Display/EuContributionExtraField.php b/modules/oe_whitelabel_extra_project/src/Plugin/ExtraField/Display/EuContributionExtraField.php new file mode 100644 index 000000000..9b19d958b --- /dev/null +++ b/modules/oe_whitelabel_extra_project/src/Plugin/ExtraField/Display/EuContributionExtraField.php @@ -0,0 +1,104 @@ +viewBuilder = $entity_type_manager->getViewBuilder('node'); + } + + /** + * {@inheritdoc} + */ + public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { + return new static( + $configuration, + $plugin_id, + $plugin_definition, + $container->get('entity_type.manager') + ); + } + + /** + * {@inheritdoc} + */ + public function getLabel() { + return $this->t('EU contribution'); + } + + /** + * {@inheritdoc} + */ + public function viewElements(ContentEntityInterface $entity) { + if ($entity->get('oe_project_eu_contrib')->isEmpty() && $entity->get('oe_project_budget_eu')->isEmpty()) { + return []; + } + $build = []; + + $display_options = [ + 'label' => 'hidden', + 'type' => 'number_decimal', + 'settings' => [ + 'thousand_separator' => '.', + 'decimal_separator' => ',', + 'scale' => 2, + 'prefix_suffix' => TRUE, + ], + ]; + if ($entity->get('oe_project_eu_contrib')->isEmpty()) { + // Fallback to old field. + $build[] = $this->viewBuilder->viewField($entity->get('oe_project_budget_eu'), $display_options); + } + else { + // Render new field value. + $build[] = $this->viewBuilder->viewField($entity->get('oe_project_eu_contrib'), $display_options); + } + + return $build; + } + +} From a4e80ac64f7db759ec25906eb579ba7e5104008d Mon Sep 17 00:00:00 2001 From: drishu Date: Fri, 24 Mar 2023 10:33:13 +0200 Subject: [PATCH 14/27] OEL-2267: Use new pseudo fields in project contributions section. --- .../oe_whitelabel_extra_project.module | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/modules/oe_whitelabel_extra_project/oe_whitelabel_extra_project.module b/modules/oe_whitelabel_extra_project/oe_whitelabel_extra_project.module index 2300a0dcd..0ba9afb00 100644 --- a/modules/oe_whitelabel_extra_project/oe_whitelabel_extra_project.module +++ b/modules/oe_whitelabel_extra_project/oe_whitelabel_extra_project.module @@ -255,8 +255,8 @@ function _oe_whitelabel_extra_project_preprocess_status_and_progress(array &$var */ function _oe_whitelabel_extra_project_preprocess_contributions(array &$variables): void { $field_bg_classes = [ - 'oe_project_budget' => 'bg-gray-400', - 'oe_project_budget_eu' => 'bg-primary', + 'extra_field_oe_whitelabel_extra_project_project_budget' => 'bg-gray-400', + 'extra_field_oe_whitelabel_extra_project_eu_contrib' => 'bg-primary', ]; $legend_items = []; foreach ($field_bg_classes as $field_name => $bg_class) { @@ -295,8 +295,14 @@ function _oe_whitelabel_extra_project_preprocess_contributions(array &$variables /** @var \Drupal\node\NodeInterface $node */ $node = $variables['node']; - $overall_budget = $node->get('oe_project_budget')->value; - $eu_budget = $node->get('oe_project_budget_eu')->value; + $overall_budget = $node->get('oe_project_eu_budget')->value; + if (empty($overall_budget)) { + $overall_budget = $node->get('oe_project_budget')->value; + } + $eu_budget = $node->get('oe_project_eu_contrib')->value; + if (empty($eu_budget)) { + $eu_budget = $node->get('oe_project_budget_eu')->value; + } if ($overall_budget === NULL || $eu_budget === NULL From 1b37f378c25ce2e9a416ba4722683aafe7697868 Mon Sep 17 00:00:00 2001 From: drishu Date: Fri, 24 Mar 2023 10:47:21 +0200 Subject: [PATCH 15/27] OEL-2267: Add update path for the new budget decimal fields. --- ..._whitelabel_extra_project.post_update.php | 36 ++ ...y_form_display.node.oe_project.default.yml | 341 ++++++++++++++++++ ...tity_view_display.node.oe_project.full.yml | 234 ++++++++++++ 3 files changed, 611 insertions(+) create mode 100644 modules/oe_whitelabel_extra_project/oe_whitelabel_extra_project.post_update.php create mode 100644 modules/oe_whitelabel_extra_project/post_updates/00001_decimal_budget_fields/core.entity_form_display.node.oe_project.default.yml create mode 100644 modules/oe_whitelabel_extra_project/post_updates/00001_decimal_budget_fields/core.entity_view_display.node.oe_project.full.yml diff --git a/modules/oe_whitelabel_extra_project/oe_whitelabel_extra_project.post_update.php b/modules/oe_whitelabel_extra_project/oe_whitelabel_extra_project.post_update.php new file mode 100644 index 000000000..f10b74bdd --- /dev/null +++ b/modules/oe_whitelabel_extra_project/oe_whitelabel_extra_project.post_update.php @@ -0,0 +1,36 @@ +get('hidden'); + $properties['extra_field_oe_theme_content_project_budget'] = TRUE; + $view_display->set('hidden', $properties); + $view_display->save(); + } +} diff --git a/modules/oe_whitelabel_extra_project/post_updates/00001_decimal_budget_fields/core.entity_form_display.node.oe_project.default.yml b/modules/oe_whitelabel_extra_project/post_updates/00001_decimal_budget_fields/core.entity_form_display.node.oe_project.default.yml new file mode 100644 index 000000000..194926ee2 --- /dev/null +++ b/modules/oe_whitelabel_extra_project/post_updates/00001_decimal_budget_fields/core.entity_form_display.node.oe_project.default.yml @@ -0,0 +1,341 @@ +langcode: en +status: true +dependencies: + config: + - field.field.node.oe_project.body + - field.field.node.oe_project.oe_cx_achievements_and_milestone + - field.field.node.oe_project.oe_cx_gallery + - field.field.node.oe_project.oe_cx_impacts + - field.field.node.oe_project.oe_cx_lead_contributors + - field.field.node.oe_project.oe_cx_objective + - field.field.node.oe_project.oe_departments + - field.field.node.oe_project.oe_documents + - field.field.node.oe_project.oe_featured_media + - field.field.node.oe_project.oe_project_budget + - field.field.node.oe_project.oe_project_budget_eu + - field.field.node.oe_project.oe_project_calls + - field.field.node.oe_project.oe_project_contact + - field.field.node.oe_project.oe_project_coordinators + - field.field.node.oe_project.oe_project_dates + - field.field.node.oe_project.oe_project_eu_budget + - field.field.node.oe_project.oe_project_eu_contrib + - field.field.node.oe_project.oe_project_funding_programme + - field.field.node.oe_project.oe_project_locations + - field.field.node.oe_project.oe_project_participants + - field.field.node.oe_project.oe_project_result_files + - field.field.node.oe_project.oe_project_results + - field.field.node.oe_project.oe_project_website + - field.field.node.oe_project.oe_reference_code + - field.field.node.oe_project.oe_subject + - field.field.node.oe_project.oe_summary + - field.field.node.oe_project.oe_teaser + - node.type.oe_project + module: + - datetime_range + - field_group + - inline_entity_form + - link + - oe_content_featured_media_field + - rdf_skos + - text +third_party_settings: + field_group: + group_result: + children: + - oe_project_results + - oe_project_result_files + label: Result + region: content + parent_name: '' + weight: 13 + format_type: details + format_settings: + classes: '' + id: '' + open: true + description: '' + required_fields: true + group_budget: + children: + - oe_project_eu_budget + - oe_project_eu_contrib + label: Budget + region: content + parent_name: group_details + weight: 6 + format_type: tab + format_settings: + classes: '' + id: '' + formatter: open + description: '' + required_fields: true + group_details: + children: + - oe_project_dates + - group_budget + - oe_project_website + - oe_project_funding_programme + - oe_reference_code + - oe_project_coordinators + label: 'Project details' + region: content + parent_name: '' + weight: 4 + format_type: html_element + format_settings: + classes: '' + show_empty_fields: false + id: '' + element: div + show_label: true + label_element: h3 + label_element_classes: '' + attributes: '' + effect: none + speed: fast + required_fields: true +id: node.oe_project.default +targetEntityType: node +bundle: oe_project +mode: default +content: + oe_cx_achievements_and_milestone: + type: text_textarea + weight: 10 + region: content + settings: + rows: 5 + placeholder: '' + third_party_settings: { } + oe_cx_gallery: + type: entity_reference_autocomplete + weight: 11 + region: content + settings: + match_operator: CONTAINS + match_limit: 10 + size: 60 + placeholder: '' + third_party_settings: { } + oe_cx_impacts: + type: text_textarea + weight: 7 + region: content + settings: + rows: 5 + placeholder: '' + third_party_settings: { } + oe_cx_lead_contributors: + type: inline_entity_form_complex + weight: 9 + region: content + settings: + form_mode: default + override_labels: false + label_singular: '' + label_plural: '' + allow_new: true + allow_existing: false + match_operator: CONTAINS + allow_duplicate: false + collapsible: false + collapsed: false + revision: false + removed_reference: optional + third_party_settings: { } + oe_cx_objective: + type: text_textarea + weight: 6 + region: content + settings: + rows: 5 + placeholder: '' + third_party_settings: { } + oe_documents: + type: entity_reference_autocomplete + weight: 12 + region: content + settings: + match_operator: CONTAINS + match_limit: 10 + size: 60 + placeholder: '' + third_party_settings: { } + oe_featured_media: + type: oe_featured_media_autocomplete + weight: 1 + region: content + settings: + match_operator: CONTAINS + match_limit: 10 + size: 60 + placeholder: '' + third_party_settings: { } + oe_project_coordinators: + type: inline_entity_form_complex + weight: 10 + region: content + settings: + form_mode: default + override_labels: false + label_singular: '' + label_plural: '' + allow_new: true + allow_existing: false + match_operator: CONTAINS + allow_duplicate: false + collapsible: false + collapsed: false + revision: false + removed_reference: optional + third_party_settings: { } + oe_project_dates: + type: daterange_datelist + weight: 5 + region: content + settings: + increment: 15 + date_order: DMY + time_type: none + third_party_settings: { } + oe_project_eu_budget: + type: number + weight: 0 + region: content + settings: + placeholder: '' + third_party_settings: { } + oe_project_eu_contrib: + type: number + weight: 2 + region: content + settings: + placeholder: '' + third_party_settings: { } + oe_project_funding_programme: + type: skos_concept_entity_reference_autocomplete + weight: 8 + region: content + settings: + match_operator: CONTAINS + match_limit: 10 + size: 60 + placeholder: '' + third_party_settings: { } + oe_project_participants: + type: inline_entity_form_complex + weight: 8 + region: content + settings: + form_mode: default + override_labels: true + label_singular: participant + label_plural: participants + allow_new: true + allow_existing: false + match_operator: CONTAINS + allow_duplicate: false + collapsible: true + collapsed: false + revision: true + removed_reference: keep + third_party_settings: { } + oe_project_result_files: + type: entity_reference_autocomplete + weight: 0 + region: content + settings: + match_operator: CONTAINS + match_limit: 10 + size: 60 + placeholder: '' + third_party_settings: { } + oe_project_results: + type: text_textarea + weight: 0 + region: content + settings: + rows: 5 + placeholder: '' + third_party_settings: { } + oe_project_website: + type: link_default + weight: 7 + region: content + settings: + placeholder_url: '' + placeholder_title: '' + third_party_settings: { } + oe_reference_code: + type: string_textfield + weight: 9 + region: content + settings: + size: 60 + placeholder: '' + third_party_settings: { } + oe_subject: + type: skos_concept_entity_reference_autocomplete + weight: 3 + region: content + settings: + match_operator: CONTAINS + match_limit: 10 + size: 60 + placeholder: '' + third_party_settings: { } + oe_summary: + type: text_textarea + weight: 5 + region: content + settings: + rows: 5 + placeholder: '' + third_party_settings: { } + oe_teaser: + type: text_textarea + weight: 2 + region: content + settings: + rows: 5 + placeholder: '' + third_party_settings: { } + status: + type: boolean_checkbox + weight: 14 + region: content + settings: + display_label: true + third_party_settings: { } + title: + type: string_textfield + weight: 0 + region: content + settings: + size: 60 + placeholder: '' + third_party_settings: { } + translation: + weight: 10 + region: content + settings: { } + third_party_settings: { } +hidden: + body: true + created: true + langcode: true + oe_content_content_owner: true + oe_content_legacy_link: true + oe_content_navigation_title: true + oe_content_short_title: true + oe_departments: true + oe_project_budget: true + oe_project_budget_eu: true + oe_project_calls: true + oe_project_contact: true + oe_project_locations: true + path: true + promote: true + sticky: true + uid: true diff --git a/modules/oe_whitelabel_extra_project/post_updates/00001_decimal_budget_fields/core.entity_view_display.node.oe_project.full.yml b/modules/oe_whitelabel_extra_project/post_updates/00001_decimal_budget_fields/core.entity_view_display.node.oe_project.full.yml new file mode 100644 index 000000000..4ec06b28d --- /dev/null +++ b/modules/oe_whitelabel_extra_project/post_updates/00001_decimal_budget_fields/core.entity_view_display.node.oe_project.full.yml @@ -0,0 +1,234 @@ +langcode: en +status: true +dependencies: + config: + - core.entity_view_mode.node.full + - field.field.node.oe_project.body + - field.field.node.oe_project.oe_cx_achievements_and_milestone + - field.field.node.oe_project.oe_cx_gallery + - field.field.node.oe_project.oe_cx_impacts + - field.field.node.oe_project.oe_cx_lead_contributors + - field.field.node.oe_project.oe_cx_objective + - field.field.node.oe_project.oe_departments + - field.field.node.oe_project.oe_documents + - field.field.node.oe_project.oe_featured_media + - field.field.node.oe_project.oe_project_budget + - field.field.node.oe_project.oe_project_budget_eu + - field.field.node.oe_project.oe_project_calls + - field.field.node.oe_project.oe_project_contact + - field.field.node.oe_project.oe_project_coordinators + - field.field.node.oe_project.oe_project_dates + - field.field.node.oe_project.oe_project_eu_budget + - field.field.node.oe_project.oe_project_eu_contrib + - field.field.node.oe_project.oe_project_funding_programme + - field.field.node.oe_project.oe_project_locations + - field.field.node.oe_project.oe_project_participants + - field.field.node.oe_project.oe_project_result_files + - field.field.node.oe_project.oe_project_results + - field.field.node.oe_project.oe_project_website + - field.field.node.oe_project.oe_reference_code + - field.field.node.oe_project.oe_subject + - field.field.node.oe_project.oe_summary + - field.field.node.oe_project.oe_teaser + - node.type.oe_project + module: + - datetime_range + - entity_reference_revisions + - field_group + - link + - rdf_skos + - text + - user +third_party_settings: + field_group: + group_project_details: + children: + - group_website + - group_coordinators + label: 'Project details' + parent_name: '' + region: content + weight: 2 + format_type: html_element + format_settings: + classes: '' + show_empty_fields: false + id: '' + element: div + show_label: false + label_element: h3 + label_element_classes: 'fw-bold mb-4' + attributes: '' + effect: none + speed: fast + group_coordinators: + children: + - oe_project_coordinators + label: Coordinators + parent_name: group_project_details + region: content + weight: 11 + format_type: oe_whitelabel_helper_description_list_pattern + format_settings: { } + group_budget: + children: + - extra_field_oe_whitelabel_extra_project_project_budget + - extra_field_oe_whitelabel_extra_project_eu_contrib + label: Budget + parent_name: '' + region: content + weight: 1 + format_type: html_element + format_settings: + classes: '' + show_empty_fields: false + id: '' + element: div + show_label: false + label_element: h3 + label_element_classes: '' + attributes: '' + effect: none + speed: fast + group_website: + children: + - oe_project_website + - oe_project_funding_programme + - oe_reference_code + label: Website + parent_name: group_project_details + region: content + weight: 10 + format_type: oe_whitelabel_helper_description_list_pattern + format_settings: { } +id: node.oe_project.full +targetEntityType: node +bundle: oe_project +mode: full +content: + extra_field_oe_whitelabel_extra_project_eu_contrib: + settings: { } + third_party_settings: { } + weight: 6 + region: content + extra_field_oe_whitelabel_extra_project_project_budget: + settings: { } + third_party_settings: { } + weight: 5 + region: content + oe_cx_achievements_and_milestone: + type: text_default + label: hidden + settings: { } + third_party_settings: { } + weight: 8 + region: content + oe_cx_impacts: + type: text_default + label: hidden + settings: { } + third_party_settings: { } + weight: 5 + region: content + oe_cx_lead_contributors: + type: entity_reference_revisions_entity_view + label: hidden + settings: + view_mode: default + link: '' + third_party_settings: { } + weight: 6 + region: content + oe_cx_objective: + type: text_default + label: hidden + settings: { } + third_party_settings: { } + weight: 4 + region: content + oe_project_coordinators: + type: entity_reference_revisions_label + label: hidden + settings: + link: false + third_party_settings: { } + weight: 4 + region: content + oe_project_dates: + type: daterange_default + label: hidden + settings: + timezone_override: '' + format_type: oe_whitelabel_project_date + separator: '-' + third_party_settings: { } + weight: 0 + region: content + oe_project_funding_programme: + type: skos_concept_entity_reference_label + label: hidden + settings: + link: false + third_party_settings: { } + weight: 4 + region: content + oe_project_participants: + type: entity_reference_revisions_entity_view + label: hidden + settings: + view_mode: default + link: '' + third_party_settings: { } + weight: 7 + region: content + oe_project_website: + type: link + label: hidden + settings: + trim_length: 80 + url_only: false + url_plain: false + rel: '' + target: '' + third_party_settings: { } + weight: 3 + region: content + oe_reference_code: + type: string + label: hidden + settings: + link_to_entity: false + third_party_settings: { } + weight: 6 + region: content + oe_summary: + type: text_default + label: hidden + settings: { } + third_party_settings: { } + weight: 3 + region: content +hidden: + body: true + langcode: true + links: true + oe_content_content_owner: true + oe_content_legacy_link: true + oe_content_navigation_title: true + oe_content_short_title: true + oe_cx_gallery: true + oe_departments: true + oe_documents: true + oe_featured_media: true + oe_project_budget: true + oe_project_budget_eu: true + oe_project_calls: true + oe_project_contact: true + oe_project_eu_budget: true + oe_project_eu_contrib: true + oe_project_locations: true + oe_project_result_files: true + oe_project_results: true + oe_subject: true + oe_teaser: true + search_api_excerpt: true From 630e9ed35f50bc71d3243014d060757644552085 Mon Sep 17 00:00:00 2001 From: drishu Date: Fri, 24 Mar 2023 14:53:41 +0200 Subject: [PATCH 16/27] OEL-2267: Remove new fields from banner and teaser displays. --- ...tity_view_display.node.oe_project.oe_w_content_banner.yml | 3 +++ .../core.entity_view_display.node.oe_project.teaser.yml | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/modules/oe_whitelabel_extra_project/config/install/core.entity_view_display.node.oe_project.oe_w_content_banner.yml b/modules/oe_whitelabel_extra_project/config/install/core.entity_view_display.node.oe_project.oe_w_content_banner.yml index 3461df553..107c91138 100644 --- a/modules/oe_whitelabel_extra_project/config/install/core.entity_view_display.node.oe_project.oe_w_content_banner.yml +++ b/modules/oe_whitelabel_extra_project/config/install/core.entity_view_display.node.oe_project.oe_w_content_banner.yml @@ -57,6 +57,8 @@ content: region: content hidden: body: true + extra_field_oe_whitelabel_extra_project_eu_contrib: true + extra_field_oe_whitelabel_extra_project_project_budget: true langcode: true links: true oe_content_content_owner: true @@ -87,3 +89,4 @@ hidden: oe_project_website: true oe_reference_code: true oe_summary: true + search_api_excerpt: true diff --git a/modules/oe_whitelabel_extra_project/config/install/core.entity_view_display.node.oe_project.teaser.yml b/modules/oe_whitelabel_extra_project/config/install/core.entity_view_display.node.oe_project.teaser.yml index a7e02d283..513ec1229 100644 --- a/modules/oe_whitelabel_extra_project/config/install/core.entity_view_display.node.oe_project.teaser.yml +++ b/modules/oe_whitelabel_extra_project/config/install/core.entity_view_display.node.oe_project.teaser.yml @@ -46,7 +46,7 @@ third_party_settings: label: Stakeholders parent_name: '' region: hidden - weight: 30 + weight: 35 format_type: html_element format_settings: classes: '' @@ -98,6 +98,8 @@ content: region: content hidden: body: true + extra_field_oe_whitelabel_extra_project_eu_contrib: true + extra_field_oe_whitelabel_extra_project_project_budget: true langcode: true links: true oe_content_content_owner: true @@ -126,3 +128,4 @@ hidden: oe_project_website: true oe_reference_code: true oe_summary: true + search_api_excerpt: true From 34170dd479012881e9c0d9a377e746de69021732 Mon Sep 17 00:00:00 2001 From: drishu Date: Sat, 25 Mar 2023 17:35:30 +0200 Subject: [PATCH 17/27] OEL-2267: Move post_update into correct folder. --- ...y_form_display.node.oe_project.default.yml | 0 ...tity_view_display.node.oe_project.full.yml | 0 ...ay.node.oe_project.oe_w_content_banner.yml | 92 ++++++++++++ ...ty_view_display.node.oe_project.teaser.yml | 131 ++++++++++++++++++ 4 files changed, 223 insertions(+) rename modules/oe_whitelabel_extra_project/{ => config}/post_updates/00001_decimal_budget_fields/core.entity_form_display.node.oe_project.default.yml (100%) rename modules/oe_whitelabel_extra_project/{ => config}/post_updates/00001_decimal_budget_fields/core.entity_view_display.node.oe_project.full.yml (100%) create mode 100644 modules/oe_whitelabel_extra_project/config/post_updates/00001_decimal_budget_fields/core.entity_view_display.node.oe_project.oe_w_content_banner.yml create mode 100644 modules/oe_whitelabel_extra_project/config/post_updates/00001_decimal_budget_fields/core.entity_view_display.node.oe_project.teaser.yml diff --git a/modules/oe_whitelabel_extra_project/post_updates/00001_decimal_budget_fields/core.entity_form_display.node.oe_project.default.yml b/modules/oe_whitelabel_extra_project/config/post_updates/00001_decimal_budget_fields/core.entity_form_display.node.oe_project.default.yml similarity index 100% rename from modules/oe_whitelabel_extra_project/post_updates/00001_decimal_budget_fields/core.entity_form_display.node.oe_project.default.yml rename to modules/oe_whitelabel_extra_project/config/post_updates/00001_decimal_budget_fields/core.entity_form_display.node.oe_project.default.yml diff --git a/modules/oe_whitelabel_extra_project/post_updates/00001_decimal_budget_fields/core.entity_view_display.node.oe_project.full.yml b/modules/oe_whitelabel_extra_project/config/post_updates/00001_decimal_budget_fields/core.entity_view_display.node.oe_project.full.yml similarity index 100% rename from modules/oe_whitelabel_extra_project/post_updates/00001_decimal_budget_fields/core.entity_view_display.node.oe_project.full.yml rename to modules/oe_whitelabel_extra_project/config/post_updates/00001_decimal_budget_fields/core.entity_view_display.node.oe_project.full.yml diff --git a/modules/oe_whitelabel_extra_project/config/post_updates/00001_decimal_budget_fields/core.entity_view_display.node.oe_project.oe_w_content_banner.yml b/modules/oe_whitelabel_extra_project/config/post_updates/00001_decimal_budget_fields/core.entity_view_display.node.oe_project.oe_w_content_banner.yml new file mode 100644 index 000000000..107c91138 --- /dev/null +++ b/modules/oe_whitelabel_extra_project/config/post_updates/00001_decimal_budget_fields/core.entity_view_display.node.oe_project.oe_w_content_banner.yml @@ -0,0 +1,92 @@ +langcode: en +status: true +dependencies: + config: + - core.entity_view_mode.node.oe_w_content_banner + - field.field.node.oe_project.body + - field.field.node.oe_project.oe_cx_achievements_and_milestone + - field.field.node.oe_project.oe_cx_gallery + - field.field.node.oe_project.oe_cx_impacts + - field.field.node.oe_project.oe_cx_lead_contributors + - field.field.node.oe_project.oe_cx_objective + - field.field.node.oe_project.oe_departments + - field.field.node.oe_project.oe_documents + - field.field.node.oe_project.oe_featured_media + - field.field.node.oe_project.oe_project_budget + - field.field.node.oe_project.oe_project_budget_eu + - field.field.node.oe_project.oe_project_calls + - field.field.node.oe_project.oe_project_contact + - field.field.node.oe_project.oe_project_coordinators + - field.field.node.oe_project.oe_project_dates + - field.field.node.oe_project.oe_project_eu_budget + - field.field.node.oe_project.oe_project_eu_contrib + - field.field.node.oe_project.oe_project_funding_programme + - field.field.node.oe_project.oe_project_locations + - field.field.node.oe_project.oe_project_participants + - field.field.node.oe_project.oe_project_result_files + - field.field.node.oe_project.oe_project_results + - field.field.node.oe_project.oe_project_website + - field.field.node.oe_project.oe_reference_code + - field.field.node.oe_project.oe_subject + - field.field.node.oe_project.oe_summary + - field.field.node.oe_project.oe_teaser + - node.type.oe_project + module: + - rdf_skos + - text + - user +id: node.oe_project.oe_w_content_banner +targetEntityType: node +bundle: oe_project +mode: oe_w_content_banner +content: + oe_subject: + type: skos_concept_entity_reference_label + label: hidden + settings: + link: false + third_party_settings: { } + weight: 1 + region: content + oe_teaser: + type: text_default + label: hidden + settings: { } + third_party_settings: { } + weight: 0 + region: content +hidden: + body: true + extra_field_oe_whitelabel_extra_project_eu_contrib: true + extra_field_oe_whitelabel_extra_project_project_budget: true + langcode: true + links: true + oe_content_content_owner: true + oe_content_legacy_link: true + oe_content_navigation_title: true + oe_content_short_title: true + oe_cx_achievements_and_milestone: true + oe_cx_gallery: true + oe_cx_impacts: true + oe_cx_lead_contributors: true + oe_cx_objective: true + oe_departments: true + oe_documents: true + oe_featured_media: true + oe_project_budget: true + oe_project_budget_eu: true + oe_project_calls: true + oe_project_contact: true + oe_project_coordinators: true + oe_project_dates: true + oe_project_eu_budget: true + oe_project_eu_contrib: true + oe_project_funding_programme: true + oe_project_locations: true + oe_project_participants: true + oe_project_result_files: true + oe_project_results: true + oe_project_website: true + oe_reference_code: true + oe_summary: true + search_api_excerpt: true diff --git a/modules/oe_whitelabel_extra_project/config/post_updates/00001_decimal_budget_fields/core.entity_view_display.node.oe_project.teaser.yml b/modules/oe_whitelabel_extra_project/config/post_updates/00001_decimal_budget_fields/core.entity_view_display.node.oe_project.teaser.yml new file mode 100644 index 000000000..513ec1229 --- /dev/null +++ b/modules/oe_whitelabel_extra_project/config/post_updates/00001_decimal_budget_fields/core.entity_view_display.node.oe_project.teaser.yml @@ -0,0 +1,131 @@ +langcode: en +status: true +dependencies: + config: + - core.entity_view_mode.node.teaser + - field.field.node.oe_project.body + - field.field.node.oe_project.oe_cx_achievements_and_milestone + - field.field.node.oe_project.oe_cx_gallery + - field.field.node.oe_project.oe_cx_impacts + - field.field.node.oe_project.oe_cx_lead_contributors + - field.field.node.oe_project.oe_cx_objective + - field.field.node.oe_project.oe_departments + - field.field.node.oe_project.oe_documents + - field.field.node.oe_project.oe_featured_media + - field.field.node.oe_project.oe_project_budget + - field.field.node.oe_project.oe_project_budget_eu + - field.field.node.oe_project.oe_project_calls + - field.field.node.oe_project.oe_project_contact + - field.field.node.oe_project.oe_project_coordinators + - field.field.node.oe_project.oe_project_dates + - field.field.node.oe_project.oe_project_eu_budget + - field.field.node.oe_project.oe_project_eu_contrib + - field.field.node.oe_project.oe_project_funding_programme + - field.field.node.oe_project.oe_project_locations + - field.field.node.oe_project.oe_project_participants + - field.field.node.oe_project.oe_project_result_files + - field.field.node.oe_project.oe_project_results + - field.field.node.oe_project.oe_project_website + - field.field.node.oe_project.oe_reference_code + - field.field.node.oe_project.oe_subject + - field.field.node.oe_project.oe_summary + - field.field.node.oe_project.oe_teaser + - node.type.oe_project + module: + - datetime_range + - field_group + - oe_content_featured_media_field + - rdf_skos + - text + - user +third_party_settings: + field_group: + group_stakeholders: + children: + - oe_project_participants + label: Stakeholders + parent_name: '' + region: hidden + weight: 35 + format_type: html_element + format_settings: + classes: '' + id: '' + element: div + show_label: false + label_element: h3 + label_element_classes: '' + attributes: '' + effect: none + speed: fast +id: node.oe_project.teaser +targetEntityType: node +bundle: oe_project +mode: teaser +content: + oe_featured_media: + type: oe_featured_media_label + label: hidden + settings: + link: true + third_party_settings: { } + weight: 0 + region: content + oe_project_dates: + type: daterange_default + label: hidden + settings: + timezone_override: '' + format_type: oe_whitelabel_project_date + separator: '-' + third_party_settings: { } + weight: 3 + region: content + oe_subject: + type: skos_concept_entity_reference_label + label: hidden + settings: + link: false + third_party_settings: { } + weight: 2 + region: content + oe_teaser: + type: text_default + label: hidden + settings: { } + third_party_settings: { } + weight: 1 + region: content +hidden: + body: true + extra_field_oe_whitelabel_extra_project_eu_contrib: true + extra_field_oe_whitelabel_extra_project_project_budget: true + langcode: true + links: true + oe_content_content_owner: true + oe_content_legacy_link: true + oe_content_navigation_title: true + oe_content_short_title: true + oe_cx_achievements_and_milestone: true + oe_cx_gallery: true + oe_cx_impacts: true + oe_cx_lead_contributors: true + oe_cx_objective: true + oe_departments: true + oe_documents: true + oe_project_budget: true + oe_project_budget_eu: true + oe_project_calls: true + oe_project_contact: true + oe_project_coordinators: true + oe_project_eu_budget: true + oe_project_eu_contrib: true + oe_project_funding_programme: true + oe_project_locations: true + oe_project_participants: true + oe_project_result_files: true + oe_project_results: true + oe_project_website: true + oe_reference_code: true + oe_summary: true + search_api_excerpt: true From 2d225857b5ae9a8c1f076723291a32fada98af4b Mon Sep 17 00:00:00 2001 From: drishu Date: Sat, 25 Mar 2023 17:37:55 +0200 Subject: [PATCH 18/27] OEL-2267: Use config importer to sync teaser and banner displays. --- ...oe_whitelabel_extra_project.post_update.php} | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) rename modules/oe_whitelabel_extra_project/{oe_whitelabel_extra_project.post_update.php => oe_whitelabel_extra_project.post_update.php} (50%) diff --git a/modules/oe_whitelabel_extra_project/oe_whitelabel_extra_project.post_update.php b/modules/oe_whitelabel_extra_project/oe_whitelabel_extra_project.post_update.php similarity index 50% rename from modules/oe_whitelabel_extra_project/oe_whitelabel_extra_project.post_update.php rename to modules/oe_whitelabel_extra_project/oe_whitelabel_extra_project.post_update.php index f10b74bdd..f9fb6cab4 100644 --- a/modules/oe_whitelabel_extra_project/oe_whitelabel_extra_project.post_update.php +++ b/modules/oe_whitelabel_extra_project/oe_whitelabel_extra_project.post_update.php @@ -7,7 +7,6 @@ declare(strict_types = 1); -use Drupal\Core\Entity\Entity\EntityViewDisplay; use Drupal\oe_bootstrap_theme\ConfigImporter; /** @@ -17,20 +16,8 @@ function oe_whitelabel_extra_project_post_update_00001(): void { $configs = [ 'core.entity_form_display.node.oe_project.default', 'core.entity_view_display.node.oe_project.full', + 'core.entity_view_display.node.oe_project.oe_w_content_banner', + 'core.entity_view_display.node.oe_project.teaser', ]; ConfigImporter::importMultiple('module', 'oe_whitelabel_extra_project', '/config/post_updates/00001_decimal_budget_fields', $configs, TRUE); - - // Ensure the new budget extra fields are disabled on all other displays. - $display_types = [ - 'default', - 'oe_w_content_banner', - 'teaser', - ]; - foreach ($display_types as $display_type) { - $view_display = EntityViewDisplay::load('node.oe_project.' . $display_type); - $properties = $view_display->get('hidden'); - $properties['extra_field_oe_theme_content_project_budget'] = TRUE; - $view_display->set('hidden', $properties); - $view_display->save(); - } } From be3e818736b45bc1c4254ae57df782ca5c111c9b Mon Sep 17 00:00:00 2001 From: drishu Date: Tue, 28 Mar 2023 17:12:22 +0300 Subject: [PATCH 19/27] OEL-2267: Add missing dependency. --- .../oe_whitelabel_extra_project.info.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/oe_whitelabel_extra_project/oe_whitelabel_extra_project.info.yml b/modules/oe_whitelabel_extra_project/oe_whitelabel_extra_project.info.yml index ee019b8e8..0b0482b5d 100644 --- a/modules/oe_whitelabel_extra_project/oe_whitelabel_extra_project.info.yml +++ b/modules/oe_whitelabel_extra_project/oe_whitelabel_extra_project.info.yml @@ -4,6 +4,7 @@ description: Module to override content extra project. package: OpenEuropa Whitelabel Theme core_version_requirement: ^9.3 dependencies: + - extra_field:extra_field - oe_content_extra:oe_content_extra_project - oe_whitelabel_helper:oe_whitelabel_helper From 54fe19047ae31a352d2d2a6e85e98918f1e60484 Mon Sep 17 00:00:00 2001 From: drishu Date: Tue, 28 Mar 2023 17:22:54 +0300 Subject: [PATCH 20/27] OEL-2267: Update tests with new budget fields. --- .../ContentProjectRenderTest.php | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/src/FunctionalJavascript/ContentProjectRenderTest.php b/tests/src/FunctionalJavascript/ContentProjectRenderTest.php index b34da6e37..e1c0cbd36 100644 --- a/tests/src/FunctionalJavascript/ContentProjectRenderTest.php +++ b/tests/src/FunctionalJavascript/ContentProjectRenderTest.php @@ -277,6 +277,26 @@ public function testProjectRendering(): void { $this->assertProjectStatusVisible(); $this->assertProjectStatus('bg-secondary', 'Planned'); $this->assertProjectProgress(0); + + // Assert budget with new fields. + $node->set('oe_project_eu_budget', '300.00'); + $node->set('oe_project_eu_contrib', '100.00'); + $node->save(); + $this->drupalGet($node->toUrl()); + $description_list = $project_content->find('css', '.bcl-description-list'); + + $description_list_assert->assertPattern([ + 'items' => [ + [ + 'term' => 'Overall budget', + 'definition' => '€300,00', + ], + [ + 'term' => 'EU contribution', + 'definition' => '€100,00', + ], + ], + ], $description_list->getOuterHtml()); } /** From a4fa2064735b58606b45974d5a75e4df4919c931 Mon Sep 17 00:00:00 2001 From: drishu Date: Tue, 11 Apr 2023 16:19:40 +0300 Subject: [PATCH 21/27] OEL-2267: Test with values float fields couldn't handle. --- .../src/FunctionalJavascript/ContentProjectRenderTest.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/src/FunctionalJavascript/ContentProjectRenderTest.php b/tests/src/FunctionalJavascript/ContentProjectRenderTest.php index e1c0cbd36..27ac2cf84 100644 --- a/tests/src/FunctionalJavascript/ContentProjectRenderTest.php +++ b/tests/src/FunctionalJavascript/ContentProjectRenderTest.php @@ -279,8 +279,8 @@ public function testProjectRendering(): void { $this->assertProjectProgress(0); // Assert budget with new fields. - $node->set('oe_project_eu_budget', '300.00'); - $node->set('oe_project_eu_contrib', '100.00'); + $node->set('oe_project_eu_budget', '104479592'); + $node->set('oe_project_eu_contrib', '7812356'); $node->save(); $this->drupalGet($node->toUrl()); $description_list = $project_content->find('css', '.bcl-description-list'); @@ -289,11 +289,11 @@ public function testProjectRendering(): void { 'items' => [ [ 'term' => 'Overall budget', - 'definition' => '€300,00', + 'definition' => '€104.479.592,00', ], [ 'term' => 'EU contribution', - 'definition' => '€100,00', + 'definition' => '€7.812.356,00', ], ], ], $description_list->getOuterHtml()); From 680cc83a4df1cc0fb30e9ce1340aa643f68b0887 Mon Sep 17 00:00:00 2001 From: drishu Date: Wed, 12 Apr 2023 09:22:57 +0300 Subject: [PATCH 22/27] OEL-2267: Implement base class for the budget fields. --- .../Display/BudgetExtraFieldBase.php | 108 ++++++++++++++++++ .../Display/EuContributionExtraField.php | 76 ++---------- .../Display/OverallBudgetExtraField.php | 76 ++---------- 3 files changed, 122 insertions(+), 138 deletions(-) create mode 100644 modules/oe_whitelabel_extra_project/src/Plugin/ExtraField/Display/BudgetExtraFieldBase.php diff --git a/modules/oe_whitelabel_extra_project/src/Plugin/ExtraField/Display/BudgetExtraFieldBase.php b/modules/oe_whitelabel_extra_project/src/Plugin/ExtraField/Display/BudgetExtraFieldBase.php new file mode 100644 index 000000000..26e7b5823 --- /dev/null +++ b/modules/oe_whitelabel_extra_project/src/Plugin/ExtraField/Display/BudgetExtraFieldBase.php @@ -0,0 +1,108 @@ +viewBuilder = $entity_type_manager->getViewBuilder('node'); + } + + /** + * {@inheritdoc} + */ + public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { + return new static( + $configuration, + $plugin_id, + $plugin_definition, + $container->get('entity_type.manager') + ); + } + + /** + * {@inheritdoc} + */ + public function viewElements(ContentEntityInterface $entity) { + $field_budget = $this->getFieldBudget(); + $field_eu_budget = $this->getFieldEuBudget(); + + if ($entity->get($field_budget)->isEmpty() && $entity->get($field_eu_budget)->isEmpty()) { + return []; + } + + $build = []; + $display_options = [ + 'label' => 'hidden', + 'type' => 'number_decimal', + 'settings' => [ + 'thousand_separator' => '.', + 'decimal_separator' => ',', + 'scale' => 2, + 'prefix_suffix' => TRUE, + ], + ]; + + if ($entity->get($field_eu_budget)->isEmpty()) { + // Fallback to old field. + $build[] = $this->viewBuilder->viewField($entity->get($field_budget), $display_options); + } + else { + // Render new field value. + $build[] = $this->viewBuilder->viewField($entity->get($field_eu_budget), $display_options); + } + + return $build; + } + + /** + * Returns the old budget field name. + * + * @return string + * The budget field. + */ + abstract protected function getFieldBudget(): string; + + /** + * Returns the new budget field name. + * + * @return string + * The budget field. + */ + abstract protected function getFieldEuBudget(): string; + +} diff --git a/modules/oe_whitelabel_extra_project/src/Plugin/ExtraField/Display/EuContributionExtraField.php b/modules/oe_whitelabel_extra_project/src/Plugin/ExtraField/Display/EuContributionExtraField.php index 9b19d958b..19ee9f9e3 100644 --- a/modules/oe_whitelabel_extra_project/src/Plugin/ExtraField/Display/EuContributionExtraField.php +++ b/modules/oe_whitelabel_extra_project/src/Plugin/ExtraField/Display/EuContributionExtraField.php @@ -4,13 +4,6 @@ namespace Drupal\oe_whitelabel_extra_project\Plugin\ExtraField\Display; -use Drupal\Core\Entity\ContentEntityInterface; -use Drupal\Core\Entity\EntityTypeManagerInterface; -use Drupal\Core\Plugin\ContainerFactoryPluginInterface; -use Drupal\Core\StringTranslation\StringTranslationTrait; -use Drupal\extra_field\Plugin\ExtraFieldDisplayFormattedBase; -use Symfony\Component\DependencyInjection\ContainerInterface; - /** * Display overall budget. * @@ -23,82 +16,27 @@ * visible = true * ) */ -class EuContributionExtraField extends ExtraFieldDisplayFormattedBase implements ContainerFactoryPluginInterface { - - use StringTranslationTrait; - - /** - * The entity view builder. - * - * @var \Drupal\Core\Entity\EntityViewBuilder - */ - protected $viewBuilder; - - /** - * OverallBudgetExtraField constructor. - * - * @param array $configuration - * A configuration array containing information about the plugin instance. - * @param string $plugin_id - * The plugin_id for the plugin instance. - * @param mixed $plugin_definition - * The plugin implementation definition. - * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager - * The entity type manager. - */ - public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityTypeManagerInterface $entity_type_manager) { - parent::__construct($configuration, $plugin_id, $plugin_definition); - $this->viewBuilder = $entity_type_manager->getViewBuilder('node'); - } +class EuContributionExtraField extends BudgetExtraFieldBase { /** * {@inheritdoc} */ - public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { - return new static( - $configuration, - $plugin_id, - $plugin_definition, - $container->get('entity_type.manager') - ); + public function getLabel() { + return $this->t('EU contribution'); } /** * {@inheritdoc} */ - public function getLabel() { - return $this->t('EU contribution'); + protected function getFieldBudget(): string { + return 'oe_project_budget_eu'; } /** * {@inheritdoc} */ - public function viewElements(ContentEntityInterface $entity) { - if ($entity->get('oe_project_eu_contrib')->isEmpty() && $entity->get('oe_project_budget_eu')->isEmpty()) { - return []; - } - $build = []; - - $display_options = [ - 'label' => 'hidden', - 'type' => 'number_decimal', - 'settings' => [ - 'thousand_separator' => '.', - 'decimal_separator' => ',', - 'scale' => 2, - 'prefix_suffix' => TRUE, - ], - ]; - if ($entity->get('oe_project_eu_contrib')->isEmpty()) { - // Fallback to old field. - $build[] = $this->viewBuilder->viewField($entity->get('oe_project_budget_eu'), $display_options); - } - else { - // Render new field value. - $build[] = $this->viewBuilder->viewField($entity->get('oe_project_eu_contrib'), $display_options); - } - - return $build; + protected function getFieldEuBudget(): string { + return 'oe_project_eu_contrib'; } } diff --git a/modules/oe_whitelabel_extra_project/src/Plugin/ExtraField/Display/OverallBudgetExtraField.php b/modules/oe_whitelabel_extra_project/src/Plugin/ExtraField/Display/OverallBudgetExtraField.php index b7b182155..ee598fce9 100644 --- a/modules/oe_whitelabel_extra_project/src/Plugin/ExtraField/Display/OverallBudgetExtraField.php +++ b/modules/oe_whitelabel_extra_project/src/Plugin/ExtraField/Display/OverallBudgetExtraField.php @@ -4,13 +4,6 @@ namespace Drupal\oe_whitelabel_extra_project\Plugin\ExtraField\Display; -use Drupal\Core\Entity\ContentEntityInterface; -use Drupal\Core\Entity\EntityTypeManagerInterface; -use Drupal\Core\Plugin\ContainerFactoryPluginInterface; -use Drupal\Core\StringTranslation\StringTranslationTrait; -use Drupal\extra_field\Plugin\ExtraFieldDisplayFormattedBase; -use Symfony\Component\DependencyInjection\ContainerInterface; - /** * Display overall budget. * @@ -23,82 +16,27 @@ * visible = true * ) */ -class OverallBudgetExtraField extends ExtraFieldDisplayFormattedBase implements ContainerFactoryPluginInterface { - - use StringTranslationTrait; - - /** - * The entity view builder. - * - * @var \Drupal\Core\Entity\EntityViewBuilder - */ - protected $viewBuilder; - - /** - * OverallBudgetExtraField constructor. - * - * @param array $configuration - * A configuration array containing information about the plugin instance. - * @param string $plugin_id - * The plugin_id for the plugin instance. - * @param mixed $plugin_definition - * The plugin implementation definition. - * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager - * The entity type manager. - */ - public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityTypeManagerInterface $entity_type_manager) { - parent::__construct($configuration, $plugin_id, $plugin_definition); - $this->viewBuilder = $entity_type_manager->getViewBuilder('node'); - } +class OverallBudgetExtraField extends BudgetExtraFieldBase { /** * {@inheritdoc} */ - public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { - return new static( - $configuration, - $plugin_id, - $plugin_definition, - $container->get('entity_type.manager') - ); + public function getLabel() { + return $this->t('Overall budget'); } /** * {@inheritdoc} */ - public function getLabel() { - return $this->t('Overall budget'); + protected function getFieldBudget(): string { + return 'oe_project_budget'; } /** * {@inheritdoc} */ - public function viewElements(ContentEntityInterface $entity) { - if ($entity->get('oe_project_budget')->isEmpty() && $entity->get('oe_project_eu_budget')->isEmpty()) { - return []; - } - $build = []; - - $display_options = [ - 'label' => 'hidden', - 'type' => 'number_decimal', - 'settings' => [ - 'thousand_separator' => '.', - 'decimal_separator' => ',', - 'scale' => 2, - 'prefix_suffix' => TRUE, - ], - ]; - if ($entity->get('oe_project_eu_budget')->isEmpty()) { - // Fallback to old field. - $build[] = $this->viewBuilder->viewField($entity->get('oe_project_budget'), $display_options); - } - else { - // Render new field value. - $build[] = $this->viewBuilder->viewField($entity->get('oe_project_eu_budget'), $display_options); - } - - return $build; + protected function getFieldEuBudget(): string { + return 'oe_project_eu_budget'; } } From 335dd692a3229bba56c5d16ed34a1a110a0900b7 Mon Sep 17 00:00:00 2001 From: drishu Date: Wed, 12 Apr 2023 10:04:52 +0300 Subject: [PATCH 23/27] OEL-2267: Merge redundant code. --- .../ExtraField/Display/BudgetExtraFieldBase.php | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/modules/oe_whitelabel_extra_project/src/Plugin/ExtraField/Display/BudgetExtraFieldBase.php b/modules/oe_whitelabel_extra_project/src/Plugin/ExtraField/Display/BudgetExtraFieldBase.php index 26e7b5823..cbcedb3b4 100644 --- a/modules/oe_whitelabel_extra_project/src/Plugin/ExtraField/Display/BudgetExtraFieldBase.php +++ b/modules/oe_whitelabel_extra_project/src/Plugin/ExtraField/Display/BudgetExtraFieldBase.php @@ -26,7 +26,7 @@ abstract class BudgetExtraFieldBase extends ExtraFieldDisplayFormattedBase imple protected $viewBuilder; /** - * OverallBudgetExtraField constructor. + * BudgetExtraFieldBase constructor. * * @param array $configuration * A configuration array containing information about the plugin instance. @@ -77,14 +77,8 @@ public function viewElements(ContentEntityInterface $entity) { ], ]; - if ($entity->get($field_eu_budget)->isEmpty()) { - // Fallback to old field. - $build[] = $this->viewBuilder->viewField($entity->get($field_budget), $display_options); - } - else { - // Render new field value. - $build[] = $this->viewBuilder->viewField($entity->get($field_eu_budget), $display_options); - } + $field_name = $entity->get($field_eu_budget)->isEmpty() ? $field_budget : $field_eu_budget; + $build[] = $this->viewBuilder->viewField($entity->get($field_name), $display_options); return $build; } From a551b6d9f88b0e8bc4c9e97d7e77ca39860aa735 Mon Sep 17 00:00:00 2001 From: drishu Date: Wed, 12 Apr 2023 10:41:34 +0300 Subject: [PATCH 24/27] OEL-2267: Ignore outdated typed_link patch. --- composer.json | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index b6cc9eecb..35994831b 100644 --- a/composer.json +++ b/composer.json @@ -28,7 +28,7 @@ "drupal/field_group": "^3.2", "drupal/search_api": "^1.21", "drupal/search_api_autocomplete": "^1.5", - "drupal/typed_link": "^2.0", + "drupal/typed_link": "^2.0.1", "drush/drush": "^11.1", "mikey179/vfsstream": "^1.6.10", "openeuropa/code-review": "^2.0", @@ -86,6 +86,13 @@ "https://www.drupal.org/project/entity_reference_revisions/issues/2937835": "https://www.drupal.org/files/issues/2021-03-26/entity_reference_revisions-field_formatter_label-2937835-36.patch" } }, + "patches-ignore": { + "openeuropa/oe_content": { + "drupal/typed_link": { + "Outdated": "https://www.drupal.org/files/issues/2022-02-09/typed_link_constraints-3263477-2.patch" + } + } + }, "drupal-scaffold": { "locations": { "web-root": "./build" From 38ee1358419af06f7a1b60b54a55b7430d49b2c1 Mon Sep 17 00:00:00 2001 From: drishu Date: Mon, 17 Apr 2023 17:00:07 +0300 Subject: [PATCH 25/27] OEL-2267: Improve BudgetExtraFieldBase method names. --- .../Plugin/ExtraField/Display/BudgetExtraFieldBase.php | 8 ++++---- .../ExtraField/Display/EuContributionExtraField.php | 4 ++-- .../Plugin/ExtraField/Display/OverallBudgetExtraField.php | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/modules/oe_whitelabel_extra_project/src/Plugin/ExtraField/Display/BudgetExtraFieldBase.php b/modules/oe_whitelabel_extra_project/src/Plugin/ExtraField/Display/BudgetExtraFieldBase.php index cbcedb3b4..c960ee258 100644 --- a/modules/oe_whitelabel_extra_project/src/Plugin/ExtraField/Display/BudgetExtraFieldBase.php +++ b/modules/oe_whitelabel_extra_project/src/Plugin/ExtraField/Display/BudgetExtraFieldBase.php @@ -58,8 +58,8 @@ public static function create(ContainerInterface $container, array $configuratio * {@inheritdoc} */ public function viewElements(ContentEntityInterface $entity) { - $field_budget = $this->getFieldBudget(); - $field_eu_budget = $this->getFieldEuBudget(); + $field_budget = $this->getLegacyBudgetFieldName(); + $field_eu_budget = $this->getBudgetFieldName(); if ($entity->get($field_budget)->isEmpty() && $entity->get($field_eu_budget)->isEmpty()) { return []; @@ -89,7 +89,7 @@ public function viewElements(ContentEntityInterface $entity) { * @return string * The budget field. */ - abstract protected function getFieldBudget(): string; + abstract protected function getLegacyBudgetFieldName(): string; /** * Returns the new budget field name. @@ -97,6 +97,6 @@ abstract protected function getFieldBudget(): string; * @return string * The budget field. */ - abstract protected function getFieldEuBudget(): string; + abstract protected function getBudgetFieldName(): string; } diff --git a/modules/oe_whitelabel_extra_project/src/Plugin/ExtraField/Display/EuContributionExtraField.php b/modules/oe_whitelabel_extra_project/src/Plugin/ExtraField/Display/EuContributionExtraField.php index 19ee9f9e3..bac51b83e 100644 --- a/modules/oe_whitelabel_extra_project/src/Plugin/ExtraField/Display/EuContributionExtraField.php +++ b/modules/oe_whitelabel_extra_project/src/Plugin/ExtraField/Display/EuContributionExtraField.php @@ -28,14 +28,14 @@ public function getLabel() { /** * {@inheritdoc} */ - protected function getFieldBudget(): string { + protected function getLegacyBudgetFieldName(): string { return 'oe_project_budget_eu'; } /** * {@inheritdoc} */ - protected function getFieldEuBudget(): string { + protected function getBudgetFieldName(): string { return 'oe_project_eu_contrib'; } diff --git a/modules/oe_whitelabel_extra_project/src/Plugin/ExtraField/Display/OverallBudgetExtraField.php b/modules/oe_whitelabel_extra_project/src/Plugin/ExtraField/Display/OverallBudgetExtraField.php index ee598fce9..e22fbae3d 100644 --- a/modules/oe_whitelabel_extra_project/src/Plugin/ExtraField/Display/OverallBudgetExtraField.php +++ b/modules/oe_whitelabel_extra_project/src/Plugin/ExtraField/Display/OverallBudgetExtraField.php @@ -28,14 +28,14 @@ public function getLabel() { /** * {@inheritdoc} */ - protected function getFieldBudget(): string { + protected function getLegacyBudgetFieldName(): string { return 'oe_project_budget'; } /** * {@inheritdoc} */ - protected function getFieldEuBudget(): string { + protected function getBudgetFieldName(): string { return 'oe_project_eu_budget'; } From 63558fd1c9016422a506e778d292e352f16b1145 Mon Sep 17 00:00:00 2001 From: drishu Date: Fri, 21 Apr 2023 11:54:14 +0300 Subject: [PATCH 26/27] OEL-2115: Drop drupal-extension for drupal-dev. --- composer.json | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index 35994831b..591a8197c 100644 --- a/composer.json +++ b/composer.json @@ -20,8 +20,8 @@ "drupal/composite_reference": "^2.1", "drupal/config_devel": "~1.2", "drupal/core-composer-scaffold": "^9.4", + "drupal/core-dev": "^9.4", "drupal/description_list_field": "^1.0@alpha", - "drupal/drupal-extension": "^5.0.0alpha1", "drupal/entity_reference_revisions": "^1.9", "drupal/extra_field": "^2.1", "drupal/facets_form": "1.0.0-alpha3", @@ -42,8 +42,7 @@ "openeuropa/oe_paragraphs": "^1.17", "openeuropa/oe_starter_content": "^1.0.0", "openeuropa/task-runner-drupal-project-symlink": "^1.0-beta6", - "phpspec/prophecy-phpunit": "^2", - "symfony/phpunit-bridge": "^6.0" + "phpspec/prophecy-phpunit": "^2" }, "scripts": { "post-install-cmd": "./vendor/bin/run drupal:site-setup", From f1e591881961ce9ab47b81b6dbef57550f5a6999 Mon Sep 17 00:00:00 2001 From: drishu Date: Fri, 21 Apr 2023 11:54:53 +0300 Subject: [PATCH 27/27] OEL-2115: Replace property_exists with attr(). --- tests/src/Functional/ContentEventRenderTest.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/src/Functional/ContentEventRenderTest.php b/tests/src/Functional/ContentEventRenderTest.php index e1c415265..2d6c8a3fd 100644 --- a/tests/src/Functional/ContentEventRenderTest.php +++ b/tests/src/Functional/ContentEventRenderTest.php @@ -94,9 +94,10 @@ public function testEventPage(): void { $this->drupalGet('node/' . $node->id()); $crawler = $client->getCrawler(); + /** @var \Symfony\Component\DomCrawler\Crawler $link */ $link = $crawler->filter('.bcl-content-banner a[href="/build/node/' . $node->id() . '"]'); $this->assertCount(1, $link); - $this->assertFalse(property_exists($link, 'target')); + $this->assertNull($link->attr('target')); $this->assertStringContainsString('Register', $link->text()); $this->assertStringContainsString('calendar-check', $link->html());