Skip to content

Commit c186c0f

Browse files
committed
visaDetailController
1 parent ea65110 commit c186c0f

File tree

3 files changed

+112
-1
lines changed

3 files changed

+112
-1
lines changed
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace App\Infrastructure\Controller\MyArea\Organization\VisaModel;
6+
7+
use App\Application\CommandBusInterface;
8+
use App\Application\Organization\VisaModel\Query\GetVisaModelQuery;
9+
use App\Application\QueryBusInterface;
10+
use App\Domain\Organization\VisaModel\Exception\VisaModelNotFoundException;
11+
use App\Infrastructure\Controller\MyArea\Organization\AbstractOrganizationController;
12+
use App\Infrastructure\Security\Voter\OrganizationVoter;
13+
use Symfony\Bundle\SecurityBundle\Security;
14+
use Symfony\Component\HttpFoundation\Response;
15+
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
16+
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
17+
use Symfony\Component\Routing\Annotation\Route;
18+
use Symfony\Component\Routing\Requirement\Requirement;
19+
20+
final class VisaDetailController extends AbstractOrganizationController
21+
{
22+
public function __construct(
23+
private \Twig\Environment $twig,
24+
private CommandBusInterface $commandBus,
25+
QueryBusInterface $queryBus,
26+
Security $security,
27+
) {
28+
parent::__construct($queryBus, $security);
29+
}
30+
31+
#[Route(
32+
'/organizations/{organizationUuid}/visa_models/{uuid}/detail',
33+
name: 'app_config_visa_models_detail',
34+
requirements: ['organizationUuid' => Requirement::UUID, 'uuid' => Requirement::UUID],
35+
methods: ['GET'],
36+
)]
37+
public function __invoke(string $organizationUuid, string $uuid): Response
38+
{
39+
$organization = $this->getOrganization($organizationUuid);
40+
41+
if (!$this->security->isGranted(OrganizationVoter::VIEW, $organization)) {
42+
throw new AccessDeniedHttpException();
43+
}
44+
45+
try {
46+
$visaModel = $this->queryBus->handle(new GetVisaModelQuery($uuid));
47+
} catch (VisaModelNotFoundException) {
48+
throw new NotFoundHttpException();
49+
}
50+
51+
return new Response(
52+
content: $this->twig->render(
53+
name: 'my_area/organization/visa_model/visa_detail.html.twig',
54+
context: [
55+
'organization' => $organization,
56+
'visaModel' => $visaModel,
57+
],
58+
),
59+
);
60+
}
61+
}

templates/my_area/organization/visa_model/index.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
{{ visa.description|u.truncate(75, '...', false) }}</td>
5252
<td>
5353
<div class="fr-btns-group fr-btns-group--center fr-btns-group--inline-sm">
54-
<a href="#" class="fr-btn fr-icon-eye-line fr-btn--tertiary-no-outline"></a>
54+
<a href="{{ path('app_config_visa_models_detail', { uuid: visa.uuid, organizationUuid: organization.uuid }) }}" class="fr-btn fr-icon-eye-line fr-btn--tertiary-no-outline"></a>
5555
{% if is_granted(constant('App\\Infrastructure\\Security\\Voter\\OrganizationVoter::EDIT'), organization) %}
5656
{% if visa.organizationUuid %}
5757
<a title="{{ 'common.update'|trans }}" href="{{ path('app_config_visa_models_edit', { uuid: visa.uuid, organizationUuid: organization.uuid }) }}" class="fr-btn fr-icon-edit-line fr-btn--tertiary-no-outline">
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
{% extends 'layouts/layout.html.twig' %}
2+
{% set metaTitle = visaModel is defined ? visaModel.name : 'visa.add.title'|trans %}
3+
{% block title %}
4+
{{ metaTitle }} - {{ parent() }}
5+
{% endblock %}
6+
7+
{% block body %}
8+
<section class="fr-container fr-py-5w">
9+
<div class="fr-grid-row fr-grid-row--gutters">
10+
<div class="fr-col-12 fr-col-md-4">
11+
{% include 'my_area/organization/_menu.html.twig' with { organization } only %}
12+
</div>
13+
<div class="fr-col-12 fr-col-md-8">
14+
{% include "common/breadcrumb.html.twig" with { items: [
15+
{ title: 'user.myarea'|trans, path: 'app_my_area'},
16+
{ title: organization.name, url: path('app_config_organization_detail', {uuid: organization.uuid}), generatedPath: true },
17+
{ title: 'visa.list.title'|trans, url: path('app_config_visa_models_list', {uuid: organization.uuid}), generatedPath: true },
18+
{ title: metaTitle },
19+
]} %}
20+
<h2>{{ metaTitle }}</h2>
21+
22+
<div class="app-card app-card--raised fr-mb-2w">
23+
<p>{{ visaModel.name }}</p>
24+
<p>{{ visaModel.description }}</p>
25+
</div>
26+
<div class="app-card fr-mb-2w app-card--with-full-background">
27+
<div class="app-card__header">
28+
<span class="app-card__img fr-icon-x-check fr-x-icon--primary fr-x-icon--xl" aria-hidden="true"></span>
29+
<h3 class="app-card__title fr-h4 fr-mb-0">{{ 'visas.form.visas'|trans }}</h3>
30+
</div>
31+
<div class="app-card__content">
32+
<ul
33+
id="visa-list"
34+
class="fr-raw-list fr-fieldset__element"
35+
data-testid="visa-list"
36+
data-form-collection-target="collectionContainer"
37+
>
38+
{% for item in visaModel.visas %}
39+
<li class="app-card app-card--no-header fr-mb-2w">
40+
{{ item }}
41+
</li>
42+
{% else %}
43+
{% do visaModel.visas.setRendered %}
44+
{% endfor %}
45+
</ul>
46+
</div>
47+
</div>
48+
</div>
49+
</section>
50+
{% endblock %}

0 commit comments

Comments
 (0)