mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
Create an event budget kind admin entity
This commit is contained in:
parent
4e4d7cfc10
commit
9baf15221f
@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Chill is a software for social workers
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view
|
||||||
|
* the LICENSE file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Chill\EventBundle\Controller\Admin;
|
||||||
|
|
||||||
|
use Chill\MainBundle\CRUD\Controller\CRUDController;
|
||||||
|
use Chill\MainBundle\Pagination\PaginatorInterface;
|
||||||
|
use Doctrine\ORM\QueryBuilder;
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
|
||||||
|
class EventBudgetKindController extends CRUDController
|
||||||
|
{
|
||||||
|
protected function orderQuery(string $action, $query, Request $request, PaginatorInterface $paginator)
|
||||||
|
{
|
||||||
|
/* @var QueryBuilder $query */
|
||||||
|
$query->addOrderBy('e.type', 'ASC');
|
||||||
|
|
||||||
|
return parent::orderQuery($action, $query, $request, $paginator);
|
||||||
|
}
|
||||||
|
}
|
@ -11,8 +11,11 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Chill\EventBundle\DependencyInjection;
|
namespace Chill\EventBundle\DependencyInjection;
|
||||||
|
|
||||||
|
use Chill\EventBundle\Controller\Admin\EventBudgetKindController;
|
||||||
use Chill\EventBundle\Controller\EventThemeController;
|
use Chill\EventBundle\Controller\EventThemeController;
|
||||||
|
use Chill\EventBundle\Entity\EventBudgetKind;
|
||||||
use Chill\EventBundle\Entity\EventTheme;
|
use Chill\EventBundle\Entity\EventTheme;
|
||||||
|
use Chill\EventBundle\Form\EventBudgetKindType;
|
||||||
use Chill\EventBundle\Form\EventThemeType;
|
use Chill\EventBundle\Form\EventThemeType;
|
||||||
use Chill\EventBundle\Security\EventVoter;
|
use Chill\EventBundle\Security\EventVoter;
|
||||||
use Chill\EventBundle\Security\ParticipationVoter;
|
use Chill\EventBundle\Security\ParticipationVoter;
|
||||||
@ -114,6 +117,27 @@ class ChillEventExtension extends Extension implements PrependExtensionInterface
|
|||||||
],
|
],
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
'class' => EventBudgetKind::class,
|
||||||
|
'name' => 'event_budget_kind',
|
||||||
|
'base_path' => '/admin/event/budget',
|
||||||
|
'form_class' => EventBudgetKindType::class,
|
||||||
|
'controller' => EventBudgetKindController::class,
|
||||||
|
'actions' => [
|
||||||
|
'index' => [
|
||||||
|
'template' => '@ChillEvent/Admin/BudgetKind/index.html.twig',
|
||||||
|
'role' => 'ROLE_ADMIN',
|
||||||
|
],
|
||||||
|
'new' => [
|
||||||
|
'role' => 'ROLE_ADMIN',
|
||||||
|
'template' => '@ChillEvent/Admin/BudgetKind/new.html.twig',
|
||||||
|
],
|
||||||
|
'edit' => [
|
||||||
|
'role' => 'ROLE_ADMIN',
|
||||||
|
'template' => '@ChillEvent/Admin/BudgetKind/edit.html.twig',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
18
src/Bundle/ChillEventBundle/Entity/BudgetTypeEnum.php
Normal file
18
src/Bundle/ChillEventBundle/Entity/BudgetTypeEnum.php
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Chill is a software for social workers
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view
|
||||||
|
* the LICENSE file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Chill\EventBundle\Entity;
|
||||||
|
|
||||||
|
enum BudgetTypeEnum: string
|
||||||
|
{
|
||||||
|
case CHARGE = 'Charge';
|
||||||
|
case RESOURCE = 'Resource';
|
||||||
|
}
|
78
src/Bundle/ChillEventBundle/Entity/EventBudgetKind.php
Normal file
78
src/Bundle/ChillEventBundle/Entity/EventBudgetKind.php
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Chill is a software for social workers
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view
|
||||||
|
* the LICENSE file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Chill\EventBundle\Entity;
|
||||||
|
|
||||||
|
use Doctrine\DBAL\Types\Types;
|
||||||
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Type of event budget element.
|
||||||
|
*/
|
||||||
|
#[ORM\Entity]
|
||||||
|
#[ORM\Table(name: 'chill_event_budget_element_kind')]
|
||||||
|
class EventBudgetKind
|
||||||
|
{
|
||||||
|
#[ORM\Id]
|
||||||
|
#[ORM\GeneratedValue]
|
||||||
|
#[ORM\Column(type: Types::INTEGER)]
|
||||||
|
private ?int $id = null;
|
||||||
|
|
||||||
|
#[ORM\Column(type: Types::BOOLEAN, options: ['default' => true])]
|
||||||
|
private bool $isActive = true;
|
||||||
|
|
||||||
|
#[ORM\Column(enumType: BudgetTypeEnum::class)]
|
||||||
|
private BudgetTypeEnum $type;
|
||||||
|
|
||||||
|
#[ORM\Column(type: Types::JSON, length: 255, options: ['default' => '{}', 'jsonb' => true])]
|
||||||
|
private array $name = [];
|
||||||
|
|
||||||
|
public function getId(): ?int
|
||||||
|
{
|
||||||
|
return $this->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getIsActive(): bool
|
||||||
|
{
|
||||||
|
return $this->isActive;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getType(): BudgetTypeEnum
|
||||||
|
{
|
||||||
|
return $this->type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getName(): ?array
|
||||||
|
{
|
||||||
|
return $this->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setIsActive(bool $isActive): self
|
||||||
|
{
|
||||||
|
$this->isActive = $isActive;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setType(BudgetTypeEnum $type): self
|
||||||
|
{
|
||||||
|
$this->type = $type;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setName(array $name): self
|
||||||
|
{
|
||||||
|
$this->name = $name;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
}
|
53
src/Bundle/ChillEventBundle/Form/EventBudgetKindType.php
Normal file
53
src/Bundle/ChillEventBundle/Form/EventBudgetKindType.php
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Chill is a software for social workers
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view
|
||||||
|
* the LICENSE file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Chill\EventBundle\Form;
|
||||||
|
|
||||||
|
use Chill\EventBundle\Entity\BudgetTypeEnum;
|
||||||
|
use Chill\MainBundle\Form\Type\TranslatableStringFormType;
|
||||||
|
use Symfony\Component\Form\AbstractType;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\EnumType;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\NumberType;
|
||||||
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||||
|
|
||||||
|
class EventBudgetKindType extends AbstractType
|
||||||
|
{
|
||||||
|
public function __construct(private readonly TranslatorInterface $translator) {}
|
||||||
|
|
||||||
|
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||||
|
{
|
||||||
|
$builder
|
||||||
|
->add('name', TranslatableStringFormType::class, [
|
||||||
|
'label' => 'Title',
|
||||||
|
])
|
||||||
|
->add('type', EnumType::class, [
|
||||||
|
'class' => BudgetTypeEnum::class,
|
||||||
|
'choice_label' => fn (BudgetTypeEnum $type): string => $this->translator->trans($type->value),
|
||||||
|
'expanded' => true,
|
||||||
|
'multiple' => false,
|
||||||
|
'mapped' => true,
|
||||||
|
'label' => 'event.admin.Select budget type',
|
||||||
|
])
|
||||||
|
->add('isActive', CheckboxType::class, [
|
||||||
|
'label' => 'Actif ?',
|
||||||
|
'required' => false,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function configureOptions(OptionsResolver $resolver)
|
||||||
|
{
|
||||||
|
$resolver
|
||||||
|
->setDefault('class', ChargeKind::class);
|
||||||
|
}
|
||||||
|
}
|
@ -53,6 +53,10 @@ class AdminMenuBuilder implements LocalMenuBuilderInterface
|
|||||||
$menu->addChild('event.theme.label', [
|
$menu->addChild('event.theme.label', [
|
||||||
'route' => 'chill_crud_event_theme_index',
|
'route' => 'chill_crud_event_theme_index',
|
||||||
])->setExtras(['order' => 6540]);
|
])->setExtras(['order' => 6540]);
|
||||||
|
|
||||||
|
$menu->addChild('event.budget.label', [
|
||||||
|
'route' => 'chill_crud_event_budget_kind_index',
|
||||||
|
])->setExtras(['order' => 6550]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getMenuIds(): array
|
public static function getMenuIds(): array
|
||||||
|
@ -0,0 +1,12 @@
|
|||||||
|
{% extends '@ChillMain/CRUD/Admin/index.html.twig' %}
|
||||||
|
|
||||||
|
{% block title %}
|
||||||
|
{% include('@ChillMain/CRUD/_edit_title.html.twig') %}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block admin_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,51 @@
|
|||||||
|
{% extends '@ChillMain/Admin/layoutWithVerticalMenu.html.twig' %}
|
||||||
|
|
||||||
|
{% block title %}{{ 'admin.title.Event budget element list'|trans }}{% endblock title %}
|
||||||
|
|
||||||
|
{% block admin_content %}
|
||||||
|
|
||||||
|
<h1>{{ 'admin.title.Event budget element list'|trans }}</h1>
|
||||||
|
|
||||||
|
<table class="records_list table table-bordered border-dark">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>{{ 'Name'|trans }}</th>
|
||||||
|
<th>{{ 'Type'|trans }}</th>
|
||||||
|
<th>{{ 'Active'|trans }}</th>
|
||||||
|
<th> </th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for entity in entities %}
|
||||||
|
<tr>
|
||||||
|
<td>{{ entity.name|localize_translatable_string }}</td>
|
||||||
|
<td>{{ entity.type.value|trans }}</td>
|
||||||
|
<td style="text-align:center;">
|
||||||
|
{%- if entity.isActive -%}
|
||||||
|
<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_event_budget_kind_edit', { 'id': entity.id }) }}" class="btn btn-edit" title="{{ 'edit'|trans }}"></a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
{{ chill_pagination(paginator) }}
|
||||||
|
|
||||||
|
<ul class="record_actions sticky-form-buttons">
|
||||||
|
<li>
|
||||||
|
<a href="{{ path('chill_crud_event_budget_kind_new') }}" class="btn btn-create">
|
||||||
|
{{ 'admin.new.Create a new budget kind'|trans }}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
{% endblock %}
|
@ -0,0 +1,11 @@
|
|||||||
|
{% extends '@ChillMain/CRUD/Admin/index.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 %}
|
@ -40,4 +40,8 @@ services:
|
|||||||
tags:
|
tags:
|
||||||
- { name: form.type }
|
- { name: form.type }
|
||||||
|
|
||||||
|
Chill\EventBundle\Form\EventBudgetKindType:
|
||||||
|
tags:
|
||||||
|
- { name: form.type }
|
||||||
|
|
||||||
|
|
||||||
|
@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Chill\Migrations\Event;
|
||||||
|
|
||||||
|
use Doctrine\DBAL\Schema\Schema;
|
||||||
|
use Doctrine\Migrations\AbstractMigration;
|
||||||
|
|
||||||
|
final class Version20250505120818 extends AbstractMigration
|
||||||
|
{
|
||||||
|
public function getDescription(): string
|
||||||
|
{
|
||||||
|
return 'Add budget kind admin entity';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function up(Schema $schema): void
|
||||||
|
{
|
||||||
|
$this->addSql(<<<'SQL'
|
||||||
|
CREATE SEQUENCE chill_event_budget_element_kind_id_seq INCREMENT BY 1 MINVALUE 1 START 1
|
||||||
|
SQL);
|
||||||
|
$this->addSql(<<<'SQL'
|
||||||
|
CREATE TABLE chill_event_budget_element_kind (id INT NOT NULL, isActive BOOLEAN DEFAULT true NOT NULL, type VARCHAR(255) NOT NULL, name JSONB DEFAULT '{}' NOT NULL, PRIMARY KEY(id))
|
||||||
|
SQL);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(Schema $schema): void
|
||||||
|
{
|
||||||
|
$this->addSql(<<<'SQL'
|
||||||
|
DROP SEQUENCE chill_event_budget_element_kind_id_seq CASCADE
|
||||||
|
SQL);
|
||||||
|
$this->addSql(<<<'SQL'
|
||||||
|
DROP TABLE chill_event_budget_element_kind
|
||||||
|
SQL);
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user