diff --git a/package.json b/package.json index 3b9d4c70a..0244daedd 100644 --- a/package.json +++ b/package.json @@ -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": [ diff --git a/src/Bundle/ChillEventBundle/Controller/EventController.php b/src/Bundle/ChillEventBundle/Controller/EventController.php index ad67728d7..95817485c 100644 --- a/src/Bundle/ChillEventBundle/Controller/EventController.php +++ b/src/Bundle/ChillEventBundle/Controller/EventController.php @@ -418,7 +418,6 @@ final class EventController extends AbstractController $builder->add('event_id', HiddenType::class, [ 'data' => $event->getId(), ]); - dump($event->getId()); return $builder->getForm(); } diff --git a/src/Bundle/ChillFranceTravailApiBundle/src/ApiHelper/PartenaireRomeAppellation.php b/src/Bundle/ChillFranceTravailApiBundle/src/ApiHelper/PartenaireRomeAppellation.php index cb40311b6..a548894c9 100644 --- a/src/Bundle/ChillFranceTravailApiBundle/src/ApiHelper/PartenaireRomeAppellation.php +++ b/src/Bundle/ChillFranceTravailApiBundle/src/ApiHelper/PartenaireRomeAppellation.php @@ -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; + } } } diff --git a/src/Bundle/ChillFranceTravailApiBundle/src/Controller/RomeController.php b/src/Bundle/ChillFranceTravailApiBundle/src/Controller/RomeController.php index ef7a0619f..5a26d590c 100644 --- a/src/Bundle/ChillFranceTravailApiBundle/src/Controller/RomeController.php +++ b/src/Bundle/ChillFranceTravailApiBundle/src/Controller/RomeController.php @@ -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; } diff --git a/src/Bundle/ChillFranceTravailApiBundle/src/Resources/config/services.yml b/src/Bundle/ChillFranceTravailApiBundle/src/Resources/config/services.yml index 2bb364f7a..658a152dc 100644 --- a/src/Bundle/ChillFranceTravailApiBundle/src/Resources/config/services.yml +++ b/src/Bundle/ChillFranceTravailApiBundle/src/Resources/config/services.yml @@ -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 diff --git a/src/Bundle/ChillJobBundle/src/Entity/CSPerson.php b/src/Bundle/ChillJobBundle/src/Entity/CSPerson.php index 579698a64..1a2608388 100644 --- a/src/Bundle/ChillJobBundle/src/Entity/CSPerson.php +++ b/src/Bundle/ChillJobBundle/src/Entity/CSPerson.php @@ -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', ]; /** diff --git a/src/Bundle/ChillJobBundle/src/Entity/Immersion.php b/src/Bundle/ChillJobBundle/src/Entity/Immersion.php index 225c4c1a1..5ae19a365 100644 --- a/src/Bundle/ChillJobBundle/src/Entity/Immersion.php +++ b/src/Bundle/ChillJobBundle/src/Entity/Immersion.php @@ -527,7 +527,6 @@ class Immersion implements \Stringable public function getDuration() { return $this->duration; - // return new \DateInterval($this->duration ?? 'P7D'); } public function getDateEndComputed() diff --git a/src/Bundle/ChillJobBundle/src/Entity/Rome/Metier.php b/src/Bundle/ChillJobBundle/src/Entity/Rome/Metier.php index 668b2283f..ce44a6acf 100644 --- a/src/Bundle/ChillJobBundle/src/Entity/Rome/Metier.php +++ b/src/Bundle/ChillJobBundle/src/Entity/Rome/Metier.php @@ -36,7 +36,7 @@ class Metier * @var \Doctrine\Common\Collections\Collection */ #[ORM\OneToMany(targetEntity: Appellation::class, mappedBy: 'metier')] - private readonly \Doctrine\Common\Collections\Collection $appellations; + private \Doctrine\Common\Collections\Collection $appellations; public function __construct() { diff --git a/src/Bundle/ChillJobBundle/src/Form/ChoiceLoader/RomeAppellationChoiceLoader.php b/src/Bundle/ChillJobBundle/src/Form/ChoiceLoader/RomeAppellationChoiceLoader.php index 0952991e4..39ab23ae1 100644 --- a/src/Bundle/ChillJobBundle/src/Form/ChoiceLoader/RomeAppellationChoiceLoader.php +++ b/src/Bundle/ChillJobBundle/src/Form/ChoiceLoader/RomeAppellationChoiceLoader.php @@ -51,8 +51,10 @@ class RomeAppellationChoiceLoader implements ChoiceLoaderInterface protected $validator; /** - * RomeAppellationChoiceLoader constructor. + * @var array */ + 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); } } diff --git a/src/Bundle/ChillJobBundle/src/Form/Type/PickRomeAppellationType.php b/src/Bundle/ChillJobBundle/src/Form/Type/PickRomeAppellationType.php index 6ae77ba62..174a25c18 100644 --- a/src/Bundle/ChillJobBundle/src/Form/Type/PickRomeAppellationType.php +++ b/src/Bundle/ChillJobBundle/src/Form/Type/PickRomeAppellationType.php @@ -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, diff --git a/src/Bundle/ChillMainBundle/Controller/PermissionsGroupController.php b/src/Bundle/ChillMainBundle/Controller/PermissionsGroupController.php index ec28d3040..a326e0ff5 100644 --- a/src/Bundle/ChillMainBundle/Controller/PermissionsGroupController.php +++ b/src/Bundle/ChillMainBundle/Controller/PermissionsGroupController.php @@ -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); diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/index.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/index.js index 4cf073eb4..a420671b5 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/index.js +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/index.js @@ -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, diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkCreate/index.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkCreate/index.js index 1f8a25d3a..16d04f2ed 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkCreate/index.js +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkCreate/index.js @@ -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, diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/index.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/index.js index b0868b48b..fc6d96674 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/index.js +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/index.js @@ -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: ``, }) .use(store) -.use(VueToast, { +.use(ToastPlugin, { position: "bottom-right", type: "error", duration: 10000, diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/HouseholdMembersEditor/index.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/HouseholdMembersEditor/index.js index d2b271e17..6e4d3fe83 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/HouseholdMembersEditor/index.js +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/HouseholdMembersEditor/index.js @@ -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, diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/index.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/index.js index a64afd4a1..3a1a72c93 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/index.js +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/index.js @@ -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, diff --git a/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php b/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php index b2efb3721..eb0b559de 100644 --- a/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php +++ b/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php @@ -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 = '';