Commit 447a5885 authored by Arnaud Bey's avatar Arnaud Bey
Browse files

combos points are now editable through administration panel. fix #72

parent 63f594c6
This diff is collapsed.
......@@ -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();
......
......@@ -6,6 +6,8 @@
'- tense -': -- Tense --
abandon: Withdrawal
accept_challenge: Acceot challenge
accuracy_text: Your accuracy is %accuracy%% (%totalFound% correct found forms and %totalWrong% wrong ones).
accuracy: Accuracy
add_combo: 'Add a combo'
add_constraint: Add constraint objective
add_existing_form: 'Add existing form'
......@@ -37,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
......@@ -71,6 +74,10 @@ forfeit: Give up game
form: Form
forms_found_count: Found forms count
forms_found: 'Found forms'
forms: Forms
found_by_percent: Form found by %percent%% of all players
found_percent: %count% found forms out of %total%, being %percent%%
found: Found forms
foundables: Found forms
french: French
from: 'From'
......@@ -119,6 +126,8 @@ my_profile: My profile
name: Name
neuter: neutral
new_massive: 'New massive game'
no_combo_done: You did not make any combo during this round.
no_massive_create: There's no massive game available but you can create a new one.
number: Number
numeral: numeric
objectives: Objectives
......@@ -143,6 +152,7 @@ rank: Rank
ranking: Ranking
rankings_and_stats: Rankings and statistics
remove__from_friends: 'Remove from friends'
round_language: The round is in
round_type: Round type you want to play (1st round)
round_type2: Round type you want to play (2nd round)
round: Round
......@@ -170,24 +180,16 @@ thirdPerson: 3rd person
time: Tense
to: to
total: Total
train_again: Train again
train: 'Train'
training: Training game
tutorial_game_id: Tutorial game id
tutorial_text: Bienvenue dans le tutoriel MagicWord. Vous allez être familiarisé avec les bases du jeu et de l'interface. Vous avez 2 minutes mais, contrairement aux autres parties, vous pourrez recommencez celle-ci si vous le souhaitez.
tutorial: Tutorial
update: 'update'
verb: verb
weight: Weight
wiktionary_def: Définition wiktionary
word_length: form length
wordbox: Wordbox
wordlengthpoints: Form length bonus points
wiktionary_def: Définition wiktionary
no_combo_done: You did not make any combo during this round.
round_language: The round is in
tutorial_game_id: Tutorial game id
tutorial: Tutorial
tutorial_text: Bienvenue dans le tutoriel MagicWord. Vous allez être familiarisé avec les bases du jeu et de l'interface. Vous avez 2 minutes mais, contrairement aux autres parties, vous pourrez recommencez celle-ci si vous le souhaitez.
train_again: Train again
found: Found forms
found_percent: %count% found forms out of %total%, being %percent%%
found_by_percent: Form found by %percent%% of all players
accuracy: Accuracy
accuracy_text: Your accuracy is %accuracy%% (%totalFound% correct found forms and %totalWrong% wrong ones).
no_massive_create: There's no massive game available but you can create a new one.
......@@ -6,23 +6,30 @@
'- tense -': -- Temps --
abandon: Abandon
accept_challenge: Accepter le défi
access_type: Type d'accès
accuracy_text: Votre précision est de %accuracy%% (%totalFound% formes correctes trouvées pour %totalWrong% erronées).
accuracy: Précision
add_combo: 'Ajouter un objectif combo'
add_constraint: Ajouter un objectif contrainte
add_existing_form: 'Ajouter une forme existante'
add_findword: Ajouter un objectif findword
add_form: 'Ajouter une forme'
add_round: 'Ajouter une manche'
add_string: Ajouter une chaîne
add_to_findwords: Ajouter aux objectifs findword
add_to_friends: 'Ajouter aux contacts'
add_to_wordbox_short: wordbox
add_to_wordbox: 'Ajouter à ma wordbox'
add: Ajouter
addword: Ajouter un mot
addwords: Ajouter des mots
adjective: adjectif
adverb: adverbe
author: auteur
autofill_grid: Autofill
back_to_editor: 'Retour à l''éditeur de partie'
back_to_home: Accueil
back_to_patterns_list: Retour aux patterns
bonus_points: Points bonus
cancel: Annuler le défi
category: Catégorie
......@@ -37,7 +44,9 @@ 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
commonNoun: nom commun
conditional: conditionnel
......@@ -63,8 +72,10 @@ edit_game: 'Editer partie'
edit_password: Changer de mot de passe
edit_profile: Editer le profil
edit_round: 'Editer la manche'
edit: Editer
english: Anglais
existing_forms: 'forme(s) présente(s)'
export_game: Exporter la partie
feminine: féminin
find_words: FindWord
firstPerson: 1ère personne
......@@ -72,6 +83,10 @@ 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
foundables: Formes trouvées
french: Français
from: 'De la part de'
......@@ -82,11 +97,13 @@ games_ended: Parties terminées
games_started: Mes parties en cours
gametype: type de partie
gender: Genre
general_parameters: Paramètres généraux
generate_grid: 'Générer Grille'
give_up: Abandonner
grid: Grille
hidden: 'Masquer sa présence'
hint: Indice
homeText: Texte d'accueil
hour: heure
hours: heures
imperative: impératif
......@@ -97,11 +114,14 @@ inflexion_info: 'Infos sur la flexion'
interjection: interjection
invariable: invariable
Is lemma enough ?: Le lemme suffit ?
json_import: Import JSON
language_ui: 'Langue de l''interface'
language: Langue
lemma_info: 'Infos sur le lemme'
lemma: Lemme
letsgo: "C'est parti !"
letterlanguagepoints: Points par lettre et par langue
link: Accès via le lien uniquement
masculine: masculin
massive_end: 'Récapitulatif partie massive'
massive: 'partie massive'
......@@ -120,6 +140,8 @@ my_profile: Mon profil
name: Nom
neuter: neutre
new_massive: 'Nouvelle partie'
no_combo_done: Vous n'avez pas fait de combo sur cette manche.
no_massive_create: Il n'y a pas de partie massive disponible mais vous pouvez en créer une.
number: Nombre
numeral: numéral
objectives: Objectifs
......@@ -127,8 +149,12 @@ online: 'En ligne'
parameters: Paramètres
participle: participe
past: passé
pattern_create: Créer un pattern
pattern_edit: Edition d'un pattern
patterns_list: Liste des patterns
person: Personne
phonetic: Phonétique
piwikUrl: URL piwik (sans le http(s)://)
play: Jouer
player: Joueur
plural: pluriel
......@@ -136,14 +162,18 @@ points: Points
popularity: popularité
preposition: préposition
present: présent
profile_email: Email
profile_of: 'Profil de'
profile_pic: Image du profil
profile_text: Description du profil
profile_email: Email
pronoun: pronom
properties: Propriétés
public: Visible publiquement
rank: Rang
ranking: Classement
rankings: Classements
remove__from_friends: 'Retirer des contacts'
round_language: La manche est en
round_type: Type de manche que vous voulez jouer (1ère manche)
round_type2: Type de manche que vous voulez jouer (2ème manche)
round: Manche
......@@ -151,6 +181,7 @@ roundCount: manches
rounds: Manches
rush_rules: 'Manche RUSH : Trouvez des mots dans la grille et faites des combos pour faire un maximum de points dans le temps imparti.'
rush: Rush
save_all: Tout sauvegarder
save_grid: 'Sauvegarder la grille'
save_objectives: 'Sauvegarder les objectifs'
save: Sauvegarder
......@@ -161,6 +192,8 @@ seconds: secondes
see_combos: 'Voir les combos possibles'
see_constraints: Voir les contraintes possibles
see_grid: 'Voir la grille'
self_registration_disabled: Auto-inscription désactivée
selfRegistration: Auto-inscription
simplePast: passé simple
singular: singulier
stats: Statistiques
......@@ -171,48 +204,17 @@ thirdPerson: 3ème personne
time: Temps
to: à
total: Total
train_again: S'entrainer encore
train: 'S''entrainer'
training: Partie d'entrainement
tutorial_game_id: id de la partie tuto
tutorial_text: Bienvenue dans le tutoriel MagicWord. Vous allez être familiarisé avec les bases du jeu et de l'interface. Vous avez 2 minutes mais, contrairement aux autres parties, vous pourrez recommencez celle-ci si vous le souhaitez.
tutorial: Tutoriel
update: 'Mettre à jour'
use_pattern: Utiliser
verb: verbe
weight: Poids
wiktionary_def: Définition wiktionary
word_length: Longueur de la forme
wordbox: Ma wordbox
wordlengthpoints: Points bonus longueur de forme
public: Visible publiquement
link: Accès via le lien uniquement
access_type: Type d'accès
json_import: Import JSON
export_game: Exporter la partie
properties: Propriétés
combos_done: Combos
addwords: Ajouter des mots
addword: Ajouter un mot
general_parameters: Paramètres généraux
selfRegistration: Auto-inscription
homeText: Texte d'accueil
self_registration_disabled: Auto-inscription désactivée
edit: Editer
wiktionary_def: Définition wiktionary
no_combo_done: Vous n'avez pas fait de combo sur cette manche.
letsgo: "C'est parti !"
round_language: La manche est en
tutorial_game_id: id de la partie tuto
tutorial: Tutoriel
tutorial_text: Bienvenue dans le tutoriel MagicWord. Vous allez être familiarisé avec les bases du jeu et de l'interface. Vous avez 2 minutes mais, contrairement aux autres parties, vous pourrez recommencez celle-ci si vous le souhaitez.
train_again: S'entrainer encore
found: Formes trouvées
found_percent: %count% formes trouvées sur %total%, soit %percent%%
found_by_percent: Forme trouvée par %percent%% des joueurs
accuracy: Précision
accuracy_text: Votre précision est de %accuracy%% (%totalFound% formes correctes trouvées pour %totalWrong% erronées).
no_massive_create: Il n'y a pas de partie massive disponible mais vous pouvez en créer une.
save_all: Tout sauvegarder
piwikUrl: URL piwik (sans le http(s)://)
patterns_list: Liste des patterns
back_to_patterns_list: Retour aux patterns
pattern_edit: Edition d'un pattern
use_pattern: Utiliser
add_string: Ajouter une chaîne
pattern_create: Créer un pattern
rankings: Classements
{% 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>
......
Supports Markdown
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