Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wip: improved OrganInformation approval #1903

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,13 +79,13 @@
}

// 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,
[
'action' => 'viewSignupList',
'id' => $activityId,
'signupList' => $activity->getSignupLists()->first()->getId(),

Check failure on line 88 in module/Activity/src/Controller/ActivityController.php

View workflow job for this annotation

GitHub Actions / Psalm

PossiblyFalseReference

module/Activity/src/Controller/ActivityController.php:88:75: PossiblyFalseReference: Cannot call method getId on possibly false value (see https://psalm.dev/105)
],
);
}
Expand Down Expand Up @@ -263,7 +263,7 @@

// 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
@@ -1,4 +1,4 @@
<?php

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

View workflow job for this annotation

GitHub Actions / Psalm

UnusedBaselineEntry

module/Activity/src/Controller/AdminController.php:0:0: UnusedBaselineEntry: Baseline for issue "PossiblyFalseReference" has 1 extra entry. (see https://psalm.dev/316)

declare(strict_types=1);

Expand Down Expand Up @@ -96,7 +96,7 @@
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 @@
}
}

$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 @@

// 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 @@
{
$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,10 +446,10 @@

$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);
$em->remove($oldUpdate);
} else {
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
Loading