mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 13:24:25 +00:00
new entity ActivityTypeCategory + CRUD
This commit is contained in:
parent
3a50aea138
commit
24a7d7b34b
@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
namespace Chill\ActivityBundle\Controller;
|
||||||
|
|
||||||
|
|
||||||
|
use Chill\MainBundle\CRUD\Controller\CRUDController;
|
||||||
|
use Chill\MainBundle\Pagination\PaginatorInterface;
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
|
||||||
|
class AdminActivityTypeCategoryController 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');
|
||||||
|
}
|
||||||
|
}
|
@ -3,7 +3,7 @@
|
|||||||
/*
|
/*
|
||||||
* Chill is a software for social workers
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS,
|
* Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS,
|
||||||
* <http://www.champs-libres.coop>, <info@champs-libres.coop>
|
* <http://www.champs-libres.coop>, <info@champs-libres.coop>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
@ -44,7 +44,7 @@ class ChillActivityExtension extends Extension implements PrependExtensionInterf
|
|||||||
{
|
{
|
||||||
$configuration = new Configuration();
|
$configuration = new Configuration();
|
||||||
$config = $this->processConfiguration($configuration, $configs);
|
$config = $this->processConfiguration($configuration, $configs);
|
||||||
|
|
||||||
$container->setParameter('chill_activity.form.time_duration', $config['form']['time_duration']);
|
$container->setParameter('chill_activity.form.time_duration', $config['form']['time_duration']);
|
||||||
|
|
||||||
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../config'));
|
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../config'));
|
||||||
@ -57,17 +57,18 @@ class ChillActivityExtension extends Extension implements PrependExtensionInterf
|
|||||||
$loader->load('services/form.yaml');
|
$loader->load('services/form.yaml');
|
||||||
$loader->load('services/templating.yaml');
|
$loader->load('services/templating.yaml');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function prepend(ContainerBuilder $container)
|
public function prepend(ContainerBuilder $container)
|
||||||
{
|
{
|
||||||
$this->prependRoutes($container);
|
$this->prependRoutes($container);
|
||||||
$this->prependAuthorization($container);
|
$this->prependAuthorization($container);
|
||||||
|
$this->prependCruds($container);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-PHPdoc)
|
/* (non-PHPdoc)
|
||||||
* @see \Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface::prepend()
|
* @see \Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface::prepend()
|
||||||
*/
|
*/
|
||||||
public function prependRoutes(ContainerBuilder $container)
|
public function prependRoutes(ContainerBuilder $container)
|
||||||
{
|
{
|
||||||
//add routes for custom bundle
|
//add routes for custom bundle
|
||||||
$container->prependExtensionConfig('chill_main', array(
|
$container->prependExtensionConfig('chill_main', array(
|
||||||
@ -78,7 +79,7 @@ class ChillActivityExtension extends Extension implements PrependExtensionInterf
|
|||||||
)
|
)
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function prependAuthorization(ContainerBuilder $container)
|
public function prependAuthorization(ContainerBuilder $container)
|
||||||
{
|
{
|
||||||
$container->prependExtensionConfig('security', array(
|
$container->prependExtensionConfig('security', array(
|
||||||
@ -90,4 +91,33 @@ class ChillActivityExtension extends Extension implements PrependExtensionInterf
|
|||||||
)
|
)
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function prependCruds(ContainerBuilder $container)
|
||||||
|
{
|
||||||
|
$container->prependExtensionConfig('chill_main', [
|
||||||
|
'cruds' => [
|
||||||
|
[
|
||||||
|
'class' => \Chill\ActivityBundle\Entity\ActivityTypeCategory::class,
|
||||||
|
'name' => 'activity_type_category',
|
||||||
|
'base_path' => '/admin/activity_type_category',
|
||||||
|
'form_class' => \Chill\ActivityBundle\Form\ActivityTypeCategoryType::class,
|
||||||
|
'controller' => \Chill\ActivityBundle\Controller\AdminActivityTypeCategoryController::class,
|
||||||
|
'actions' => [
|
||||||
|
'index' => [
|
||||||
|
'template' => '@ChillActivity/ActivityTypeCategory/index.html.twig',
|
||||||
|
'role' => 'ROLE_ADMIN'
|
||||||
|
],
|
||||||
|
'new' => [
|
||||||
|
'role' => 'ROLE_ADMIN',
|
||||||
|
'template' => '@ChillActivity/ActivityTypeCategory/new.html.twig',
|
||||||
|
],
|
||||||
|
'edit' => [
|
||||||
|
'role' => 'ROLE_ADMIN',
|
||||||
|
'template' => '@ChillActivity/ActivityTypeCategory/edit.html.twig',
|
||||||
|
]
|
||||||
|
]
|
||||||
|
]
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
123
src/Bundle/ChillActivityBundle/Entity/ActivityTypeCategory.php
Normal file
123
src/Bundle/ChillActivityBundle/Entity/ActivityTypeCategory.php
Normal file
@ -0,0 +1,123 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
* Copyright (C) 2015, 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Chill\ActivityBundle\Entity;
|
||||||
|
|
||||||
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class ActivityTypeCateogry
|
||||||
|
*
|
||||||
|
* @package Chill\ActivityBundle\Entity
|
||||||
|
* @ORM\Entity()
|
||||||
|
* @ORM\Table(name="activitytypecategory")
|
||||||
|
* @ORM\HasLifecycleCallbacks()
|
||||||
|
*/
|
||||||
|
class ActivityTypeCategory
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @ORM\Id
|
||||||
|
* @ORM\Column(name="id", type="integer")
|
||||||
|
* @ORM\GeneratedValue(strategy="AUTO")
|
||||||
|
*/
|
||||||
|
private ?int $id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="json_array")
|
||||||
|
*/
|
||||||
|
private array $name = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="boolean")
|
||||||
|
*/
|
||||||
|
private bool $active = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get id
|
||||||
|
*
|
||||||
|
* @return integer
|
||||||
|
*/
|
||||||
|
public function getId(): int
|
||||||
|
{
|
||||||
|
return $this->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set name
|
||||||
|
*/
|
||||||
|
public function setName(array $name): self
|
||||||
|
{
|
||||||
|
$this->name = $name;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get name
|
||||||
|
*
|
||||||
|
* @return array | string
|
||||||
|
*/
|
||||||
|
public function getName(?string $locale = null)
|
||||||
|
{
|
||||||
|
if ($locale) {
|
||||||
|
if (isset($this->name[$locale])) {
|
||||||
|
return $this->name[$locale];
|
||||||
|
} else {
|
||||||
|
foreach ($this->name as $name) {
|
||||||
|
if (!empty($name)) {
|
||||||
|
return $name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return '';
|
||||||
|
} else {
|
||||||
|
return $this->name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get active
|
||||||
|
* return true if the category type is active.
|
||||||
|
*/
|
||||||
|
public function getActive(): bool
|
||||||
|
{
|
||||||
|
return $this->active;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is active
|
||||||
|
* return true if the category type is active
|
||||||
|
*/
|
||||||
|
public function isActive(): bool
|
||||||
|
{
|
||||||
|
return $this->getActive();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set active
|
||||||
|
* set to true if the category type is active
|
||||||
|
*/
|
||||||
|
public function setActive(bool $active): self
|
||||||
|
{
|
||||||
|
$this->active = $active;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Chill\ActivityBundle\Form;
|
||||||
|
|
||||||
|
use Chill\ActivityBundle\Entity\ActivityTypeCategory;
|
||||||
|
use Symfony\Component\Form\AbstractType;
|
||||||
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||||
|
use Chill\MainBundle\Form\Type\TranslatableStringFormType;
|
||||||
|
|
||||||
|
class ActivityTypeCategoryType extends AbstractType
|
||||||
|
{
|
||||||
|
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||||
|
{
|
||||||
|
$builder
|
||||||
|
->add('name', TranslatableStringFormType::class)
|
||||||
|
->add('active', ChoiceType::class, array(
|
||||||
|
'choices' => array(
|
||||||
|
'Yes' => true,
|
||||||
|
'No' => false
|
||||||
|
),
|
||||||
|
'expanded' => true
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function configureOptions(OptionsResolver $resolver): void
|
||||||
|
{
|
||||||
|
$resolver->setDefaults(array(
|
||||||
|
'data_class' => ActivityTypeCategory::class
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
@ -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,44 @@
|
|||||||
|
{% extends "@ChillActivity/Admin/layout_activity.html.twig" %}
|
||||||
|
|
||||||
|
{% block admin_content %}
|
||||||
|
<h1>{{ 'ActivityTypeCategory 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_category_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_category_new') }}" class="sc-button bt-create">
|
||||||
|
{{ 'Create a new activity type category'|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 %}
|
@ -14,6 +14,7 @@ chill_activity_activitytype:
|
|||||||
resource: "@ChillActivityBundle/config/routes/activitytype.yaml"
|
resource: "@ChillActivityBundle/config/routes/activitytype.yaml"
|
||||||
prefix: /
|
prefix: /
|
||||||
|
|
||||||
|
|
||||||
chill_admin_activity_index:
|
chill_admin_activity_index:
|
||||||
path: /{_locale}/admin/activity
|
path: /{_locale}/admin/activity
|
||||||
controller: Chill\ActivityBundle\Controller\AdminController::indexActivityAction
|
controller: Chill\ActivityBundle\Controller\AdminController::indexActivityAction
|
||||||
@ -32,3 +33,12 @@ chill_admin_activity_redirect_to_admin_index:
|
|||||||
admin_activity:
|
admin_activity:
|
||||||
order: 0
|
order: 0
|
||||||
label: Main admin menu
|
label: Main admin menu
|
||||||
|
|
||||||
|
chill_activity_type_category_admin:
|
||||||
|
path: /{_locale}/admin/activity/type_category
|
||||||
|
controller: cscrud_activity_type_category_controller:index
|
||||||
|
options:
|
||||||
|
menus:
|
||||||
|
admin_activity:
|
||||||
|
order: 2999
|
||||||
|
label: 'Activity Types Categories'
|
||||||
|
@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Chill\Migrations\Activity;
|
||||||
|
|
||||||
|
use Doctrine\DBAL\Schema\Schema;
|
||||||
|
use Doctrine\Migrations\AbstractMigration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Auto-generated Migration: Please modify to your needs!
|
||||||
|
*/
|
||||||
|
final class Version20210401090853 extends AbstractMigration
|
||||||
|
{
|
||||||
|
public function getDescription() : string
|
||||||
|
{
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function up(Schema $schema) : void
|
||||||
|
{
|
||||||
|
// this up() migration is auto-generated, please modify it to your needs
|
||||||
|
$this->addSql('CREATE SEQUENCE activitytypecategory_id_seq INCREMENT BY 1 MINVALUE 1 START 1000');
|
||||||
|
$this->addSql('CREATE TABLE activitytypecategory (id INT NOT NULL, name JSON NOT NULL, active BOOLEAN NOT NULL, PRIMARY KEY(id))');
|
||||||
|
$this->addSql('COMMENT ON COLUMN activitytypecategory.name IS \'(DC2Type:json_array)\'');
|
||||||
|
$this->addSql('INSERT INTO activitytypecategory VALUES(1, \'{"fr": "Défaut", "en": "Default"}\', true)');
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(Schema $schema) : void
|
||||||
|
{
|
||||||
|
// this down() migration is auto-generated, please modify it to your needs
|
||||||
|
$this->addSql('DROP SEQUENCE activitytypecategory_id_seq CASCADE');
|
||||||
|
$this->addSql('DROP TABLE activitytypecategory');
|
||||||
|
}
|
||||||
|
}
|
@ -77,6 +77,7 @@ 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 de sujet d'activités
|
Activity Reasons Category: Catégories de sujet d'activités
|
||||||
|
Activity Types Categories: Catégories des types d'activité
|
||||||
|
|
||||||
# activity reason admin
|
# activity reason admin
|
||||||
ActivityReason list: Liste des sujets
|
ActivityReason list: Liste des sujets
|
||||||
@ -99,6 +100,14 @@ ActivityReasonCategory is active and will be proposed: La catégorie est active
|
|||||||
ActivityReasonCategory is inactive and won't be proposed: La catégorie est inactive et ne sera pas proposée
|
ActivityReasonCategory is inactive and won't be proposed: La catégorie est inactive et ne sera pas proposée
|
||||||
|
|
||||||
# activity type admin
|
# 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
|
||||||
ActivityType list: Types d'activités
|
ActivityType list: Types d'activités
|
||||||
Create a new activity type: Créer un nouveau type d'activité
|
Create a new activity type: Créer un nouveau type d'activité
|
||||||
ActivityType creation: Nouveau type d'activité
|
ActivityType creation: Nouveau type d'activité
|
||||||
|
Loading…
x
Reference in New Issue
Block a user