diff --git a/CHANGELOG.md b/CHANGELOG.md
index 51cf606e6..1a3031354 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -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)
* [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)
+* [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)
* [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)
diff --git a/src/Bundle/ChillMainBundle/Resources/public/lib/api/apiMethods.js b/src/Bundle/ChillMainBundle/Resources/public/lib/api/apiMethods.js
index 75f1a21c8..80e59005f 100644
--- a/src/Bundle/ChillMainBundle/Resources/public/lib/api/apiMethods.js
+++ b/src/Bundle/ChillMainBundle/Resources/public/lib/api/apiMethods.js
@@ -21,14 +21,12 @@ const makeFetch = (method, url, body, options) => {
}
if (response.status === 422) {
- console.log('422 error')
return response.json().then(response => {
throw ValidationException(response)
});
}
if (response.status === 403) {
- console.log('403 error')
throw AccessException(response);
}
diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/components/OnTheFly.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/components/OnTheFly.vue
index 5528d563e..979f53d74 100644
--- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/components/OnTheFly.vue
+++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/components/OnTheFly.vue
@@ -223,23 +223,26 @@ export default {
default:
if (typeof this.type === 'undefined') { // action=create or addContact
- console.log('will rewrite data');
+ // console.log('will rewrite data');
if (this.action === 'addContact') {
type = '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.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 {
type = this.$refs.castNew.radioType;
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 {
throw 'error with object type';
}
}
- console.log('type', type);
- console.log('data', data);
// pass datas to parent
this.$emit('saveFormOnTheFly', { type: type, data: data });
},
diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/Entity/AddressRenderBox.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/Entity/AddressRenderBox.vue
index a7f121a87..2e88bc1cb 100644
--- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/Entity/AddressRenderBox.vue
+++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/Entity/AddressRenderBox.vue
@@ -89,11 +89,9 @@ export default {
return this.isMultiline === true ? "div" : "span";
},
multiline() {
- //console.log(this.isMultiline, typeof this.isMultiline);
return this.isMultiline === true ? "multiline" : "";
},
isConfidential() {
- console.log(this.address.confidential)
return this.address.confidential;
}
}
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Resources/ResourceItem.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Resources/ResourceItem.vue
index 37321e0bb..df2bd0c35 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Resources/ResourceItem.vue
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Resources/ResourceItem.vue
@@ -137,7 +137,7 @@ export default {
},
methods: {
saveFormOnTheFly(payload) {
- console.log('saveFormOnTheFly: type', payload.type, ', data', payload.data);
+ // console.log('saveFormOnTheFly: type', payload.type, ', data', payload.data);
payload.target = 'resource';
let body = { type: payload.type };
@@ -167,13 +167,19 @@ export default {
})
}
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.email = payload.data.email;
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;
+ 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)
.then(response => {
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/OnTheFly/Person.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/OnTheFly/Person.vue
index 366ecd6b7..e6fa85902 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/OnTheFly/Person.vue
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/OnTheFly/Person.vue
@@ -24,11 +24,11 @@
@@ -43,11 +43,11 @@
@@ -62,10 +62,10 @@
@@ -125,9 +125,9 @@
@@ -238,13 +238,13 @@ export default {
checkErrors(e) {
this.errors = [];
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) {
- 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) {
- this.errors.push("Le genre doit être renseigné");
+ this.errors.push("Le genre doit être renseigné");
}
},
loadData() {
diff --git a/src/Bundle/ChillThirdPartyBundle/DependencyInjection/ChillThirdPartyExtension.php b/src/Bundle/ChillThirdPartyBundle/DependencyInjection/ChillThirdPartyExtension.php
index 124f5b7f3..d2023fae5 100644
--- a/src/Bundle/ChillThirdPartyBundle/DependencyInjection/ChillThirdPartyExtension.php
+++ b/src/Bundle/ChillThirdPartyBundle/DependencyInjection/ChillThirdPartyExtension.php
@@ -46,6 +46,7 @@ class ChillThirdPartyExtension extends Extension implements PrependExtensionInte
$loader->load('services/fixtures.yaml');
$loader->load('services/serializer.yaml');
$loader->load('services/repository.yaml');
+ $loader->load('services/doctrineEventListener.yaml');
}
public function prepend(ContainerBuilder $container)
diff --git a/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php b/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php
index 678084045..d7efce10c 100644
--- a/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php
+++ b/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php
@@ -197,6 +197,12 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface
*/
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
* @ORM\Column(name="id", type="integer")
@@ -454,12 +460,12 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface
return $this->email;
}
- /**
- * Get id.
- *
- * @return int
- */
- public function getId()
+ public function getFirstname(): string
+ {
+ return $this->firstname;
+ }
+
+ public function getId(): ?int
{
return $this->id;
}
@@ -469,12 +475,7 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface
return $this->kind;
}
- /**
- * Get name.
- *
- * @return string
- */
- public function getName()
+ public function getName(): string
{
return $this->name;
}
@@ -766,6 +767,13 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface
return $this;
}
+ public function setFirstname(string $firstname): self
+ {
+ $this->firstname = $firstname;
+
+ return $this;
+ }
+
public function setKind(?string $kind): ThirdParty
{
$this->kind = $kind;
@@ -773,14 +781,7 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface
return $this;
}
- /**
- * Set name.
- *
- * @param string $name
- *
- * @return ThirdParty
- */
- public function setName($name)
+ public function setName($name): self
{
$this->name = $name;
diff --git a/src/Bundle/ChillThirdPartyBundle/EventListener/ThirdPartyEventListener.php b/src/Bundle/ChillThirdPartyBundle/EventListener/ThirdPartyEventListener.php
new file mode 100644
index 000000000..bdeed8866
--- /dev/null
+++ b/src/Bundle/ChillThirdPartyBundle/EventListener/ThirdPartyEventListener.php
@@ -0,0 +1,31 @@
+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);
+ }
+ }
+}
diff --git a/src/Bundle/ChillThirdPartyBundle/Form/ThirdPartyType.php b/src/Bundle/ChillThirdPartyBundle/Form/ThirdPartyType.php
index cf34c8919..242fa997b 100644
--- a/src/Bundle/ChillThirdPartyBundle/Form/ThirdPartyType.php
+++ b/src/Bundle/ChillThirdPartyBundle/Form/ThirdPartyType.php
@@ -102,6 +102,10 @@ class ThirdPartyType extends AbstractType
// Contact Person ThirdParty (child)
if (ThirdParty::KIND_CONTACT === $options['kind'] || ThirdParty::KIND_CHILD === $options['kind']) {
$builder
+ ->add('firstname', TextType::class, [
+ 'label' => 'firstname',
+ 'required' => false,
+ ])
->add('civility', PickCivilityType::class, [
'label' => 'thirdparty.Civility',
'placeholder' => 'thirdparty.choose civility',
diff --git a/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_components/OnTheFly/ThirdParty.vue b/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_components/OnTheFly/ThirdParty.vue
index 8de41b989..85f09a9ed 100644
--- a/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_components/OnTheFly/ThirdParty.vue
+++ b/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_components/OnTheFly/ThirdParty.vue
@@ -65,34 +65,64 @@
-
-
-
-
-
-
-
+
+
+
+
+
+
new Promise((resolve, reject) => {
this.thirdparty = thirdparty;
this.thirdparty.kind = thirdparty.kind;
- console.log('get thirdparty', thirdparty);
if (this.action !== 'show') {
if (thirdparty.address !== null) {
// 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);
}
},
+ addQueryItem(field, queryItem) {
+ switch (field) {
+ case 'name':
+ this.thirdparty.name = queryItem;
+ break;
+ case 'firstName':
+ this.thirdparty.firstname = queryItem;
+ break;
+ }
+ },
addQuery(query) {
this.thirdparty.name = query;
},
},
- mounted() {
- let dependencies = [];
- dependencies.push(this.loadProfessions());
- dependencies.push(this.loadCivilities());
+ mounted() {
+ let dependencies = [];
+ dependencies.push(this.loadProfessions());
+ dependencies.push(this.loadCivilities());
if (this.action !== 'create') {
if (this.id) {
dependencies.push(this.loadData());
@@ -307,12 +349,13 @@ dl {
margin-bottom: 1rem;
}
-#child-info {
+.child-info {
display: flex;
justify-content: space-between;
- div {
+ .input-section {
width: 49%;
}
}
+
diff --git a/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_js/i18n.js b/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_js/i18n.js
index 76f01e3f4..04cfc0cf4 100644
--- a/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_js/i18n.js
+++ b/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_js/i18n.js
@@ -1,6 +1,8 @@
const thirdpartyMessages = {
fr: {
thirdparty: {
+ firstname: "Prénom",
+ lastname: "Nom",
name: "Dénomination",
email: "Courriel",
phonenumber: "Téléphone",
diff --git a/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/_form.html.twig b/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/_form.html.twig
index 4827ba19c..34da002f0 100644
--- a/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/_form.html.twig
+++ b/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/_form.html.twig
@@ -5,6 +5,11 @@
{{ form_row(form.name) }}
+{% if form.firstname is defined %}
+{{ form_row(form.firstname) }}
+{% endif %}
+
+
{% if form.nameCompany is defined %}
{{ form_row(form.nameCompany) }}
{{ form_row(form.acronym) }}
diff --git a/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/_form_thirdparty_children.html.twig b/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/_form_thirdparty_children.html.twig
index eac5c2a98..81dd4997f 100644
--- a/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/_form_thirdparty_children.html.twig
+++ b/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/_form_thirdparty_children.html.twig
@@ -2,20 +2,25 @@
{% block _third_party_active_children_entry_widget %}