layout and clean activity reason crud

This commit is contained in:
Julien Fastré 2015-10-02 13:57:23 +02:00
parent 0bee5e46db
commit bebee4fbeb
8 changed files with 46 additions and 89 deletions

View File

@ -101,11 +101,8 @@ class ActivityReasonCategoryController extends Controller
throw $this->createNotFoundException('Unable to find ActivityReasonCategory entity.'); throw $this->createNotFoundException('Unable to find ActivityReasonCategory entity.');
} }
$deleteForm = $this->createDeleteForm($id);
return $this->render('ChillActivityBundle:ActivityReasonCategory:show.html.twig', array( return $this->render('ChillActivityBundle:ActivityReasonCategory:show.html.twig', array(
'entity' => $entity, 'entity' => $entity,
'delete_form' => $deleteForm->createView(),
)); ));
} }
@ -124,12 +121,10 @@ class ActivityReasonCategoryController extends Controller
} }
$editForm = $this->createEditForm($entity); $editForm = $this->createEditForm($entity);
$deleteForm = $this->createDeleteForm($id);
return $this->render('ChillActivityBundle:ActivityReasonCategory:edit.html.twig', array( return $this->render('ChillActivityBundle:ActivityReasonCategory:edit.html.twig', array(
'entity' => $entity, 'entity' => $entity,
'edit_form' => $editForm->createView(), 'edit_form' => $editForm->createView(),
'delete_form' => $deleteForm->createView(),
)); ));
} }
@ -165,7 +160,6 @@ class ActivityReasonCategoryController extends Controller
throw $this->createNotFoundException('Unable to find ActivityReasonCategory entity.'); throw $this->createNotFoundException('Unable to find ActivityReasonCategory entity.');
} }
$deleteForm = $this->createDeleteForm($id);
$editForm = $this->createEditForm($entity); $editForm = $this->createEditForm($entity);
$editForm->handleRequest($request); $editForm->handleRequest($request);
@ -178,47 +172,6 @@ class ActivityReasonCategoryController extends Controller
return $this->render('ChillActivityBundle:ActivityReasonCategory:edit.html.twig', array( return $this->render('ChillActivityBundle:ActivityReasonCategory:edit.html.twig', array(
'entity' => $entity, 'entity' => $entity,
'edit_form' => $editForm->createView(), 'edit_form' => $editForm->createView(),
'delete_form' => $deleteForm->createView(),
)); ));
} }
/**
* Deletes a ActivityReasonCategory entity.
*
*/
public function deleteAction(Request $request, $id)
{
$form = $this->createDeleteForm($id);
$form->handleRequest($request);
if ($form->isValid()) {
$em = $this->getDoctrine()->getManager();
$entity = $em->getRepository('ChillActivityBundle:ActivityReasonCategory')->find($id);
if (!$entity) {
throw $this->createNotFoundException('Unable to find ActivityReasonCategory entity.');
}
$em->remove($entity);
$em->flush();
}
return $this->redirect($this->generateUrl('chill_activity_activityreasoncategory'));
}
/**
* Creates a form to delete a ActivityReasonCategory entity by id.
*
* @param mixed $id The entity id
*
* @return \Symfony\Component\Form\Form The form
*/
private function createDeleteForm($id)
{
return $this->createFormBuilder()
->setAction($this->generateUrl('chill_activity_activityreasoncategory_delete', array('id' => $id)))
->setMethod('DELETE')
->add('submit', 'submit', array('label' => 'Delete'))
->getForm()
;
}
} }

View File

@ -45,7 +45,7 @@ class ActivityReason
/** /**
* @var boolean * @var boolean
*/ */
private $active; private $active = true;
/** /**

View File

@ -40,7 +40,7 @@ class ActivityReasonCategory
/** /**
* @var boolean * @var boolean
*/ */
private $active; private $active = true;
/** @var ArrayCollection array of ActivityReason */ /** @var ArrayCollection array of ActivityReason */
private $reasons; private $reasons;

View File

@ -41,7 +41,8 @@ CHILL_ACTIVITY_SEE: Voir une activité
Activity configuration menu: Configuration des activités Activity configuration menu: Configuration des activités
Activity Types: Types d'activité Activity Types: Types d'activité
Activity Reasons: Sujets d'une activité Activity Reasons: Sujets d'une activité
Activity Reasons Category: Catégories d'activités Activity Reasons Category: Catégories de sujet d'activités
Activity configuration: Configuration des activités
# activity reason admin # activity reason admin
ActivityReason list: Liste des sujets ActivityReason list: Liste des sujets
@ -53,3 +54,12 @@ ActivityReason edit: Modification d'un sujet
ActivityReason: Sujet d'activité ActivityReason: Sujet d'activité
The entity is inactive and won't be proposed: Le sujet est inactif et ne sera pas proposé The entity is inactive and won't be proposed: Le sujet est inactif et ne sera pas proposé
The entity is active and will be proposed: Le sujet est actif et sera proposé The entity is active and will be proposed: Le sujet est actif et sera proposé
#activity reason category admin
ActivityReasonCategory list: Catégories de sujets
Create a new activity category reason: Créer une nouvelle catégorie
ActivityReasonCategory creation: Nouvelle catégorie de sujet
ActivityReasonCategory edit: Modification d'une catégorie de sujet
ActivityReasonCategory: Catégorie de sujet d'activité
ActivityReasonCategory is active and will be proposed: La catégorie est active et sera proposée
ActivityReasonCategory is inactive and won't be proposed: La catégorie est inactive et ne sera pas proposée

View File

@ -17,16 +17,19 @@
{% extends "ChillActivityBundle::Admin/layout_activity.html.twig" %} {% extends "ChillActivityBundle::Admin/layout_activity.html.twig" %}
{% block admin_content %} {% block admin_content %}
<h1>ActivityReasonCategory edit</h1> <h1>{{ 'ActivityReasonCategory edit'|trans }}</h1>
{{ form(edit_form) }} {{ form_start(edit_form) }}
{{ form_row(edit_form.name) }}
{{ form_row(edit_form.active) }}
{{ form_row(edit_form.submit, { 'attr': { 'class': 'sc-button orange' } } ) }}
{{ form_end(edit_form) }}
<ul class="record_actions"> <ul class="record_actions">
<li> <li>
<a href="{{ path('chill_activity_activityreasoncategory') }}"> <a href="{{ path('chill_activity_activityreasoncategory') }}">
Back to the list {{ 'Back to the list'|trans }}
</a> </a>
</li> </li>
<li>{{ form(delete_form) }}</li>
</ul> </ul>
{% endblock %} {% endblock %}

View File

@ -17,40 +17,28 @@
{% extends "ChillActivityBundle::Admin/layout_activity.html.twig" %} {% extends "ChillActivityBundle::Admin/layout_activity.html.twig" %}
{% block admin_content %} {% block admin_content %}
<h1>ActivityReasonCategory list</h1> <h1>{{ 'ActivityReasonCategory list'|trans }}</h1>
<table class="records_list"> <table class="records_list">
<thead> <thead>
<tr> <tr>
<th>{{ 'Name'|trans }}</th> <th>{{ 'Name'|trans }}</th>
<th>{{ 'Active'|trans }}Active</th>
<th>{{ 'Actions'|trans }}</th> <th>{{ 'Actions'|trans }}</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{% for entity in entities %} {% for entity in entities %}
<tr> <tr>
<td><a href="{{ path('chill_activity_activityreasoncategory_show', { 'id': entity.id }) }}">{{ entity.name|localize_translatable_string }}</a></td>
<td> <td>
<a href="{{ path('chill_activity_activityreasoncategory_show', { 'id': entity.id }) }}"> <ul>
{{ entity.name|localize_translatable_string }} <li>
</a> <a href="{{ path('chill_activity_activityreasoncategory_show', { 'id': entity.id }) }}">{{ 'show'|trans }}</a>
</td> </li>
<td> <li>
{% if entity.active %} <a href="{{ path('chill_activity_activityreasoncategory_edit', { 'id': entity.id }) }}">{{ 'edit'|trans }}</a>
<p>{{ 'Active'|trans }}</p> </li>
{% else %} </ul>
<p>{{ "Inactive"|trans }}</p>
{% endif %}
</td>
<td>
<ul>
<li>
<a href="{{ path('chill_activity_activityreasoncategory_show', { 'id': entity.id }) }}">{{'show'|trans}}</a>
</li>
<li>
<a href="{{ path('chill_activity_activityreasoncategory_edit', { 'id': entity.id }) }}">{{'edit'|trans}}</a>
</li>
</ul>
</td> </td>
</tr> </tr>
{% endfor %} {% endfor %}
@ -60,7 +48,7 @@
<ul> <ul>
<li> <li>
<a href="{{ path('chill_activity_activityreasoncategory_new') }}"> <a href="{{ path('chill_activity_activityreasoncategory_new') }}">
{{'Create a new entry'|trans}} {{ 'Create a new activity category reason'|trans }}
</a> </a>
</li> </li>
</ul> </ul>

View File

@ -17,14 +17,18 @@
{% extends "ChillActivityBundle::Admin/layout_activity.html.twig" %} {% extends "ChillActivityBundle::Admin/layout_activity.html.twig" %}
{% block admin_content %} {% block admin_content %}
<h1>ActivityReasonCategory creation</h1> <h1>{{ 'ActivityReasonCategory creation'|trans }}</h1>
{{ form(form) }} {{ form_start(form) }}
{{ form_row(form.name) }}
{{ form_row(form.active) }}
{{ form_widget(form.submit, { 'attr': { 'class' : 'sc-button blue' } } ) }}
<p>{{ form_end(form) }}</p>
<ul class="record_actions"> <ul class="record_actions">
<li> <li>
<a href="{{ path('chill_activity_activityreasoncategory') }}"> <a href="{{ path('chill_activity_activityreasoncategory') }}">
Back to the list {{ 'Back to the list'|trans }}
</a> </a>
</li> </li>
</ul> </ul>

View File

@ -17,7 +17,7 @@
{% extends "ChillActivityBundle::Admin/layout_activity.html.twig" %} {% extends "ChillActivityBundle::Admin/layout_activity.html.twig" %}
{% block admin_content %} {% block admin_content %}
<h1>ActivityReasonCategory</h1> <h1>{{ 'ActivityReasonCategory'|trans }}</h1>
<table class="record_properties"> <table class="record_properties">
<tbody> <tbody>
@ -28,11 +28,11 @@
<tr> <tr>
<th>{{ 'Active'|trans }}</th> <th>{{ 'Active'|trans }}</th>
<td> <td>
{% if entity.active %} {%- if entity.active -%}
<p>{{ 'The entity is active and will be proposed'|trans }}</p> {{ 'ActivityReasonCategory is active and will be proposed'|trans }}
{% else %} {%- else -%}
<p>{{ "The entity is inactive and won't be proposed"|trans }}</p> {{ "ActivityReasonCategory is inactive and won't be proposed"|trans }}
{% endif %} {%- endif -%}
</td> </td>
</tr> </tr>
</tbody> </tbody>
@ -41,14 +41,13 @@
<ul class="record_actions"> <ul class="record_actions">
<li> <li>
<a href="{{ path('chill_activity_activityreasoncategory') }}"> <a href="{{ path('chill_activity_activityreasoncategory') }}">
Back to the list {{ 'Back to the list'|trans }}
</a> </a>
</li> </li>
<li> <li>
<a href="{{ path('chill_activity_activityreasoncategory_edit', { 'id': entity.id }) }}"> <a href="{{ path('chill_activity_activityreasoncategory_edit', { 'id': entity.id }) }}">
Edit {{ 'Edit'|trans }}
</a> </a>
</li> </li>
<li>{{ form(delete_form) }}</li>
</ul> </ul>
{% endblock %} {% endblock %}