feat: review received form submissions in the admin ui
This commit is contained in:
1 parent
f073a2014d
commit
cb2d64f2cd
19 files changed
+999
-7
No files matched your search
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace App\Model;
|
||||
|
||||
use App\Entity\ApplicationFormSubmission;
|
||||
|
||||
/**
|
||||
* The two "call held" checkboxes of the detail view. The entity stores the day each call
|
||||
* happened, the reviewer only ticks a box - this is the translation between the two.
|
||||
*
|
||||
* Unticking clears the date. Ticking a box whose date is already set leaves that date alone, so
|
||||
* saving the form again does not silently move a call from the day it happened to today.
|
||||
*/
|
||||
class ApplicationFormSubmissionCallsDto
|
||||
{
|
||||
private bool $firstCallHeld;
|
||||
|
||||
private bool $secondCallHeld;
|
||||
|
||||
public function __construct(private readonly ApplicationFormSubmission $submission)
|
||||
{
|
||||
$this->firstCallHeld = null !== $submission->getFirstCallHeldAt();
|
||||
$this->secondCallHeld = null !== $submission->getSecondCallHeldAt();
|
||||
}
|
||||
|
||||
public function isFirstCallHeld(): bool
|
||||
{
|
||||
return $this->firstCallHeld;
|
||||
}
|
||||
|
||||
public function setFirstCallHeld(bool $firstCallHeld): static
|
||||
{
|
||||
$this->firstCallHeld = $firstCallHeld;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function isSecondCallHeld(): bool
|
||||
{
|
||||
return $this->secondCallHeld;
|
||||
}
|
||||
|
||||
public function setSecondCallHeld(bool $secondCallHeld): static
|
||||
{
|
||||
$this->secondCallHeld = $secondCallHeld;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function applyToSubmission(): void
|
||||
{
|
||||
$this->submission
|
||||
->setFirstCallHeldAt($this->resolve($this->firstCallHeld, $this->submission->getFirstCallHeldAt()))
|
||||
->setSecondCallHeldAt($this->resolve($this->secondCallHeld, $this->submission->getSecondCallHeldAt()))
|
||||
;
|
||||
}
|
||||
|
||||
private function resolve(bool $held, ?\DateTimeImmutable $current): ?\DateTimeImmutable
|
||||
{
|
||||
if (false === $held) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $current ?? new \DateTimeImmutable('today');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Model;
|
||||
|
||||
class ApplicationFormSubmissionFilterDto extends AbstractFilterDto
|
||||
{
|
||||
protected ?string $name = null;
|
||||
|
||||
/**
|
||||
* A range over the arrival time, not over the follow-up dates: "what came in that week" is
|
||||
* the question a reviewer asks of this list. The datepicker hands over midnight, so the
|
||||
* repository has to stretch dateTo to the end of its day - submittedAt carries a time.
|
||||
*/
|
||||
protected ?\DateTimeImmutable $dateFrom = null;
|
||||
|
||||
protected ?\DateTimeImmutable $dateTo = null;
|
||||
|
||||
public function getName(): ?string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function setName(?string $name): static
|
||||
{
|
||||
$this->name = $name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDateFrom(): ?\DateTimeImmutable
|
||||
{
|
||||
return $this->dateFrom;
|
||||
}
|
||||
|
||||
public function setDateFrom(?\DateTimeImmutable $dateFrom): static
|
||||
{
|
||||
$this->dateFrom = $dateFrom;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDateTo(): ?\DateTimeImmutable
|
||||
{
|
||||
return $this->dateTo;
|
||||
}
|
||||
|
||||
public function setDateTo(?\DateTimeImmutable $dateTo): static
|
||||
{
|
||||
$this->dateTo = $dateTo;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user