feat: add the house manager questionnaire per travel and compact the questionnaire layout
This commit is contained in:
1 parent
d760ed3cdf
commit
bfef08b519
50 files changed
+2763
-180
No files matched your search
@@ -23,14 +23,17 @@ use Symfony\Component\Uid\Uuid;
|
||||
* A per-bus-leg questionnaire (Definition::$perBusLeg) has one response per escorted leg, the
|
||||
* others one per disposition.
|
||||
*
|
||||
* Its subject is a Disposition today. A questionnaire about something else gets a nullable foreign
|
||||
* key of its own beside $disposition, not a generic subject column.
|
||||
* Its subject is a Disposition (the teamer's questionnaires) or a Destination (the house manager's,
|
||||
* one per travel), each a nullable foreign key of its own rather than a generic subject column.
|
||||
* Exactly one is set. Each unique key leaves out the rows of the other subject: MariaDB lets the
|
||||
* NULLs repeat.
|
||||
*
|
||||
* Not soft-deletable: nothing in the UI deletes a response, and it goes with its disposition.
|
||||
* Not soft-deletable: nothing in the UI deletes a response, and it goes with its subject.
|
||||
*/
|
||||
#[ORM\Entity(repositoryClass: QuestionnaireResponseRepository::class)]
|
||||
#[ORM\HasLifecycleCallbacks]
|
||||
#[ORM\UniqueConstraint(name: 'questionnaire_disposition_leg', columns: ['questionnaire', 'disposition_id', 'leg'])]
|
||||
#[ORM\UniqueConstraint(name: 'questionnaire_destination', columns: ['questionnaire', 'destination_id'])]
|
||||
class QuestionnaireResponse implements BlameableEntityInterface, TimestampableEntityInterface
|
||||
{
|
||||
use BlameableEntity;
|
||||
@@ -72,6 +75,10 @@ class QuestionnaireResponse implements BlameableEntityInterface, TimestampableEn
|
||||
#[ORM\JoinColumn(onDelete: 'CASCADE')]
|
||||
private ?Disposition $disposition = null;
|
||||
|
||||
#[ORM\ManyToOne]
|
||||
#[ORM\JoinColumn(onDelete: 'CASCADE')]
|
||||
private ?Destination $destination = null;
|
||||
|
||||
/**
|
||||
* A BusLeg value, or '' for a questionnaire without legs rather than null: part of the unique
|
||||
* key, and MariaDB lets NULLs repeat in one.
|
||||
@@ -102,6 +109,18 @@ class QuestionnaireResponse implements BlameableEntityInterface, TimestampableEn
|
||||
return $instance;
|
||||
}
|
||||
|
||||
public static function forDestination(Definition $definition, Destination $destination): static
|
||||
{
|
||||
if ($definition->perBusLeg) {
|
||||
throw new \LogicException(sprintf('Questionnaire "%s" needs a bus leg, a travel has none', $definition->key));
|
||||
}
|
||||
|
||||
$instance = new static($definition);
|
||||
$instance->destination = $destination;
|
||||
|
||||
return $instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Keeps every answer, including those to questions that are hidden right now: switching an
|
||||
* answer back restores the follow-up already written.
|
||||
@@ -199,6 +218,11 @@ class QuestionnaireResponse implements BlameableEntityInterface, TimestampableEn
|
||||
return $this->disposition;
|
||||
}
|
||||
|
||||
public function getDestination(): ?Destination
|
||||
{
|
||||
return $this->destination;
|
||||
}
|
||||
|
||||
public function getLeg(): ?BusLeg
|
||||
{
|
||||
return BusLeg::tryFrom($this->leg);
|
||||
|
||||
Reference in new issue
Block a user