Skip to content

Commit

Permalink
Merge pull request #1958 from tomudding/feature/activity-overview-sig…
Browse files Browse the repository at this point in the history
…n-up-list-status

feat: show when sign-up list opens/closes in activity overview
  • Loading branch information
tomudding authored Jan 2, 2025
2 parents c05f9c5 + 7ffef92 commit 44a0b10
Show file tree
Hide file tree
Showing 7 changed files with 125 additions and 9 deletions.
13 changes: 13 additions & 0 deletions module/Activity/src/Model/SignupList.php
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,19 @@ public function setCloseDate(DateTime $closeDate): void
$this->closeDate = $closeDate;
}

/**
* Whether the sign-up list period is now.
*
* NOTE: this does not indicate that one is able to sign up, that depends on other factors such as approval status
* of the actual activity.
*/
public function isOpen(): bool
{
$now = new DateTime('now');

return $now >= $this->getOpenDate() && $now < $this->getCloseDate();
}

/**
* Returns true if this SignupList is only available to members of GEWIS.
*/
Expand Down
56 changes: 55 additions & 1 deletion module/Activity/view/activity/activity/list.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
declare(strict_types=1);

use Activity\Model\Activity;
use Activity\Model\SignupList as SignupListModel;
use Application\View\HelperTrait;
use Laminas\View\Renderer\PhpRenderer;

Expand Down Expand Up @@ -53,14 +54,67 @@ use Laminas\View\Renderer\PhpRenderer;
$currentTime = new DateTime('now');
$isOngoing = $currentTime >= $beginTime && $currentTime <= $endTime;
?>
<p>
<p class="date-details">
<?= ucfirst($dateTimeString) ?> <small class="text-muted">
<?php if ($isOngoing): ?>
<?= $this->translate('for') ?> <?= $timeRemaining = $this->timeDiff($currentTime, $endTime) ?>
<?php elseif ($currentTime < $beginTime): ?>
<?= $this->translate('in') ?> <?= $this->timeDiff($currentTime, $beginTime) ?>
<?php endif; ?>
</small>
<?php
$signupLists = $activity->getSignupLists()->toArray();
$firstSignupList = reset($signupLists);
$hasMoreThanOne = count($signupLists) > 1;

if ($firstSignupList): ?>
<?php
/** @var SignupListModel $firstSignupList */
$openDatePattern = ($firstSignupList->getOpenDate()->format('Y') === $currentYear) ? 'EEE. d MMM. (HH:mm)' : 'EEE. d MMM. yyyy (HH:mm)';
$closeDatePattern = ($firstSignupList->getCloseDate()->format('Y') === $currentYear) ? 'EEE. d MMM. (HH:mm)' : 'EEE. d MMM. yyyy (HH:mm)';
$openDateFormatted = $this->dateFormat($firstSignupList->getOpenDate(), pattern: $openDatePattern);
$closeDateFormatted = $this->dateFormat($firstSignupList->getCloseDate(), pattern: $closeDatePattern);
$timeDiff = $firstSignupList->getCloseDate()->diff($currentTime);

if ($timeDiff->days >= 7) {
$textClass = 'text-muted';
} elseif ($timeDiff->days < 7 && $timeDiff->days >= 1) {
$textClass = 'text-warning';
} else {
$textClass = 'text-danger';
}
?>
<br>
<?php if ($currentTime > $firstSignupList->getCloseDate()): ?>
<small class="text-muted">
<?php sprintf(
$this->translate('Sign-up closed on: %s'),
$closeDateFormatted,
) ?>
</small>
<?php elseif (!$firstSignupList->isOpen()): ?>
<small class="text-muted">
<?= sprintf(
$this->translate('Sign-up opens: %s (in %s)'),
$openDateFormatted,
$this->timeDiff($currentTime, $firstSignupList->getOpenDate()),
) ?>
</small>
<?php else: ?>
<small class="<?= $textClass ?>">
<?= sprintf(
$this->translate('Sign-up closes: %s (in %s)'),
$closeDateFormatted,
$this->timeDiff($currentTime, $firstSignupList->getCloseDate()),
) ?>
</small>
<?php endif; ?>
<?php if ($hasMoreThanOne): ?>
<small class="text-muted">
<?= $this->translate('with multiple sign-up lists') ?>
</small>
<?php endif; ?>
<?php endif; ?>
</p>
</div>
<div class="col-md-12">
Expand Down
19 changes: 17 additions & 2 deletions module/Application/language/en.po

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 17 additions & 2 deletions module/Application/language/gewisweb.pot

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 17 additions & 2 deletions module/Application/language/nl.po

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion public/css/gewis-theme.css

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion resources/scss/components/_list-group.scss
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@ Styleguide: list-group

.agenda-item-body {
h4 {
margin-bottom: 0;
margin-bottom: 0.125rem;
}

.date-details {
line-height: 1.3;
}

.markdown {
Expand Down

0 comments on commit 44a0b10

Please sign in to comment.