mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-13 13:54:23 +00:00
start CRUD controllers asideActivityBundle
This commit is contained in:
parent
ea2d6eac7b
commit
645252fd85
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace Chill\AsideActivityBundle\Controller;
|
||||
|
||||
use Chill\MainBundle\CRUD\Controller\CRUDController;
|
||||
|
||||
|
||||
/**
|
||||
* Class AsideActivityBundle
|
||||
*
|
||||
* @package Chill\AsideActivityBundle\Controller
|
||||
*/
|
||||
class AsideActivityCategoryController extends CRUDController
|
||||
{
|
||||
|
||||
}
|
@ -1,17 +1,17 @@
|
||||
<?php
|
||||
|
||||
use Chill\AsideActivityBundle\Form\AsideActivityType;
|
||||
use Doctrine\ORM\EntityManager;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
namespace Chill\AsideActivityBundle\Controller;
|
||||
|
||||
class AsideArticleController extends AbstractController
|
||||
use Chill\MainBundle\CRUD\Controller\CRUDController;
|
||||
|
||||
|
||||
/**
|
||||
* Class AsideActivityBundle
|
||||
*
|
||||
* @package Chill\AsideActivityBundle\Controller
|
||||
*/
|
||||
|
||||
class AsideActivityController extends CRUDController
|
||||
{
|
||||
public function new(EntityManager $entityManager)
|
||||
{
|
||||
$form = $this->createForm(AsideActivityType::class);
|
||||
|
||||
return $this->render('asideActivity_new.html.twig', [
|
||||
'asideActivityForm' => $form->createView(),
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -12,9 +12,10 @@ namespace Chill\AsideActivityBundle\DependencyInjection;
|
||||
use Symfony\Component\Config\FileLocator;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Extension\Extension;
|
||||
use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
|
||||
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
|
||||
use Symfony\Component\DependencyInjection\Loader;
|
||||
|
||||
final class ChillAsideActivityExtension extends Extension
|
||||
final class ChillAsideActivityExtension extends Extension implements PrependExtensionInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
@ -23,11 +24,54 @@ final class ChillAsideActivityExtension extends Extension
|
||||
*/
|
||||
public function load(array $configs, ContainerBuilder $container): void
|
||||
{
|
||||
$loader = new PhpFileLoader(
|
||||
$container,
|
||||
new FileLocator(__DIR__ . '/../Resources/config')
|
||||
);
|
||||
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../config'));
|
||||
$loader->load('services.yaml');
|
||||
}
|
||||
|
||||
$loader->load('services.php');
|
||||
public function prepend(ContainerBuilder $container)
|
||||
{
|
||||
$this->prependRoute($container);
|
||||
$this->prependCruds($container);
|
||||
}
|
||||
|
||||
protected function prependRoute(ContainerBuilder $container)
|
||||
{
|
||||
//declare routes for task bundle
|
||||
$container->prependExtensionConfig('chill_main', array(
|
||||
'routing' => array(
|
||||
'resources' => array(
|
||||
'@ChillAsideActivityBundle/config/routes.yaml',
|
||||
)
|
||||
)
|
||||
));
|
||||
}
|
||||
|
||||
protected function prependCruds(ContainerBuilder $container)
|
||||
{
|
||||
$container->prependExtensionConfig('chill_main', [
|
||||
'cruds' => [
|
||||
[
|
||||
'class' => \Chill\AsideActivityBundle\Entity\AsideActivityCategory::class,
|
||||
'name' => 'aside_activity_category',
|
||||
'base_path' => '/admin/asideactivity/category',
|
||||
'form_class' => \Chill\AsideActivityBundle\Form\AsideActivityCategoryType::class,
|
||||
'controller' => \Chill\AsideActivityBundle\Controller\AsideActivityCategoryController::class,
|
||||
'actions' => [
|
||||
'index' => [
|
||||
'template' => '@ChillAsideActivity/asideActivityCategory/index.html.twig',
|
||||
'role' => 'ROLE_ADMIN'
|
||||
],
|
||||
'new' => [
|
||||
'role' => 'ROLE_ADMIN',
|
||||
'template' => '@ChillAsideActivity/asideActivityCategory/new.html.twig',
|
||||
],
|
||||
'edit' => [
|
||||
'role' => 'ROLE_ADMIN',
|
||||
'template' => '@ChillAsideActivity/asideActivityCategory/edit.html.twig',
|
||||
]
|
||||
]
|
||||
],
|
||||
]
|
||||
]);
|
||||
}
|
||||
}
|
@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace Chill\AsideActivityBundle\Form;
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
|
@ -2,21 +2,15 @@
|
||||
|
||||
namespace Chill\AsideActivityBundle\Form;
|
||||
|
||||
use Chill\AsideActivityBundle\Entity\AsideActivityCategory;
|
||||
use Chill\AsideActivityBundle\Entity\AsideActivity;
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\Form\Extension\Core\Type\DateType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\NumberType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
class AsideActivityType extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
@ -37,20 +31,6 @@ class AsideActivityType extends AbstractType
|
||||
'placeholder' => 'L’agent pour qui l\'activité annexe est créée',
|
||||
'choice_label' => 'username'
|
||||
])
|
||||
->add('type', EntityType::class,
|
||||
[
|
||||
'label' => 'Type',
|
||||
'required' => true,
|
||||
'class' => AsideActivityCategory::class,
|
||||
'choice_label' => 'title'
|
||||
])
|
||||
->add('date', DateType::class, [
|
||||
'label' => 'Date',
|
||||
'required' => true
|
||||
])
|
||||
->add('duration', NumberType::class, [
|
||||
'label' => 'Durée'
|
||||
])
|
||||
->add('note', TextareaType::class, [
|
||||
'label' => 'Note'
|
||||
])
|
||||
|
@ -1,14 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
|
||||
|
||||
return static function (ContainerConfigurator $container) {
|
||||
|
||||
};
|
@ -0,0 +1,27 @@
|
||||
{% extends '@ChillMain/Admin/layout.html.twig' %}
|
||||
|
||||
{% block title %}
|
||||
{% include('@ChillMain/CRUD/_new_title.html.twig') %}
|
||||
{% endblock %}
|
||||
|
||||
{% block admin_content %}
|
||||
{% embed '@ChillMain/CRUD/_new_content.html.twig' %}
|
||||
{% block content_form_actions_save_and_show %}{% endblock %}
|
||||
{% endembed %}
|
||||
{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
|
||||
<h1>Creér un activité annexe</h1>
|
||||
|
||||
{{ form_start(asideActivityForm) }}
|
||||
|
||||
<label>Utilisateur</label>
|
||||
<input name='user' value='{{ app.user.username }}'>
|
||||
|
||||
{{ form_widget(asideActivityForm) }}
|
||||
|
||||
<button type="submit" class="btn btn-primary">Creér</button>
|
||||
{{ form_end(asideActivityForm)}}
|
||||
|
||||
{% endblock %}
|
@ -0,0 +1,12 @@
|
||||
{% extends "@ChillActivity/Admin/layout_activity.html.twig" %}
|
||||
|
||||
{% 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 %}
|
@ -0,0 +1,60 @@
|
||||
{#
|
||||
* 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 list'|trans }}</h1>
|
||||
|
||||
<table class="records_list">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{{ 'Name'|trans }}</th>
|
||||
<th>{{ 'Active'|trans }}</th>
|
||||
<th>{{ 'Actions'|trans }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for entity in entities %}
|
||||
<tr>
|
||||
<td>{{ entity.name|localize_translatable_string }}</td>
|
||||
<td style="text-align:center;">
|
||||
{%- if entity.active -%}
|
||||
<i class="fa fa-check-square-o"></i>
|
||||
{%- else -%}
|
||||
<i class="fa fa-square-o"></i>
|
||||
{%- endif -%}
|
||||
</td>
|
||||
<td>
|
||||
<ul class="record_actions">
|
||||
<li>
|
||||
<a href="{{ path('chill_crud_activity_type_edit', { 'id': entity.id }) }}" class="sc-button bt-edit" title="{{ 'edit'|trans }}"></a>
|
||||
</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<ul class="record_actions">
|
||||
<li>
|
||||
<a href="{{ path('chill_crud_activity_type_new') }}" class="sc-button bt-create">
|
||||
{{ 'Create a new activity type'|trans }}
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
{% endblock %}
|
@ -0,0 +1,11 @@
|
||||
{% extends "@ChillActivity/Admin/layout_activity.html.twig" %}
|
||||
|
||||
{% 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,11 +0,0 @@
|
||||
{% extends '@ChillMain/Admin/layout.html.twig' %}
|
||||
|
||||
{% block title %}
|
||||
{% include('@ChillMain/CRUD/_new_title.html.twig') %}
|
||||
{% endblock %}
|
||||
|
||||
{% block admin_content %}
|
||||
{% embed '@ChillMain/CRUD/_new_content.html.twig' %}
|
||||
{% block content_form_actions_save_and_show %}{% endblock %}
|
||||
{% endembed %}
|
||||
{% endblock %}
|
@ -0,0 +1,3 @@
|
||||
chill_asideactivities_controllers:
|
||||
resource: "@ChillAsideActivityBundle/Controller"
|
||||
type: annotation
|
Loading…
x
Reference in New Issue
Block a user