FIX [post] adjust vue components to allow thirdparty to be posted with new profession type as string

This commit is contained in:
Julie Lenaerts 2023-02-22 17:57:30 +01:00 committed by Julien Fastré
parent e50b02a8c7
commit e982e81900
Signed by: julienfastre
GPG Key ID: BDE2190974723FCB
3 changed files with 12 additions and 26 deletions

View File

@ -233,7 +233,7 @@ export default {
// 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;
data.profession = data.profession !== '' ? data.profession : '';
} else {
type = this.$refs.castNew.radioType;
data = this.$refs.castNew.castDataByType();
@ -241,8 +241,8 @@ export default {
if (typeof data.civility !== 'undefined' && null !== data.civility) {
data.civility = data.civility !== null ? {type: 'chill_main_civility', id: data.civility.id} : null;
}
if (typeof data.profession !== 'undefined' && null !== data.profession) {
data.profession = data.profession !== null ? {type: 'third_party_profession', id: data.profession.id} : null;
if (typeof data.profession !== 'undefined' && '' !== data.profession) {
data.profession = data.profession !== '' ? data.profession : '';
}
// console.log('onthefly data', data);
}

View File

@ -178,7 +178,7 @@ export default {
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};
body.profession = payload.data.profession;
}
// console.log('body', body);

View File

@ -74,11 +74,11 @@
</select>
</div>
<div class="input-group mb-3 input-section">
<select class="form-select form-select-lg" id="profession"
v-model="thirdparty.profession">
<option selected disabled :value="null">{{ $t('thirdparty.profession') }}</option>
<option v-for="profession in professions" :key="profession.id" :value="profession">{{ profession.name.fr }}</option>
</select>
<input class="form-control form-control-lg"
v-model="thirdparty.profession"
v-bind:placeholder="$t('thirdparty.profession')"
v-bind:aria-label="$t('thirdparty.profession')"
aria-describedby="profession" />
</div>
</div>
<div class="child-info">
@ -192,9 +192,8 @@ export default {
name: '',
telephone: '',
civility: null,
profession: null,
profession: '',
},
professions: [],
civilities: [],
addAddress: {
options: {
@ -274,18 +273,6 @@ export default {
this.$toast.open({message: error.body})
})
},
loadProfessions() {
const url = `/api/1.0/thirdparty/professions.json`;
return makeFetch('GET', url)
.then(response => {
this.$data.professions = response.results;
return Promise.resolve();
})
.catch((error) => {
console.log(error)
this.$toast.open({message: error.body})
})
},
submitAddress(payload) {
console.log('submitAddress', payload);
if (typeof payload.addressId !== 'undefined') { // <--
@ -311,7 +298,6 @@ export default {
},
mounted() {
let dependencies = [];
dependencies.push(this.loadProfessions());
dependencies.push(this.loadCivilities());
if (this.action !== 'create') {
if (this.id) {