feat: provide feedback as admin user
This commit is contained in:
+14
-6
@@ -1,7 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller\HouseManager\Feedback;
|
||||
namespace App\Controller\Administrative\Feedback;
|
||||
|
||||
use App\Controller\Traits\ReturnUrlTrait;
|
||||
use App\Entity\Disposition;
|
||||
use App\Entity\Feedback;
|
||||
use App\Entity\User;
|
||||
@@ -17,13 +18,15 @@ use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
|
||||
|
||||
class ProvideController extends AbstractController
|
||||
{
|
||||
use ReturnUrlTrait;
|
||||
|
||||
public function __construct(
|
||||
private readonly EntityManagerInterface $entityManager,
|
||||
private readonly EventDispatcherInterface $eventDispatcher
|
||||
) {
|
||||
}
|
||||
|
||||
#[Route('/house-manager/feedback/provide/{uuid}', name: 'app_house_manager_feedback_provide')]
|
||||
#[Route('/administrative/feedback/provide/{uuid}', name: 'app_administrative_feedback_provide')]
|
||||
#[IsGranted('FEEDBACK', subject: 'disposition')]
|
||||
public function index(Disposition $disposition, Request $request): Response
|
||||
{
|
||||
@@ -48,8 +51,8 @@ class ProvideController extends AbstractController
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
// Feedbacks without comments are published immediately
|
||||
if (empty($feedback->getComment())) {
|
||||
// Feedbacks without comments or provided by admins are published immediately
|
||||
if ($this->isGranted('ROLE_ADMINISTRATIVE') || empty($feedback->getComment())) {
|
||||
$feedback->setStatus(Feedback::STATUS_PUBLISHED);
|
||||
}
|
||||
|
||||
@@ -67,10 +70,15 @@ class ProvideController extends AbstractController
|
||||
|
||||
$this->addFlash('success', 'Das Feedback wurde entgegengenommen');
|
||||
|
||||
return $this->redirectToRoute('app_house_manager_feedback_index');
|
||||
$defaultReturnUrlRoute = $this->isGranted('ROLE_HOUSE_MANAGER') ?
|
||||
'app_house_manager_feedback_index' : $user->getDefaultRoute();
|
||||
|
||||
$returnUrl = $this->getReturnUrl($request, $defaultReturnUrlRoute);
|
||||
|
||||
return $this->redirect($returnUrl);
|
||||
}
|
||||
|
||||
return $this->render('house_manager/feedback/provide.html.twig', [
|
||||
return $this->render('administrative/feedback/provide.html.twig', [
|
||||
'form' => $form,
|
||||
'disposition' => $disposition,
|
||||
]);
|
||||
@@ -43,9 +43,10 @@ class DispositionVoter extends Voter
|
||||
$disposition = $subject;
|
||||
|
||||
return match ($attribute) {
|
||||
static::VIEW, static::EDIT, static::CONTRACT, static::INVOICE => $this->assertAdministrativeAccess() || $this->assertTeamerAccess($disposition),
|
||||
static::VIEW, static::EDIT, static::CONTRACT, static::INVOICE => $this->assertAdministrativeAccess()
|
||||
|| $this->assertTeamerAccess($token, $disposition),
|
||||
static::DELETE => $this->assertAdminAccess(),
|
||||
static::FEEDBACK => $this->assertHouseManagerAccess($token, $disposition),
|
||||
static::FEEDBACK => $this->assertAdminAccess() || $this->assertHouseManagerAccess($token, $disposition),
|
||||
default => false,
|
||||
};
|
||||
}
|
||||
@@ -80,12 +81,15 @@ class DispositionVoter extends Voter
|
||||
return $isMatchingHotel && $isPast;
|
||||
}
|
||||
|
||||
private function assertTeamerAccess(Disposition $disposition): bool
|
||||
private function assertTeamerAccess(TokenInterface $token, Disposition $disposition): bool
|
||||
{
|
||||
if (false === $this->security->isGranted('ROLE_TEAMER')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->security->getUser()->getTeamer() === $disposition->getTeamer();
|
||||
/** @var User $user */
|
||||
$user = $token->getUser();
|
||||
|
||||
return $user->getTeamer() === $disposition->getTeamer();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -166,7 +166,7 @@
|
||||
{% for disposition in overdueFeedbacks %}
|
||||
{% set assignment = disposition.assignment %}
|
||||
<li class="py-2 first:pt-0 last:pb-0 overflow-x-hidden">
|
||||
<a href="{{ path('app_administrative_assignment_detail', { 'uuid': assignment.uuid, 'r': return_url() }) }}"
|
||||
<a href="{{ path('app_administrative_feedback_provide', { 'uuid': disposition.uuid, 'r': return_url() }) }}"
|
||||
class="flex items-center space-x-1">
|
||||
{{ icon('feedback', 'w-4 h-4 shrink-0') }}
|
||||
<span class="whitespace-nowrap">{{ disposition.teamer }}</span>
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
{% extends 'house_manager/layout.html.twig' %}
|
||||
{% extends 'administrative/layout.html.twig' %}
|
||||
|
||||
{% block title %}Feedback abgeben{% endblock %}
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
{% block main_menu %}
|
||||
{% if is_granted('ROLE_MANAGER') %}
|
||||
{{ knp_menu_render(knp_menu_get('manager_main')) }}
|
||||
{% elseif is_granted('ROLE_HOUSE_MANAGER') %}
|
||||
{{ knp_menu_render(knp_menu_get('house_manager_main')) }}
|
||||
{% elseif is_granted('ROLE_ADMIN') %}
|
||||
{{ knp_menu_render(knp_menu_get('admin_main')) }}
|
||||
{% endif %}
|
||||
@@ -11,6 +13,8 @@
|
||||
{% block mobile_menu %}
|
||||
{% if is_granted('ROLE_MANAGER') %}
|
||||
{{ knp_menu_render(knp_menu_get('manager_main')) }}
|
||||
{% elseif is_granted('ROLE_HOUSE_MANAGER') %}
|
||||
{{ knp_menu_render(knp_menu_get('house_manager_main')) }}
|
||||
{% elseif is_granted('ROLE_ADMIN') %}
|
||||
{{ knp_menu_render(knp_menu_get('admin_main')) }}
|
||||
{% endif %}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{% extends 'house_manager/layout.html.twig' %}
|
||||
{% extends 'administrative/layout.html.twig' %}
|
||||
|
||||
{% block title %}Ausstehendes Feedback{% endblock %}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{% extends 'house_manager/layout.html.twig' %}
|
||||
{% extends 'administrative/layout.html.twig' %}
|
||||
|
||||
{% macro dispositionData(disposition) %}
|
||||
{% set assignment = disposition.assignment %}
|
||||
@@ -49,7 +49,7 @@
|
||||
{% for disposition in pendingFeedbacks %}
|
||||
{% set assignment = disposition.assignment %}
|
||||
<li class="py-2 first:pt-0 last:pb-0 overflow-x-hidden">
|
||||
<a href="{{ path('app_house_manager_feedback_provide', { 'uuid': disposition.uuid, 'r': return_url() }) }}"
|
||||
<a href="{{ path('app_administrative_feedback_provide', { 'uuid': disposition.uuid, 'r': return_url() }) }}"
|
||||
class="flex items-center space-x-1">
|
||||
{{ icon('feedback', 'w-4 h-4 shrink-0') }}
|
||||
{{ _self.dispositionData(disposition) }}
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
{% extends 'layout.html.twig' %}
|
||||
|
||||
{% block main_menu %}
|
||||
{{ knp_menu_render(knp_menu_get('house_manager_main')) }}
|
||||
{% endblock %}
|
||||
|
||||
{% block mobile_menu %}
|
||||
{{ knp_menu_render(knp_menu_get('house_manager_main')) }}
|
||||
{% endblock %}
|
||||
@@ -1,4 +1,4 @@
|
||||
{% extends 'manager/layout.html.twig' %}
|
||||
{% extends 'administrative/layout.html.twig' %}
|
||||
|
||||
{% block content %}
|
||||
<div class="grid grid-cols-1 lg:grid-cols-2 gap-8">
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
{% extends 'layout.html.twig' %}
|
||||
|
||||
{% block main_menu %}
|
||||
{{ knp_menu_render(knp_menu_get('manager_main')) }}
|
||||
{% endblock %}
|
||||
|
||||
{% block mobile_menu %}
|
||||
{{ knp_menu_render(knp_menu_get('manager_main')) }}
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user