diff --git a/migrations/Version20231206154001.php b/migrations/Version20231206154001.php new file mode 100644 index 0000000..e890701 --- /dev/null +++ b/migrations/Version20231206154001.php @@ -0,0 +1,31 @@ +addSql('ALTER TABLE feedback DROP comment_public'); + } + + public function down(Schema $schema): void + { + // this down() migration is auto-generated, please modify it to your needs + $this->addSql('ALTER TABLE feedback ADD comment_public TINYINT(1) NOT NULL'); + } +} diff --git a/migrations/Version20231206164142.php b/migrations/Version20231206164142.php new file mode 100644 index 0000000..45a6730 --- /dev/null +++ b/migrations/Version20231206164142.php @@ -0,0 +1,31 @@ +addSql('ALTER TABLE feedback ADD job_profile_name VARCHAR(255) NOT NULL, CHANGE assignment_destination destination_name VARCHAR(255) NOT NULL'); + } + + public function down(Schema $schema): void + { + // this down() migration is auto-generated, please modify it to your needs + $this->addSql('ALTER TABLE feedback ADD assignment_destination VARCHAR(255) NOT NULL, DROP destination_name, DROP job_profile_name'); + } +} diff --git a/src/Controller/HouseManager/Feedback/ProvideController.php b/src/Controller/HouseManager/Feedback/ProvideController.php index c7d3390..d8e9638 100644 --- a/src/Controller/HouseManager/Feedback/ProvideController.php +++ b/src/Controller/HouseManager/Feedback/ProvideController.php @@ -30,20 +30,29 @@ class ProvideController extends AbstractController { $assignment = $disposition->getAssignment(); $destination = $assignment->getDestination(); + + if (null !== $disposition->getFeedback()) { + $this->addFlash('error', 'Es liegt schon ein Feedback vor.'); + + return $this->redirectToRoute('app_house_manager_feedback_index'); + } + $feedbackSet = $assignment ->getJobProfile() ->getFeedbackSet() ; - $feedback = new Feedback(); + + $feedback = new Feedback($assignment); $form = $this->createForm(FeedbackType::class, $feedback, ['feedback_set' => $feedbackSet]); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { - $feedback - ->setAssignmentDestination($destination) - ->setAssignmentDate($assignment->getEffectivePeriod()->start->toDateTimeImmutable()) - ; + // Feedbacks without comments are published immediately + if (empty($feedback->getComment())) { + $feedback->setStatus(Feedback::STATUS_PUBLISHED); + } + $teamer = $disposition->getTeamer(); $teamer->addFeedback($feedback); $disposition->setFeedback($feedback); diff --git a/src/Entity/Feedback.php b/src/Entity/Feedback.php index 6a1ff94..c6323e3 100644 --- a/src/Entity/Feedback.php +++ b/src/Entity/Feedback.php @@ -8,6 +8,7 @@ use App\Repository\FeedbackRepository; use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Mapping as ORM; use Symfony\Component\Uid\Uuid; +use Symfony\Component\Validator\Constraints as Assert; #[ORM\Entity(repositoryClass: FeedbackRepository::class)] class Feedback implements BlameableEntityInterface, TimestampableEntityInterface @@ -33,23 +34,30 @@ class Feedback implements BlameableEntityInterface, TimestampableEntityInterface private ?Teamer $teamer = null; #[ORM\Column(length: 255)] - private ?string $assignmentDestination = null; + private ?string $destinationName; + + #[ORM\Column(length: 255)] + private ?string $jobProfileName; #[ORM\Column(type: Types::DATE_IMMUTABLE)] - private ?\DateTimeImmutable $assignmentDate = null; + private ?\DateTimeImmutable $assignmentDate; #[ORM\Column] + #[Assert\Count(min: 1, minMessage: 'Bitte gib eine Bewertung ab')] private array $ratings = []; #[ORM\Column(type: Types::TEXT, nullable: true)] private ?string $comment = null; - #[ORM\Column] - private ?bool $commentPublic = false; + #[ORM\Column(type: Types::TEXT, nullable: true)] + private ?string $commentInternal = null; - public function __construct() + public function __construct(Assignment $assignment) { $this->uuid = Uuid::v4(); + $this->destinationName = $assignment->getDestination()->getProduct(); + $this->assignmentDate = $assignment->getEffectiveDateFrom(); + $this->jobProfileName = $assignment->getJobProfile()->getName(); } public function getId(): ?int @@ -86,14 +94,26 @@ class Feedback implements BlameableEntityInterface, TimestampableEntityInterface return $this; } - public function getAssignmentDestination(): ?string + public function getDestination(): ?Destination { - return $this->assignmentDestination; + return $this->destination; } - public function setAssignmentDestination(string $assignmentDestination): static + public function setDestination(?Destination $destination): static { - $this->assignmentDestination = $assignmentDestination; + $this->destination = $destination; + + return $this; + } + + public function getDestinationName(): ?string + { + return $this->destinationName; + } + + public function setDestinationName(string $destinationName): static + { + $this->destinationName = $destinationName; return $this; } @@ -110,6 +130,18 @@ class Feedback implements BlameableEntityInterface, TimestampableEntityInterface return $this; } + public function getJobProfileName(): ?string + { + return $this->jobProfileName; + } + + public function setJobProfileName(?string $jobProfileName): static + { + $this->jobProfileName = $jobProfileName; + + return $this; + } + public function getRatings(): array { return $this->ratings; @@ -149,14 +181,14 @@ class Feedback implements BlameableEntityInterface, TimestampableEntityInterface return $this; } - public function isCommentPublic(): ?bool + public function getCommentInternal(): ?string { - return $this->commentPublic; + return $this->commentInternal; } - public function setCommentPublic(bool $commentPublic): static + public function setCommentInternal(?string $commentInternal): static { - $this->commentPublic = $commentPublic; + $this->commentInternal = $commentInternal; return $this; } diff --git a/src/Form/FeedbackType.php b/src/Form/FeedbackType.php index fdf0fab..821446e 100644 --- a/src/Form/FeedbackType.php +++ b/src/Form/FeedbackType.php @@ -20,7 +20,15 @@ class FeedbackType extends AbstractType 'feedback_set' => $options['feedback_set'], ]) ->add('comment', TextareaType::class, [ - 'label' => 'Kommentar', + 'label' => 'Kommentar (öffentlich)', + 'required' => false, + 'attr' => [ + 'rows' => 5, + ], + 'help' => 'Bitte formuliere deinen Kommentar so, dass er an das Team weitergegeben werden kann', + ]) + ->add('commentInternal', TextareaType::class, [ + 'label' => 'Kommentar (intern)', 'required' => false, 'attr' => [ 'rows' => 5, diff --git a/templates/house_manager/feedback/provide.html.twig b/templates/house_manager/feedback/provide.html.twig index ede6cdf..8026346 100644 --- a/templates/house_manager/feedback/provide.html.twig +++ b/templates/house_manager/feedback/provide.html.twig @@ -22,6 +22,9 @@
{{ form_row(form.comment) }}
+
+ {{ form_row(form.commentInternal) }} +