From 5ae08ebd13fcf4d2aaca183273e6e1511133ef7d Mon Sep 17 00:00:00 2001 From: Xbird Date: Fri, 25 Nov 2022 10:23:02 +0000 Subject: [PATCH] Fix templates + add public wanted reason --- migrations/Version20221125100938.php | 31 ++++++++++++++++++++++++ src/Controller/TemplateController.php | 2 +- src/Entity/Directory.php | 18 ++++++++++++++ src/Form/DirectoryType.php | 1 + templates/_cells/directoryCard.html.twig | 7 ++++-- templates/wanted/index.html.twig | 5 +++- translations/messages+intl-icu.en.yaml | 3 ++- translations/messages+intl-icu.fr.yaml | 3 ++- visionversion.json | 2 +- 9 files changed, 65 insertions(+), 7 deletions(-) create mode 100644 migrations/Version20221125100938.php diff --git a/migrations/Version20221125100938.php b/migrations/Version20221125100938.php new file mode 100644 index 0000000..162a2da --- /dev/null +++ b/migrations/Version20221125100938.php @@ -0,0 +1,31 @@ +addSql('ALTER TABLE directory ADD wanted_public_reason TINYINT(1) DEFAULT \'0\' NOT NULL'); + } + + public function down(Schema $schema): void + { + // this down() migration is auto-generated, please modify it to your needs + $this->addSql('ALTER TABLE directory DROP wanted_public_reason'); + } +} diff --git a/src/Controller/TemplateController.php b/src/Controller/TemplateController.php index 9fabf3a..8bc21a5 100644 --- a/src/Controller/TemplateController.php +++ b/src/Controller/TemplateController.php @@ -19,7 +19,7 @@ class TemplateController extends AbstractController /** * @var Array $templates */ - $templates = $TemplateRepository->listForUser($this->getUser())->getResult(); + $templates = $TemplateRepository->listForUser($this->getUser())->archive(false)->getResult(); $json = []; foreach ($templates as $template) { diff --git a/src/Entity/Directory.php b/src/Entity/Directory.php index c923730..f155aab 100644 --- a/src/Entity/Directory.php +++ b/src/Entity/Directory.php @@ -427,6 +427,12 @@ class Directory */ private $wantedPublicDisplay = false; + /** + * @ORM\Column(type="boolean", options={"default":"0"}) + * @Gedmo\Versioned + */ + private $wantedPublicReason = false; + /** * @ORM\OneToMany(targetEntity=Infringement::class, mappedBy="directory", orphanRemoval=true) * @ORM\OrderBy({"createdAt" = "DESC"}) @@ -1376,6 +1382,18 @@ class Directory return $this; } + public function getWantedPublicReason(): ?bool + { + return $this->wantedPublicReason; + } + + public function setWantedPublicReason(bool $wantedPublicReason): self + { + $this->wantedPublicReason = $wantedPublicReason; + + return $this; + } + /** * @return Collection|Infringement[] */ diff --git a/src/Form/DirectoryType.php b/src/Form/DirectoryType.php index 7e64dee..5b3dc1d 100644 --- a/src/Form/DirectoryType.php +++ b/src/Form/DirectoryType.php @@ -69,6 +69,7 @@ class DirectoryType extends AbstractType ->add('wantedReason', null, ['label' => 'form_label_wantedReason', 'help' => 'form_help_wantedReason']) ->add('wantedDisplay', null, ['label' => 'form_label_wantedDisplay']) ->add('wantedPublicDisplay', null, ['label' => 'form_label_wantedPublicDisplay']) + ->add('wantedPublicReason', null, ['label' => 'form_label_wantedPublicReason']) ; } diff --git a/templates/_cells/directoryCard.html.twig b/templates/_cells/directoryCard.html.twig index d18188b..0a0023c 100644 --- a/templates/_cells/directoryCard.html.twig +++ b/templates/_cells/directoryCard.html.twig @@ -63,7 +63,10 @@ {% if directory.hasnopapers %}
  • {% trans %}title_hasnopapers{% endtrans %}
  • {% endif %} - {% if directory.wanted %} + + {% endif %} + {% if app.user %} + {% if directory.wanted and ( app.user.hasPermission('general_legal_view') or directory.wantedPublicReason) %}
  • {% trans %}title_directory_wanted_light{% endtrans %} : {{ directory.wantedReason | default('value_no_value'|trans) }}
  • {% endif %} {% endif %} @@ -73,7 +76,7 @@
    {{ directory.address | default('value_no_value'|trans) | raw }}
    - + {% if app.user and app.user.hasPermission('general_medical_view') %} diff --git a/templates/wanted/index.html.twig b/templates/wanted/index.html.twig index e056f7f..ddfe6e7 100644 --- a/templates/wanted/index.html.twig +++ b/templates/wanted/index.html.twig @@ -15,7 +15,10 @@
    {% trans %}title_wanted{% endtrans %}
    -

    {{i.fullname}}

    +

    {{i.fullname}}

    + {% if i.wantedPublicReason %} +

    {{i.wantedReason}}

    + {% endif %}