mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-30 22:16:14 +00:00
ActivityType replace Admin Conroller with Crud system
This commit is contained in:
parent
24a7d7b34b
commit
580dc71218
@ -1,178 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Chill\ActivityBundle\Controller;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
use Chill\ActivityBundle\Entity\ActivityType;
|
||||
use Chill\ActivityBundle\Form\ActivityTypeType;
|
||||
|
||||
/**
|
||||
* Class ActivityTypeController
|
||||
*
|
||||
* @package Chill\ActivityBundle\Controller
|
||||
*/
|
||||
class ActivityTypeController extends AbstractController
|
||||
{
|
||||
|
||||
/**
|
||||
* Lists all ActivityType entities.
|
||||
*
|
||||
*/
|
||||
public function indexAction()
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
||||
$entities = $em->getRepository('ChillActivityBundle:ActivityType')->findAll();
|
||||
|
||||
return $this->render('ChillActivityBundle:ActivityType:index.html.twig', array(
|
||||
'entities' => $entities,
|
||||
));
|
||||
}
|
||||
/**
|
||||
* Creates a new ActivityType entity.
|
||||
*
|
||||
*/
|
||||
public function createAction(Request $request)
|
||||
{
|
||||
$entity = new ActivityType();
|
||||
$form = $this->createCreateForm($entity);
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isValid()) {
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$em->persist($entity);
|
||||
$em->flush();
|
||||
|
||||
return $this->redirect($this->generateUrl('chill_activity_activitytype_show', array('id' => $entity->getId())));
|
||||
}
|
||||
|
||||
return $this->render('ChillActivityBundle:ActivityType:new.html.twig', array(
|
||||
'entity' => $entity,
|
||||
'form' => $form->createView(),
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a form to create a ActivityType entity.
|
||||
*
|
||||
* @param ActivityType $entity The entity
|
||||
*
|
||||
* @return \Symfony\Component\Form\Form The form
|
||||
*/
|
||||
private function createCreateForm(ActivityType $entity)
|
||||
{
|
||||
$form = $this->createForm(ActivityTypeType::class, $entity, array(
|
||||
'action' => $this->generateUrl('chill_activity_activitytype_create'),
|
||||
'method' => 'POST',
|
||||
));
|
||||
|
||||
$form->add('submit', SubmitType::class, array('label' => 'Create'));
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays a form to create a new ActivityType entity.
|
||||
*
|
||||
*/
|
||||
public function newAction()
|
||||
{
|
||||
$entity = new ActivityType();
|
||||
$form = $this->createCreateForm($entity);
|
||||
|
||||
return $this->render('ChillActivityBundle:ActivityType:new.html.twig', array(
|
||||
'entity' => $entity,
|
||||
'form' => $form->createView(),
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds and displays a ActivityType entity.
|
||||
*
|
||||
*/
|
||||
public function showAction($id)
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
||||
$entity = $em->getRepository('ChillActivityBundle:ActivityType')->find($id);
|
||||
|
||||
if (!$entity) {
|
||||
throw $this->createNotFoundException('Unable to find ActivityType entity.');
|
||||
}
|
||||
|
||||
return $this->render('ChillActivityBundle:ActivityType:show.html.twig', array(
|
||||
'entity' => $entity,
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays a form to edit an existing ActivityType entity.
|
||||
*
|
||||
*/
|
||||
public function editAction($id)
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
||||
$entity = $em->getRepository('ChillActivityBundle:ActivityType')->find($id);
|
||||
|
||||
if (!$entity) {
|
||||
throw $this->createNotFoundException('Unable to find ActivityType entity.');
|
||||
}
|
||||
|
||||
$editForm = $this->createEditForm($entity);
|
||||
|
||||
return $this->render('ChillActivityBundle:ActivityType:edit.html.twig', array(
|
||||
'entity' => $entity,
|
||||
'edit_form' => $editForm->createView()
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a form to edit a ActivityType entity.
|
||||
*
|
||||
* @param ActivityType $entity The entity
|
||||
*
|
||||
* @return \Symfony\Component\Form\Form The form
|
||||
*/
|
||||
private function createEditForm(ActivityType $entity)
|
||||
{
|
||||
$form = $this->createForm(ActivityTypeType::class, $entity, array(
|
||||
'action' => $this->generateUrl('chill_activity_activitytype_update', array('id' => $entity->getId())),
|
||||
'method' => 'PUT',
|
||||
));
|
||||
|
||||
$form->add('submit', SubmitType::class, array('label' => 'Update'));
|
||||
|
||||
return $form;
|
||||
}
|
||||
/**
|
||||
* Edits an existing ActivityType entity.
|
||||
*
|
||||
*/
|
||||
public function updateAction(Request $request, $id)
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
||||
$entity = $em->getRepository('ChillActivityBundle:ActivityType')->find($id);
|
||||
|
||||
if (!$entity) {
|
||||
throw $this->createNotFoundException('Unable to find ActivityType entity.');
|
||||
}
|
||||
|
||||
$editForm = $this->createEditForm($entity);
|
||||
$editForm->handleRequest($request);
|
||||
|
||||
if ($editForm->isValid()) {
|
||||
$em->flush();
|
||||
|
||||
return $this->redirect($this->generateUrl('chill_activity_activitytype_edit', array('id' => $id)));
|
||||
}
|
||||
|
||||
return $this->render('ChillActivityBundle:ActivityType:edit.html.twig', array(
|
||||
'entity' => $entity,
|
||||
'edit_form' => $editForm->createView(),
|
||||
));
|
||||
}
|
||||
}
|
@ -1,9 +1,7 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Chill\ActivityBundle\Controller;
|
||||
|
||||
|
||||
use Chill\MainBundle\CRUD\Controller\CRUDController;
|
||||
use Chill\MainBundle\Pagination\PaginatorInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace Chill\ActivityBundle\Controller;
|
||||
|
||||
use Chill\MainBundle\CRUD\Controller\CRUDController;
|
||||
use Chill\MainBundle\Pagination\PaginatorInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
class AdminActivityTypeController extends CRUDController
|
||||
{
|
||||
/**
|
||||
* @param string $action
|
||||
* @param \Doctrine\ORM\QueryBuilder|mixed $query
|
||||
* @param Request $request
|
||||
* @param PaginatorInterface $paginator
|
||||
* @return \Doctrine\ORM\QueryBuilder|mixed
|
||||
*/
|
||||
protected function orderQuery(string $action, $query, Request $request, PaginatorInterface $paginator)
|
||||
{
|
||||
/** @var \Doctrine\ORM\QueryBuilder $query */
|
||||
return $query->orderBy('e.id', 'ASC');
|
||||
}
|
||||
}
|
@ -96,6 +96,27 @@ class ChillActivityExtension extends Extension implements PrependExtensionInterf
|
||||
{
|
||||
$container->prependExtensionConfig('chill_main', [
|
||||
'cruds' => [
|
||||
[
|
||||
'class' => \Chill\ActivityBundle\Entity\ActivityType::class,
|
||||
'name' => 'activity_type',
|
||||
'base_path' => '/admin/activity_type',
|
||||
'form_class' => \Chill\ActivityBundle\Form\ActivityTypeType::class,
|
||||
'controller' => \Chill\ActivityBundle\Controller\AdminActivityTypeController::class,
|
||||
'actions' => [
|
||||
'index' => [
|
||||
'template' => '@ChillActivity/ActivityType/index.html.twig',
|
||||
'role' => 'ROLE_ADMIN'
|
||||
],
|
||||
'new' => [
|
||||
'role' => 'ROLE_ADMIN',
|
||||
'template' => '@ChillActivity/ActivityType/new.html.twig',
|
||||
],
|
||||
'edit' => [
|
||||
'role' => 'ROLE_ADMIN',
|
||||
'template' => '@ChillActivity/ActivityType/edit.html.twig',
|
||||
]
|
||||
]
|
||||
],
|
||||
[
|
||||
'class' => \Chill\ActivityBundle\Entity\ActivityTypeCategory::class,
|
||||
'name' => 'activity_type_category',
|
||||
|
@ -33,15 +33,7 @@ class ActivityTypeType extends AbstractType
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$resolver->setDefaults(array(
|
||||
'data_class' => 'Chill\ActivityBundle\Entity\ActivityType'
|
||||
'data_class' => \Chill\ActivityBundle\Entity\ActivityType::class
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getBlockPrefix()
|
||||
{
|
||||
return 'chill_activitybundle_activitytype';
|
||||
}
|
||||
}
|
||||
|
@ -1,40 +1,12 @@
|
||||
{#
|
||||
* Copyright (C) 2014, Champs Libres Cooperative SCRLFS, <http://www.champs-libres.coop>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#}
|
||||
{% extends "@ChillActivity/Admin/layout_activity.html.twig" %}
|
||||
|
||||
{% block admin_content %}
|
||||
<h1>{{ 'ActivityType edit'|trans }}</h1>
|
||||
|
||||
{{ form_start(edit_form) }}
|
||||
{{ form_row(edit_form.active) }}
|
||||
{{ form_row(edit_form.name) }}
|
||||
|
||||
|
||||
|
||||
<ul class="record_actions">
|
||||
<li class="cancel">
|
||||
<a href="{{ path('chill_activity_activitytype') }}" class="sc-button bt-cancel">
|
||||
{{ 'Back to the list'|trans }}
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
{{ form_widget(edit_form.submit, { 'attr' : { 'class' : 'sc-button bt-update' } } ) }}
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
{{ form_end(edit_form) }}
|
||||
{% block title %}
|
||||
{% include('@ChillMain/CRUD/_edit_title.html.twig') %}
|
||||
{% endblock %}
|
||||
|
||||
{% block layout_wvm_content %}
|
||||
{% embed '@ChillMain/CRUD/_edit_content.html.twig' %}
|
||||
{% block content_form_actions_view %}{% endblock %}
|
||||
{% block content_form_actions_save_and_show %}{% endblock %}
|
||||
{% endembed %}
|
||||
{% endblock %}
|
||||
|
@ -30,7 +30,7 @@
|
||||
<tbody>
|
||||
{% for entity in entities %}
|
||||
<tr>
|
||||
<td><a href="{{ path('chill_activity_activitytype_show', { 'id': entity.id }) }}">{{ entity.name|localize_translatable_string }}</a></td>
|
||||
<td>{{ entity.name|localize_translatable_string }}</td>
|
||||
<td style="text-align:center;">
|
||||
{%- if entity.active -%}
|
||||
<i class="fa fa-check-square-o"></i>
|
||||
@ -41,10 +41,7 @@
|
||||
<td>
|
||||
<ul class="record_actions">
|
||||
<li>
|
||||
<a href="{{ path('chill_activity_activitytype_show', { 'id': entity.id }) }}" class="sc-button bt-show" title="{{ 'show'|trans }}"></a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="{{ path('chill_activity_activitytype_edit', { 'id': entity.id }) }}" class="sc-button bt-edit" title="{{ 'edit'|trans }}"></a>
|
||||
<a href="{{ path('chill_crud_activity_type_edit', { 'id': entity.id }) }}" class="sc-button bt-edit" title="{{ 'edit'|trans }}"></a>
|
||||
</li>
|
||||
</ul>
|
||||
</td>
|
||||
@ -55,7 +52,7 @@
|
||||
|
||||
<ul class="record_actions">
|
||||
<li>
|
||||
<a href="{{ path('chill_activity_activitytype_new') }}" class="sc-button bt-create">
|
||||
<a href="{{ path('chill_crud_activity_type_new') }}" class="sc-button bt-create">
|
||||
{{ 'Create a new activity type'|trans }}
|
||||
</a>
|
||||
</li>
|
||||
|
@ -1,38 +1,11 @@
|
||||
{#
|
||||
* Copyright (C) 2014, Champs Libres Cooperative SCRLFS, <http://www.champs-libres.coop>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#}
|
||||
{% extends "@ChillActivity/Admin/layout_activity.html.twig" %}
|
||||
|
||||
{% block admin_content %}
|
||||
<h1>{{ 'ActivityType creation'|trans }}</h1>
|
||||
|
||||
{{ form_start(form) }}
|
||||
{{ form_row(form.active) }}
|
||||
{{ form_row(form.name) }}
|
||||
|
||||
<ul class="record_actions">
|
||||
<li class="cancel">
|
||||
<a href="{{ path('chill_activity_activitytype') }}" class="sc-button bt-cancel">
|
||||
{{ 'Back to the list'|trans }}
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
{{ form_widget(form.submit, { 'attr' : { 'class' : 'sc-button bt-new' } } ) }}
|
||||
</li>
|
||||
</ul>
|
||||
{{ form_end(form) }}
|
||||
|
||||
{% block title %}
|
||||
{% include('@ChillMain/CRUD/_new_title.html.twig') %}
|
||||
{% endblock %}
|
||||
|
||||
{% block layout_wvm_content %}
|
||||
{% embed '@ChillMain/CRUD/_new_content.html.twig' %}
|
||||
{% block content_form_actions_save_and_show %}{% endblock %}
|
||||
{% endembed %}
|
||||
{% endblock %}
|
||||
|
@ -1,42 +0,0 @@
|
||||
{#
|
||||
* Copyright (C) 2014, Champs Libres Cooperative SCRLFS, <http://www.champs-libres.coop>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#}
|
||||
{% extends "@ChillActivity/Admin/layout_activity.html.twig" %}
|
||||
|
||||
{% block admin_content %}
|
||||
<h1>{{ 'ActivityType'|trans }}</h1>
|
||||
|
||||
<table class="record_properties">
|
||||
<tbody>
|
||||
<tr>
|
||||
<th>{{ 'Name'|trans }}</th>
|
||||
<td>{{ entity.name|localize_translatable_string }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<ul class="record_actions">
|
||||
<li class="cancel">
|
||||
<a href="{{ path('chill_activity_activitytype') }}" class="sc-button bt-cancel">
|
||||
{{ 'Back to the list'|trans }}
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="{{ path('chill_activity_activitytype_edit', { 'id': entity.id }) }}" class="sc-button bt-edit">
|
||||
{{ 'Edit'|trans }}
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
{% endblock %}
|
@ -10,11 +10,6 @@ chill_activity_activityreasoncategory:
|
||||
resource: "@ChillActivityBundle/config/routes/activityreasoncategory.yaml"
|
||||
prefix: /
|
||||
|
||||
chill_activity_activitytype:
|
||||
resource: "@ChillActivityBundle/config/routes/activitytype.yaml"
|
||||
prefix: /
|
||||
|
||||
|
||||
chill_admin_activity_index:
|
||||
path: /{_locale}/admin/activity
|
||||
controller: Chill\ActivityBundle\Controller\AdminController::indexActivityAction
|
||||
@ -34,6 +29,15 @@ chill_admin_activity_redirect_to_admin_index:
|
||||
order: 0
|
||||
label: Main admin menu
|
||||
|
||||
chill_activity_type_admin:
|
||||
path: /{_locale}/admin/activity/type
|
||||
controller: cscrud_activity_type_controller:index
|
||||
options:
|
||||
menus:
|
||||
admin_activity:
|
||||
order: 2020
|
||||
label: 'Activity Types'
|
||||
|
||||
chill_activity_type_category_admin:
|
||||
path: /{_locale}/admin/activity/type_category
|
||||
controller: cscrud_activity_type_category_controller:index
|
||||
|
@ -1,35 +0,0 @@
|
||||
chill_activity_activitytype:
|
||||
path: /{_locale}/admin/activitytype/
|
||||
controller: Chill\ActivityBundle\Controller\ActivityTypeController::indexAction
|
||||
options:
|
||||
menus:
|
||||
admin_activity:
|
||||
order: 2020
|
||||
label: "Activity Types"
|
||||
|
||||
chill_activity_activitytype_show:
|
||||
path: /{_locale}/admin/activitytype/{id}/show
|
||||
controller: Chill\ActivityBundle\Controller\ActivityTypeController::showAction
|
||||
|
||||
chill_activity_activitytype_new:
|
||||
path: /{_locale}/admin/activitytype/new
|
||||
controller: Chill\ActivityBundle\Controller\ActivityTypeController::newAction
|
||||
|
||||
chill_activity_activitytype_create:
|
||||
path: /{_locale}/admin/activitytype/create
|
||||
controller: Chill\ActivityBundle\Controller\ActivityTypeController::createAction
|
||||
methods: POST
|
||||
|
||||
chill_activity_activitytype_edit:
|
||||
path: /{_locale}/admin/activitytype/{id}/edit
|
||||
controller: Chill\ActivityBundle\Controller\ActivityTypeController::editAction
|
||||
|
||||
chill_activity_activitytype_update:
|
||||
path: /{_locale}/admin/activitytype/{id}/update
|
||||
controller: Chill\ActivityBundle\Controller\ActivityTypeController::updateAction
|
||||
methods: [POST, PUT]
|
||||
|
||||
chill_activity_activitytype_delete:
|
||||
path: /{_locale}/admin/activitytype/{id}/delete
|
||||
controller: Chill\ActivityBundle\Controller\ActivityTypeController::deleteAction
|
||||
methods: [POST, DELETE]
|
@ -79,6 +79,15 @@ Activity Reasons: Sujets d'une activité
|
||||
Activity Reasons Category: Catégories de sujet d'activités
|
||||
Activity Types Categories: Catégories des types d'activité
|
||||
|
||||
# Crud
|
||||
crud:
|
||||
activity_type:
|
||||
title_new: Nouveau type d'activité
|
||||
title_edit: Edition d'un type d'activité
|
||||
activity_type_category:
|
||||
title_new: Nouvelle catégorie de type d'activité
|
||||
title_edit: Edition d'une catégorie de type d'activité
|
||||
|
||||
# activity reason admin
|
||||
ActivityReason list: Liste des sujets
|
||||
Create a new activity reason: Créer un nouveau sujet
|
||||
@ -99,20 +108,13 @@ 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
|
||||
|
||||
# activity type admin
|
||||
ActivityTypeCategory list: Liste des catégories des types d'activité
|
||||
Create a new activity type category: Créer une nouvelle catégorie de type d'activité
|
||||
crud:
|
||||
activity_type_category:
|
||||
title_new: Nouvelle catégorie de type d'activité
|
||||
title_edit: Edition d'une catégorie de type d'activité
|
||||
|
||||
# activitycategory type admin
|
||||
# activity type type admin
|
||||
ActivityType list: Types d'activités
|
||||
Create a new activity type: Créer un nouveau type d'activité
|
||||
ActivityType creation: Nouveau type d'activité
|
||||
ActivityType: Type d'activité
|
||||
ActivityType edit: Modifier une activité
|
||||
|
||||
# activity type category admin
|
||||
ActivityTypeCategory list: Liste des catégories des types d'activité
|
||||
Create a new activity type category: Créer une nouvelle catégorie de type d'activité
|
||||
|
||||
# activity delete
|
||||
Remove activity: Supprimer une activité
|
||||
|
Loading…
x
Reference in New Issue
Block a user