Skip to content

Commit 77dca90

Browse files
committed
DRAFT: feat: improved
1 parent 5d7d87c commit 77dca90

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+996
-352
lines changed

module/Activity/src/Controller/ActivityController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public function viewAction(): mixed
7979
}
8080

8181
// If the Activity has a sign-up list always display it by redirecting the request.
82-
if (0 !== $activity->getSignupLists()->count()) {
82+
if (!$activity->getSignupLists()->isEmpty()) {
8383
return $this->forward()->dispatch(
8484
self::class,
8585
[
@@ -263,7 +263,7 @@ public function signupAction(): Response|ViewModel
263263

264264
// Let user edit subscription details
265265
if (null !== ($signup = $this->signupMapper->getSignUp($signupList, $identity))) {
266-
if (0 === $signupList->getFields()->count()) {
266+
if ($signupList->getFields()->isEmpty()) {
267267
return $this->redirect()->toRoute(
268268
'activity/view/signuplist',
269269
[

module/Activity/src/Controller/AdminController.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public function updateAction(): Response|ViewModel
9696
throw new NotAllowedException($this->translator->translate('You are not allowed to update this activity'));
9797
}
9898

99-
if (0 !== $activity->getSignupLists()->count()) {
99+
if (!$activity->getSignupLists()->isEmpty()) {
100100
$openingDates = [];
101101
$participants = 0;
102102

@@ -144,11 +144,11 @@ public function updateAction(): Response|ViewModel
144144
}
145145
}
146146

147-
$updateProposal = $activity->getUpdateProposal();
147+
$updateProposals = $activity->getUpdateProposals();
148148

149-
if (0 !== $updateProposal->count()) {
149+
if (!$updateProposals->isEmpty()) {
150150
// If there already is an update proposal for this activity, show that instead of the original activity.
151-
$activity = $updateProposal->first()->getNew();
151+
$activity = $updateProposals->first()->getNew();
152152
}
153153

154154
$activityData = $activity->toArray();
@@ -213,7 +213,7 @@ public function participantsAction(): ViewModel
213213

214214
// If the activity does not have any sign-up lists there is no need
215215
// to check the participants or any sign-up lists.
216-
if (0 === $activity->getSignupLists()->count()) {
216+
if ($activity->getSignupLists()->isEmpty()) {
217217
return $this->notFoundAction();
218218
}
219219

module/Activity/src/Model/Activity.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ public function setStatus(int $status): void
274274
/**
275275
* @return Collection<array-key, ActivityUpdateProposal>
276276
*/
277-
public function getUpdateProposal(): Collection
277+
public function getUpdateProposals(): Collection
278278
{
279279
return $this->updateProposal;
280280
}

module/Activity/src/Service/Activity.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ protected function findOrgan(int $organId): OrganModel
140140
{
141141
$organ = $this->organService->getOrgan($organId);
142142

143-
if (!$this->organService->canEditOrgan($organ)) {
143+
if (!$this->organService->canUseOrgan($organ)) {
144144
throw new NotAllowedException(
145145
$this->translator->translate('You are not allowed to create an activity for this organ'),
146146
);
@@ -446,8 +446,8 @@ public function createUpdateProposal(
446446

447447
$em = $this->entityManager;
448448

449-
if (0 !== $currentActivity->getUpdateProposal()->count()) {
450-
$proposal = $currentActivity->getUpdateProposal()->first();
449+
if (0 !== $currentActivity->getUpdateProposals()->count()) {
450+
$proposal = $currentActivity->getUpdateProposals()->first();
451451
//Remove old update proposal
452452
$oldUpdate = $proposal->getNew();
453453
$proposal->setNew($newActivity);

module/Activity/src/Service/ActivityCalendar.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ protected function canDeleteOption(ActivityCalendarOptionModel $option): bool
230230

231231
$organ = $option->getProposal()->getOrgan();
232232

233-
return null !== $organ && $this->organService->canEditOrgan($organ);
233+
return null !== $organ && $this->organService->canUseOrgan($organ);
234234
}
235235

236236
/**

module/Activity/view/activity/admin-approval/view-proposal.phtml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ $this->breadcrumbs()
240240
</div>
241241
<hr>
242242
</div>
243-
<?php if ($old->getCategories()->count() !== 0 || $new->getCategories()->count() !== 0): ?>
243+
<?php if (!$old->getCategories()->isEmpty() || !$new->getCategories()->isEmpty()): ?>
244244
<div class="col-md-12">
245245
<h2><?= $this->translate('Activity Categories') ?></h2>
246246
</div>
@@ -267,7 +267,7 @@ $this->breadcrumbs()
267267
<?php endforeach; ?>
268268
</div>
269269
<?php endif; ?>
270-
<?php if ($old->getSignupLists()->count() !== 0 || $new->getSignupLists()->count() !== 0): ?>
270+
<?php if (!$old->getSignupLists()->isEmpty() || !$new->getSignupLists()->isEmpty()): ?>
271271
<div class="col-md-12">
272272
<h2><?= $this->translate('Sign-up Lists') ?></h2>
273273
</div>

module/Activity/view/activity/admin-approval/view.phtml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ $this->breadcrumbs()
173173
</div>
174174
<hr>
175175
</div>
176-
<?php if ($activity->getCategories()->count() > 0): ?>
176+
<?php if (!$activity->getCategories()->isEmpty()): ?>
177177
<div class="col-md-12">
178178
<h2><?= $this->translate('Activity Categories') ?></h2>
179179
</div>
@@ -187,7 +187,7 @@ $this->breadcrumbs()
187187
<?php endforeach; ?>
188188
</div>
189189
<?php endif; ?>
190-
<?php if ($activity->getSignupLists()->count() > 0): ?>
190+
<?php if (!$activity->getSignupLists()->isEmpty()): ?>
191191
<div class="col-md-12">
192192
<h2><?= $this->translate('Sign-up Lists') ?></h2>
193193
</div>

module/Activity/view/activity/admin/list.phtml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@ use Laminas\View\Renderer\PhpRenderer;
4646
<td><?= (null === $activity->getCompany()) ? $this->translate('None') : $this->escapeHtml($activity->getCompany()->getName()) ?></td>
4747
<td><?= $this->escapeHtml($activity->getCreator()->getFullName()) ?></td>
4848
<?php if ($admin): ?>
49-
<td><?= $activity->getUpdateProposal()->count() === 0 ? '(-)' :
50-
'<a href="' . $this->url('activity_admin_approval/proposal', ['id' => $activity->getUpdateProposal()->first()->getId()]) . '">' . $this->translate('Update pending') . '</a>' ?></td>
49+
<td><?= $activity->getUpdateProposals()->count() === 0 ? '(-)' :
50+
'<a href="' . $this->url('activity_admin_approval/proposal', ['id' => $activity->getUpdateProposals()->first()->getId()]) . '">' . $this->translate('Update pending') . '</a>' ?></td>
5151
<?php else: ?>
52-
<td><?= $activity->getUpdateProposal()->count() === 0 ? '(-)' : $this->translate('Update pending') ?></td>
52+
<td><?= $activity->getUpdateProposals()->count() === 0 ? '(-)' : $this->translate('Update pending') ?></td>
5353
<?php endif; ?>
5454
<?php if (!$admin): ?>
5555
<td>

module/Application/src/Model/Enums/ApprovableStatus.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,13 @@ enum ApprovableStatus: int
1313
case Unapproved = 0;
1414
case Approved = 1;
1515
case Rejected = 2;
16+
17+
public function getIcon(): string
18+
{
19+
return match ($this) {
20+
self::Unapproved => 'fa-circle-question',
21+
self::Approved => 'fa-circle-check',
22+
self::Rejected => 'fa-circle-xmark',
23+
};
24+
}
1625
}

module/Application/src/Model/Traits/ApprovableTrait.php

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,24 @@ enumType: ApprovableStatus::class,
7070
)]
7171
protected ?ApprovableTextModel $approvableText = null;
7272

73-
public function getApproved(): ApprovableStatus
73+
public function getApproval(): ApprovableStatus
7474
{
7575
return $this->approved;
7676
}
7777

7878
public function isApproved(): bool
7979
{
80-
return ApprovableStatus::Approved === $this->getApproved();
80+
return ApprovableStatus::Approved === $this->getApproval();
81+
}
82+
83+
public function isRejected(): bool
84+
{
85+
return ApprovableStatus::Rejected === $this->getApproval();
86+
}
87+
88+
public function isUnapproved(): bool
89+
{
90+
return ApprovableStatus::Unapproved === $this->getApproval();
8191
}
8292

8393
public function setApproved(ApprovableStatus $approved): void
@@ -122,7 +132,7 @@ public function toGdprArray(): array
122132
{
123133
return [
124134
'id' => $this->getId(),
125-
'approved' => $this->getApproved()->value,
135+
'approved' => $this->getApproval()->value,
126136
'approvedAt' => $this->getApprovedAt()?->format(DateTimeInterface::ATOM),
127137
'approvableText' => $this->getApprovableText()?->getMessage(),
128138
];

0 commit comments

Comments
 (0)