Merge branch 'testing-2024-03' into add-module-emploi

This commit is contained in:
Julie Lenaerts 2024-06-25 15:54:54 +02:00
commit 1812e84c92
17 changed files with 90 additions and 91 deletions

View File

@ -27,7 +27,7 @@
"popper.js": "^1.16.1", "popper.js": "^1.16.1",
"postcss-loader": "^7.0.2", "postcss-loader": "^7.0.2",
"raw-loader": "^4.0.2", "raw-loader": "^4.0.2",
"sass-loader": "^13.0.0", "sass-loader": "^14.0.0",
"select2": "^4.0.13", "select2": "^4.0.13",
"select2-bootstrap-theme": "0.1.0-beta.10", "select2-bootstrap-theme": "0.1.0-beta.10",
"style-loader": "^3.3.1", "style-loader": "^3.3.1",
@ -56,7 +56,7 @@
"vue": "^3.2.37", "vue": "^3.2.37",
"vue-i18n": "^9.1.6", "vue-i18n": "^9.1.6",
"vue-multiselect": "3.0.0-alpha.2", "vue-multiselect": "3.0.0-alpha.2",
"vue-toast-notification": "^2.0", "vue-toast-notification": "^3.1.2",
"vuex": "^4.0.0" "vuex": "^4.0.0"
}, },
"browserslist": [ "browserslist": [

View File

@ -418,7 +418,6 @@ final class EventController extends AbstractController
$builder->add('event_id', HiddenType::class, [ $builder->add('event_id', HiddenType::class, [
'data' => $event->getId(), 'data' => $event->getId(),
]); ]);
dump($event->getId());
return $builder->getForm(); return $builder->getForm();
} }

View File

@ -12,11 +12,8 @@ declare(strict_types=1);
namespace Chill\FranceTravailApiBundle\ApiHelper; namespace Chill\FranceTravailApiBundle\ApiHelper;
use GuzzleHttp\Client; use GuzzleHttp\Client;
use GuzzleHttp\Exception\ClientException;
use GuzzleHttp\Psr7\Request;
use GuzzleHttp\Utils;
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;
use Symfony\Component\HttpFoundation\Response; use Symfony\Contracts\HttpClient\Exception\HttpExceptionInterface;
/** /**
* Queries for ROME partenaires api. * Queries for ROME partenaires api.
@ -39,9 +36,12 @@ class PartenaireRomeAppellation
*/ */
protected $logger; protected $logger;
private const BASE = 'https://api.pole-emploi.io/partenaire/rome-metiers/v1/metiers/';
public function __construct( public function __construct(
ApiWrapper $wrapper, ApiWrapper $wrapper,
LoggerInterface $logger LoggerInterface $logger,
private \Symfony\Contracts\HttpClient\HttpClientInterface $httpClient,
) { ) {
$this->wrapper = $wrapper; $this->wrapper = $wrapper;
$this->logger = $logger; $this->logger = $logger;
@ -58,60 +58,49 @@ class PartenaireRomeAppellation
]); ]);
} }
/** public function getListeAppellation(string $search): array
* @param string $search
*/
public function getListeAppellation($search)
{ {
$bearer = $this->getBearer(); $bearer = $this->getBearer();
$request = new Request('GET', 'appellation');
$parameters = [
'query' => [
'q' => $search,
'fq' => 'libelle',
],
'headers' => [
'Authorization' => 'Bearer '.$bearer,
],
];
try { try {
$response = $this->handleRequest( $response = $this->httpClient->request(
$request, 'GET',
$parameters, self::BASE.'appellation/requete',
$this->client, [
$this->logger 'headers' => [
'Authorization' => 'Bearer '.$bearer,
'Accept' => 'application/json',
],
'query' => [
'q' => $search,
],
]
); );
return Utils::jsonDecode((string) $response->getBody()); return $response->toArray()['resultats'];
} catch (ClientException $e) { } catch (HttpExceptionInterface $exception) {
dump($e->getResponse()->getBody()->getContents()); throw $exception;
} }
return new Response('No appellation found');
} }
public function getAppellation($code) public function getAppellation(string $code): array
{ {
$bearer = $this->getBearer(); $bearer = $this->getBearer();
$request = new Request('GET', sprintf('appellation/%s', $code)); try {
$parameters = [ $response = $this->httpClient->request('GET', sprintf(self::BASE.'appellation/%s', $code), [
'headers' => [ 'headers' => [
'Authorization' => 'Bearer '.$bearer, 'Authorization' => 'Bearer '.$bearer,
], 'Accept' => 'application/json',
'query' => [ ],
'champs' => 'code,libelle,metier(code,libelle)', 'query' => [
], 'champs' => 'code,libelle,metier(code,libelle)',
]; ],
]);
$response = $this->handleRequest( return $response->toArray();
$request, } catch (HttpExceptionInterface $exception) {
$parameters, throw $exception;
$this->client, }
$this->logger
);
return Utils::jsonDecode((string) $response->getBody());
} }
} }

View File

@ -41,8 +41,8 @@ class RomeController extends AbstractController
$results = []; $results = [];
foreach ($appellations as $appellation) { foreach ($appellations as $appellation) {
$appellation->id = 'original-'.$appellation->code; $appellation['id'] = 'original-'.$appellation['code'];
$appellation->text = $appellation->libelle; $appellation['text'] = $appellation['libelle'];
$results[] = $appellation; $results[] = $appellation;
} }

View File

@ -1,12 +1,14 @@
services: services:
_defaults:
autowire: true
autoconfigure: true
Chill\FranceTravailApiBundle\ApiHelper\ApiWrapper: Chill\FranceTravailApiBundle\ApiHelper\ApiWrapper:
$clientId: '%env(FRANCE_TRAVAIL_CLIENT_ID)%' $clientId: '%env(FRANCE_TRAVAIL_CLIENT_ID)%'
$clientSecret: '%env(FRANCE_TRAVAIL_CLIENT_SECRET)%' $clientSecret: '%env(FRANCE_TRAVAIL_CLIENT_SECRET)%'
$redis: '@Chill\MainBundle\Redis\ChillRedis' $redis: '@Chill\MainBundle\Redis\ChillRedis'
Chill\FranceTravailApiBundle\ApiHelper\PartenaireRomeAppellation: Chill\FranceTravailApiBundle\ApiHelper\PartenaireRomeAppellation: ~
$wrapper: '@Chill\FranceTravailApiBundle\ApiHelper\ApiWrapper'
$logger: '@Psr\Log\LoggerInterface'
Chill\FranceTravailApiBundle\Controller\RomeController: Chill\FranceTravailApiBundle\Controller\RomeController:
autowire: true autowire: true

View File

@ -113,7 +113,7 @@ class CSPerson
'ASS', 'ASS',
'RSA', 'RSA',
'AAH', 'AAH',
'autre', // 'autre',
]; ];
/** /**
@ -140,7 +140,7 @@ class CSPerson
'referent_RSA', 'referent_RSA',
'mission_locale', 'mission_locale',
'rqth', 'rqth',
'autre', // 'autre',
]; ];
/** /**
@ -226,7 +226,7 @@ class CSPerson
'scooter', 'scooter',
'velo', 'velo',
'voiture', 'voiture',
'autre', // 'autre',
]; ];
/** /**

View File

@ -527,7 +527,6 @@ class Immersion implements \Stringable
public function getDuration() public function getDuration()
{ {
return $this->duration; return $this->duration;
// return new \DateInterval($this->duration ?? 'P7D');
} }
public function getDateEndComputed() public function getDateEndComputed()

View File

@ -36,7 +36,7 @@ class Metier
* @var \Doctrine\Common\Collections\Collection<int, \Chill\JobBundle\Entity\Rome\Appellation> * @var \Doctrine\Common\Collections\Collection<int, \Chill\JobBundle\Entity\Rome\Appellation>
*/ */
#[ORM\OneToMany(targetEntity: Appellation::class, mappedBy: 'metier')] #[ORM\OneToMany(targetEntity: Appellation::class, mappedBy: 'metier')]
private readonly \Doctrine\Common\Collections\Collection $appellations; private \Doctrine\Common\Collections\Collection $appellations;
public function __construct() public function __construct()
{ {

View File

@ -51,8 +51,10 @@ class RomeAppellationChoiceLoader implements ChoiceLoaderInterface
protected $validator; protected $validator;
/** /**
* RomeAppellationChoiceLoader constructor. * @var array<string, array{0: Appellation, 1: Metier}>
*/ */
private $toBeCreated = [];
public function __construct( public function __construct(
EntityManagerInterface $em, EntityManagerInterface $em,
PartenaireRomeAppellation $apiAppellation, PartenaireRomeAppellation $apiAppellation,
@ -83,33 +85,44 @@ class RomeAppellationChoiceLoader implements ChoiceLoaderInterface
if (str_starts_with($v, 'original-')) { if (str_starts_with($v, 'original-')) {
$code = \substr($v, \strlen('original-')); $code = \substr($v, \strlen('original-'));
$appellation = $this->appellationRepository->findOneBy(['code' => $code]); $appellation = $this->appellationRepository->findOneBy(['code' => $code]);
if ($appellation) {
$metier = $appellation->getMetier();
}
if (null === $appellation) {
if (array_key_exists($v, $this->toBeCreated)) {
[$appellation, $metier] = $this->toBeCreated[$v];
}
}
} else { } else {
$id = $v; $id = $v;
$appellation = $this->appellationRepository->find($id); $appellation = $this->appellationRepository->find($id);
$metier = $appellation->getMetier();
} }
if (null === $appellation && '' !== $code) { if (null === $appellation && '' !== $code) {
$def = $this->apiAppellation->getAppellation($code); $def = $this->apiAppellation->getAppellation($code);
$metier = $this->em->getRepository(Metier::class)
->findOneBy(['code' => $def->metier->code])
;
if (null === $metier) { $metier ??= $this->em->getRepository(Metier::class)
$metier = (new Metier()) ->findOneBy(['code' => $def['metier']['code']])
->setCode($def->metier->code) ?? (new Metier())
->setLibelle($def->metier->libelle) ->setCode($def['metier']['code'])
; ->setLibelle($def['metier']['libelle']);
}
$appellation = new Appellation(); $appellation = new Appellation();
$appellation $appellation
->setCode($def->code) ->setCode($def['code'])
->setLibelle($def->libelle) ->setLibelle($def['libelle'])
->setMetier($metier) ->setMetier($metier)
; ;
if ([] === $this->validator->validate($appellation) && [] === $this->validator->validate($metier)) { $errorsAppellation = $this->validator->validate($appellation);
$errorsMetier = $this->validator->validate($metier);
if (0 === $errorsAppellation->count() && 0 === $errorsMetier->count()) {
$this->toBeCreated[$v] = [$appellation, $metier];
$this->em->persist($appellation); $this->em->persist($appellation);
} }
} }

View File

@ -88,7 +88,7 @@ class PickRomeAppellationType extends AbstractType
->setDefault('class', Appellation::class) ->setDefault('class', Appellation::class)
->setDefault('choice_label', fn (Appellation $a) => $a->getLibelle()) ->setDefault('choice_label', fn (Appellation $a) => $a->getLibelle())
->setDefault('placeholder', 'Choisir une appellation') ->setDefault('placeholder', 'Choisir une appellation')
// ->setDefault('attr', ['class' => 'select2 ']) ->setDefault('attr', ['class' => 'select2 '])
->setDefault('choice_loader', fn (Options $o) => new RomeAppellationChoiceLoader( ->setDefault('choice_loader', fn (Options $o) => new RomeAppellationChoiceLoader(
$this->em, $this->em,
$this->apiPartenaire, $this->apiPartenaire,

View File

@ -61,8 +61,6 @@ final class PermissionsGroupController extends AbstractController
$form = $this->createAddRoleScopeForm($permissionsGroup); $form = $this->createAddRoleScopeForm($permissionsGroup);
$form->handleRequest($request); $form->handleRequest($request);
dump($form->isSubmitted());
if ($form->isSubmitted() && $form->isValid()) { if ($form->isSubmitted() && $form->isValid()) {
$roleScope = $this->getPersistentRoleScopeBy( $roleScope = $this->getPersistentRoleScopeBy(
$form['composed_role_scope']->getData()->getRole(), $form['composed_role_scope']->getData()->getRole(),
@ -153,7 +151,7 @@ final class PermissionsGroupController extends AbstractController
/** /**
* remove an association between permissionsGroup and roleScope. * remove an association between permissionsGroup and roleScope.
*/ */
#[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/admin/permissionsgroup/{pgid}/delete_link_role_scope/{rsid}', name: 'admin_permissionsgroup_delete_role_scope', methods: ['DELETE'])] #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/admin/permissionsgroup/{pgid}/delete_link_role_scope/{rsid}', name: 'admin_permissionsgroup_delete_role_scope', methods: ['POST'])]
public function deleteLinkRoleScopeAction(int $pgid, int $rsid): Response public function deleteLinkRoleScopeAction(int $pgid, int $rsid): Response
{ {
$permissionsGroup = $this->permissionsGroupRepository->find($pgid); $permissionsGroup = $this->permissionsGroupRepository->find($pgid);

View File

@ -2,10 +2,10 @@ import { createApp } from 'vue'
import { _createI18n } from 'ChillMainAssets/vuejs/_js/i18n' import { _createI18n } from 'ChillMainAssets/vuejs/_js/i18n'
import { appMessages } from './js/i18n' import { appMessages } from './js/i18n'
import { initPromise } from './store' import { initPromise } from './store'
import VueToast from 'vue-toast-notification';
import 'vue-toast-notification/dist/theme-sugar.css'; import 'vue-toast-notification/dist/theme-sugar.css';
import App from './App.vue'; import App from './App.vue';
import Banner from './components/Banner.vue'; import Banner from './components/Banner.vue';
import ToastPlugin from "vue-toast-notification";
const root = window.vueRootComponent; const root = window.vueRootComponent;
@ -22,7 +22,7 @@ if (root === 'app') {
}) })
.use(store) .use(store)
.use(i18n) .use(i18n)
.use(VueToast, { .use(ToastPlugin, {
position: "bottom-right", position: "bottom-right",
type: "error", type: "error",
duration: 5000, duration: 5000,
@ -46,7 +46,7 @@ if (root === 'banner') {
}) })
.use(store) .use(store)
.use(i18n) .use(i18n)
.use(VueToast, { .use(ToastPlugin, {
position: "bottom-right", position: "bottom-right",
type: "error", type: "error",
duration: 5000, duration: 5000,

View File

@ -3,7 +3,7 @@ import {_createI18n} from 'ChillMainAssets/vuejs/_js/i18n';
import {store} from './store'; import {store} from './store';
import {personMessages} from 'ChillPersonAssets/vuejs/_js/i18n' import {personMessages} from 'ChillPersonAssets/vuejs/_js/i18n'
import App from './App.vue'; import App from './App.vue';
import VueToast from "vue-toast-notification"; import ToastPlugin from "vue-toast-notification";
const i18n = _createI18n(personMessages); const i18n = _createI18n(personMessages);
@ -12,7 +12,7 @@ const app = createApp({
}) })
.use(store) .use(store)
.use(i18n) .use(i18n)
.use(VueToast, { .use(ToastPlugin, {
position: "bottom-right", position: "bottom-right",
type: "error", type: "error",
duration: 10000, duration: 10000,

View File

@ -2,9 +2,9 @@ import { createApp } from 'vue';
import { _createI18n } from 'ChillMainAssets/vuejs/_js/i18n'; import { _createI18n } from 'ChillMainAssets/vuejs/_js/i18n';
import { store } from './store'; import { store } from './store';
import { personMessages } from 'ChillPersonAssets/vuejs/_js/i18n'; import { personMessages } from 'ChillPersonAssets/vuejs/_js/i18n';
import VueToast from 'vue-toast-notification';
import 'vue-toast-notification/dist/theme-sugar.css'; import 'vue-toast-notification/dist/theme-sugar.css';
import App from './App.vue'; import App from './App.vue';
import ToastPlugin from "vue-toast-notification";
const i18n = _createI18n(personMessages); const i18n = _createI18n(personMessages);
@ -12,7 +12,7 @@ const app = createApp({
template: `<app></app>`, template: `<app></app>`,
}) })
.use(store) .use(store)
.use(VueToast, { .use(ToastPlugin, {
position: "bottom-right", position: "bottom-right",
type: "error", type: "error",
duration: 10000, duration: 10000,

View File

@ -2,8 +2,8 @@ import { createApp } from 'vue';
import { _createI18n } from 'ChillMainAssets/vuejs/_js/i18n'; import { _createI18n } from 'ChillMainAssets/vuejs/_js/i18n';
import { appMessages } from './js/i18n'; import { appMessages } from './js/i18n';
import { store } from './store'; import { store } from './store';
import VueToast from 'vue-toast-notification';
import 'vue-toast-notification/dist/theme-sugar.css'; import 'vue-toast-notification/dist/theme-sugar.css';
import ToastPlugin from 'vue-toast-notification';
import App from './App.vue'; import App from './App.vue';
@ -14,7 +14,7 @@ const app = createApp({
}) })
.use(store) .use(store)
.use(i18n) .use(i18n)
.use(VueToast, { .use(ToastPlugin, {
position: "bottom-right", position: "bottom-right",
type: "error", type: "error",
duration: 5000, duration: 5000,

View File

@ -3,10 +3,9 @@ import { store } from "./store.js"
import { _createI18n } from 'ChillMainAssets/vuejs/_js/i18n' import { _createI18n } from 'ChillMainAssets/vuejs/_js/i18n'
import { visMessages } from './i18n' import { visMessages } from './i18n'
import App from './App.vue' import App from './App.vue'
import VueToast from 'vue-toast-notification';
import 'vue-toast-notification/dist/theme-sugar.css'; import 'vue-toast-notification/dist/theme-sugar.css';
import './vis-network'; import './vis-network';
import ToastPlugin from "vue-toast-notification";
const i18n = _createI18n(visMessages) const i18n = _createI18n(visMessages)
const container = document.getElementById('relationship-graph') const container = document.getElementById('relationship-graph')
@ -27,7 +26,7 @@ const app = createApp({
}) })
.use(store) .use(store)
.use(i18n) .use(i18n)
.use(VueToast, { .use(ToastPlugin, {
position: "bottom-right", position: "bottom-right",
type: "error", type: "error",
duration: 5000, duration: 5000,

View File

@ -85,7 +85,7 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface, \Strin
/** /**
* [fr] Sigle. * [fr] Sigle.
*/ */
#[Assert\Length(min: 2)] // #[Assert\Length(min: 2)]
#[Groups(['read', 'write', 'docgen:read', 'docgen:read:3party:parent'])] #[Groups(['read', 'write', 'docgen:read', 'docgen:read:3party:parent'])]
#[ORM\Column(name: 'acronym', type: \Doctrine\DBAL\Types\Types::STRING, length: 64, nullable: true)] #[ORM\Column(name: 'acronym', type: \Doctrine\DBAL\Types\Types::STRING, length: 64, nullable: true)]
private ?string $acronym = ''; private ?string $acronym = '';
@ -184,7 +184,7 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface, \Strin
/** /**
* [fr] Raison sociale. * [fr] Raison sociale.
*/ */
#[Assert\Length(min: 3)] // #[Assert\Length(min: 3)]
#[Groups(['read', 'write', 'docgen:read', 'docgen:read:3party:parent'])] #[Groups(['read', 'write', 'docgen:read', 'docgen:read:3party:parent'])]
#[ORM\Column(name: 'name_company', type: \Doctrine\DBAL\Types\Types::STRING, length: 255, nullable: true)] #[ORM\Column(name: 'name_company', type: \Doctrine\DBAL\Types\Types::STRING, length: 255, nullable: true)]
private ?string $nameCompany = ''; private ?string $nameCompany = '';