mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
Merge branch 'issue716_change_field_thirdparty' into 'master'
Change profession field into string type See merge request Chill-Projet/chill-bundles!492
This commit is contained in:
commit
15d68df8c6
@ -233,7 +233,7 @@ export default {
|
|||||||
// console.log('data original', data);
|
// console.log('data original', data);
|
||||||
data.parent = {type: "thirdparty", id: this.parent.id};
|
data.parent = {type: "thirdparty", id: this.parent.id};
|
||||||
data.civility = data.civility !== null ? {type: 'chill_main_civility', id: data.civility.id} : null;
|
data.civility = data.civility !== null ? {type: 'chill_main_civility', id: data.civility.id} : null;
|
||||||
data.profession = data.profession !== null ? {type: 'third_party_profession', id: data.profession.id} : null;
|
data.profession = data.profession !== '' ? data.profession : '';
|
||||||
} else {
|
} else {
|
||||||
type = this.$refs.castNew.radioType;
|
type = this.$refs.castNew.radioType;
|
||||||
data = this.$refs.castNew.castDataByType();
|
data = this.$refs.castNew.castDataByType();
|
||||||
@ -241,8 +241,8 @@ export default {
|
|||||||
if (typeof data.civility !== 'undefined' && null !== data.civility) {
|
if (typeof data.civility !== 'undefined' && null !== data.civility) {
|
||||||
data.civility = data.civility !== null ? {type: 'chill_main_civility', id: data.civility.id} : null;
|
data.civility = data.civility !== null ? {type: 'chill_main_civility', id: data.civility.id} : null;
|
||||||
}
|
}
|
||||||
if (typeof data.profession !== 'undefined' && null !== data.profession) {
|
if (typeof data.profession !== 'undefined' && '' !== data.profession) {
|
||||||
data.profession = data.profession !== null ? {type: 'third_party_profession', id: data.profession.id} : null;
|
data.profession = data.profession !== '' ? data.profession : '';
|
||||||
}
|
}
|
||||||
// console.log('onthefly data', data);
|
// console.log('onthefly data', data);
|
||||||
}
|
}
|
||||||
|
@ -178,7 +178,7 @@ export default {
|
|||||||
body.civility = {type: 'chill_main_civility', id: payload.data.civility.id};
|
body.civility = {type: 'chill_main_civility', id: payload.data.civility.id};
|
||||||
}
|
}
|
||||||
if (null !== payload.data.profession) {
|
if (null !== payload.data.profession) {
|
||||||
body.profession = {type: 'third_party_profession', id: payload.data.profession.id};
|
body.profession = payload.data.profession;
|
||||||
}
|
}
|
||||||
// console.log('body', body);
|
// console.log('body', body);
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="container tpartycontainer">
|
<div class="container tpartycontainer">
|
||||||
<div class="tparty-identification">
|
<div class="tparty-identification">
|
||||||
<span v-if="item.result.profession" class="profession">{{ item.result.profession.name.fr }}</span>
|
<span v-if="item.result.profession" class="profession">{{ item.result.profession }}</span>
|
||||||
<span class="name">
|
<span class="name">
|
||||||
{{ item.result.text }}
|
{{ item.result.text }}
|
||||||
</span>
|
</span>
|
||||||
|
@ -151,21 +151,6 @@ class ChillThirdPartyExtension extends Extension implements PrependExtensionInte
|
|||||||
],
|
],
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
[
|
|
||||||
'class' => \Chill\ThirdPartyBundle\Entity\ThirdPartyProfession::class,
|
|
||||||
// 'controller' => \Chill\MainBundle\Controller\ProfessionApiController::class,
|
|
||||||
'name' => 'profession',
|
|
||||||
'base_path' => '/api/1.0/thirdparty/professions',
|
|
||||||
'base_role' => 'ROLE_USER',
|
|
||||||
'actions' => [
|
|
||||||
'_index' => [
|
|
||||||
'methods' => [
|
|
||||||
Request::METHOD_GET => true,
|
|
||||||
Request::METHOD_HEAD => true,
|
|
||||||
],
|
|
||||||
],
|
|
||||||
],
|
|
||||||
],
|
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
@ -250,14 +250,11 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* [fr] Qualité.
|
* [fr] Qualité.
|
||||||
*
|
* @ORM\Column(name="profession", type="text", nullable=false)
|
||||||
* @var ThirdPartyProfession
|
|
||||||
* @ORM\ManyToOne(targetEntity="Chill\ThirdPartyBundle\Entity\ThirdPartyProfession")
|
|
||||||
* ORM\JoinColumn(name="profession", referencedColumnName="id", nullable=true)
|
|
||||||
* @Groups({"read", "write", "docgen:read", "docgen:read:3party:parent"})
|
* @Groups({"read", "write", "docgen:read", "docgen:read:3party:parent"})
|
||||||
* @Context(normalizationContext={"groups": "docgen:read"}, groups={"docgen:read:3party:parent"})
|
* @Context(normalizationContext={"groups": "docgen:read"}, groups={"docgen:read:3party:parent"})
|
||||||
*/
|
*/
|
||||||
private ?ThirdPartyProfession $profession = null;
|
private string $profession = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Column(name="telephone", type="phone_number", nullable=true)
|
* @ORM\Column(name="telephone", type="phone_number", nullable=true)
|
||||||
@ -491,9 +488,9 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return ThirdPartyProfession
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getProfession(): ?ThirdPartyProfession
|
public function getProfession(): string
|
||||||
{
|
{
|
||||||
return $this->profession;
|
return $this->profession;
|
||||||
}
|
}
|
||||||
@ -811,7 +808,7 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface
|
|||||||
/**
|
/**
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function setProfession(?ThirdPartyProfession $profession): ThirdParty
|
public function setProfession(string $profession): self
|
||||||
{
|
{
|
||||||
$this->profession = $profession;
|
$this->profession = $profession;
|
||||||
|
|
||||||
|
@ -20,14 +20,10 @@ use Chill\MainBundle\Form\Type\PickCivilityType;
|
|||||||
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
|
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
|
||||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||||
use Chill\ThirdPartyBundle\Entity\ThirdParty;
|
use Chill\ThirdPartyBundle\Entity\ThirdParty;
|
||||||
use Chill\ThirdPartyBundle\Entity\ThirdPartyProfession;
|
|
||||||
use Chill\ThirdPartyBundle\Form\Type\PickThirdPartyTypeCategoryType;
|
use Chill\ThirdPartyBundle\Form\Type\PickThirdPartyTypeCategoryType;
|
||||||
use Chill\ThirdPartyBundle\Security\Voter\ThirdPartyVoter;
|
use Chill\ThirdPartyBundle\Security\Voter\ThirdPartyVoter;
|
||||||
use Chill\ThirdPartyBundle\ThirdPartyType\ThirdPartyTypeManager;
|
use Chill\ThirdPartyBundle\ThirdPartyType\ThirdPartyTypeManager;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Doctrine\ORM\EntityRepository;
|
|
||||||
use Doctrine\ORM\QueryBuilder;
|
|
||||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
|
||||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
|
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
|
||||||
use Symfony\Component\Form\AbstractType;
|
use Symfony\Component\Form\AbstractType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||||
@ -111,17 +107,8 @@ class ThirdPartyType extends AbstractType
|
|||||||
'placeholder' => 'thirdparty.choose civility',
|
'placeholder' => 'thirdparty.choose civility',
|
||||||
'required' => false,
|
'required' => false,
|
||||||
])
|
])
|
||||||
->add('profession', EntityType::class, [
|
->add('profession', TextType::class, [
|
||||||
'label' => 'thirdparty.Profession',
|
'label' => 'thirdparty.Profession',
|
||||||
'class' => ThirdPartyProfession::class,
|
|
||||||
'choice_label' => function (ThirdPartyProfession $profession): string {
|
|
||||||
return $this->translatableStringHelper->localize($profession->getName());
|
|
||||||
},
|
|
||||||
'query_builder' => static function (EntityRepository $er): QueryBuilder {
|
|
||||||
return $er->createQueryBuilder('p')
|
|
||||||
->where('p.active = true');
|
|
||||||
},
|
|
||||||
'placeholder' => 'thirdparty.choose profession',
|
|
||||||
'required' => false,
|
'required' => false,
|
||||||
])
|
])
|
||||||
->add('contactDataAnonymous', CheckboxType::class, [
|
->add('contactDataAnonymous', CheckboxType::class, [
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
<ul class="list-content fa-ul">
|
<ul class="list-content fa-ul">
|
||||||
<li v-if="getProfession.length > 0">
|
<li v-if="getProfession.length > 0">
|
||||||
<i class="fa fa-li fa-id-card"></i>
|
<i class="fa fa-li fa-id-card"></i>
|
||||||
<p><span v-for="p in getProfession" :key="p" class="list-item list-professions">{{ p[0].toUpperCase() + p.slice(1).toLowerCase() }}</span></p>
|
<p><span>{{ getProfession[0] }}</span></p>
|
||||||
</li>
|
</li>
|
||||||
<li v-if="hasParent">
|
<li v-if="hasParent">
|
||||||
<i class="fa fa-li fa-hand-o-right"></i>
|
<i class="fa fa-li fa-hand-o-right"></i>
|
||||||
@ -136,13 +136,14 @@ export default {
|
|||||||
getProfession() {
|
getProfession() {
|
||||||
let profession = []
|
let profession = []
|
||||||
if (this.hasParent && this.thirdparty.profession) {
|
if (this.hasParent && this.thirdparty.profession) {
|
||||||
profession.push(this.thirdparty.profession.name.fr)
|
profession.push(this.thirdparty.profession)
|
||||||
return profession;
|
return profession;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.hasParent && this.thirdparty.category) {
|
if (!this.hasParent && this.thirdparty.category) {
|
||||||
profession = this.thirdparty.category.map((category) => category.text);
|
profession = this.thirdparty.category.map((category) => category.text);
|
||||||
}
|
}
|
||||||
|
|
||||||
return profession;
|
return profession;
|
||||||
}
|
}
|
||||||
/* TODO need backend normalizer to serve children without circular reference
|
/* TODO need backend normalizer to serve children without circular reference
|
||||||
|
@ -74,11 +74,11 @@
|
|||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div class="input-group mb-3 input-section">
|
<div class="input-group mb-3 input-section">
|
||||||
<select class="form-select form-select-lg" id="profession"
|
<input class="form-control form-control-lg"
|
||||||
v-model="thirdparty.profession">
|
v-model="thirdparty.profession"
|
||||||
<option selected disabled :value="null">{{ $t('thirdparty.profession') }}</option>
|
v-bind:placeholder="$t('thirdparty.profession')"
|
||||||
<option v-for="profession in professions" :key="profession.id" :value="profession">{{ profession.name.fr }}</option>
|
v-bind:aria-label="$t('thirdparty.profession')"
|
||||||
</select>
|
aria-describedby="profession" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="child-info">
|
<div class="child-info">
|
||||||
@ -192,9 +192,8 @@ export default {
|
|||||||
name: '',
|
name: '',
|
||||||
telephone: '',
|
telephone: '',
|
||||||
civility: null,
|
civility: null,
|
||||||
profession: null,
|
profession: '',
|
||||||
},
|
},
|
||||||
professions: [],
|
|
||||||
civilities: [],
|
civilities: [],
|
||||||
addAddress: {
|
addAddress: {
|
||||||
options: {
|
options: {
|
||||||
@ -274,18 +273,6 @@ export default {
|
|||||||
this.$toast.open({message: error.body})
|
this.$toast.open({message: error.body})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
loadProfessions() {
|
|
||||||
const url = `/api/1.0/thirdparty/professions.json`;
|
|
||||||
return makeFetch('GET', url)
|
|
||||||
.then(response => {
|
|
||||||
this.$data.professions = response.results;
|
|
||||||
return Promise.resolve();
|
|
||||||
})
|
|
||||||
.catch((error) => {
|
|
||||||
console.log(error)
|
|
||||||
this.$toast.open({message: error.body})
|
|
||||||
})
|
|
||||||
},
|
|
||||||
submitAddress(payload) {
|
submitAddress(payload) {
|
||||||
console.log('submitAddress', payload);
|
console.log('submitAddress', payload);
|
||||||
if (typeof payload.addressId !== 'undefined') { // <--
|
if (typeof payload.addressId !== 'undefined') { // <--
|
||||||
@ -311,7 +298,6 @@ export default {
|
|||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
let dependencies = [];
|
let dependencies = [];
|
||||||
dependencies.push(this.loadProfessions());
|
|
||||||
dependencies.push(this.loadCivilities());
|
dependencies.push(this.loadCivilities());
|
||||||
if (this.action !== 'create') {
|
if (this.action !== 'create') {
|
||||||
if (this.id) {
|
if (this.id) {
|
||||||
|
@ -112,14 +112,3 @@ paths:
|
|||||||
description: "OK"
|
description: "OK"
|
||||||
422:
|
422:
|
||||||
description: "Object with validation errors"
|
description: "Object with validation errors"
|
||||||
|
|
||||||
/1.0/thirdparty/professions.json:
|
|
||||||
get:
|
|
||||||
tags:
|
|
||||||
- thirdparty
|
|
||||||
summary: Return all thirdparty professions
|
|
||||||
responses:
|
|
||||||
200:
|
|
||||||
description: "ok"
|
|
||||||
401:
|
|
||||||
description: "Unauthorized"
|
|
||||||
|
@ -7,7 +7,3 @@ services:
|
|||||||
Chill\ThirdPartyBundle\DataFixtures\ORM\LoadThirdPartyCategory:
|
Chill\ThirdPartyBundle\DataFixtures\ORM\LoadThirdPartyCategory:
|
||||||
tags:
|
tags:
|
||||||
- { 'name': doctrine.fixture.orm }
|
- { 'name': doctrine.fixture.orm }
|
||||||
|
|
||||||
Chill\ThirdPartyBundle\DataFixtures\ORM\LoadThirdPartyProfession:
|
|
||||||
tags:
|
|
||||||
- { 'name': doctrine.fixture.orm }
|
|
||||||
|
@ -0,0 +1,63 @@
|
|||||||
|
<?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\Migrations\ThirdParty;
|
||||||
|
|
||||||
|
use Chill\ThirdPartyBundle\Entity\ThirdPartyProfession;
|
||||||
|
use Doctrine\DBAL\Schema\Schema;
|
||||||
|
use Doctrine\DBAL\Types\Types;
|
||||||
|
use Doctrine\Migrations\AbstractMigration;
|
||||||
|
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
|
||||||
|
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||||
|
|
||||||
|
final class Version20230215175150 extends AbstractMigration implements ContainerAwareInterface
|
||||||
|
{
|
||||||
|
public ContainerInterface $container;
|
||||||
|
|
||||||
|
public function down(Schema $schema): void
|
||||||
|
{
|
||||||
|
$this->addSql('ALTER TABLE chill_3party.third_party DROP profession');
|
||||||
|
// $this->addSql('ALTER TABLE chill_3party.third_party ADD profession_id INT DEFAULT NULL');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDescription(): string
|
||||||
|
{
|
||||||
|
return 'Change profession to a string field and transfer values';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function setContainer(?ContainerInterface $container = null)
|
||||||
|
{
|
||||||
|
$this->container = $container;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function up(Schema $schema): void
|
||||||
|
{
|
||||||
|
$this->addSql('ALTER TABLE chill_3party.third_party ADD profession TEXT DEFAULT \'\' NOT NULL');
|
||||||
|
|
||||||
|
$em = $this->container->get('doctrine.orm.entity_manager');
|
||||||
|
$professions = $em->getRepository(ThirdPartyProfession::class)->findAll();
|
||||||
|
|
||||||
|
foreach ($professions as $p) {
|
||||||
|
$id = $p->getId();
|
||||||
|
$name = $p->getName()['fr'];
|
||||||
|
|
||||||
|
$this->addSql(
|
||||||
|
'UPDATE chill_3party.third_party SET profession = :profession
|
||||||
|
WHERE chill_3party.third_party.profession_id = :id;',
|
||||||
|
['profession' => $name, 'id' => $id],
|
||||||
|
['profession' => Types::STRING, 'id' => Types::INTEGER]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user