Skip to content

Commit

Permalink
DRAFT: feat: improved
Browse files Browse the repository at this point in the history
  • Loading branch information
tomudding committed Dec 11, 2024
1 parent 5abea51 commit 189a210
Show file tree
Hide file tree
Showing 46 changed files with 994 additions and 349 deletions.
4 changes: 2 additions & 2 deletions module/Activity/src/Controller/ActivityController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
[
Expand Down Expand Up @@ -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',
[
Expand Down
10 changes: 5 additions & 5 deletions module/Activity/src/Controller/AdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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();

Check failure on line 151 in module/Activity/src/Controller/AdminController.php

View workflow job for this annotation

GitHub Actions / Psalm

PossiblyFalseReference

module/Activity/src/Controller/AdminController.php:151:51: PossiblyFalseReference: Cannot call method getNew on possibly false value (see https://psalm.dev/105)
}

$activityData = $activity->toArray();
Expand Down Expand Up @@ -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();
}

Expand Down
2 changes: 1 addition & 1 deletion module/Activity/src/Model/Activity.php
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ public function setStatus(int $status): void
/**
* @return Collection<array-key, ActivityUpdateProposal>
*/
public function getUpdateProposal(): Collection
public function getUpdateProposals(): Collection
{
return $this->updateProposal;
}
Expand Down
6 changes: 3 additions & 3 deletions module/Activity/src/Service/Activity.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
);
Expand Down Expand Up @@ -446,8 +446,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();

Check failure on line 452 in module/Activity/src/Service/Activity.php

View workflow job for this annotation

GitHub Actions / Psalm

PossiblyFalseReference

module/Activity/src/Service/Activity.php:452:37: PossiblyFalseReference: Cannot call method getNew on possibly false value (see https://psalm.dev/105)
$proposal->setNew($newActivity);
Expand Down
2 changes: 1 addition & 1 deletion module/Activity/src/Service/ActivityCalendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ $this->breadcrumbs()
</div>
<hr>
</div>
<?php if ($old->getCategories()->count() !== 0 || $new->getCategories()->count() !== 0): ?>
<?php if (!$old->getCategories()->isEmpty() || !$new->getCategories()->isEmpty()): ?>
<div class="col-md-12">
<h2><?= $this->translate('Activity Categories') ?></h2>
</div>
Expand All @@ -267,7 +267,7 @@ $this->breadcrumbs()
<?php endforeach; ?>
</div>
<?php endif; ?>
<?php if ($old->getSignupLists()->count() !== 0 || $new->getSignupLists()->count() !== 0): ?>
<?php if (!$old->getSignupLists()->isEmpty() || !$new->getSignupLists()->isEmpty()): ?>
<div class="col-md-12">
<h2><?= $this->translate('Sign-up Lists') ?></h2>
</div>
Expand Down
4 changes: 2 additions & 2 deletions module/Activity/view/activity/admin-approval/view.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ $this->breadcrumbs()
</div>
<hr>
</div>
<?php if ($activity->getCategories()->count() > 0): ?>
<?php if (!$activity->getCategories()->isEmpty()): ?>
<div class="col-md-12">
<h2><?= $this->translate('Activity Categories') ?></h2>
</div>
Expand All @@ -187,7 +187,7 @@ $this->breadcrumbs()
<?php endforeach; ?>
</div>
<?php endif; ?>
<?php if ($activity->getSignupLists()->count() > 0): ?>
<?php if (!$activity->getSignupLists()->isEmpty()): ?>
<div class="col-md-12">
<h2><?= $this->translate('Sign-up Lists') ?></h2>
</div>
Expand Down
6 changes: 3 additions & 3 deletions module/Activity/view/activity/admin/list.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ use Laminas\View\Renderer\PhpRenderer;
<td><?= (null === $activity->getCompany()) ? $this->translate('None') : $this->escapeHtml($activity->getCompany()->getName()) ?></td>
<td><?= $this->escapeHtml($activity->getCreator()->getFullName()) ?></td>
<?php if ($admin): ?>
<td><?= $activity->getUpdateProposal()->count() === 0 ? '(-)' :
'<a href="' . $this->url('activity_admin_approval/proposal', ['id' => $activity->getUpdateProposal()->first()->getId()]) . '">' . $this->translate('Update pending') . '</a>' ?></td>
<td><?= $activity->getUpdateProposals()->count() === 0 ? '(-)' :
'<a href="' . $this->url('activity_admin_approval/proposal', ['id' => $activity->getUpdateProposals()->first()->getId()]) . '">' . $this->translate('Update pending') . '</a>' ?></td>
<?php else: ?>
<td><?= $activity->getUpdateProposal()->count() === 0 ? '(-)' : $this->translate('Update pending') ?></td>
<td><?= $activity->getUpdateProposals()->count() === 0 ? '(-)' : $this->translate('Update pending') ?></td>
<?php endif; ?>
<?php if (!$admin): ?>
<td>
Expand Down
9 changes: 9 additions & 0 deletions module/Application/src/Model/Enums/ApprovableStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
};
}
}
16 changes: 13 additions & 3 deletions module/Application/src/Model/Traits/ApprovableTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(),
];
Expand Down
10 changes: 10 additions & 0 deletions module/Application/src/Model/Traits/UpdateProposableTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -42,4 +45,11 @@ public function setIsUpdate(bool $isUpdate): void
{
$this->isUpdate = $isUpdate;
}

/**
* Get update proposals for this entity.
*
* @psalm-return Collection<array-key, T>
*/
abstract public function getUpdateProposals(): Collection;
}
94 changes: 59 additions & 35 deletions module/Application/view/partial/admin.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -40,31 +40,30 @@ use Laminas\View\Renderer\PhpRenderer;
</a>
<ul class="dropdown-menu">
<li>
<a href="<?= $this->url('activity_admin') ?>"><?= $this->translate(
'Overview'
) ?></a>
<a href="<?= $this->url('activity_admin') ?>">
<?= $this->translate('Overview') ?>
</a>
</li>
<?php
if ($this->acl('activity_service_acl')->isAllowed('activity', 'listCategories')): ?>
<li>
<a href="<?= $this->url('activity_admin_categories') ?>"><?= $this->translate(
'Categories'
) ?></a>
<a href="<?= $this->url('activity_admin_categories') ?>">
<?= $this->translate('Categories') ?>
</a>
</li>
<?php
endif; ?>
<?php endif; ?>
<?php
if ($this->acl('activity_service_acl')->isAllowed(
'activity_calendar_period',
'view'
)): ?>
)):
?>
<li>
<a href="<?= $this->url('activity_admin_options') ?>"><?= $this->translate(
'Option Calendar'
) ?></a>
<a href="<?= $this->url('activity_admin_options') ?>">
<?= $this->translate('Option Calendar') ?>
</a>
</li>
<?php
endif; ?>
<?php endif; ?>
</ul>
</li>
<?php endif; ?>
Expand All @@ -75,15 +74,13 @@ use Laminas\View\Renderer\PhpRenderer;
<?= $this->translate('Career') ?> <span class="caret"></span>
</a>
<ul class="dropdown-menu">
<?php
if ($this->acl('company_service_acl')->isAllowed('company', 'listAll')): ?>
<?php if ($this->acl('company_service_acl')->isAllowed('company', 'listAll')): ?>
<li>
<a href="<?= $this->url('company_admin') ?>">
<?= $this->translate('Companies') ?>
</a>
</li>
<?php
endif; ?>
<?php endif; ?>
<?php
if (
$this->acl('company_service_acl')->isAllowed('company', 'approve')
Expand Down Expand Up @@ -146,48 +143,73 @@ use Laminas\View\Renderer\PhpRenderer;
</a>
<ul class="dropdown-menu">
<li>
<a href="<?= $this->url('decision_admin/minutes') ?>"><?= $this->translate(
'Minutes'
) ?></a>
<a href="<?= $this->url('decision_admin/minutes') ?>">
<?= $this->translate('Minutes') ?>
</a>
</li>
<li>
<a href="<?= $this->url('decision_admin/document') ?>"><?= $this->translate(
'Documents'
) ?></a>
<a href="<?= $this->url('decision_admin/document') ?>">
<?= $this->translate('Documents') ?>
</a>
</li>
<li>
<a href="<?= $this->url('decision_admin/authorizations') ?>"><?= $this->translate(
'Authorizations'
) ?></a>
<a href="<?= $this->url('decision_admin/authorizations') ?>">
<?= $this->translate('Authorizations') ?>
</a>
</li>
</ul>
</li>
<?php endif; ?>
<?php if ($this->acl('decision_service_acl')->isAllowed('decision_organ_admin', 'view')): ?>
<li>
<a href="<?= $this->url('admin_organ') ?>">
<?= $this->translate('Organs') ?>
<li class="dropdown">
<a href="<?= $this->hashUrl() ?>" class="dropdown-toggle" data-toggle="dropdown"
role="button" aria-haspopup="true" aria-expanded="false">
<?= $this->translate('Organs') ?> <span class="caret"></span>
</a>
<ul class="dropdown-menu">
<li>
<a href="<?= $this->url('admin_organ') ?>">
<?= $this->translate('Overview') ?>
</a>
</li>
<?php
if ($this->acl('decision_service_acl')->isAllowed('organInformation', 'approve')):
?>
<li>
<a href="<?= $this->url('admin_organ_approval') ?>">
<?= $this->translate('Approvals') ?>
</a>
</li>
<?php endif; ?>
</ul>
</li>
<?php endif; ?>
<?php if ($this->acl('frontpage_service_acl')->isAllowed('news_item', 'create')): ?>
<li class="<?= $this->moduleIsActive(['frontpage', 'news']) ? 'active' : '' ?>">
<a href="<?= $this->url('admin_news') ?>"><?= $this->translate('News') ?></a>
<a href="<?= $this->url('admin_news') ?>">
<?= $this->translate('News') ?>
</a>
</li>
<?php endif; ?>
<?php if ($this->acl('frontpage_service_acl')->isAllowed('page', 'create')): ?>
<li class="<?= $this->moduleIsActive(['frontpage', 'page']) ? 'active' : '' ?>">
<a href="<?= $this->url('admin_page') ?>"><?= $this->translate('Pages') ?></a>
<a href="<?= $this->url('admin_page') ?>">
<?= $this->translate('Pages') ?>
</a>
</li>
<?php endif; ?>
<?php if ($this->acl('photo_service_acl')->isAllowed('photo_admin', 'view')): ?>
<li>
<a href="<?= $this->url('admin_photo') ?>"><?= $this->translate('Photos') ?></a>
<a href="<?= $this->url('admin_photo') ?>">
<?= $this->translate('Photos') ?>
</a>
</li>
<?php endif; ?>
<?php if ($this->acl('frontpage_service_acl')->isAllowed('poll', 'approve')): ?>
<li class="<?= $this->moduleIsActive(['frontpage', 'poll']) ? 'active' : '' ?>">
<a href="<?= $this->url('admin_poll') ?>"><?= $this->translate('Polls') ?></a>
<a href="<?= $this->url('admin_poll') ?>">
<?= $this->translate('Polls') ?>
</a>
</li>
<?php endif; ?>
<?php if ($this->acl('user_service_acl')->isAllowed('user_admin', 'view')): ?>
Expand Down Expand Up @@ -231,7 +253,9 @@ use Laminas\View\Renderer\PhpRenderer;
<div class="container-admin">
<ol class="breadcrumb">
<li class="active">
<a href="<?= $this->url('admin') ?>"><?= $this->translate('Admin') ?></a>
<a href="<?= $this->url('admin') ?>">
<?= $this->translate('Admin') ?>
</a>
</li>
<?= $this->breadcrumbs() ?>
</ol>
Expand Down
2 changes: 1 addition & 1 deletion module/Company/src/Controller/CompanyAccountController.php
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ public function editJobAction(): Response|ViewModel

$isJobRejected = false;
$jobRejectedMessage = null;
if (ApprovableStatus::Rejected === $job->getApproved()) {
if (ApprovableStatus::Rejected === $job->getApproval()) {
$isJobRejected = true;
$jobRejectedMessage = $job->getApprovableText()?->getMessage();
}
Expand Down
Loading

0 comments on commit 189a210

Please sign in to comment.