Commit e803ebfb authored by Arnaud Bey's avatar Arnaud Bey
Browse files

Merge branch 'combopoints-editable' into 'master'

combos points are now editable through administration panel

Closes #72

See merge request lzbk/MagicWord!62
parents 5711ae09 4c21149c
......@@ -2,11 +2,12 @@
namespace MagicWordBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use MagicWordBundle\Entity\Rules\WordLengthPoints;
use MagicWordBundle\Entity\Letter\LetterLanguage;
use MagicWordBundle\Entity\Rules\ComboPoints;
use MagicWordBundle\Entity\Rules\WordLengthPoints;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
class AdministrationController extends Controller
......@@ -29,6 +30,18 @@ class AdministrationController extends Controller
return $this->render('MagicWordBundle:Administration:wordlengthpoints.html.twig', ['wordlengthpoints' => $wordlengthpoints]);
}
/**
* @Route("/administration/combopoints", name="combopoints")
*/
public function comboPointsAction()
{
$combopoints = $this->getDoctrine()->getRepository('MagicWordBundle:Rules\ComboPoints')->findAll();
return $this->render('MagicWordBundle:Administration:combopoints.html.twig', ['combopoints' => $combopoints]);
}
/**
* @Route("/administration/wordlengthpoints/{id}", name="wordlengthpoint_edit")
* @Method("GET")
......@@ -40,6 +53,17 @@ class AdministrationController extends Controller
return $this->render('MagicWordBundle:Administration:wordlengthpoint-edit.html.twig', ['form' => $form, 'wordlengthpoint' => $wordlengthpoint]);
}
/**
* @Route("/administration/combopoints/{id}", name="combopoint_edit")
* @Method("GET")
*/
public function comboPointEditAction(ComboPoints $combopoint)
{
$form = $this->get('mw_manager.administration')->getComboPointForm($combopoint);
return $this->render('MagicWordBundle:Administration:wordlengthpoint-edit.html.twig', ['form' => $form, 'wordlengthpoint' => $combopoint]);
}
/**
* @Route("/administration/wordlengthpoints/{id}", name="wordlengthpoint_submit")
* @Method("POST")
......@@ -51,6 +75,17 @@ class AdministrationController extends Controller
return $this->redirectToRoute('wordlengthpoints');
}
/**
* @Route("/administration/combopoints/{id}", name="combopoint_submit")
* @Method("POST")
*/
public function comboPointSubmitAction(ComboPoints $combopoint, Request $request)
{
$this->get('mw_manager.administration')->handleComboPointForm($combopoint, $request);
return $this->redirectToRoute('combopoints');
}
/**
* @Route("/administration/letterslanguage", name="letterslanguage")
*/
......
<?php
namespace MagicWordBundle\Form\Type;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
class ComboPointsType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('points', IntegerType::class, array(
'attr' => [
'placeholder' => 'bonus_points',
'translation_domain' => 'messages',
],
'label' => 'bonus_points',
));
$builder->add('save', SubmitType::class, array(
'attr' => array('class' => 'btn btn-default'),
'label' => 'save',
'translation_domain' => 'messages',
));
}
public function getName()
{
return 'comboPoints';
}
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
'data_class' => 'MagicWordBundle\Entity\Rules\ComboPoints',
));
}
}
......@@ -3,13 +3,15 @@
namespace MagicWordBundle\Manager;
use JMS\DiExtraBundle\Annotation as DI;
use MagicWordBundle\Entity\Rules\WordLengthPoints;
use MagicWordBundle\Entity\GeneralParameters;
use MagicWordBundle\Entity\Letter\LetterLanguage;
use MagicWordBundle\Entity\Rules\ComboPoints;
use MagicWordBundle\Entity\Rules\WordLengthPoints;
use MagicWordBundle\Form\Type\ComboPointsType;
use MagicWordBundle\Form\Type\GeneralParametersType;
use MagicWordBundle\Form\Type\LetterLanguagePointsType;
use MagicWordBundle\Form\Type\WordLengthPointsType;
use Symfony\Component\HttpFoundation\Request;
use MagicWordBundle\Form\Type\LetterLanguagePointsType;
use MagicWordBundle\Form\Type\GeneralParametersType;
use MagicWordBundle\Entity\GeneralParameters;
/**
* @DI\Service("mw_manager.administration")
......@@ -38,6 +40,13 @@ class AdministrationManager
return $form;
}
public function getComboPointForm(ComboPoints $comboPoints)
{
$form = $this->formFactory->createBuilder(ComboPointsType::class, $comboPoints)->getForm()->createView();
return $form;
}
public function handleWordLengthPointForm(WordLengthPoints $wordlengthpoint, Request $request)
{
$form = $this->formFactory->createBuilder(WordLengthPointsType::class, $wordlengthpoint)->getForm();
......@@ -51,6 +60,20 @@ class AdministrationManager
return;
}
public function handleComboPointForm(ComboPoints $comboPoints, Request $request)
{
$form = $this->formFactory->createBuilder(ComboPointsType::class, $comboPoints)->getForm();
$form->handleRequest($request);
if ($form->isValid()) {
$this->em->persist($comboPoints);
$this->em->flush();
}
return;
}
public function getLetterLanguageForm(LetterLanguage $letterlanguage)
{
$form = $this->formFactory->createBuilder(LetterLanguagePointsType::class, $letterlanguage)->getForm()->createView();
......
......@@ -39,6 +39,7 @@ cleaned_content: 'Cleaned form'
close: Close
combo_length: 'Combo length'
combo_number: 'Combo count'
combopoints: Points bonus combo
combos__with_length: 'combo(s) with a length of'
combos: Combos
commonNoun: common noun
......
......@@ -44,6 +44,7 @@ cleaned_content: 'Flexion "nettoyée"'
close: Fermer
combo_length: 'Puissance des combos'
combo_number: 'Nombre de combos'
combopoints: Points bonus combo
combos__with_length: 'combo(s) de puissance'
combos_done: Combos
combos: Combo
......@@ -82,6 +83,7 @@ forfeit: Abandonner la partie
form: Forme
forms_found_count: Nombre de formes trouvées
forms_found: 'forme(s) trouvée(s)'
forms: Formes
found_by_percent: Forme trouvée par %percent%% des joueurs
found_percent: %count% formes trouvées sur %total%, soit %percent%%
found: Formes trouvées
......
{% extends '::base.html.twig' %}
{% block title %}{{ 'combopoints' | trans }}{% endblock %}
{% block body -%}
<div class="panel panel-default">
<div class="panel-heading">
<h4>
{% include "MagicWordBundle:Common:backtohome.html.twig" %}
{{ "combopoints" | trans }} - {{ combopoint.length }}
</h4>
</div>
<div class="panel-body">
{{ form(form) }}
</div>
</div>
{% endblock %}
{% extends '::base.html.twig' %}
{% block body -%}
<div class="panel panel-default">
<div class="panel-heading">
<h4>
{% include "MagicWordBundle:Common:backtohome.html.twig" %}
{{ "combopoints" | trans }}
</h4>
</div>
<ul class="list-group">
{% for combopoint in combopoints %}
<li class="list-group-item">
{{ combopoint.length }} {{'forms'| trans}} - {{ combopoint.points }}pts
<span class="pull-right">
<a href="{{ path('combopoint_edit', {"id": combopoint.id}) }}" class="btn btn-default btn-xs">
<i class="fa fa-pencil" aria-hidden="true"></i> Editer
</a>
</span>
</li>
{% endfor %}
</ul>
</div>
{% endblock %}
......@@ -25,6 +25,11 @@
{{ "wordlengthpoints" | trans }}
</a>
</li>
<li class="list-group-item">
<a href="{{ path('combopoints') }}">
{{ "combopoints" | trans }}
</a>
</li>
</ul>
</div>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment