Skip to content

Commit

Permalink
#36 : optimisation
Browse files Browse the repository at this point in the history
  • Loading branch information
baptiste-its committed Mar 1, 2021
1 parent d9e28d2 commit da435a0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 34 deletions.
22 changes: 0 additions & 22 deletions src/Controller/AdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -359,28 +359,6 @@ public function text(Request $request)
);
}

/**
* @return \Symfony\Component\HttpFoundation\RedirectResponse
* @Route("/admin/textactive", name="admin_textactive")
*/
public function textActive()
{
$option = $this->optionsRepository->findOneBy(
[
'label' => 'Text'
]
);
if ($option->getActive()) {
$option->setActive(0);
} else {
$option->setActive(1);
}
$this->om->persist($option);
$this->om->flush();

return $this->redirect($_SERVER['HTTP_REFERER']);
}

/**
* @Route("/admin/price", name="admin_price")
* @param OptionsRepository $optionsRepository
Expand Down
17 changes: 5 additions & 12 deletions templates/admin/text.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@

<div class="jumbotron first" style="padding-bottom: 15px; padding-top: 40px">
{{ form_start(form) }}
<h4 class="mt-4">Premier text</h4>
<h4>Premier text</h4>
<div class="text-primary" style="font-size: 20px">
{{ form_row(form.firstText, {'label': false, 'id': 'text_home_content1'}) }}
</div>
Expand All @@ -60,7 +60,7 @@
<div class="text-primary">
{{ form_row(form.firstActive) }}
</div>
<h4 class="mt-4">Deuxième text</h4>
<h4 class="mt-5">Deuxième text</h4>
<div class="text-primary" style="font-size: 20px">
{{ form_row(form.secondText, {'label': false, 'id': 'text_home_content2'}) }}
</div>
Expand All @@ -70,7 +70,7 @@
<div class="text-primary">
{{ form_row(form.secondActive) }}
</div>
<h4 class="mt-4">Troisième text</h4>
<h4 class="mt-5">Troisième text</h4>
<div class="text-primary" style="font-size: 20px">
{{ form_row(form.thirdText, {'label': false, 'id': 'text_home_content3'}) }}
</div>
Expand All @@ -81,19 +81,12 @@
{{ form_row(form.thirdActive) }}
</div>
<div class="row justify-content-around">
<div class="col-3">
<div class="col-4">
<a href="{{ path('admin_home') }}" class="btn btn-primary btn-lg btn-block" role="button" aria-pressed="true">Retour</a>
</div>
<div class="col-3">
<div class="col-4">
<button type="submit" class="btn btn-success btn-lg btn-block">Sauvegarder les textes</button>
</div>
<div class="col-3">
{% if text1.active %}
<a href="{{ path('admin_textactive') }}" class="btn btn-outline-warning btn-lg btn-block" role="button" aria-pressed="true">Désactiver le texte</a>
{% else %}
<a href="{{ path('admin_textactive') }}" class="btn btn-warning btn-lg btn-block" role="button" aria-pressed="true">Activer le texte</a>
{% endif %}
</div>
</div>
{{ form_end(form) }}
</div>
Expand Down

0 comments on commit da435a0

Please sign in to comment.