diff --git a/module/Activity/src/Controller/ActivityController.php b/module/Activity/src/Controller/ActivityController.php index 99f7ca476d..47fb3747d8 100644 --- a/module/Activity/src/Controller/ActivityController.php +++ b/module/Activity/src/Controller/ActivityController.php @@ -79,7 +79,7 @@ public function viewAction(): mixed } // If the Activity has a sign-up list always display it by redirecting the request. - if (0 !== $activity->getSignupLists()->count()) { + if (!$activity->getSignupLists()->isEmpty()) { return $this->forward()->dispatch( self::class, [ @@ -263,7 +263,7 @@ public function signupAction(): Response|ViewModel // Let user edit subscription details if (null !== ($signup = $this->signupMapper->getSignUp($signupList, $identity))) { - if (0 === $signupList->getFields()->count()) { + if ($signupList->getFields()->isEmpty()) { return $this->redirect()->toRoute( 'activity/view/signuplist', [ diff --git a/module/Activity/src/Controller/AdminController.php b/module/Activity/src/Controller/AdminController.php index ad38b2201b..c54c6156f5 100644 --- a/module/Activity/src/Controller/AdminController.php +++ b/module/Activity/src/Controller/AdminController.php @@ -96,7 +96,7 @@ public function updateAction(): Response|ViewModel throw new NotAllowedException($this->translator->translate('You are not allowed to update this activity')); } - if (0 !== $activity->getSignupLists()->count()) { + if (!$activity->getSignupLists()->isEmpty()) { $openingDates = []; $participants = 0; @@ -144,11 +144,11 @@ public function updateAction(): Response|ViewModel } } - $updateProposal = $activity->getUpdateProposal(); + $updateProposals = $activity->getUpdateProposals(); - if (0 !== $updateProposal->count()) { + if (!$updateProposals->isEmpty()) { // If there already is an update proposal for this activity, show that instead of the original activity. - $activity = $updateProposal->first()->getNew(); + $activity = $updateProposals->first()->getNew(); } $activityData = $activity->toArray(); @@ -213,7 +213,7 @@ public function participantsAction(): ViewModel // If the activity does not have any sign-up lists there is no need // to check the participants or any sign-up lists. - if (0 === $activity->getSignupLists()->count()) { + if ($activity->getSignupLists()->isEmpty()) { return $this->notFoundAction(); } diff --git a/module/Activity/src/Model/Activity.php b/module/Activity/src/Model/Activity.php index de69664014..1004ca3fc5 100644 --- a/module/Activity/src/Model/Activity.php +++ b/module/Activity/src/Model/Activity.php @@ -274,7 +274,7 @@ public function setStatus(int $status): void /** * @return Collection */ - public function getUpdateProposal(): Collection + public function getUpdateProposals(): Collection { return $this->updateProposal; } diff --git a/module/Activity/src/Service/Activity.php b/module/Activity/src/Service/Activity.php index 89a4002b33..3b21510cf6 100644 --- a/module/Activity/src/Service/Activity.php +++ b/module/Activity/src/Service/Activity.php @@ -140,7 +140,7 @@ protected function findOrgan(int $organId): OrganModel { $organ = $this->organService->getOrgan($organId); - if (!$this->organService->canEditOrgan($organ)) { + if (!$this->organService->canUseOrgan($organ)) { throw new NotAllowedException( $this->translator->translate('You are not allowed to create an activity for this organ'), ); @@ -443,8 +443,8 @@ public function createUpdateProposal( $em = $this->entityManager; - if (0 !== $currentActivity->getUpdateProposal()->count()) { - $proposal = $currentActivity->getUpdateProposal()->first(); + if (0 !== $currentActivity->getUpdateProposals()->count()) { + $proposal = $currentActivity->getUpdateProposals()->first(); //Remove old update proposal $oldUpdate = $proposal->getNew(); $proposal->setNew($newActivity); diff --git a/module/Activity/src/Service/ActivityCalendar.php b/module/Activity/src/Service/ActivityCalendar.php index 31ad91d787..5e129c0f0f 100644 --- a/module/Activity/src/Service/ActivityCalendar.php +++ b/module/Activity/src/Service/ActivityCalendar.php @@ -230,7 +230,7 @@ protected function canDeleteOption(ActivityCalendarOptionModel $option): bool $organ = $option->getProposal()->getOrgan(); - return null !== $organ && $this->organService->canEditOrgan($organ); + return null !== $organ && $this->organService->canUseOrgan($organ); } /** diff --git a/module/Activity/view/activity/admin-approval/view-proposal.phtml b/module/Activity/view/activity/admin-approval/view-proposal.phtml index e9577cb3dd..55c1404835 100644 --- a/module/Activity/view/activity/admin-approval/view-proposal.phtml +++ b/module/Activity/view/activity/admin-approval/view-proposal.phtml @@ -240,7 +240,7 @@ $this->breadcrumbs()
- getCategories()->count() !== 0 || $new->getCategories()->count() !== 0): ?> + getCategories()->isEmpty() || !$new->getCategories()->isEmpty()): ?>

translate('Activity Categories') ?>

@@ -267,7 +267,7 @@ $this->breadcrumbs() - getSignupLists()->count() !== 0 || $new->getSignupLists()->count() !== 0): ?> + getSignupLists()->isEmpty() || !$new->getSignupLists()->isEmpty()): ?>

translate('Sign-up Lists') ?>

diff --git a/module/Activity/view/activity/admin-approval/view.phtml b/module/Activity/view/activity/admin-approval/view.phtml index 9d64ec9825..9085f0839e 100644 --- a/module/Activity/view/activity/admin-approval/view.phtml +++ b/module/Activity/view/activity/admin-approval/view.phtml @@ -173,7 +173,7 @@ $this->breadcrumbs()
- getCategories()->count() > 0): ?> + getCategories()->isEmpty()): ?>

translate('Activity Categories') ?>

@@ -187,7 +187,7 @@ $this->breadcrumbs() - getSignupLists()->count() > 0): ?> + getSignupLists()->isEmpty()): ?>

translate('Sign-up Lists') ?>

diff --git a/module/Activity/view/activity/admin/list.phtml b/module/Activity/view/activity/admin/list.phtml index 5d740a1823..fbd3bc3897 100644 --- a/module/Activity/view/activity/admin/list.phtml +++ b/module/Activity/view/activity/admin/list.phtml @@ -46,10 +46,10 @@ use Laminas\View\Renderer\PhpRenderer; getCompany()) ? $this->translate('None') : $this->escapeHtml($activity->getCompany()->getName()) ?> escapeHtml($activity->getCreator()->getFullName()) ?> - getUpdateProposal()->count() === 0 ? '(-)' : - '' . $this->translate('Update pending') . '' ?> + getUpdateProposals()->count() === 0 ? '(-)' : + '' . $this->translate('Update pending') . '' ?> - getUpdateProposal()->count() === 0 ? '(-)' : $this->translate('Update pending') ?> + getUpdateProposals()->count() === 0 ? '(-)' : $this->translate('Update pending') ?> diff --git a/module/Application/src/Model/Enums/ApprovableStatus.php b/module/Application/src/Model/Enums/ApprovableStatus.php index 206be67d22..8853307516 100644 --- a/module/Application/src/Model/Enums/ApprovableStatus.php +++ b/module/Application/src/Model/Enums/ApprovableStatus.php @@ -13,4 +13,13 @@ enum ApprovableStatus: int case Unapproved = 0; case Approved = 1; case Rejected = 2; + + public function getIcon(): string + { + return match ($this) { + self::Unapproved => 'fa-circle-question', + self::Approved => 'fa-circle-check', + self::Rejected => 'fa-circle-xmark', + }; + } } diff --git a/module/Application/src/Model/Traits/ApprovableTrait.php b/module/Application/src/Model/Traits/ApprovableTrait.php index c60bc1a9aa..19a885071a 100644 --- a/module/Application/src/Model/Traits/ApprovableTrait.php +++ b/module/Application/src/Model/Traits/ApprovableTrait.php @@ -70,14 +70,24 @@ enumType: ApprovableStatus::class, )] protected ?ApprovableTextModel $approvableText = null; - public function getApproved(): ApprovableStatus + public function getApproval(): ApprovableStatus { return $this->approved; } public function isApproved(): bool { - return ApprovableStatus::Approved === $this->getApproved(); + return ApprovableStatus::Approved === $this->getApproval(); + } + + public function isRejected(): bool + { + return ApprovableStatus::Rejected === $this->getApproval(); + } + + public function isUnapproved(): bool + { + return ApprovableStatus::Unapproved === $this->getApproval(); } public function setApproved(ApprovableStatus $approved): void @@ -122,7 +132,7 @@ public function toGdprArray(): array { return [ 'id' => $this->getId(), - 'approved' => $this->getApproved()->value, + 'approved' => $this->getApproval()->value, 'approvedAt' => $this->getApprovedAt()?->format(DateTimeInterface::ATOM), 'approvableText' => $this->getApprovableText()?->getMessage(), ]; diff --git a/module/Application/src/Model/Traits/UpdateProposableTrait.php b/module/Application/src/Model/Traits/UpdateProposableTrait.php index 629e563af2..ad8d8b4825 100644 --- a/module/Application/src/Model/Traits/UpdateProposableTrait.php +++ b/module/Application/src/Model/Traits/UpdateProposableTrait.php @@ -4,12 +4,15 @@ namespace Application\Model\Traits; +use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping\Column; /** * A trait which provides basic (repeated) functionality for proposed update entities. * * TODO: Make activities also use this trait. + * + * @template T of object */ trait UpdateProposableTrait { @@ -42,4 +45,11 @@ public function setIsUpdate(bool $isUpdate): void { $this->isUpdate = $isUpdate; } + + /** + * Get update proposals for this entity. + * + * @psalm-return Collection + */ + abstract public function getUpdateProposals(): Collection; } diff --git a/module/Application/view/partial/admin.phtml b/module/Application/view/partial/admin.phtml index 59d058befa..4ac3a167fa 100644 --- a/module/Application/view/partial/admin.phtml +++ b/module/Application/view/partial/admin.phtml @@ -40,31 +40,30 @@ use Laminas\View\Renderer\PhpRenderer; @@ -75,15 +74,13 @@ use Laminas\View\Renderer\PhpRenderer; translate('Career') ?>