mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
further transitioning to using the general makeFetch method everywhere + toasts
This commit is contained in:
parent
58119b3de0
commit
cb1002ca04
@ -329,7 +329,7 @@ export default {
|
||||
},
|
||||
hasSuggestions() {
|
||||
if (typeof(this.context.suggestions) !== 'undefined') {
|
||||
console.log('hasSuggestions', this.context.suggestions);
|
||||
// console.log('hasSuggestions', this.context.suggestions);
|
||||
return this.context.suggestions.length > 0;
|
||||
}
|
||||
return false;
|
||||
@ -360,9 +360,9 @@ export default {
|
||||
//console.log('validTo', this.validTo);
|
||||
//console.log('useDatePane', this.useDatePane);
|
||||
|
||||
console.log('Mounted now !');
|
||||
// console.log('Mounted now !');
|
||||
if (this.context.edit) {
|
||||
console.log('getInitialAddress', this.context.addressId);
|
||||
// console.log('getInitialAddress', this.context.addressId);
|
||||
this.getInitialAddress(this.context.addressId);
|
||||
}
|
||||
this.openShowPane();
|
||||
@ -375,32 +375,32 @@ export default {
|
||||
*/
|
||||
openShowPane() {
|
||||
if (this.flag.editPane === false && this.bypassFirstStep) {
|
||||
console.log('bypassFirstStep');
|
||||
// console.log('bypassFirstStep');
|
||||
this.closeShowPane();
|
||||
this.openEditPane();
|
||||
} else {
|
||||
this.flag.showPane = true;
|
||||
console.log('step0: open the Show Panel');
|
||||
// console.log('step0: open the Show Panel');
|
||||
}
|
||||
},
|
||||
closeShowPane() {
|
||||
// Show pane can be closed only when openPanesInModal is false
|
||||
if (!this.inModal) {
|
||||
this.flag.showPane = false;
|
||||
console.log('step0: close the Show Panel');
|
||||
// console.log('step0: close the Show Panel');
|
||||
}
|
||||
},
|
||||
openSuggestPane() {
|
||||
this.flag.suggestPane = true;
|
||||
console.log('step1: open the Suggestion Panel');
|
||||
// console.log('step1: open the Suggestion Panel');
|
||||
},
|
||||
closeSuggestPane() {
|
||||
this.flag.suggestPane = false;
|
||||
console.log('step1: close the Suggestion Panel');
|
||||
// console.log('step1: close the Suggestion Panel');
|
||||
},
|
||||
openEditPane() {
|
||||
if (this.flag.suggestPane === false && this.displaySuggestions) {
|
||||
console.log('displaySuggestions');
|
||||
// console.log('displaySuggestions');
|
||||
this.openSuggestPane();
|
||||
} else {
|
||||
if (this.flag.datePane === false) {
|
||||
@ -411,7 +411,7 @@ export default {
|
||||
},
|
||||
closeEditPane() {
|
||||
this.flag.editPane = false;
|
||||
console.log('step2: close the Edit Panel');
|
||||
// console.log('step2: close the Edit Panel');
|
||||
if (!this.context.edit && this.useDatePane) {
|
||||
this.openDatePane();
|
||||
} else {
|
||||
@ -423,15 +423,15 @@ export default {
|
||||
},
|
||||
openDatePane() {
|
||||
this.flag.datePane = true;
|
||||
console.log('step3: open the Date Panel');
|
||||
// console.log('step3: open the Date Panel');
|
||||
},
|
||||
closeDatePane() {
|
||||
this.applyChanges();
|
||||
this.flag.datePane = false;
|
||||
console.log('step3: close the Date Panel');
|
||||
// console.log('step3: close the Date Panel');
|
||||
},
|
||||
resetPane() {
|
||||
console.log('resetPane');
|
||||
// console.log('resetPane');
|
||||
this.flag.suggestPane = false;
|
||||
this.flag.editPane = false;
|
||||
this.flag.datePane = false;
|
||||
@ -446,15 +446,15 @@ export default {
|
||||
afterLastPaneAction(params) {
|
||||
this.initForm();
|
||||
if (this.forceRedirect) {
|
||||
console.log("redirect to backUrl");
|
||||
// console.log("redirect to backUrl");
|
||||
window.location.assign(this.context.backUrl);
|
||||
} else {
|
||||
console.log("don't redirect");
|
||||
// console.log("don't redirect");
|
||||
this.resetPane();
|
||||
if (!this.context.edit) {
|
||||
this.context.edit = true;
|
||||
this.context.addressId = params.addressId;
|
||||
console.log("context is now edit, with address", params.addressId);
|
||||
// console.log("context is now edit, with address", params.addressId);
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -490,7 +490,7 @@ export default {
|
||||
if (this.flag.datePane === true) {
|
||||
this.flag.datePane = false;
|
||||
}
|
||||
console.log('step2: open the Edit panel');
|
||||
// console.log('step2: open the Edit panel');
|
||||
this.flag.editPane = true;
|
||||
this.flag.loading = false;
|
||||
resolve()
|
||||
@ -533,7 +533,7 @@ export default {
|
||||
* Make form ready for new changes
|
||||
*/
|
||||
initForm() {
|
||||
console.log('init form');
|
||||
// console.log('init form');
|
||||
|
||||
this.entity.loaded.addresses = [];
|
||||
this.entity.loaded.cities = [];
|
||||
@ -558,7 +558,7 @@ export default {
|
||||
|
||||
this.entity.selected.writeNew.address = this.context.edit;
|
||||
this.entity.selected.writeNew.postcode = this.context.edit;
|
||||
console.log('!! just set writeNew.postcode to', this.entity.selected.writeNew.postcode);
|
||||
// console.log('!! just set writeNew.postcode to', this.entity.selected.writeNew.postcode);
|
||||
},
|
||||
|
||||
/*
|
||||
@ -568,7 +568,7 @@ export default {
|
||||
*/
|
||||
applyChanges()
|
||||
{
|
||||
console.log('apply changes');
|
||||
// console.log('apply changes');
|
||||
|
||||
let newAddress = {
|
||||
'isNoAddress': this.entity.selected.isNoAddress,
|
||||
@ -604,7 +604,7 @@ export default {
|
||||
}
|
||||
|
||||
if (this.validFrom) {
|
||||
console.log('add validFrom in fetch body', this.entity.selected.valid.from);
|
||||
// console.log('add validFrom in fetch body', this.entity.selected.valid.from);
|
||||
newAddress = Object.assign(newAddress, {
|
||||
'validFrom': {
|
||||
datetime: `${this.entity.selected.valid.from.toISOString().split('T')[0]}T00:00:00+0100`
|
||||
@ -612,7 +612,7 @@ export default {
|
||||
});
|
||||
}
|
||||
if (this.validTo && null !== this.entity.selected.valid.to) {
|
||||
console.log('add validTo in fetch body', this.entity.selected.valid.to);
|
||||
// console.log('add validTo in fetch body', this.entity.selected.valid.to);
|
||||
newAddress = Object.assign(newAddress, {
|
||||
'validTo': {
|
||||
datetime: `${this.entity.selected.valid.to.toISOString().split('T')[0]}T00:00:00+0100`
|
||||
@ -624,7 +624,7 @@ export default {
|
||||
newPostcode = Object.assign(newPostcode, {
|
||||
'country': {'id': this.entity.selected.country.id },
|
||||
});//TODO why not assign postcodeBody here = Object.assign(postcodeBody, {'origin': 3}); ?
|
||||
console.log('writeNew postcode is true! newPostcode: ', newPostcode);
|
||||
// console.log('writeNew postcode is true! newPostcode: ', newPostcode);
|
||||
newAddress = Object.assign(newAddress, {
|
||||
'newPostcode': newPostcode
|
||||
});
|
||||
@ -649,17 +649,17 @@ export default {
|
||||
*/
|
||||
addNewAddress(payload)
|
||||
{
|
||||
console.log('addNewAddress', payload);
|
||||
// console.log('addNewAddress', payload);
|
||||
this.flag.loading = true;
|
||||
|
||||
if ('newPostcode' in payload) {
|
||||
|
||||
let postcodeBody = payload.newPostcode;
|
||||
postcodeBody = Object.assign(postcodeBody, {'origin': 3});
|
||||
console.log('juste before post new postcode', postcodeBody);
|
||||
// console.log('juste before post new postcode', postcodeBody);
|
||||
return postPostalCode(postcodeBody)
|
||||
.then(postalCode => {
|
||||
console.log('new postcode created', postalCode.id);
|
||||
// console.log('new postcode created', postalCode.id);
|
||||
payload.postcode = {'id': postalCode.id };
|
||||
return this.postNewAddress(payload);
|
||||
});
|
||||
@ -671,7 +671,7 @@ export default {
|
||||
|
||||
postNewAddress(payload)
|
||||
{
|
||||
console.log('postNewAddress', payload);
|
||||
// console.log('postNewAddress', payload);
|
||||
return postAddress(payload)
|
||||
.then(address => new Promise((resolve, reject) => {
|
||||
this.entity.address = address;
|
||||
@ -708,10 +708,10 @@ export default {
|
||||
let postcodeBody = payload.newAddress.newPostcode;
|
||||
postcodeBody = Object.assign(postcodeBody, {'origin': 3});
|
||||
|
||||
console.log('juste before post new postcode', postcodeBody);
|
||||
// console.log('juste before post new postcode', postcodeBody);
|
||||
return postPostalCode(postcodeBody)
|
||||
.then(postalCode => {
|
||||
console.log('new postcode created', postalCode.id);
|
||||
// console.log('new postcode created', postalCode.id);
|
||||
payload.newAddress.postcode = {'id': postalCode.id };
|
||||
return this.patchExistingAddress(payload);
|
||||
});
|
||||
@ -722,7 +722,7 @@ export default {
|
||||
},
|
||||
|
||||
patchExistingAddress(payload) {
|
||||
console.log('patchExistingAddress', payload);
|
||||
// console.log('patchExistingAddress', payload);
|
||||
return patchAddress(payload.addressId, payload.newAddress)
|
||||
.then(address => new Promise((resolve, reject) => {
|
||||
this.entity.address = address;
|
||||
@ -752,7 +752,7 @@ export default {
|
||||
* @param address the address selected
|
||||
*/
|
||||
pickAddress(address) {
|
||||
console.log('pickAddress', address);
|
||||
// console.log('pickAddress', address);
|
||||
duplicateAddress(address).then(newAddress => {
|
||||
this.entity.address = newAddress;
|
||||
this.flag.loading = false;
|
||||
|
@ -108,7 +108,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 = 'participation';
|
||||
this.$store.dispatch('patchOnTheFly', payload)
|
||||
.catch(({name, violations}) => {
|
||||
|
@ -58,7 +58,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';
|
||||
this.$store.dispatch('patchOnTheFly', payload)
|
||||
.catch(({name, violations}) => {
|
||||
|
@ -121,7 +121,7 @@ let initPromise = Promise.all([scopesPromise, accompanyingCoursePromise])
|
||||
state.accompanyingCourse.resources.push(resource);
|
||||
},
|
||||
updatePerson(state, payload) {
|
||||
console.log('### mutation: updatePerson', payload);
|
||||
// console.log('### mutation: updatePerson', payload);
|
||||
let i = null;
|
||||
switch (payload.target) {
|
||||
case 'participation':
|
||||
@ -138,7 +138,7 @@ let initPromise = Promise.all([scopesPromise, accompanyingCoursePromise])
|
||||
}
|
||||
},
|
||||
updateThirdparty(state, payload) {
|
||||
console.log('### mutation: updateThirdparty', payload);
|
||||
// console.log('### mutation: updateThirdparty', payload);
|
||||
let i = null;
|
||||
switch (payload.target) {
|
||||
case 'requestor':
|
||||
@ -166,11 +166,11 @@ let initPromise = Promise.all([scopesPromise, accompanyingCoursePromise])
|
||||
state.accompanyingCourse.initialComment = comment;
|
||||
},
|
||||
updateSocialIssues(state, value) {
|
||||
console.log('updateSocialIssues', value);
|
||||
// console.log('updateSocialIssues', value);
|
||||
state.accompanyingCourse.socialIssues = value;
|
||||
},
|
||||
refreshSocialIssues(state, issues) {
|
||||
console.log('refreshSocialIssues', issues);
|
||||
// console.log('refreshSocialIssues', issues);
|
||||
state.accompanyingCourse.socialIssues = issues;
|
||||
},
|
||||
updateOrigin(state, value) {
|
||||
@ -358,35 +358,62 @@ let initPromise = Promise.all([scopesPromise, accompanyingCoursePromise])
|
||||
*/
|
||||
patchOnTheFly({ commit }, payload) {
|
||||
// TODO should be into the dedicated component, no ? JF
|
||||
console.log('## action: patch OnTheFly', payload);
|
||||
// console.log('## action: patch OnTheFly', payload);
|
||||
let body = { type: payload.type };
|
||||
|
||||
if (payload.type === 'person') {
|
||||
const id = payload.data.id;
|
||||
const url = `/api/1.0/person/person/${id}.json`;
|
||||
body.firstName = payload.data.firstName;
|
||||
body.lastName = payload.data.lastName;
|
||||
if (payload.data.birthdate !== null) { body.birthdate = payload.data.birthdate; }
|
||||
body.phonenumber = payload.data.phonenumber;
|
||||
body.mobilenumber = payload.data.mobilenumber;
|
||||
body.gender = payload.data.gender;
|
||||
console.log('id', payload.data.id, 'and body', body);
|
||||
patchPerson(payload.data.id, body)
|
||||
.then(person => new Promise((resolve, reject) => {
|
||||
console.log('patch person', person);
|
||||
commit('updatePerson', { target: payload.target, person: person });
|
||||
resolve();
|
||||
}));
|
||||
|
||||
makeFetch('PATCH', url, body)
|
||||
.then((response) => {
|
||||
commit('updatePerson', {target: payload.target, person: response});
|
||||
})
|
||||
.catch((error) => {
|
||||
commit('catchError', error);
|
||||
throw error;
|
||||
})
|
||||
|
||||
|
||||
// console.log('id', payload.data.id, 'and body', body);
|
||||
|
||||
// patchPerson(payload.data.id, body)
|
||||
// .then(person => new Promise((resolve, reject) => {
|
||||
// // console.log('patch person', person);
|
||||
// commit('updatePerson', { target: payload.target, person: person });
|
||||
// resolve();
|
||||
// }));
|
||||
}
|
||||
else if (payload.type === 'thirdparty') {
|
||||
body.name = payload.data.text;
|
||||
body.email = payload.data.email;
|
||||
body.telephone = payload.data.phonenumber;
|
||||
body.address = { id: payload.data.address.address_id };
|
||||
console.log('id', payload.data.id, 'and body', body);
|
||||
patchThirdparty(payload.data.id, body)
|
||||
.then(thirdparty => new Promise((resolve, reject) => {
|
||||
console.log('patch thirdparty', thirdparty);
|
||||
commit('updateThirdparty', { target: payload.target, thirdparty: thirdparty });
|
||||
resolve();
|
||||
}));
|
||||
|
||||
// console.log('id', payload.data.id, 'and body', body);
|
||||
// patchThirdparty(payload.data.id, body)
|
||||
// .then(thirdparty => new Promise((resolve, reject) => {
|
||||
// console.log('patch thirdparty', thirdparty);
|
||||
// commit('updateThirdparty', { target: payload.target, thirdparty: thirdparty });
|
||||
// resolve();
|
||||
// }));
|
||||
|
||||
const id = payload.data.id;
|
||||
const url = `/api/1.0/thirdparty/thirdparty/${id}.json`;
|
||||
makeFetch('PATCH', url, body)
|
||||
.then((response) => {
|
||||
commit('updateThirdparty', {target: payload.target, thirdparty: response});
|
||||
})
|
||||
.catch((error) => {
|
||||
commit('catchError', error);
|
||||
throw error;
|
||||
})
|
||||
}
|
||||
},
|
||||
/**
|
||||
|
@ -232,16 +232,16 @@ export default {
|
||||
addPriorSuggestion() {
|
||||
//console.log('addPriorSuggestion', this.hasPriorSuggestion);
|
||||
if (this.hasPriorSuggestion) {
|
||||
console.log('addPriorSuggestion',);
|
||||
// console.log('addPriorSuggestion',);
|
||||
this.suggested.unshift(this.priorSuggestion);
|
||||
this.selected.unshift(this.priorSuggestion);
|
||||
|
||||
console.log('reset priorSuggestion');
|
||||
// console.log('reset priorSuggestion');
|
||||
this.newPriorSuggestion(null);
|
||||
}
|
||||
},
|
||||
newPriorSuggestion(entity) {
|
||||
console.log('newPriorSuggestion', entity);
|
||||
// console.log('newPriorSuggestion', entity);
|
||||
if (entity !== null) {
|
||||
let suggestion = {
|
||||
key: entity.type + entity.id,
|
||||
@ -249,30 +249,35 @@ export default {
|
||||
result: entity
|
||||
}
|
||||
this.search.priorSuggestion = suggestion;
|
||||
console.log('search priorSuggestion', this.search.priorSuggestion);
|
||||
// console.log('search priorSuggestion', this.search.priorSuggestion);
|
||||
} else {
|
||||
this.search.priorSuggestion = {};
|
||||
}
|
||||
},
|
||||
saveFormOnTheFly({ type, data }) {
|
||||
console.log('saveFormOnTheFly from addPersons, type', type, ', data', data);
|
||||
// console.log('saveFormOnTheFly from addPersons, type', type, ', data', data);
|
||||
if (type === 'person') {
|
||||
console.log('type person with', data);
|
||||
// console.log('type person with', data);
|
||||
postPerson(data)
|
||||
.then(person => new Promise((resolve, reject) => {
|
||||
console.log('onthefly create: post person', person);
|
||||
// console.log('onthefly create: post person', person);
|
||||
this.newPriorSuggestion(person);
|
||||
resolve();
|
||||
}));
|
||||
}
|
||||
else if (type === 'thirdparty') {
|
||||
console.log('type thirdparty with', data);
|
||||
postThirdparty(data)
|
||||
.then(thirdparty => new Promise((resolve, reject) => {
|
||||
console.log('onthefly create: post thirdparty', thirdparty);
|
||||
this.newPriorSuggestion(thirdparty);
|
||||
resolve();
|
||||
}));
|
||||
const url = `/api/1.0/thirdparty/thirdparty.json`;
|
||||
makeFetch('POST', url, data)
|
||||
.then((response) => {
|
||||
this.newPriorSuggestion(response);
|
||||
})
|
||||
.catch(({name, violations}) => {
|
||||
if (name === 'ValidationException' || name === 'AccessException') {
|
||||
violations.forEach((violation) => this.$toast.open({message: violation}));
|
||||
} else {
|
||||
this.$toast.open({message: 'An error occurred'})
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -1,55 +1,55 @@
|
||||
/*
|
||||
* GET a thirdparty by id
|
||||
*/
|
||||
const getThirdparty = (id) => {
|
||||
const url = `/api/1.0/thirdparty/thirdparty/${id}.json`;
|
||||
return fetch(url)
|
||||
.then(response => {
|
||||
if (response.ok) {
|
||||
return response.json();
|
||||
}
|
||||
throw Error('Error with request resource response');
|
||||
});
|
||||
};
|
||||
// const getThirdparty = (id) => {
|
||||
// const url = `/api/1.0/thirdparty/thirdparty/${id}.json`;
|
||||
// return fetch(url)
|
||||
// .then(response => {
|
||||
// if (response.ok) {
|
||||
// return response.json();
|
||||
// }
|
||||
// throw Error('Error with request resource response');
|
||||
// });
|
||||
// };
|
||||
|
||||
/*
|
||||
* POST a new thirdparty
|
||||
*/
|
||||
const postThirdparty = (body) => {
|
||||
const url = `/api/1.0/thirdparty/thirdparty.json`;
|
||||
return fetch(url, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json;charset=utf-8'
|
||||
},
|
||||
body: JSON.stringify(body)
|
||||
})
|
||||
.then(response => {
|
||||
if (response.ok) { return response.json(); }
|
||||
throw Error('Error with request resource response');
|
||||
});
|
||||
};
|
||||
// const postThirdparty = (body) => {
|
||||
// const url = `/api/1.0/thirdparty/thirdparty.json`;
|
||||
// return fetch(url, {
|
||||
// method: 'POST',
|
||||
// headers: {
|
||||
// 'Content-Type': 'application/json;charset=utf-8'
|
||||
// },
|
||||
// body: JSON.stringify(body)
|
||||
// })
|
||||
// .then(response => {
|
||||
// if (response.ok) { return response.json(); }
|
||||
// throw Error('Error with request resource response');
|
||||
// });
|
||||
// };
|
||||
|
||||
/*
|
||||
* PATCH an existing thirdparty
|
||||
*/
|
||||
const patchThirdparty = (id, body) => {
|
||||
const url = `/api/1.0/thirdparty/thirdparty/${id}.json`;
|
||||
return fetch(url, {
|
||||
method: 'PATCH',
|
||||
headers: {
|
||||
'Content-Type': 'application/json;charset=utf-8'
|
||||
},
|
||||
body: JSON.stringify(body)
|
||||
})
|
||||
.then(response => {
|
||||
if (response.ok) { return response.json(); }
|
||||
throw Error('Error with request resource response');
|
||||
});
|
||||
};
|
||||
// const patchThirdparty = (id, body) => {
|
||||
// const url = `/api/1.0/thirdparty/thirdparty/${id}.json`;
|
||||
// return fetch(url, {
|
||||
// method: 'PATCH',
|
||||
// headers: {
|
||||
// 'Content-Type': 'application/json;charset=utf-8'
|
||||
// },
|
||||
// body: JSON.stringify(body)
|
||||
// })
|
||||
// .then(response => {
|
||||
// if (response.ok) { return response.json(); }
|
||||
// throw Error('Error with request resource response');
|
||||
// });
|
||||
// };
|
||||
|
||||
export {
|
||||
getThirdparty,
|
||||
postThirdparty,
|
||||
patchThirdparty
|
||||
// getThirdparty,
|
||||
// postThirdparty,
|
||||
// patchThirdparty
|
||||
};
|
||||
|
@ -94,7 +94,7 @@
|
||||
<script>
|
||||
import ThirdPartyRenderBox from '../Entity/ThirdPartyRenderBox.vue';
|
||||
import AddAddress from 'ChillMainAssets/vuejs/Address/components/AddAddress';
|
||||
import { getThirdparty } from '../../_api/OnTheFly';
|
||||
import { makeFetch } from 'ChillMainAssets/lib/api/apiMethods'
|
||||
|
||||
const i18n = {
|
||||
messages: {
|
||||
@ -165,38 +165,58 @@ export default {
|
||||
context.addressId = this.thirdparty.address.address_id;
|
||||
context.edit = true;
|
||||
}
|
||||
console.log('context', context);
|
||||
// console.log('context', context);
|
||||
//this.context = context; <--
|
||||
return context;
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
loadData(){
|
||||
getThirdparty(this.id).then(thirdparty => 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
|
||||
this.$refs.addAddress.getInitialAddress(thirdparty.address.address_id);
|
||||
}
|
||||
}
|
||||
resolve();
|
||||
}));
|
||||
const url = `/api/1.0/thirdparty/thirdparty/${this.id}.json`;
|
||||
makeFetch('GET', url)
|
||||
.then((response) => {
|
||||
console.log(response);
|
||||
this.thirdparty = response;
|
||||
this.thirdparty.kind = response.kind
|
||||
if (this.action !== 'show') {
|
||||
if (response.address !== null) {
|
||||
// bof! we force getInitialAddress because addressId not available when mounted
|
||||
this.$refs.addAddress.getInitialAddress(response.address.address_id);
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(({name, violations}) => {
|
||||
if (name === 'ValidationException' || name === 'AccessException') {
|
||||
violations.forEach((violation) => this.$toast.open({message: violation}));
|
||||
} else {
|
||||
this.$toast.open({message: 'An error occurred'})
|
||||
}
|
||||
});
|
||||
// getThirdparty(this.id).then(thirdparty => 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
|
||||
// this.$refs.addAddress.getInitialAddress(thirdparty.address.address_id);
|
||||
// }
|
||||
// }
|
||||
// resolve();
|
||||
// }));
|
||||
},
|
||||
submitAddress(payload) {
|
||||
console.log('submitAddress', payload);
|
||||
// console.log('submitAddress', payload);
|
||||
if (typeof payload.addressId !== 'undefined') { // <--
|
||||
this.context.edit = true;
|
||||
this.context.addressId = payload.addressId; // bof! use legacy and not legacy in payload
|
||||
this.thirdparty.address = payload.address; // <--
|
||||
console.log('switch address to edit mode', this.context);
|
||||
// console.log('switch address to edit mode', this.context);
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
console.log('mounted', this.action);
|
||||
// console.log('mounted', this.action);
|
||||
if (this.action !== 'create') {
|
||||
this.loadData();
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user