feat: feedback approval by admins
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller\Admin\Feedback;
|
||||
|
||||
use App\Entity\Feedback;
|
||||
use App\Form\FeedbackApproveType;
|
||||
use App\Model\AjaxModalResponseDto;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
use Symfony\Component\Security\Http\Attribute\IsGranted;
|
||||
|
||||
class ApproveController extends AbstractController
|
||||
{
|
||||
public function __construct(
|
||||
private readonly EntityManagerInterface $entityManager,
|
||||
private readonly LoggerInterface $logger
|
||||
) {
|
||||
}
|
||||
|
||||
#[Route('/admin/feedback/approve/{uuid}', name: 'app_admin_feedback_approve')]
|
||||
#[IsGranted('ROLE_ADMIN')]
|
||||
public function index(Feedback $feedback, Request $request): JsonResponse
|
||||
{
|
||||
$response = new AjaxModalResponseDto();
|
||||
$action = $this->generateUrl('app_admin_feedback_approve', ['uuid' => $feedback->getUuid()]);
|
||||
$form = $this->createForm(FeedbackApproveType::class, $feedback, ['action' => $action, 'ajax_submit' => true]);
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$feedback->setStatus(Feedback::STATUS_PUBLISHED);
|
||||
$this->entityManager->flush();
|
||||
|
||||
$this->addFlash('success', 'Das Feedback wurde freigegeben');
|
||||
$this->logger->info('Approve feedback', [
|
||||
'feedback_uuid' => $feedback->getUuid(),
|
||||
]);
|
||||
|
||||
$returnUrl = $this->generateUrl('app_admin_index');
|
||||
$response->setCloseAndRedirect($returnUrl);
|
||||
} else {
|
||||
$response->setContent($this->renderView('admin/feedback/approve.html.twig', [
|
||||
'feedback' => $feedback,
|
||||
'form' => $form->createView(),
|
||||
]));
|
||||
}
|
||||
|
||||
return $this->json($response);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Form;
|
||||
|
||||
use App\Entity\Feedback;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
class FeedbackApproveType extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||
{
|
||||
$builder
|
||||
->add('comment', TextareaType::class, [
|
||||
'label' => 'Kommentar (öffentlich)',
|
||||
'required' => false,
|
||||
'attr' => [
|
||||
'rows' => 5,
|
||||
],
|
||||
])
|
||||
->add('commentInternal', TextareaType::class, [
|
||||
'label' => 'Kommentar (intern)',
|
||||
'required' => false,
|
||||
'attr' => [
|
||||
'rows' => 5,
|
||||
],
|
||||
])
|
||||
;
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => Feedback::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
{{ form_start(form) }}
|
||||
<div class="flex flex-col space-y-4 pb-4">
|
||||
{{ form_row(form.comment) }}
|
||||
{{ form_row(form.commentInternal) }}
|
||||
</div>
|
||||
<button type="submit" class="btn">
|
||||
Speichern und freigeben
|
||||
</button>
|
||||
{{ form_rest(form) }}
|
||||
{{ form_end(form) }}
|
||||
@@ -120,14 +120,20 @@
|
||||
<ul class="divide-y divide-gray-200">
|
||||
{% for feedback in feedbacks %}
|
||||
<li class="py-2 first:pt-0 last:pb-0">
|
||||
<a href="#" class="flex items-center space-x-1 truncate">
|
||||
<button type="button"
|
||||
class="flex items-center space-x-1 truncate"
|
||||
{{ stimulus_controller('modal-button', [], [], {'ajax-modal': '#ajax-modal'}) }}
|
||||
{{ stimulus_action('modal-button', 'ajax', null, {
|
||||
'title': 'Feedback freigeben',
|
||||
'url': path('app_admin_feedback_approve', { 'uuid': feedback.uuid })
|
||||
}) }}>
|
||||
{{ icon('feedback', 'w-4 h-4 shrink-0') }}
|
||||
<span class="whitespace-nowrap">{{ feedback.teamer }}</span>
|
||||
{% include '_partials/_dot.html.twig' %}
|
||||
<span class="whitespace-nowrap">{{ feedback.destinationName }}</span>
|
||||
{% include '_partials/_dot.html.twig' %}
|
||||
<span class="whitespace-nowrap">{{ feedback.jobProfileName }}</span>
|
||||
</a>
|
||||
</button>
|
||||
</li>
|
||||
{% else %}
|
||||
<li class="py-2 first:pt-0 last:pb-0">
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
</td>
|
||||
<td>
|
||||
{% if disposition.feedback %}
|
||||
{{ (disposition.feedback.averageRating/100)|format_number({fraction_digit: 2}) }}
|
||||
{{ disposition.feedback.averageRating|format_rating }}
|
||||
{% else %}
|
||||
-
|
||||
{% endif %}
|
||||
|
||||
Reference in New Issue
Block a user