WIP: Implement feedback functionality

This commit is contained in:
Björn Fromme
2023-11-02 18:01:12 +01:00
parent 2689f93683
commit 2599fd69dc
28 changed files with 640 additions and 43 deletions
+34
View File
@@ -84,6 +84,9 @@ class Assignment implements BlameableEntityInterface, TimestampableEntityInterfa
#[ORM\ManyToOne]
private ?User $owner = null;
#[ORM\OneToMany(mappedBy: 'assignment', targetEntity: Feedback::class)]
private Collection $feedbacks;
public function __construct()
{
$this->uuid = Uuid::v4();
@@ -93,6 +96,7 @@ class Assignment implements BlameableEntityInterface, TimestampableEntityInterfa
$this->teamers = new ArrayCollection();
$this->benefits = "Anreise im E&P Reisebus\nUnterkunft\nVerpflegung\nSkipass\n";
$this->documents = new ArrayCollection();
$this->feedbacks = new ArrayCollection();
}
public static function duplicate(Assignment $assignment): static
@@ -436,4 +440,34 @@ class Assignment implements BlameableEntityInterface, TimestampableEntityInterfa
return $this;
}
/**
* @return Collection<int, Feedback>
*/
public function getFeedbacks(): Collection
{
return $this->feedbacks;
}
public function addFeedback(Feedback $feedback): static
{
if (!$this->feedbacks->contains($feedback)) {
$this->feedbacks->add($feedback);
$feedback->setAssignment($this);
}
return $this;
}
public function removeFeedback(Feedback $feedback): static
{
if ($this->feedbacks->removeElement($feedback)) {
// set the owning side to null (unless already changed)
if ($feedback->getAssignment() === $this) {
$feedback->setAssignment(null);
}
}
return $this;
}
}
+13 -27
View File
@@ -26,8 +26,9 @@ class Feedback implements BlameableEntityInterface, TimestampableEntityInterface
#[ORM\ManyToOne(inversedBy: 'feedback')]
private ?Teamer $teamer = null;
#[ORM\Column(type: Types::TEXT)]
private ?string $body = null;
#[ORM\ManyToOne(inversedBy: 'feedbacks')]
#[ORM\JoinColumn(onDelete: 'SET NULL')]
private ?Assignment $assignment = null;
#[ORM\Column(length: 255)]
private ?string $assignmentDestination = null;
@@ -35,11 +36,8 @@ class Feedback implements BlameableEntityInterface, TimestampableEntityInterface
#[ORM\Column(type: Types::DATE_IMMUTABLE)]
private ?\DateTimeImmutable $assignmentDate = null;
#[ORM\Column(length: 255)]
private ?string $authorName = null;
#[ORM\Column(length: 255)]
private ?string $authorEmail = null;
#[ORM\Column]
private array $ratings = [];
public function __construct()
{
@@ -68,14 +66,14 @@ class Feedback implements BlameableEntityInterface, TimestampableEntityInterface
return $this;
}
public function getBody(): ?string
public function getAssignment(): ?Assignment
{
return $this->body;
return $this->assignment;
}
public function setBody(string $body): static
public function setAssignment(?Assignment $assignment): static
{
$this->body = $body;
$this->assignment = $assignment;
return $this;
}
@@ -104,26 +102,14 @@ class Feedback implements BlameableEntityInterface, TimestampableEntityInterface
return $this;
}
public function getAuthorName(): ?string
public function getRatings(): array
{
return $this->authorName;
return $this->ratings;
}
public function setAuthorName(string $authorName): static
public function setRatings(array $ratings): static
{
$this->authorName = $authorName;
return $this;
}
public function getAuthorEmail(): ?string
{
return $this->authorEmail;
}
public function setAuthorEmail(string $authorEmail): static
{
$this->authorEmail = $authorEmail;
$this->ratings = $ratings;
return $this;
}
+56
View File
@@ -0,0 +1,56 @@
<?php
namespace App\Entity;
use App\Entity\Traits\TimestampableEntity;
use App\Repository\FeedbackSetRepository;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
#[ORM\Entity(repositoryClass: FeedbackSetRepository::class)]
class FeedbackSet implements TimestampableEntityInterface
{
use TimestampableEntity;
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 255)]
#[Assert\NotBlank(message: 'Bitte gib die Bezeichnung ein')]
private ?string $name = null;
#[ORM\Column]
#[Assert\Count(min: 1, minMessage: 'Bitte füge mindestens eine Bewertung hinzu')]
private array $items = [];
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): static
{
$this->name = $name;
return $this;
}
public function getItems(): array
{
return $this->items;
}
public function setItems(array $items): static
{
$this->items = $items;
return $this;
}
}
+16
View File
@@ -38,6 +38,10 @@ class JobProfile implements BlameableEntityInterface, TimestampableEntityInterfa
#[ORM\ManyToMany(targetEntity: Training::class)]
private Collection $requiredTrainings;
#[ORM\ManyToOne]
#[ORM\JoinColumn(onDelete: 'SET NULL')]
private ?FeedbackSet $feedbackSet = null;
public function __construct()
{
$this->uuid = Uuid::v4();
@@ -101,4 +105,16 @@ class JobProfile implements BlameableEntityInterface, TimestampableEntityInterfa
return $this;
}
public function getFeedbackSet(): ?FeedbackSet
{
return $this->feedbackSet;
}
public function setFeedbackSet(?FeedbackSet $feedbackSet): static
{
$this->feedbackSet = $feedbackSet;
return $this;
}
}
+17
View File
@@ -48,6 +48,9 @@ class User implements UserInterface, TimestampableEntityInterface
#[ORM\OneToOne(inversedBy: 'user', cascade: ['persist', 'remove'])]
private ?Contact $contact = null;
#[ORM\Column(nullable: true)]
private ?int $hotelBusProId = null;
public function __construct()
{
$this->uuid = Uuid::v4();
@@ -178,6 +181,8 @@ class User implements UserInterface, TimestampableEntityInterface
return 'app_admin_index';
} elseif ($this->hasRole('ROLE_MANAGER')) {
return 'app_manager_index';
} elseif ($this->hasRole('ROLE_HOUSE_MANAGER')) {
return 'app_house_manager_index';
} else {
return 'app_teamer_index';
}
@@ -215,4 +220,16 @@ class User implements UserInterface, TimestampableEntityInterface
return $this;
}
public function getHotelBusProId(): ?int
{
return $this->hotelBusProId;
}
public function setHotelBusProId(?int $hotelBusProId): static
{
$this->hotelBusProId = $hotelBusProId;
return $this;
}
}