Merge branch 'master' of git://github.com/Chill-project/Activity

This commit is contained in:
Marc Ducobu 2015-07-06 00:27:44 +02:00
commit 7e688d8573
7 changed files with 71 additions and 20 deletions

View File

@ -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,
@ -113,8 +126,6 @@ class ActivityController extends Controller
)
);
$form->add('submit', 'submit', array('label' => 'Create'));
return $form;
}
@ -233,8 +244,6 @@ class ActivityController extends Controller
'role' => new Role('CHILL_ACTIVITY_UPDATE')
));
$form->add('submit', 'submit', array('label' => 'Update'));
return $form;
}
/**
@ -260,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,

View File

@ -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' => ''

View File

@ -14,13 +14,21 @@ not present: absent
Delete: Supprimer
Update: Mettre à jour
Update activity: Édition de l'activité
Scope: Cercle
#forms
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%
#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.

View File

@ -23,7 +23,20 @@
{% block personcontent %}
<h1>{{ "Update activity"|trans }}</h1>
{{ form(edit_form) }}
{{ form_start(edit_form) }}
{{ form_widget(edit_form) }}
<div class="grid-12 centered sticky-form-buttons">
<button class="sc-button green margin-10" type="submit"><i class="fa fa-save"></i> {{ 'Save activity'|trans }}</button>
<button class="sc-button red margin-10" type="reset"><i class="fa fa-eraser"></i> {{ 'Reset form'|trans }}</button>
</div>
{{ form_end(edit_form) }}
{# {{ form(delete_form) }} #}
{% endblock %}
{% block js %}
<script type="text/javascript">
chill.displayAlertWhenLeavingModifiedForm('form[name="{{ edit_form.vars.form.vars.name }}"]', '{{ "You are going to leave a page with unsubmitted data. Are you sure you want to leave ?"|trans }}');
</script>
{% endblock %}

View File

@ -28,7 +28,6 @@
<th>{{'Duration Time' | trans }}</th>
<th>{{'Reason' | trans}}</th>
<th>{{'Type' | trans}}</th>
<th>{{'Attendee' | trans }}</th>
<th></th>
<th></th>
</tr>
@ -40,7 +39,6 @@
<td>{{ activity.durationTime|date('H:i') }}</td>
<td>{{ activity.reason.name | localize_translatable_string }}</td>
<td>{{ activity.type.name | localize_translatable_string }}</td>
<td>{{ activity.attendee }}</td>
<td>
<a href="{{ path('chill_activity_activity_show', { 'id': activity.id, 'person_id': person.id }) }}">{{ 'Show the activity' | trans }}</a>
</td>

View File

@ -23,13 +23,17 @@
{% block personcontent %}
<h1>{{ "Activity creation"|trans }}</h1>
{{ form(form) }}
{{ form_start(form) }}
<ul class="record_actions">
<li>
<a href="{{ path('chill_activity_activity_list', {'person_id': person.id}) }}">
{{ "Back to the list" | trans }}
</a>
</li>
</ul>
{{ form_widget(form) }}
<div class="grid-12 centered sticky-form-buttons">
<button class="sc-button green margin-10" type="submit"><i class="fa fa-save"></i> {{ 'Add a new activity'|trans }}</button>
</div>
{{ form_end(form) }}
{% endblock %}
{% block js %}
<script type="text/javascript">
chill.displayAlertWhenLeavingUnsubmittedForm('form[name="{{ form.vars.form.vars.name }}"]', '{{ "You are going to leave a page with unsubmitted data. Are you sure you want to leave ?"|trans }}');
</script>
{% endblock %}

View File

@ -3,6 +3,8 @@
{% set activeRouteKey = 'chill_activity_activity_list' %}
{% block personcontent -%}
<h1>{{ "Activity"|trans }}</h1>
<a href="{{ path('chill_activity_activity_edit', { 'id': entity.id, 'person_id': person.id }) }}">
<i class="fa fa-pencil"></i> {{ 'Edit the activity'|trans }}
</a>
@ -23,9 +25,9 @@
<dt class="inline">{{ 'Type'|trans }}</dt>
<dd>{{ entity.type.name | localize_translatable_string }}</dd>
<dt class="inline">{{ 'Attendee'|trans }}</dt>
<dd>{{ entity.attendee }}</dd>
<dd>{% if entity.attendee is not null %}{% if entity.attendee %}{{ 'present'|trans|capitalize }} {% else %} {{ 'not present'|trans|capitalize }}{% endif %}{% else %}{{ 'None'|trans|capitalize }}{% endif %}</dd>
<dt class="inline">{{ 'Remark'|trans }}</dt>
<dd>{{ entity.remark }}</dd>
<dd>{% if entity.remark is empty %}{{ 'No remarks'|trans }}{% else %}<pre>{{ entity.remark }}</pre>{% endif %}</dd>
<dt class="inline">{{ ''|trans }}</dt>
<dd></dd>
<dt class="inline">{{ ''|trans }}</dt>
@ -36,5 +38,5 @@
<i class="fa fa-pencil"></i> {{ 'Edit the activity'|trans }}
</a>
{{ form(delete_form) }}
{# {{ form(delete_form) }} #}
{% endblock personcontent %}