mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
Add Motive API and related fixtures to ChillTicketBundle
This update introduces the Motive API Controller to the ChillTicket bundle with its corresponding service configuration. Also included are related data fixtures for loading motive information. The motive entity has been updated to improve its serialization properties and new types were added to the TypeScript definitions of the bundle.
This commit is contained in:
parent
ecdc1e25bf
commit
71a3a1924a
25
src/Bundle/ChillTicketBundle/chill.api.specs.yaml
Normal file
25
src/Bundle/ChillTicketBundle/chill.api.specs.yaml
Normal file
@ -0,0 +1,25 @@
|
||||
components:
|
||||
schemas:
|
||||
Motive:
|
||||
type: object
|
||||
properties:
|
||||
id:
|
||||
type: integer
|
||||
label:
|
||||
type: object
|
||||
additionalProperties:
|
||||
type: string
|
||||
example:
|
||||
fr: Retard de livraison
|
||||
active:
|
||||
type: boolean
|
||||
|
||||
paths:
|
||||
/1.0/ticket/motive.json:
|
||||
get:
|
||||
tags:
|
||||
- ticket
|
||||
summary: A list of available ticket's motive
|
||||
responses:
|
||||
200:
|
||||
description: "OK"
|
@ -0,0 +1,25 @@
|
||||
<?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\TicketBundle\Controller;
|
||||
|
||||
use Chill\MainBundle\CRUD\Controller\ApiController;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
final class MotiveApiController extends ApiController
|
||||
{
|
||||
protected function customizeQuery(string $action, Request $request, $query): void
|
||||
{
|
||||
/* @var $query QueryBuilder */
|
||||
$query->andWhere('e.active = TRUE');
|
||||
}
|
||||
}
|
@ -0,0 +1,82 @@
|
||||
<?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\TicketBundle\DataFixtures\ORM;
|
||||
|
||||
use Chill\TicketBundle\Entity\Motive;
|
||||
use Doctrine\Bundle\FixturesBundle\Fixture;
|
||||
use Doctrine\Bundle\FixturesBundle\FixtureGroupInterface;
|
||||
use Doctrine\Persistence\ObjectManager;
|
||||
|
||||
final class LoadMotives extends Fixture implements FixtureGroupInterface
|
||||
{
|
||||
public static function getGroups(): array
|
||||
{
|
||||
return ['ticket'];
|
||||
}
|
||||
|
||||
public function load(ObjectManager $manager)
|
||||
{
|
||||
foreach (explode("\n", self::MOTIVES) as $label) {
|
||||
if ('' === trim($label)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$motive = new Motive();
|
||||
$motive->setLabel(['fr' => trim($label)]);
|
||||
|
||||
$manager->persist($motive);
|
||||
}
|
||||
|
||||
$manager->flush();
|
||||
}
|
||||
|
||||
private const MOTIVES = <<<'TXT'
|
||||
Coordonnées
|
||||
Horaire de passage
|
||||
Retard de livraison
|
||||
Erreur de livraison
|
||||
Colis incomplet
|
||||
MATLOC
|
||||
Retard DASRI
|
||||
Planning d'astreintes
|
||||
Planning des tournées
|
||||
Contrôle pompe
|
||||
Changement de rendez-vous
|
||||
Renseignement facturation/prestation
|
||||
Décès patient
|
||||
Demande de prise en charge
|
||||
Information absence
|
||||
Demande bulletin de situation
|
||||
Difficultés accès logement
|
||||
Déplacement inutile
|
||||
Problème de prélèvement/de commande
|
||||
Parc auto
|
||||
Demande d'admission
|
||||
Retrait de matériel au domicile
|
||||
Comptes-rendus
|
||||
Démarchage commercial
|
||||
Demande de transport
|
||||
Demande laboratoire
|
||||
Demande admission
|
||||
Suivi de prise en charge
|
||||
Mauvaise adresse
|
||||
Patient absent
|
||||
Annulation
|
||||
Colis perdu
|
||||
Changement de rendez-vous
|
||||
Coordination interservices
|
||||
Problème de substitution produits
|
||||
Problème ordonnance
|
||||
Réclamations facture
|
||||
Préparation urgente
|
||||
TXT;
|
||||
}
|
@ -11,16 +11,54 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\TicketBundle\DependencyInjection;
|
||||
|
||||
use Chill\TicketBundle\Controller\MotiveApiController;
|
||||
use Chill\TicketBundle\Entity\Motive;
|
||||
use Symfony\Component\Config\FileLocator;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
|
||||
use Symfony\Component\DependencyInjection\Loader;
|
||||
use Symfony\Component\DependencyInjection\Extension\Extension;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
class ChillTicketExtension extends Extension
|
||||
class ChillTicketExtension extends Extension implements PrependExtensionInterface
|
||||
{
|
||||
public function load(array $configs, ContainerBuilder $container)
|
||||
{
|
||||
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../config'));
|
||||
$loader->load('services.yaml');
|
||||
}
|
||||
|
||||
public function prepend(ContainerBuilder $container)
|
||||
{
|
||||
$this->prependApi($container);
|
||||
}
|
||||
|
||||
private function prependApi(ContainerBuilder $container): void
|
||||
{
|
||||
$container->prependExtensionConfig('chill_main', [
|
||||
'apis' => [
|
||||
[
|
||||
'class' => Motive::class,
|
||||
'name' => 'motive',
|
||||
'base_path' => '/api/1.0/ticket/motive',
|
||||
'controller' => MotiveApiController::class,
|
||||
'base_role' => 'ROLE_USER',
|
||||
'actions' => [
|
||||
'_index' => [
|
||||
'methods' => [
|
||||
Request::METHOD_GET => true,
|
||||
Request::METHOD_HEAD => true,
|
||||
],
|
||||
],
|
||||
'_entity' => [
|
||||
'methods' => [
|
||||
Request::METHOD_GET => true,
|
||||
Request::METHOD_HEAD => true,
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -12,20 +12,25 @@ declare(strict_types=1);
|
||||
namespace Chill\TicketBundle\Entity;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Serializer\Annotation as Serializer;
|
||||
|
||||
#[ORM\Entity()]
|
||||
#[ORM\Table(name: 'motive', schema: 'chill_ticket')]
|
||||
#[Serializer\DiscriminatorMap(typeProperty: 'type', mapping: ['ticket_motive' => Motive::class])]
|
||||
class Motive
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::INTEGER, nullable: false)]
|
||||
#[ORM\GeneratedValue(strategy: 'AUTO')]
|
||||
#[Serializer\Groups(['read'])]
|
||||
private ?int $id = null;
|
||||
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::JSON, nullable: false, options: ['default' => '[]'])]
|
||||
#[Serializer\Groups(['read'])]
|
||||
private array $label = [];
|
||||
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN, nullable: false, options: ['default' => true])]
|
||||
#[Serializer\Groups(['read'])]
|
||||
private bool $active = true;
|
||||
|
||||
public function isActive(): bool
|
||||
|
@ -1,3 +1,11 @@
|
||||
import {TranslatableString} from "../../../../ChillMainBundle/Resources/public/types";
|
||||
|
||||
export interface Ticket {
|
||||
id: number
|
||||
}
|
||||
|
||||
export interface Motive {
|
||||
id: number,
|
||||
active: boolean,
|
||||
label: TranslatableString
|
||||
}
|
||||
|
@ -11,3 +11,6 @@ services:
|
||||
Chill\TicketBundle\Action\Ticket\Handler\:
|
||||
resource: '../Action/Ticket/Handler/'
|
||||
|
||||
|
||||
Chill\TicketBundle\DataFixtures\:
|
||||
resource: '../DataFixtures/'
|
||||
|
Loading…
x
Reference in New Issue
Block a user