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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -61,8 +61,6 @@ final class PermissionsGroupController extends AbstractController
$form = $this->createAddRoleScopeForm($permissionsGroup);
$form->handleRequest($request);
dump($form->isSubmitted());
if ($form->isSubmitted() && $form->isValid()) {
$roleScope = $this->getPersistentRoleScopeBy(
$form['composed_role_scope']->getData()->getRole(),
@ -153,7 +151,7 @@ final class PermissionsGroupController extends AbstractController
/**
* 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
{
$permissionsGroup = $this->permissionsGroupRepository->find($pgid);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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