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) {
|
||||
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);
|
||||
}
|
||||
} else {
|
||||
|
@ -278,6 +278,7 @@ export default {
|
||||
},
|
||||
saveFormOnTheFly({ type, data }) {
|
||||
console.log('saveFormOnTheFly from addPersons, type', type, ', data', data);
|
||||
//TODO: create a household if address in data.
|
||||
if (type === 'person') {
|
||||
makeFetch('POST', '/api/1.0/person/person.json', data)
|
||||
.then(response => {
|
||||
|
@ -138,6 +138,16 @@
|
||||
aria-describedby="email" />
|
||||
</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">
|
||||
<ul>
|
||||
<li v-for="(e, i) in errors" :key="i">{{ e }}</li>
|
||||
@ -150,24 +160,41 @@
|
||||
<script>
|
||||
import { getCivilities, getPerson, getPersonAltNames } from '../../_api/OnTheFly';
|
||||
import PersonRenderBox from '../Entity/PersonRenderBox.vue';
|
||||
import AddAddress from "ChillMainAssets/vuejs/Address/components/AddAddress.vue";
|
||||
|
||||
export default {
|
||||
name: "OnTheFlyPerson",
|
||||
props: ['id', 'type', 'action', 'query'],
|
||||
//emits: ['createAction'],
|
||||
components: {
|
||||
PersonRenderBox
|
||||
PersonRenderBox,
|
||||
AddAddress
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
person: {
|
||||
type: 'person',
|
||||
altNames: []
|
||||
altNames: [],
|
||||
addressId: null
|
||||
},
|
||||
config: {
|
||||
altNames: [],
|
||||
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: []
|
||||
}
|
||||
},
|
||||
@ -299,6 +326,9 @@ export default {
|
||||
this.person.firstName = queryItem;
|
||||
break;
|
||||
}
|
||||
},
|
||||
submitNewAddress(payload) {
|
||||
this.person.addressId = payload.addressId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -42,6 +42,9 @@ const personMessages = {
|
||||
civility: {
|
||||
title: "Civilité",
|
||||
placeholder: "Choisissez la civilité",
|
||||
},
|
||||
address: {
|
||||
create_address: "Ajouter une adresse"
|
||||
}
|
||||
},
|
||||
error_only_one_person: "Une seule personne peut être sélectionnée !"
|
||||
|
Loading…
x
Reference in New Issue
Block a user