Skip to content

Commit

Permalink
Improved detailed organ view
Browse files Browse the repository at this point in the history
The ordered subdecisions in an `Organ` are now also sorted by their
individual subdecision number, this is to ensure correct ordering in
the list.

Additionally, the formatting has changed to show in which meeting the
decision was made (with clickable link) and the actual (sub)decisions
can now also be linked.
  • Loading branch information
tomudding committed Mar 14, 2024
1 parent 6a59378 commit 3b20433
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 43 deletions.
11 changes: 10 additions & 1 deletion module/Decision/src/Model/Organ.php
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,16 @@ public function getOrderedSubdecisions(): array
{
$array = $this->subdecisions->toArray();
usort($array, static function ($dA, $dB) {
return $dA->getDecision()->getMeeting()->getDate() > $dB->getDecision()->getMeeting()->getDate() ? -1 : 1;
// Compare the meeting dates first (note that we compare B against A).
$dateComparison = $dB->getDecision()->getMeeting()->getDate()
<=> $dA->getDecision()->getMeeting()->getDate();

if (0 === $dateComparison) {
// If the meeting dates are equal, compare the subdecision numbers (note that we compare B against A).
return $dB->getNumber() <=> $dA->getNumber();
}

return $dateComparison;
});

return $array;
Expand Down
117 changes: 75 additions & 42 deletions module/Decision/view/decision/organ/view.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -22,55 +22,88 @@ $this->headTitle($organ->getName());
<div class="row">
<h1><?= $this->escapeHtml($organ->getName()) ?> (<?= $this->escapeHtml($organ->getAbbr()) ?>)</h1>
<div class="col-md-4">
<h2><?= $this->translate('Active members') ?></h2>
<ul>
<?php foreach ($activeMembers as $membership): ?>
<li>
<a href="<?= $this->url(
'member/view',
['lidnr' => $membership['member']->getLidnr()],
) ?>">
<?= $this->escapeHtml($membership['member']->getFullName()) ?>
</a>
<?php if (!empty($membership['functions'])): ?>
(<?= $this->escapeHtml(
implode(
', ',
array_map(
fn (string $value): string => $this->translate($value),
$membership['functions'],
),
)
) ?>)
<?php endif ?>
</li>
<?php endforeach ?>
</ul>
<?php if (!empty($activeMembers)): ?>
<h2><?= $this->translate('Active members') ?></h2>
<ul class="list-unstyled">
<?php foreach ($activeMembers as $membership): ?>
<li>
<a href="<?= $this->url(
'member/view',
['lidnr' => $membership['member']->getLidnr()],
) ?>">
<?= $this->escapeHtml($membership['member']->getFullName()) ?>
</a>
<?php if (!empty($membership['functions'])): ?>
(<?= $this->escapeHtml(
implode(
', ',
array_map(
fn (string $value): string => $this->translate($value),
$membership['functions'],
),
)
) ?>)
<?php endif ?>
</li>
<?php endforeach ?>
</ul>
<?php endif; ?>

<h2><?= $this->translate('Inactive members') ?></h2>
<ul>
<?php foreach ($inactiveMembers as $membership): ?>
<li>
<a href="<?= $this->url('member/view', ['lidnr' => $membership->getLidnr()]) ?>">
<?= $this->escapeHtml($membership->getFullName()) ?>
</a>
</li>
<?php endforeach ?>
</ul>
<?php if (!empty($inactiveMembers)): ?>
<h2><?= $this->translate('Inactive members') ?></h2>
<ul class="list-unstyled">
<?php foreach ($inactiveMembers as $membership): ?>
<li>
<a href="<?= $this->url('member/view', ['lidnr' => $membership->getLidnr()]) ?>">
<?= $this->escapeHtml($membership->getFullName()) ?>
</a>
</li>
<?php endforeach ?>
</ul>
<?php endif; ?>

<h2><?= $this->translate('Old members') ?></h2>
<ul>
<?php foreach ($oldMembers as $member): ?>
<li><?= $this->escapeHtml($member->getFullName()) ?></li>
<?php endforeach ?>
</ul>
<?php if (!empty($oldMembers)): ?>
<h2><?= $this->translate('Old members') ?></h2>
<ul class="list-unstyled">
<?php foreach ($oldMembers as $member): ?>
<li><?= $this->escapeHtml($member->getFullName()) ?></li>
<?php endforeach ?>
</ul>
<?php endif; ?>
</div>

<div class="col-md-8">
<h2><?= $this->translate('Organ mutations') ?></h2>
<ul>
<ul class="list-unstyled">
<?php foreach ($organ->getOrderedSubdecisions() as $subdecision): ?>
<li><?= $this->escapeHtml($subdecision->getContent()) ?></li>
<?php
$id = vsprintf('%s %s.%s.%s', [
$subdecision->getMeetingType()->value,
$subdecision->getMeetingNumber(),
$subdecision->getDecisionPoint(),
$subdecision->getDecisionNumber(),
]);
$extendedId = $id . '.' . $subdecision->getNumber();
?>
<li id="<?= urlencode($extendedId) ?>" class="link-permalink-container">
<strong class="decision-meeting">
<a href="<?= $this->url(
'decision/meeting',
[
'type' => $subdecision->getMeetingType()->value,
'number' => $subdecision->getMeetingNumber(),
],
) ?>">
<?= $id ?>
</a>
</strong>
<span class="decision-content">
<?= $this->escapeHtml($subdecision->getContent()) ?>
<a href="#<?= urlencode($extendedId) ?>" class="link-permalink">
<span class="fa fa-link"></span>
</a>
</span>
</li>
<?php endforeach ?>
</ul>
</div>
Expand Down

0 comments on commit 3b20433

Please sign in to comment.