mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
person: add address when creating a person
This commit is contained in:
parent
946ae31d11
commit
ae45f5f40b
@ -240,6 +240,13 @@ export default {
|
|||||||
if (typeof data.profession !== 'undefined' && null !== data.profession) {
|
if (typeof data.profession !== 'undefined' && null !== data.profession) {
|
||||||
data.profession = data.profession !== null ? {type: 'third_party_profession', id: data.profession.id} : null;
|
data.profession = data.profession !== null ? {type: 'third_party_profession', id: data.profession.id} : null;
|
||||||
}
|
}
|
||||||
|
if (null !== data.addressId) {
|
||||||
|
console.log(data)
|
||||||
|
//TODO make a good address object
|
||||||
|
// attach the addressId
|
||||||
|
// test if this condition is safe
|
||||||
|
|
||||||
|
}
|
||||||
// console.log('onthefly data', data);
|
// console.log('onthefly data', data);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -278,6 +278,7 @@ export default {
|
|||||||
},
|
},
|
||||||
saveFormOnTheFly({ type, data }) {
|
saveFormOnTheFly({ type, data }) {
|
||||||
console.log('saveFormOnTheFly from addPersons, type', type, ', data', data);
|
console.log('saveFormOnTheFly from addPersons, type', type, ', data', data);
|
||||||
|
//TODO: create a household if address in data.
|
||||||
if (type === 'person') {
|
if (type === 'person') {
|
||||||
makeFetch('POST', '/api/1.0/person/person.json', data)
|
makeFetch('POST', '/api/1.0/person/person.json', data)
|
||||||
.then(response => {
|
.then(response => {
|
||||||
|
@ -138,6 +138,16 @@
|
|||||||
aria-describedby="email" />
|
aria-describedby="email" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div v-if="action === 'create'" class="form-floating mb-3">
|
||||||
|
<add-address
|
||||||
|
:context="addAddress.context"
|
||||||
|
:options="addAddress.options"
|
||||||
|
:addressChangedCallback="submitNewAddress"
|
||||||
|
ref="addAddress">
|
||||||
|
</add-address>
|
||||||
|
</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>
|
||||||
@ -150,24 +160,41 @@
|
|||||||
<script>
|
<script>
|
||||||
import { getCivilities, getPerson, getPersonAltNames } from '../../_api/OnTheFly';
|
import { getCivilities, getPerson, getPersonAltNames } from '../../_api/OnTheFly';
|
||||||
import PersonRenderBox from '../Entity/PersonRenderBox.vue';
|
import PersonRenderBox from '../Entity/PersonRenderBox.vue';
|
||||||
|
import AddAddress from "ChillMainAssets/vuejs/Address/components/AddAddress.vue";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "OnTheFlyPerson",
|
name: "OnTheFlyPerson",
|
||||||
props: ['id', 'type', 'action', 'query'],
|
props: ['id', 'type', 'action', 'query'],
|
||||||
//emits: ['createAction'],
|
//emits: ['createAction'],
|
||||||
components: {
|
components: {
|
||||||
PersonRenderBox
|
PersonRenderBox,
|
||||||
|
AddAddress
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
person: {
|
person: {
|
||||||
type: 'person',
|
type: 'person',
|
||||||
altNames: []
|
altNames: [],
|
||||||
|
addressId: null
|
||||||
},
|
},
|
||||||
config: {
|
config: {
|
||||||
altNames: [],
|
altNames: [],
|
||||||
civilities: []
|
civilities: []
|
||||||
},
|
},
|
||||||
|
addAddress: {
|
||||||
|
options: {
|
||||||
|
button: {
|
||||||
|
text: { create: 'person.address.create_address' },
|
||||||
|
size: 'btn-sm'
|
||||||
|
},
|
||||||
|
title: { create: 'person.address.create_address' },
|
||||||
|
},
|
||||||
|
context: {
|
||||||
|
target: {}, // boilerplate for getting the address id
|
||||||
|
edit: false,
|
||||||
|
addressId: null
|
||||||
|
}
|
||||||
|
},
|
||||||
errors: []
|
errors: []
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -299,6 +326,9 @@ export default {
|
|||||||
this.person.firstName = queryItem;
|
this.person.firstName = queryItem;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
submitNewAddress(payload) {
|
||||||
|
this.person.addressId = payload.addressId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,6 +42,9 @@ const personMessages = {
|
|||||||
civility: {
|
civility: {
|
||||||
title: "Civilité",
|
title: "Civilité",
|
||||||
placeholder: "Choisissez la civilité",
|
placeholder: "Choisissez la civilité",
|
||||||
|
},
|
||||||
|
address: {
|
||||||
|
create_address: "Ajouter une adresse"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
error_only_one_person: "Une seule personne peut être sélectionnée !"
|
error_only_one_person: "Une seule personne peut être sélectionnée !"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user