Skip to content
Snippets Groups Projects
Commit eb77fb75 authored by Jonathan Foucher's avatar Jonathan Foucher
Browse files
parent b7481705
No related branches found
No related tags found
No related merge requests found
Pipeline #83488 passed
......@@ -47,6 +47,7 @@ use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\Routing\RouterInterface;
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
use Symfony\Component\Security\Core\Security;
use Symfony\Contracts\Translation\TranslatorInterface;
use Symfony\Polyfill\Intl\Icu\Exception\MethodNotImplementedException;
......@@ -82,6 +83,7 @@ class SurveyController extends CRUDController
private Repository\Referentiel $referentielRepository;
private $router;
private RequestStack $requestStack;
private Security $security;
public function __construct(
EntityManagerInterface $entityManager,
......@@ -96,6 +98,7 @@ class SurveyController extends CRUDController
Repository\Referentiel $referentielRepository,
RouterInterface $router,
RequestStack $requestStack,
Security $security,
) {
parent::__construct($entityManager, $translator, $repository, $pdf, $userProvider, $authorizationChecker);
$this->questionRepository = $questionRepository;
......@@ -106,6 +109,7 @@ class SurveyController extends CRUDController
$this->referentielRepository = $referentielRepository;
$this->router = $router;
$this->requestStack = $requestStack;
$this->security = $security;
}
protected function getDomain(): string
......@@ -492,20 +496,20 @@ class SurveyController extends CRUDController
return new JsonResponse($reponse);
}
private function generateActionCellContent(Model\Survey $survey)
private function generateActionCellContent(Model\Survey $survey): string
{
$id = $survey->getId();
return
'<a href="' . $this->router->generate('maturity_survey_report', ['id' => $id]) . '">
$content = '<a href="' . $this->router->generate('maturity_survey_report', ['id' => $id]) . '">
<i aria-hidden="true" class="fa fa-print"></i> '
. $this->translator->trans('global.action.print') .
'</a>' .
'<a href="' . $this->router->generate('maturity_survey_synthesis', ['id' => $id]) . '">
<i aria-hidden="true" class="fa fa-chart-line"></i> ' .
$this->translator->trans('global.action.synthesis') .
'</a>' .
'<a href="' . $this->router->generate('maturity_survey_edit', ['id' => $id]) . '">
'</a>';
if ($this->security->isGranted('ROLE_USER')) {
$content .= '<a href="' . $this->router->generate('maturity_survey_edit', ['id' => $id]) . '">
<i aria-hidden="true" class="fa fa-pencil"></i> '
. $this->translator->trans('global.action.edit') .
'</a>' .
......@@ -513,6 +517,9 @@ class SurveyController extends CRUDController
<i aria-hidden="true" class="fa fa-trash"></i> ' .
$this->translator->trans('global.action.delete') .
'</a>';
}
return $content;
}
protected function getLabelAndKeysArray(): array
......
......@@ -90,16 +90,30 @@
</div>
<div class="box-body">
{% for answerSurvey in domainAnswers %}
<div class="form-group answer-preco">
<ul class="form-group answer-preco">
<label for="{{ answerSurvey.mesurements.vars.id }}">
{{ answerSurvey.vars.value.answer.recommendation }}
</label>
{% if is_granted('ROLE_USER') %}
<div style="display: flex;">
{{ form_widget(answerSurvey.mesurements) }}
<button id="{{ answerSurvey.mesurements.vars.id }}_add_button" aria-label="{{ 'registry.mesurement.action.add_mesurement'|trans }}" type="button" class="btn reponse-modal-button" data-toggle="modal" data-target="#mesurement-modal" data-select-id="{{ answerSurvey.mesurements.vars.id }}">
<span class="fa fa-plus-circle"></span>
</button>
</div>
{% else %}
<ul>
{% for m in answerSurvey.mesurements.vars.data %}
<li>
<a href="{{ url('registry_mesurement_show', {id:m.id}) }}">
{{ m.name }}
</a>
</li>
{% endfor %}
</ul>
{% endif %}
</div>
{% endfor %}
</div>
......
......@@ -45,6 +45,7 @@ use Symfony\Component\HttpFoundation\BinaryFileResponse;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\Routing\RouterInterface;
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
use Symfony\Component\Security\Core\Security;
use Symfony\Contracts\Translation\TranslatorInterface;
class SurveyControllerTest extends TestCase
......@@ -113,6 +114,10 @@ class SurveyControllerTest extends TestCase
* @var RequestStack
*/
private $requestStack;
/**
* @var Security
*/
private $security;
public function setUp(): void
{
......@@ -128,6 +133,7 @@ class SurveyControllerTest extends TestCase
$this->referentielRepository = $this->prophesize(Repository\Referentiel::class);
$this->router = $this->prophesize(RouterInterface::class);
$this->requestStack = $this->prophesize(RequestStack::class);
$this->security = $this->prophesize(Security::class);
$this->controller = new SurveyController(
$this->managerProphecy->reveal(),
......@@ -141,7 +147,8 @@ class SurveyControllerTest extends TestCase
$this->pdf->reveal(),
$this->referentielRepository->reveal(),
$this->router->reveal(),
$this->requestStack->reveal()
$this->requestStack->reveal(),
$this->security->reveal()
);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment