Skip to content

Commit

Permalink
Add historical overview for detailed organ information
Browse files Browse the repository at this point in the history
  • Loading branch information
tomudding committed Mar 14, 2024
1 parent c430286 commit 6a59378
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 10 deletions.
22 changes: 17 additions & 5 deletions module/Decision/config/module.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -249,26 +249,35 @@
],
'priority' => 100,
],
'organ' => [
'organs' => [
'type' => Literal::class,
'options' => [
'route' => '/organ',
'route' => '/organs',
'defaults' => [
'controller' => OrganController::class,
'action' => 'index',
],
],
'may_terminate' => true,
'child_routes' => [
'show' => [
'history' => [
'type' => Literal::class,
'options' => [
'route' => '/history',
'defaults' => [
'action' => 'history',
],
],
],
'view' => [
'type' => Segment::class,
'options' => [
'route' => '/show/:organ',
'route' => '/view/:organ',
'constraints' => [
'organ' => '[0-9]+',
],
'defaults' => [
'action' => 'show',
'action' => 'view',
],
],
],
Expand Down Expand Up @@ -400,6 +409,9 @@
'template_path_stack' => [
'decision' => __DIR__ . '/../view/',
],
'template_map' => [
'decision/organ/history' => __DIR__ . '/../view/decision/organ/index.phtml',
],
],
'doctrine' => [
'driver' => [
Expand Down
13 changes: 12 additions & 1 deletion module/Decision/src/Controller/OrganController.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,26 @@ public function indexAction(): ViewModel
{
return new ViewModel(
[
'historical' => false,
'organs' => $this->organService->getOrgans(),
],
);
}

public function historyAction(): ViewModel
{
return new ViewModel(
[
'historical' => true,
'organs' => $this->organService->getOrgans(true),
],
);
}

/**
* Show an organ.
*/
public function showAction(): ViewModel
public function viewAction(): ViewModel
{
$organId = (int) $this->params()->fromRoute('organ');
$organ = $this->organService->getOrgan($organId);
Expand Down
8 changes: 6 additions & 2 deletions module/Decision/src/Service/Organ.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,17 @@ public function __construct(
*
* @return OrganModel[]
*/
public function getOrgans(): array
public function getOrgans(bool $abrogated = false): array
{
if (!$this->aclService->isAllowed('list', 'organ')) {
throw new NotAllowedException($this->translator->translate('Not allowed to view the list of organs'));
}

return $this->organMapper->findActive();
if (!$abrogated) {
return $this->organMapper->findActive();
}

return $this->organMapper->findAbrogated();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion module/Decision/view/decision/member/index.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ $this->headTitle($this->translate('Members'));
<div class="col-md-12">
<h2><?= $this->translate('Association') ?></h2>
<div class="grid grid-col-5">
<a href="<?= $this->url('organ') ?>" class="panel panel-image align-middle">
<a href="<?= $this->url('organs') ?>" class="panel panel-image align-middle">
<div class="big-icon fas fa-sitemap"></div>
<div class="panel-heading"><?= $this->translate('Organs') ?></div>
</a>
Expand Down
11 changes: 10 additions & 1 deletion module/Decision/view/decision/organ/index.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use Laminas\View\Renderer\PhpRenderer;

/**
* @var PhpRenderer|HelperTrait $this
* @var bool $historical
* @var OrganModel[] $organs
*/

Expand All @@ -22,11 +23,14 @@ $this->headTitle($this->translate('Organ list'));
<th><?= $this->translate('Abbreviation') ?></th>
<th><?= $this->translate('Name') ?></th>
<th><?= $this->translate('Type') ?></th>
<?php if ($historical): ?>
<th><?= $this->translate('Abrogation Date') ?></th>
<?php endif; ?>
</tr>
</thead>
<tbody>
<?php foreach ($organs as $organ): ?>
<?php $url = $this->url('organ/show', ['organ' => $organ->getId()]) ?>
<?php $url = $this->url('organs/view', ['organ' => $organ->getId()]) ?>
<tr>
<td>
<a style="display: block; height: 100%; width:100%" href="<?= $url ?>">
Expand All @@ -43,6 +47,11 @@ $this->headTitle($this->translate('Organ list'));
<?= $organ->getType()->getName($this->plugin('translate')->getTranslator()) ?>
</a>
</td>
<?php if ($historical): ?>
<td>
<?= $organ->getAbrogationDate()?->format('Y-m-d') ?>
</td>
<?php endif; ?>
</tr>
<?php endforeach; ?>
</tbody>
Expand Down

0 comments on commit 6a59378

Please sign in to comment.