Merge branch 'issue491_thirdparty_edit_modal' into 'master'

Thirdparty: fix edit modal + add firstname

See merge request Chill-Projet/chill-bundles!379
This commit is contained in:
Julien Fastré 2022-03-24 18:33:31 +00:00
commit 367188b03d
23 changed files with 350 additions and 96 deletions

View File

@ -56,6 +56,10 @@ and this project adheres to
* [phonenumber] Remove placeholder in phonenumber field (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/496) * [phonenumber] Remove placeholder in phonenumber field (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/496)
* [person_resource] separate create page created to avoid confusion (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/504) * [person_resource] separate create page created to avoid confusion (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/504)
* [contact] add contact button color changed plus the pipe at the side removed (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/506) * [contact] add contact button color changed plus the pipe at the side removed (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/506)
* [thirdparty] For contacts show current civility/profession in edit form + fix saving of edited information (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/491)
* [household] create-edit household composition placed in separate page to avoid confusion (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/505)
* [blur] Improved positioning of toggle icon (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/486)
* [thirdparty] add firstname field to thirdparty 'child' or 'contact' types (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/508)
* [household] create-edit household composition placed in separate page to avoid confusion (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/505) * [household] create-edit household composition placed in separate page to avoid confusion (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/505)
* [blur] Improved positioning of toggle icon (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/486) * [blur] Improved positioning of toggle icon (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/486)
* [parcours] List of parcours for a specific user so they can be reassigned in case of absence (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/509) * [parcours] List of parcours for a specific user so they can be reassigned in case of absence (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/509)

View File

@ -21,14 +21,12 @@ const makeFetch = (method, url, body, options) => {
} }
if (response.status === 422) { if (response.status === 422) {
console.log('422 error')
return response.json().then(response => { return response.json().then(response => {
throw ValidationException(response) throw ValidationException(response)
}); });
} }
if (response.status === 403) { if (response.status === 403) {
console.log('403 error')
throw AccessException(response); throw AccessException(response);
} }

View File

@ -223,23 +223,26 @@ export default {
default: default:
if (typeof this.type === 'undefined') { // action=create or addContact if (typeof this.type === 'undefined') { // action=create or addContact
console.log('will rewrite data'); // console.log('will rewrite data');
if (this.action === 'addContact') { if (this.action === 'addContact') {
type = 'thirdparty' type = 'thirdparty'
data = this.$refs.castThirdparty.$data.thirdparty; data = this.$refs.castThirdparty.$data.thirdparty;
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.profession = data.profession !== null ? {type: 'third_party_profession', id: data.profession.id} : null;
} else { } else {
type = this.$refs.castNew.radioType; type = this.$refs.castNew.radioType;
data = this.$refs.castNew.castDataByType(); data = this.$refs.castNew.castDataByType();
console.log(data) // console.log('type', type);
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;
// console.log('onthefly data', data);
} }
} else { } else {
throw 'error with object type'; throw 'error with object type';
} }
} }
console.log('type', type);
console.log('data', data);
// pass datas to parent // pass datas to parent
this.$emit('saveFormOnTheFly', { type: type, data: data }); this.$emit('saveFormOnTheFly', { type: type, data: data });
}, },

View File

@ -89,11 +89,9 @@ export default {
return this.isMultiline === true ? "div" : "span"; return this.isMultiline === true ? "div" : "span";
}, },
multiline() { multiline() {
//console.log(this.isMultiline, typeof this.isMultiline);
return this.isMultiline === true ? "multiline" : ""; return this.isMultiline === true ? "multiline" : "";
}, },
isConfidential() { isConfidential() {
console.log(this.address.confidential)
return this.address.confidential; return this.address.confidential;
} }
} }

View File

@ -137,7 +137,7 @@ export default {
}, },
methods: { methods: {
saveFormOnTheFly(payload) { saveFormOnTheFly(payload) {
console.log('saveFormOnTheFly: type', payload.type, ', data', payload.data); // console.log('saveFormOnTheFly: type', payload.type, ', data', payload.data);
payload.target = 'resource'; payload.target = 'resource';
let body = { type: payload.type }; let body = { type: payload.type };
@ -167,13 +167,19 @@ export default {
}) })
} }
else if (payload.type === 'thirdparty') { else if (payload.type === 'thirdparty') {
console.log('data', payload.data) // console.log('data', payload.data)
body.firstname = payload.data.firstname;
body.name = payload.data.name; body.name = payload.data.name;
body.email = payload.data.email; body.email = payload.data.email;
body.telephone = payload.data.telephone; body.telephone = payload.data.telephone;
body.civility = payload.data.civility;
body.profession = payload.data.profession;
body.address = payload.data.address ? { id: payload.data.address.address_id } : null; body.address = payload.data.address ? { id: payload.data.address.address_id } : null;
if (null !== payload.data.civility) {
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};
}
// console.log('body', body);
makeFetch('PATCH', `/api/1.0/thirdparty/thirdparty/${payload.data.id}.json`, body) makeFetch('PATCH', `/api/1.0/thirdparty/thirdparty/${payload.data.id}.json`, body)
.then(response => { .then(response => {

View File

@ -24,11 +24,11 @@
<div class="form-floating mb-3"> <div class="form-floating mb-3">
<input <input
class="form-control form-control-lg" class="form-control form-control-lg"
id="lastname" id="lastname"
v-model="lastName" v-model="lastName"
:placeholder="$t('person.lastname')" :placeholder="$t('person.lastname')"
@change="checkErrors" @change="checkErrors"
/> />
<label for="lastname">{{ $t('person.lastname') }}</label> <label for="lastname">{{ $t('person.lastname') }}</label>
</div> </div>
@ -43,11 +43,11 @@
<div class="form-floating mb-3"> <div class="form-floating mb-3">
<input <input
class="form-control form-control-lg" class="form-control form-control-lg"
id="firstname" id="firstname"
v-model="firstName" v-model="firstName"
:placeholder="$t('person.firstname')" :placeholder="$t('person.firstname')"
@change="checkErrors" @change="checkErrors"
/> />
<label for="firstname">{{ $t('person.firstname') }}</label> <label for="firstname">{{ $t('person.firstname') }}</label>
</div> </div>
@ -62,10 +62,10 @@
<div v-for="(a, i) in config.altNames" :key="a.key" class="form-floating mb-3"> <div v-for="(a, i) in config.altNames" :key="a.key" class="form-floating mb-3">
<input <input
class="form-control form-control-lg" class="form-control form-control-lg"
:id="a.key" :id="a.key"
:value="personAltNamesLabels[i]" :value="personAltNamesLabels[i]"
@input="onAltNameInput" @input="onAltNameInput"
/> />
<label :for="a.key">{{ a.labels.fr }}</label> <label :for="a.key">{{ a.labels.fr }}</label>
</div> </div>
@ -125,9 +125,9 @@
</div> </div>
<div class="alert alert-warning" v-if="errors.length"> <div class="alert alert-warning" v-if="errors.length">
<ul> <ul>
<li v-for="(e, i) in errors" :key="i">{{ e }}</li> <li v-for="(e, i) in errors" :key="i">{{ e }}</li>
</ul> </ul>
</div> </div>
</div> </div>
@ -238,13 +238,13 @@ export default {
checkErrors(e) { checkErrors(e) {
this.errors = []; this.errors = [];
if (!this.person.lastName) { if (!this.person.lastName) {
this.errors.push("Le nom ne doit pas être vide."); this.errors.push("Le nom ne doit pas être vide.");
} }
if (!this.person.firstName) { if (!this.person.firstName) {
this.errors.push("Le prénom ne doit pas être vide."); this.errors.push("Le prénom ne doit pas être vide.");
} }
if (!this.person.gender) { if (!this.person.gender) {
this.errors.push("Le genre doit être renseigné"); this.errors.push("Le genre doit être renseigné");
} }
}, },
loadData() { loadData() {

View File

@ -46,6 +46,7 @@ class ChillThirdPartyExtension extends Extension implements PrependExtensionInte
$loader->load('services/fixtures.yaml'); $loader->load('services/fixtures.yaml');
$loader->load('services/serializer.yaml'); $loader->load('services/serializer.yaml');
$loader->load('services/repository.yaml'); $loader->load('services/repository.yaml');
$loader->load('services/doctrineEventListener.yaml');
} }
public function prepend(ContainerBuilder $container) public function prepend(ContainerBuilder $container)

View File

@ -197,6 +197,12 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface
*/ */
private ?string $email = null; private ?string $email = null;
/**
* @ORM\Column(name="firstname", type="text", options={"default":""})
* @Groups({"read", "write", "docgen:read", "docgen:read:3party:parent"})
*/
private string $firstname = '';
/** /**
* @var int * @var int
* @ORM\Column(name="id", type="integer") * @ORM\Column(name="id", type="integer")
@ -454,12 +460,12 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface
return $this->email; return $this->email;
} }
/** public function getFirstname(): string
* Get id. {
* return $this->firstname;
* @return int }
*/
public function getId() public function getId(): ?int
{ {
return $this->id; return $this->id;
} }
@ -469,12 +475,7 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface
return $this->kind; return $this->kind;
} }
/** public function getName(): string
* Get name.
*
* @return string
*/
public function getName()
{ {
return $this->name; return $this->name;
} }
@ -766,6 +767,13 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface
return $this; return $this;
} }
public function setFirstname(string $firstname): self
{
$this->firstname = $firstname;
return $this;
}
public function setKind(?string $kind): ThirdParty public function setKind(?string $kind): ThirdParty
{ {
$this->kind = $kind; $this->kind = $kind;
@ -773,14 +781,7 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface
return $this; return $this;
} }
/** public function setName($name): self
* Set name.
*
* @param string $name
*
* @return ThirdParty
*/
public function setName($name)
{ {
$this->name = $name; $this->name = $name;

View File

@ -0,0 +1,31 @@
<?php
/**
* 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.
*/
declare(strict_types=1);
namespace Chill\ThirdPartyBundle\EventListener;
use Chill\ThirdPartyBundle\Entity\ThirdParty;
use const MB_CASE_TITLE;
class ThirdPartyEventListener
{
public function prePersistThirdParty(ThirdParty $thirdparty): void
{
if ($thirdparty->getKind() !== 'company') {
$firstnameCaps = mb_convert_case(mb_strtolower($thirdparty->getFirstname()), MB_CASE_TITLE, 'UTF-8');
$firstnameCaps = ucwords(strtolower($firstnameCaps), " \t\r\n\f\v'-");
$thirdparty->setFirstName($firstnameCaps);
$lastnameCaps = mb_strtoupper($thirdparty->getName(), 'UTF-8');
$thirdparty->setName($lastnameCaps);
}
}
}

View File

@ -102,6 +102,10 @@ class ThirdPartyType extends AbstractType
// Contact Person ThirdParty (child) // Contact Person ThirdParty (child)
if (ThirdParty::KIND_CONTACT === $options['kind'] || ThirdParty::KIND_CHILD === $options['kind']) { if (ThirdParty::KIND_CONTACT === $options['kind'] || ThirdParty::KIND_CHILD === $options['kind']) {
$builder $builder
->add('firstname', TextType::class, [
'label' => 'firstname',
'required' => false,
])
->add('civility', PickCivilityType::class, [ ->add('civility', PickCivilityType::class, [
'label' => 'thirdparty.Civility', 'label' => 'thirdparty.Civility',
'placeholder' => 'thirdparty.choose civility', 'placeholder' => 'thirdparty.choose civility',

View File

@ -65,34 +65,64 @@
</div> </div>
<div v-if="thirdparty.kind === 'child' || thirdparty.kind === 'contact'"> <div v-if="thirdparty.kind === 'child' || thirdparty.kind === 'contact'">
<div id="child-info"> <div class="child-info">
<div class="input-group mb-3"> <div class="input-group mb-3 input-section">
<select class="form-select form-select-lg" id="profession" <select class="form-select form-select-lg" id="civility"
v-model="thirdparty.civility"> v-model="thirdparty.civility">
<option selected disabled :value="null" >{{ $t('thirdparty.civility') }}</option> <option selected disabled :value="null" >{{ $t('thirdparty.civility') }}</option>
<option v-for="civility in civilities" :key="civility.id" :value="{type: 'chill_main_civility', id: civility.id }">{{ civility.name.fr }}</option> <option v-for="civility in civilities" :key="civility.id" :value="civility">{{ civility.name.fr }}</option>
</select> </select>
</div> </div>
<div class="input-group mb-3"> <div class="input-group mb-3 input-section">
<select class="form-select form-select-lg" id="civility" <select class="form-select form-select-lg" id="profession"
v-model="thirdparty.profession"> v-model="thirdparty.profession">
<option selected disabled :value="null">{{ $t('thirdparty.profession') }}</option> <option selected disabled :value="null">{{ $t('thirdparty.profession') }}</option>
<option v-for="profession in professions" :key="profession.id" :value="{type: 'third_party_profession', id: profession.id }">{{ profession.name.fr }}</option> <option v-for="profession in professions" :key="profession.id" :value="profession">{{ profession.name.fr }}</option>
</select> </select>
</div> </div>
</div> </div>
<div class="child-info">
<div class="input-section">
<div class="form-floating mb-3">
<input class="form-control form-control-lg" id="firstname" v-model="thirdparty.firstname" v-bind:placeholder="$t('thirdparty.firstname')" />
<label for="firstname">{{ $t('thirdparty.firstname') }}</label>
</div>
<div v-if="queryItems">
<ul class="list-suggest add-items inline">
<li v-for="(qi, i) in queryItems" :key="i" @click="addQueryItem('firstName', qi)">
<span class="person-text">{{ qi }}</span>
</li>
</ul>
</div>
</div>
<div class="input-section">
<div class="form-floating mb-3">
<input class="form-control form-control-lg" id="name" v-model="thirdparty.name" v-bind:placeholder="$t('thirdparty.lastname')" />
<label for="name">{{ $t('thirdparty.lastname') }}</label>
</div>
<div v-if="queryItems">
<ul class="list-suggest add-items inline">
<li v-for="(qi, i) in queryItems" :key="i" @click="addQueryItem('name', qi)">
<span class="person-text">{{ qi }}</span>
</li>
</ul>
</div>
</div>
</div>
</div> </div>
<div class="form-floating mb-3"> <div v-if="thirdparty.kind === 'company'">
<input class="form-control form-control-lg" id="name" v-model="thirdparty.name" v-bind:placeholder="$t('thirdparty.name')" /> <div class="form-floating mb-3">
<label for="name">{{ $t('thirdparty.name') }}</label> <input class="form-control form-control-lg" id="name" v-model="thirdparty.name" v-bind:placeholder="$t('thirdparty.name')" />
</div> <label for="name">{{ $t('thirdparty.name') }}</label>
<div v-if="query"> </div>
<ul class="list-suggest add-items inline"> <div v-if="query">
<li @click="addQuery(query)"> <ul class="list-suggest add-items inline">
<span class="person-text">{{ query }}</span> <li @click="addQuery(query)">
</li> <span class="person-text">{{ query }}</span>
</ul> </li>
</ul>
</div>
</div> </div>
<template <template
@ -158,6 +188,7 @@ export default {
type: 'thirdparty', type: 'thirdparty',
address: null, address: null,
kind: 'company', kind: 'company',
firstname: '',
name: '', name: '',
telephone: '', telephone: '',
civility: null, civility: null,
@ -209,17 +240,18 @@ export default {
context.addressId = this.thirdparty.address.address_id; context.addressId = this.thirdparty.address.address_id;
context.edit = true; context.edit = true;
} }
console.log('context', context);
//this.context = context; <-- //this.context = context; <--
return context; return context;
}, },
queryItems() {
return this.query ? this.query.split(' ') : null;
},
}, },
methods: { methods: {
loadData(){ loadData(){
return getThirdparty(this.id).then(thirdparty => new Promise((resolve, reject) => { return getThirdparty(this.id).then(thirdparty => new Promise((resolve, reject) => {
this.thirdparty = thirdparty; this.thirdparty = thirdparty;
this.thirdparty.kind = thirdparty.kind; this.thirdparty.kind = thirdparty.kind;
console.log('get thirdparty', thirdparty);
if (this.action !== 'show') { if (this.action !== 'show') {
if (thirdparty.address !== null) { if (thirdparty.address !== null) {
// bof! we force getInitialAddress because addressId not available when mounted // bof! we force getInitialAddress because addressId not available when mounted
@ -262,14 +294,24 @@ export default {
console.log('switch address to edit mode', this.context); console.log('switch address to edit mode', this.context);
} }
}, },
addQueryItem(field, queryItem) {
switch (field) {
case 'name':
this.thirdparty.name = queryItem;
break;
case 'firstName':
this.thirdparty.firstname = queryItem;
break;
}
},
addQuery(query) { addQuery(query) {
this.thirdparty.name = query; this.thirdparty.name = query;
}, },
}, },
mounted() { mounted() {
let dependencies = []; let dependencies = [];
dependencies.push(this.loadProfessions()); 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) {
dependencies.push(this.loadData()); dependencies.push(this.loadData());
@ -307,12 +349,13 @@ dl {
margin-bottom: 1rem; margin-bottom: 1rem;
} }
#child-info { .child-info {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
div { .input-section {
width: 49%; width: 49%;
} }
} }
</style> </style>

View File

@ -1,6 +1,8 @@
const thirdpartyMessages = { const thirdpartyMessages = {
fr: { fr: {
thirdparty: { thirdparty: {
firstname: "Prénom",
lastname: "Nom",
name: "Dénomination", name: "Dénomination",
email: "Courriel", email: "Courriel",
phonenumber: "Téléphone", phonenumber: "Téléphone",

View File

@ -5,6 +5,11 @@
{{ form_row(form.name) }} {{ form_row(form.name) }}
{% if form.firstname is defined %}
{{ form_row(form.firstname) }}
{% endif %}
{% if form.nameCompany is defined %} {% if form.nameCompany is defined %}
{{ form_row(form.nameCompany) }} {{ form_row(form.nameCompany) }}
{{ form_row(form.acronym) }} {{ form_row(form.acronym) }}

View File

@ -2,20 +2,25 @@
{% block _third_party_active_children_entry_widget %} {% block _third_party_active_children_entry_widget %}
<div class="container"> <div class="container">
<div class="row"> <div class="row">
<div class="form-group col-md-3 mb-3"> <div class="form-group col-md-6 mb-3">
{{ form_widget(form.civility) }} {{ form_widget(form.civility) }}
{{ form_errors(form.civility) }} {{ form_errors(form.civility) }}
{{ form_label(form.civility) }} {{ form_label(form.civility) }}
</div> </div>
<div class="form-group col-md-5 mb-3"> <div class="form-group col-md-6 mb-3">
{{ form_widget(form.profession) }}
{{ form_errors(form.profession) }}
{{ form_label(form.profession) }}
</div>
<div class="form-group col-md-6 mb-3">
{{ form_widget(form.name) }} {{ form_widget(form.name) }}
{{ form_errors(form.name) }} {{ form_errors(form.name) }}
{{ form_label(form.name) }} {{ form_label(form.name) }}
</div> </div>
<div class="form-group col-md-4 mb-3"> <div class="form-group col-md-6 mb-3">
{{ form_widget(form.profession) }} {{ form_widget(form.firstname) }}
{{ form_errors(form.profession) }} {{ form_errors(form.firstname) }}
{{ form_label(form.profession) }} {{ form_label(form.firstname) }}
</div> </div>
</div> </div>
<div class="row"> <div class="row">

View File

@ -1,7 +1,8 @@
{% extends "@ChillMain/layout.html.twig" %} {% extends "@ChillMain/layout.html.twig" %}
{% set thirdParty = entity %} {% set thirdParty = entity %}
{% set title_ = 'Show third party %name%'|trans({'%name%' : thirdParty.name }) %} {% set name = thirdParty.firstname is not empty ? thirdParty.firstname ~ ' ' ~ thirdParty.name : thirdParty.name %}
{% set title_ = 'Show third party %name%'|trans({'%name%' : name }) %}
{% block title title_ %} {% block title title_ %}
@ -25,7 +26,7 @@
<dt>{{ 'Name'|trans }}</dt> <dt>{{ 'Name'|trans }}</dt>
<dd> <dd>
{% if thirdParty.isLeaf == true %}{{ thirdParty.civility }}{% endif %} {% if thirdParty.isLeaf == true %}{{ thirdParty.civility }}{% endif %}
{{ thirdParty.name }} {{ thirdParty.firstname ~ ' ' ~ thirdParty.name }}
</dd> </dd>
{% if thirdParty.kind == 'company' %} {% if thirdParty.kind == 'company' %}

View File

@ -43,6 +43,7 @@ class ThirdPartyNormalizer implements NormalizerAwareInterface, NormalizerInterf
{ {
return [ return [
'type' => 'thirdparty', 'type' => 'thirdparty',
'firstname' => $thirdParty->getFirstname(),
'name' => $thirdParty->getName(), 'name' => $thirdParty->getName(),
'text' => $this->thirdPartyRender->renderString($thirdParty, []), 'text' => $this->thirdPartyRender->renderString($thirdParty, []),
'id' => $thirdParty->getId(), 'id' => $thirdParty->getId(),

View File

@ -77,7 +77,9 @@ class ThirdPartyRender extends AbstractChillEntityRender
$acronym = ''; $acronym = '';
} }
return $civility . $entity->getName() . $acronym; $firstname = empty($entity->getFirstname()) ? '' : $entity->getFirstname();
return $civility . $firstname . ' ' . $entity->getName() . $acronym;
} }
public function supports($entity, array $options): bool public function supports($entity, array $options): bool

View File

@ -20,6 +20,8 @@ components:
type: string type: string
enum: enum:
- "thirdparty" - "thirdparty"
firstname:
type: string
name: name:
type: string type: string
email: email:

View File

@ -0,0 +1,9 @@
services:
Chill\ThirdPartyBundle\EventListener\ThirdPartyEventListener:
autoconfigure: true
tags:
-
name: 'doctrine.orm.entity_listener'
event: 'prePersist'
entity: 'Chill\ThirdPartyBundle\Entity\ThirdParty'
method: 'prePersistThirdParty'

View File

@ -39,15 +39,15 @@ final class Version20211007165001 extends AbstractMigration
$this->addSql(" $this->addSql("
UPDATE chill_3party.third_party UPDATE chill_3party.third_party
SET canonicalized = SET canonicalized =
UNACCENT( UNACCENT(
LOWER( LOWER(
name || name ||
CASE WHEN COALESCE(name_company, '') <> '' THEN ' ' ELSE '' END || CASE WHEN COALESCE(name_company, '') <> '' THEN ' ' ELSE '' END ||
COALESCE(name_company, '') || COALESCE(name_company, '') ||
CASE WHEN COALESCE(acronym, '') <> '' THEN ' ' ELSE '' END || CASE WHEN COALESCE(acronym, '') <> '' THEN ' ' ELSE '' END ||
COALESCE(acronym, '') COALESCE(acronym, '')
) )
) )
"); ");
$this->addSql(" $this->addSql("
CREATE OR REPLACE FUNCTION chill_3party.canonicalize() RETURNS TRIGGER CREATE OR REPLACE FUNCTION chill_3party.canonicalize() RETURNS TRIGGER

View File

@ -0,0 +1,38 @@
<?php
/**
* 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.
*/
declare(strict_types=1);
namespace Chill\Migrations\ThirdParty;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20220322095659 extends AbstractMigration
{
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE chill_3party.third_party DROP firstname');
}
public function getDescription(): string
{
return 'Add firstname to thirdparty';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE chill_3party.third_party ADD firstname TEXT DEFAULT \'\'');
}
}

View File

@ -0,0 +1,99 @@
<?php
declare(strict_types=1);
namespace Chill\Migrations\ThirdParty;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
final class Version20220324175549 extends AbstractMigration
{
public function getDescription(): string
{
return 'indexing of firstname on third parties';
}
public function up(Schema $schema): void
{
$this->addSql("
UPDATE chill_3party.third_party
SET canonicalized =
UNACCENT(
LOWER(
name ||
CASE WHEN firstname <> '' THEN ' ' ELSE '' END ||
firstname ||
CASE WHEN COALESCE(name_company, '') <> '' THEN ' ' ELSE '' END ||
COALESCE(name_company, '') ||
CASE WHEN COALESCE(acronym, '') <> '' THEN ' ' ELSE '' END ||
COALESCE(acronym, '')
)
)
");
$this->addSql("
CREATE OR REPLACE FUNCTION chill_3party.canonicalize() RETURNS TRIGGER
LANGUAGE plpgsql
AS
$$
BEGIN
NEW.canonicalized =
UNACCENT(
LOWER(
NEW.name ||
CASE WHEN NEW.firstname <> '' THEN ' ' ELSE '' END ||
NEW.firstname ||
CASE WHEN COALESCE(NEW.name_company, '') <> '' THEN ' ' ELSE '' END ||
COALESCE(NEW.name_company, '') ||
CASE WHEN COALESCE(NEW.acronym, '') <> '' THEN ' ' ELSE '' END ||
COALESCE(NEW.acronym, '')
)
)
;
return NEW;
END
$$
");
}
public function down(Schema $schema): void
{
$this->addSql("
CREATE OR REPLACE FUNCTION chill_3party.canonicalize() RETURNS TRIGGER
LANGUAGE plpgsql
AS
$$
BEGIN
NEW.canonicalized =
UNACCENT(
LOWER(
NEW.name ||
CASE WHEN COALESCE(NEW.name_company, '') <> '' THEN ' ' ELSE '' END ||
COALESCE(NEW.name_company, '') ||
CASE WHEN COALESCE(NEW.acronym, '') <> '' THEN ' ' ELSE '' END ||
COALESCE(NEW.acronym, '')
)
)
;
return NEW;
END
$$
");
$this->addSql("
UPDATE chill_3party.third_party
SET canonicalized =
UNACCENT(
LOWER(
name ||
CASE WHEN COALESCE(name_company, '') <> '' THEN ' ' ELSE '' END ||
COALESCE(name_company, '') ||
CASE WHEN COALESCE(acronym, '') <> '' THEN ' ' ELSE '' END ||
COALESCE(acronym, '')
)
)
");
}
}

View File

@ -1,6 +1,7 @@
Third party: Tiers Third party: Tiers
Third parties: Tiers Third parties: Tiers
third parties: tiers third parties: tiers
firstname: Prénom
name: Nom name: Nom
telephone: Téléphone telephone: Téléphone
adress: Adresse adress: Adresse