From 4736fca67959aa836f34f7ae4f4abbfd4ae715dd Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Tue, 30 Jan 2024 14:02:02 +0100 Subject: [PATCH 1/3] Fix the conditions upon which social actions should be optional or required in relation to social issues within the activity creation form --- src/Bundle/ChillActivityBundle/Entity/ActivityType.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Bundle/ChillActivityBundle/Entity/ActivityType.php b/src/Bundle/ChillActivityBundle/Entity/ActivityType.php index c14c8292b..2db0f805d 100644 --- a/src/Bundle/ChillActivityBundle/Entity/ActivityType.php +++ b/src/Bundle/ChillActivityBundle/Entity/ActivityType.php @@ -291,7 +291,9 @@ class ActivityType public function checkSocialActionsVisibility(ExecutionContextInterface $context, mixed $payload) { if ($this->socialIssuesVisible !== $this->socialActionsVisible) { - if (!(2 === $this->socialIssuesVisible && 1 === $this->socialActionsVisible)) { + // if social issues are invisible then social actions cannot be optional or required + if social issues are optional then social actions shouldn't be required + if (0 === $this->socialIssuesVisible && (1 === $this->socialActionsVisible || 2 === $this->socialActionsVisible) + || (1 === $this->socialIssuesVisible && 2 === $this->socialActionsVisible)) { $context ->buildViolation('The socialActionsVisible value is not compatible with the socialIssuesVisible value') ->atPath('socialActionsVisible') From 574ad42a76f45fd980a93c9d67b448a42ec70c81 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Tue, 30 Jan 2024 14:03:37 +0100 Subject: [PATCH 2/3] Add changie for fix in activity entity/form --- .changes/unreleased/Fixed-20240130-140301.yaml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .changes/unreleased/Fixed-20240130-140301.yaml diff --git a/.changes/unreleased/Fixed-20240130-140301.yaml b/.changes/unreleased/Fixed-20240130-140301.yaml new file mode 100644 index 000000000..45fb94f6a --- /dev/null +++ b/.changes/unreleased/Fixed-20240130-140301.yaml @@ -0,0 +1,6 @@ +kind: Fixed +body: Fix the conditions upon which social actions should be optional or required + in relation to social issues within the activity creation form +time: 2024-01-30T14:03:01.942955636+01:00 +custom: + Issue: "256" From 13854e59de837bf2fc5b9c3834ef7b7dc53fde14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 7 Feb 2024 14:22:18 +0100 Subject: [PATCH 3/3] Add grouping parenthesis on condition about social issue and social action visibility This improve readability and avoid errors with boolean operator precedence --- src/Bundle/ChillActivityBundle/Entity/ActivityType.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Bundle/ChillActivityBundle/Entity/ActivityType.php b/src/Bundle/ChillActivityBundle/Entity/ActivityType.php index 2db0f805d..96c369b39 100644 --- a/src/Bundle/ChillActivityBundle/Entity/ActivityType.php +++ b/src/Bundle/ChillActivityBundle/Entity/ActivityType.php @@ -292,8 +292,10 @@ class ActivityType { if ($this->socialIssuesVisible !== $this->socialActionsVisible) { // if social issues are invisible then social actions cannot be optional or required + if social issues are optional then social actions shouldn't be required - if (0 === $this->socialIssuesVisible && (1 === $this->socialActionsVisible || 2 === $this->socialActionsVisible) - || (1 === $this->socialIssuesVisible && 2 === $this->socialActionsVisible)) { + if ( + (0 === $this->socialIssuesVisible && (1 === $this->socialActionsVisible || 2 === $this->socialActionsVisible)) + || (1 === $this->socialIssuesVisible && 2 === $this->socialActionsVisible) + ) { $context ->buildViolation('The socialActionsVisible value is not compatible with the socialIssuesVisible value') ->atPath('socialActionsVisible')