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);
|
||||
data.parent = {type: "thirdparty", id: this.parent.id};
|
||||
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 {
|
||||
type = this.$refs.castNew.radioType;
|
||||
data = this.$refs.castNew.castDataByType();
|
||||
@ -241,8 +241,8 @@ export default {
|
||||
if (typeof data.civility !== 'undefined' && null !== data.civility) {
|
||||
data.civility = data.civility !== null ? {type: 'chill_main_civility', id: data.civility.id} : null;
|
||||
}
|
||||
if (typeof data.profession !== 'undefined' && null !== data.profession) {
|
||||
data.profession = data.profession !== null ? {type: 'third_party_profession', id: data.profession.id} : null;
|
||||
if (typeof data.profession !== 'undefined' && '' !== data.profession) {
|
||||
data.profession = data.profession !== '' ? data.profession : '';
|
||||
}
|
||||
// console.log('onthefly data', data);
|
||||
}
|
||||
|
@ -178,7 +178,7 @@ export default {
|
||||
body.civility = {type: 'chill_main_civility', id: payload.data.civility.id};
|
||||
}
|
||||
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);
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<div class="container tpartycontainer">
|
||||
<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">
|
||||
{{ item.result.text }}
|
||||
</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é.
|
||||
*
|
||||
* @var ThirdPartyProfession
|
||||
* @ORM\ManyToOne(targetEntity="Chill\ThirdPartyBundle\Entity\ThirdPartyProfession")
|
||||
* ORM\JoinColumn(name="profession", referencedColumnName="id", nullable=true)
|
||||
* @ORM\Column(name="profession", type="text", nullable=false)
|
||||
* @Groups({"read", "write", "docgen:read", "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)
|
||||
@ -491,9 +488,9 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ThirdPartyProfession
|
||||
* @return string
|
||||
*/
|
||||
public function getProfession(): ?ThirdPartyProfession
|
||||
public function getProfession(): string
|
||||
{
|
||||
return $this->profession;
|
||||
}
|
||||
@ -811,7 +808,7 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function setProfession(?ThirdPartyProfession $profession): ThirdParty
|
||||
public function setProfession(string $profession): self
|
||||
{
|
||||
$this->profession = $profession;
|
||||
|
||||
|
@ -20,14 +20,10 @@ use Chill\MainBundle\Form\Type\PickCivilityType;
|
||||
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
|
||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||
use Chill\ThirdPartyBundle\Entity\ThirdParty;
|
||||
use Chill\ThirdPartyBundle\Entity\ThirdPartyProfession;
|
||||
use Chill\ThirdPartyBundle\Form\Type\PickThirdPartyTypeCategoryType;
|
||||
use Chill\ThirdPartyBundle\Security\Voter\ThirdPartyVoter;
|
||||
use Chill\ThirdPartyBundle\ThirdPartyType\ThirdPartyTypeManager;
|
||||
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\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||
@ -111,17 +107,8 @@ class ThirdPartyType extends AbstractType
|
||||
'placeholder' => 'thirdparty.choose civility',
|
||||
'required' => false,
|
||||
])
|
||||
->add('profession', EntityType::class, [
|
||||
->add('profession', TextType::class, [
|
||||
'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,
|
||||
])
|
||||
->add('contactDataAnonymous', CheckboxType::class, [
|
||||
|
@ -36,7 +36,7 @@
|
||||
<ul class="list-content fa-ul">
|
||||
<li v-if="getProfession.length > 0">
|
||||
<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 v-if="hasParent">
|
||||
<i class="fa fa-li fa-hand-o-right"></i>
|
||||
@ -136,13 +136,14 @@ export default {
|
||||
getProfession() {
|
||||
let profession = []
|
||||
if (this.hasParent && this.thirdparty.profession) {
|
||||
profession.push(this.thirdparty.profession.name.fr)
|
||||
profession.push(this.thirdparty.profession)
|
||||
return profession;
|
||||
}
|
||||
|
||||
if (!this.hasParent && this.thirdparty.category) {
|
||||
profession = this.thirdparty.category.map((category) => category.text);
|
||||
}
|
||||
|
||||
return profession;
|
||||
}
|
||||
/* TODO need backend normalizer to serve children without circular reference
|
||||
|
@ -73,13 +73,13 @@
|
||||
<option v-for="civility in civilities" :key="civility.id" :value="civility">{{ civility.name.fr }}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="input-group mb-3 input-section">
|
||||
<select class="form-select form-select-lg" id="profession"
|
||||
v-model="thirdparty.profession">
|
||||
<option selected disabled :value="null">{{ $t('thirdparty.profession') }}</option>
|
||||
<option v-for="profession in professions" :key="profession.id" :value="profession">{{ profession.name.fr }}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="input-group mb-3 input-section">
|
||||
<input class="form-control form-control-lg"
|
||||
v-model="thirdparty.profession"
|
||||
v-bind:placeholder="$t('thirdparty.profession')"
|
||||
v-bind:aria-label="$t('thirdparty.profession')"
|
||||
aria-describedby="profession" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="child-info">
|
||||
<div class="input-section">
|
||||
@ -192,9 +192,8 @@ export default {
|
||||
name: '',
|
||||
telephone: '',
|
||||
civility: null,
|
||||
profession: null,
|
||||
profession: '',
|
||||
},
|
||||
professions: [],
|
||||
civilities: [],
|
||||
addAddress: {
|
||||
options: {
|
||||
@ -274,18 +273,6 @@ export default {
|
||||
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) {
|
||||
console.log('submitAddress', payload);
|
||||
if (typeof payload.addressId !== 'undefined') { // <--
|
||||
@ -311,7 +298,6 @@ export default {
|
||||
},
|
||||
mounted() {
|
||||
let dependencies = [];
|
||||
dependencies.push(this.loadProfessions());
|
||||
dependencies.push(this.loadCivilities());
|
||||
if (this.action !== 'create') {
|
||||
if (this.id) {
|
||||
|
@ -112,14 +112,3 @@ paths:
|
||||
description: "OK"
|
||||
422:
|
||||
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:
|
||||
tags:
|
||||
- { '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