rename key in payload

This commit is contained in:
Mathieu Jaumotte 2021-08-16 18:38:08 +02:00
parent e8e2607076
commit 29b5e700f6
3 changed files with 6 additions and 12 deletions

View File

@ -25,7 +25,7 @@ export default {
let payload = { let payload = {
entity: this.context.entity.type, entity: this.context.entity.type,
entityId: this.context.entity.id, entityId: this.context.entity.id,
addressToPatch: 'person', locationStatusTo: 'person',
personId: this.person.id personId: this.person.id
}; };
this.$store.dispatch('updateLocation', payload); this.$store.dispatch('updateLocation', payload);

View File

@ -121,7 +121,7 @@ export default {
let payload = { let payload = {
entity: this.context.entity.type, entity: this.context.entity.type,
entityId: this.context.entity.id, entityId: this.context.entity.id,
addressToPatch: 'none' locationStatusTo: 'none'
}; };
this.$store.dispatch('updateLocation', payload); this.$store.dispatch('updateLocation', payload);
}, },
@ -130,12 +130,8 @@ export default {
}, },
submitTemporaryAddress() { submitTemporaryAddress() {
console.log('@@@ click on Submit Temporary Address Button'); console.log('@@@ click on Submit Temporary Address Button');
let payload = this.$refs.addAddress.submitNewAddress(); let payload = this.$refs.addAddress.submitNewAddress();
payload['locationStatusTo'] = 'address'; // <== temporary, not none, not person
// precise in payload that it is a temporary address
payload['addressToPatch'] = 'address';
this.$store.dispatch('updateLocation', payload); this.$store.dispatch('updateLocation', payload);
} }
}, },

View File

@ -226,15 +226,13 @@ let initPromise = getAccompanyingCourse(id)
console.log('## action: updateLocation', payload); console.log('## action: updateLocation', payload);
let body = { 'type': payload.entity, 'id': payload.entityId }; let body = { 'type': payload.entity, 'id': payload.entityId };
let location = {}; let location = {};
if (payload.addressToPatch === 'person') { if (payload.locationStatusTo === 'person') { // patch for person address (don't remove addressLocation)
// payload to patch person address (don't remove addressLocation)
location = { 'personLocation': { 'type': 'person', 'id': payload.personId }}; location = { 'personLocation': { 'type': 'person', 'id': payload.personId }};
} }
else if(payload.addressToPatch === 'address') { else if (payload.locationStatusTo === 'address') { // patch for temporary address
// payload to patch temporary address
location = { 'personLocation': null, 'addressLocation': { 'id': payload.addressId }}; location = { 'personLocation': null, 'addressLocation': { 'id': payload.addressId }};
} }
else { else { // patch to remove person address
location = { 'personLocation': null }; location = { 'personLocation': null };
} }
Object.assign(body, location); Object.assign(body, location);