From 943032a9188bd8f375b60ed4e3fe5f7c3ea05cc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Sun, 5 Jul 2015 23:23:29 +0200 Subject: [PATCH 1/4] layout of time widget --- Form/ActivityType.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Form/ActivityType.php b/Form/ActivityType.php index bf8fc492d..b6c52fb4a 100644 --- a/Form/ActivityType.php +++ b/Form/ActivityType.php @@ -67,7 +67,10 @@ class ActivityType extends AbstractType 'widget' => 'single_text', 'format' => 'dd-MM-yyyy') ) - ->add('durationTime', 'time') + ->add('durationTime', 'time', array( + 'widget' => 'text', + 'hours' => array(0, 1, 2, 3, 4, 5, 6, 7, 8) + )) ->add('remark', 'textarea', array( 'required' => false, 'empty_data' => '' From 7f367a857e3abe61d89035a486992591d4b1d61a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Sun, 5 Jul 2015 23:45:49 +0200 Subject: [PATCH 2/4] layout of show and list - remove attendee from list - multiple case in show + layout --- Resources/translations/messages.fr.yml | 1 + Resources/views/Activity/list.html.twig | 2 -- Resources/views/Activity/show.html.twig | 6 ++++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Resources/translations/messages.fr.yml b/Resources/translations/messages.fr.yml index 574b12017..54cf7de0b 100644 --- a/Resources/translations/messages.fr.yml +++ b/Resources/translations/messages.fr.yml @@ -14,6 +14,7 @@ not present: absent Delete: Supprimer Update: Mettre à jour Update activity: Édition de l'activité +Scope: Cercle #forms Activity creation: Nouvelle activité diff --git a/Resources/views/Activity/list.html.twig b/Resources/views/Activity/list.html.twig index 5e2871555..c68371dd5 100644 --- a/Resources/views/Activity/list.html.twig +++ b/Resources/views/Activity/list.html.twig @@ -28,7 +28,6 @@ {{'Duration Time' | trans }} {{'Reason' | trans}} {{'Type' | trans}} - {{'Attendee' | trans }} @@ -40,7 +39,6 @@ {{ activity.durationTime|date('H:i') }} {{ activity.reason.name | localize_translatable_string }} {{ activity.type.name | localize_translatable_string }} - {{ activity.attendee }} {{ 'Show the activity' | trans }} diff --git a/Resources/views/Activity/show.html.twig b/Resources/views/Activity/show.html.twig index 32717fa48..f09b3a8de 100644 --- a/Resources/views/Activity/show.html.twig +++ b/Resources/views/Activity/show.html.twig @@ -3,6 +3,8 @@ {% set activeRouteKey = 'chill_activity_activity_list' %} {% block personcontent -%} +

{{ "Activity"|trans }}

+ {{ 'Edit the activity'|trans }} @@ -23,9 +25,9 @@
{{ 'Type'|trans }}
{{ entity.type.name | localize_translatable_string }}
{{ 'Attendee'|trans }}
-
{{ entity.attendee }}
+
{% if entity.attendee is not null %}{% if entity.attendee %}{{ 'present'|trans|capitalize }} {% else %} {{ 'not present'|trans|capitalize }}{% endif %}{% else %}{{ 'None'|trans|capitalize }}{% endif %}
{{ 'Remark'|trans }}
-
{{ entity.remark }}
+
{% if entity.remark is empty %}{{ 'No remarks'|trans }}{% else %}
{{ entity.remark }}
{% endif %}
{{ ''|trans }}
{{ ''|trans }}
From e0561340a5b8c5286b6b3041222b4f913b5cc20b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Sun, 5 Jul 2015 23:58:15 +0200 Subject: [PATCH 3/4] add layout for form, consistency with reports - add buttons at the bottom --- Controller/ActivityController.php | 2 -- Resources/translations/messages.fr.yml | 2 ++ Resources/views/Activity/edit.html.twig | 15 ++++++++++++++- Resources/views/Activity/new.html.twig | 20 ++++++++++++-------- Resources/views/Activity/show.html.twig | 2 +- 5 files changed, 29 insertions(+), 12 deletions(-) diff --git a/Controller/ActivityController.php b/Controller/ActivityController.php index 21a61cd01..a99007a81 100644 --- a/Controller/ActivityController.php +++ b/Controller/ActivityController.php @@ -113,8 +113,6 @@ class ActivityController extends Controller ) ); - $form->add('submit', 'submit', array('label' => 'Create')); - return $form; } diff --git a/Resources/translations/messages.fr.yml b/Resources/translations/messages.fr.yml index 54cf7de0b..90950fbf7 100644 --- a/Resources/translations/messages.fr.yml +++ b/Resources/translations/messages.fr.yml @@ -20,6 +20,8 @@ Scope: Cercle Activity creation: Nouvelle activité Create: Créer Back to the list: Retour à la liste +Save activity: Sauver l'activité +Reset form: Remise à zéro du formulaire #timeline '%user% has done an %activity_type% on %date%': %user% a effectué une activité de type "%activity_type%" le %date% diff --git a/Resources/views/Activity/edit.html.twig b/Resources/views/Activity/edit.html.twig index 5b96d5f4b..d92ecab39 100644 --- a/Resources/views/Activity/edit.html.twig +++ b/Resources/views/Activity/edit.html.twig @@ -23,7 +23,20 @@ {% block personcontent %}

{{ "Update activity"|trans }}

- {{ form(edit_form) }} + {{ form_start(edit_form) }} + + {{ form_widget(edit_form) }} +
+ + +
+ {{ form_end(edit_form) }} {# {{ form(delete_form) }} #} {% endblock %} + +{% block js %} + +{% endblock %} diff --git a/Resources/views/Activity/new.html.twig b/Resources/views/Activity/new.html.twig index 7e036ef68..4e55698a0 100644 --- a/Resources/views/Activity/new.html.twig +++ b/Resources/views/Activity/new.html.twig @@ -23,13 +23,17 @@ {% block personcontent %}

{{ "Activity creation"|trans }}

- {{ form(form) }} + {{ form_start(form) }} - + {{ form_widget(form) }} +
+ +
+ {{ form_end(form) }} +{% endblock %} + +{% block js %} + {% endblock %} \ No newline at end of file diff --git a/Resources/views/Activity/show.html.twig b/Resources/views/Activity/show.html.twig index f09b3a8de..1be4948d9 100644 --- a/Resources/views/Activity/show.html.twig +++ b/Resources/views/Activity/show.html.twig @@ -38,5 +38,5 @@ {{ 'Edit the activity'|trans }} - {{ form(delete_form) }} + {# {{ form(delete_form) }} #} {% endblock personcontent %} From e36c195ecf7d8d744a5cc53c9cd53d96955c63f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 6 Jul 2015 00:10:13 +0200 Subject: [PATCH 4/4] add flashbag message for activity --- Controller/ActivityController.php | 31 +++++++++++++++++++++++--- Resources/translations/messages.fr.yml | 5 +++++ 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/Controller/ActivityController.php b/Controller/ActivityController.php index a99007a81..21e87264e 100644 --- a/Controller/ActivityController.php +++ b/Controller/ActivityController.php @@ -80,11 +80,24 @@ class ActivityController extends Controller $em->persist($entity); $em->flush(); + + $this->get('session') + ->getFlashBag() + ->add('success', + $this->get('translator') + ->trans('Success : activity created!') + ); return $this->redirect( $this->generateUrl('chill_activity_activity_show', array('id' => $entity->getId(), 'person_id' => $person_id))); } + + $this->get('session') + ->getFlashBag()->add('danger', + $this->get('translator') + ->trans('The form is not valid. The activity has not been created !') + ); return $this->render('ChillActivityBundle:Activity:new.html.twig', array( 'entity' => $entity, @@ -231,8 +244,6 @@ class ActivityController extends Controller 'role' => new Role('CHILL_ACTIVITY_UPDATE') )); - $form->add('submit', 'submit', array('label' => 'Update')); - return $form; } /** @@ -258,9 +269,23 @@ class ActivityController extends Controller if ($editForm->isValid()) { $em->flush(); + + $this->get('session') + ->getFlashBag() + ->add('success', + $this->get('translator') + ->trans('Success : activity updated!') + ); - return $this->redirect($this->generateUrl('chill_activity_activity_edit', array('id' => $id, 'person_id' => $person_id))); + return $this->redirect($this->generateUrl('chill_activity_activity_show', array('id' => $id, 'person_id' => $person_id))); } + + $this->get('session') + ->getFlashBag() + ->add('danger', + $this->get('translator') + ->trans('The form is not valid. The activity has not been updated !') + ); return $this->render('ChillActivityBundle:Activity:edit.html.twig', array( 'entity' => $entity, diff --git a/Resources/translations/messages.fr.yml b/Resources/translations/messages.fr.yml index 90950fbf7..82172eca1 100644 --- a/Resources/translations/messages.fr.yml +++ b/Resources/translations/messages.fr.yml @@ -26,4 +26,9 @@ Reset form: Remise à zéro du formulaire #timeline '%user% has done an %activity_type% on %date%': %user% a effectué une activité de type "%activity_type%" le %date% +#controller +'Success : activity created!': Bravo ! L'activité a été créée. +'The form is not valid. The activity has not been created !': Le formulaire est invalide. L'activité n'a pas été créée. +'Success : activity updated!': Bravo ! L'activité a été mise à jour. +'The form is not valid. The activity has not been updated !': Le formulaire est invalide. L'activité n'a pas été mise à jour.