Fix phonenumber -> telephone for thirdparty

This commit is contained in:
Julie Lenaerts 2022-03-04 16:27:53 +01:00
parent e9236875d2
commit e32b8b0942
6 changed files with 23 additions and 17 deletions

View File

@ -93,7 +93,6 @@ import Modal from 'ChillMainAssets/vuejs/_components/Modal.vue';
import OnTheFlyCreate from './Create.vue'; import OnTheFlyCreate from './Create.vue';
import OnTheFlyPerson from 'ChillPersonAssets/vuejs/_components/OnTheFly/Person.vue'; import OnTheFlyPerson from 'ChillPersonAssets/vuejs/_components/OnTheFly/Person.vue';
import OnTheFlyThirdparty from 'ChillThirdPartyAssets/vuejs/_components/OnTheFly/ThirdParty.vue'; import OnTheFlyThirdparty from 'ChillThirdPartyAssets/vuejs/_components/OnTheFly/ThirdParty.vue';
import { postThirdparty } from "ChillThirdPartyAssets/vuejs/_api/OnTheFly";
export default { export default {
name: 'OnTheFly', name: 'OnTheFly',
@ -218,21 +217,24 @@ export default {
case 'thirdparty': case 'thirdparty':
data = this.$refs.castThirdparty.$data.thirdparty; data = this.$refs.castThirdparty.$data.thirdparty;
/* never executed ? */ /* never executed ? Yes, when editing thirdparty... */
break; break;
default: default:
if (typeof this.type === 'undefined') { // action=create or addContact if (typeof this.type === 'undefined') { // action=create or addContact
console.log('will rewrite data'); console.log('will rewrite data');
if (this.action === 'addContact') { if (this.action === 'addContact') {
type = 'thirdparty' type = 'thirdparty'
data = this.$refs.castThirdparty.$data.thirdparty; data = this.$refs.castThirdparty.$data.thirdparty;
console.log('data original', data); console.log('data original', data);
data.parent = {type: "thirdparty", id: this.parent.id}; data.parent = {type: "thirdparty", id: this.parent.id};
// data.civility = {type: 'chill_main_civility', id: civility.id };
// data.profession = {type: 'third_party_profession', id: profession.id };
} else { } else {
console.log('im here')
type = this.$refs.castNew.radioType; type = this.$refs.castNew.radioType;
data = this.$refs.castNew.castDataByType(); data = this.$refs.castNew.castDataByType();
console.log(data) console.log('saveAction', data)
} }
} else { } else {
throw 'error with object type'; throw 'error with object type';

View File

@ -40,6 +40,10 @@ class PhonenumberNormalizer implements NormalizerInterface, DenormalizerInterfac
*/ */
public function denormalize($data, $type, $format = null, array $context = []) public function denormalize($data, $type, $format = null, array $context = [])
{ {
if ("" == trim($data)) {
return null;
}
try { try {
return $this->phoneNumberUtil->parse($data, $this->defaultCarrierCode); return $this->phoneNumberUtil->parse($data, $this->defaultCarrierCode);
} catch (NumberParseException $e) { } catch (NumberParseException $e) {

View File

@ -170,7 +170,7 @@ export default {
console.log('data', payload.data) console.log('data', payload.data)
body.name = payload.data.name; body.name = payload.data.name;
body.email = payload.data.email; body.email = payload.data.email;
body.telephone = payload.data.phonenumber; body.telephone = payload.data.telephone;
body.address = payload.data.address ? { id: payload.data.address.address_id } : null; body.address = payload.data.address ? { id: payload.data.address.address_id } : null;
makeFetch('PATCH', `/api/1.0/thirdparty/thirdparty/${payload.data.id}.json`, body) makeFetch('PATCH', `/api/1.0/thirdparty/thirdparty/${payload.data.id}.json`, body)

View File

@ -61,9 +61,9 @@
<i class="fa fa-li fa-map-marker"></i> <i class="fa fa-li fa-map-marker"></i>
<address-render-box :address="thirdparty.address" :isMultiline="isMultiline"></address-render-box> <address-render-box :address="thirdparty.address" :isMultiline="isMultiline"></address-render-box>
</li> </li>
<li v-if="thirdparty.phonenumber"> <li v-if="thirdparty.telephone">
<i class="fa fa-li fa-mobile"></i> <i class="fa fa-li fa-mobile"></i>
<a :href="'tel: ' + thirdparty.phonenumber">{{ thirdparty.phonenumber }}</a> <a :href="'tel: ' + thirdparty.telephone">{{ thirdparty.telephone }}</a>
</li> </li>
<li v-if="thirdparty.email"> <li v-if="thirdparty.email">
<i class="fa fa-li fa-envelope-o"></i> <i class="fa fa-li fa-envelope-o"></i>
@ -78,9 +78,9 @@
<i class="fa fa-li fa-map-marker"></i> <i class="fa fa-li fa-map-marker"></i>
<address-render-box :address="thirdparty.address" :isMultiline="isMultiline"></address-render-box> <address-render-box :address="thirdparty.address" :isMultiline="isMultiline"></address-render-box>
</li> </li>
<li v-if="thirdparty.phonenumber"> <li v-if="thirdparty.telephone">
<i class="fa fa-li fa-mobile"></i> <i class="fa fa-li fa-mobile"></i>
<a :href="'tel: ' + thirdparty.phonenumber">{{ thirdparty.phonenumber }}</a> <a :href="'tel: ' + thirdparty.telephone">{{ thirdparty.telephone }}</a>
</li> </li>
<li v-if="thirdparty.email"> <li v-if="thirdparty.email">
<i class="fa fa-li fa-envelope-o"></i> <i class="fa fa-li fa-envelope-o"></i>

View File

@ -116,12 +116,12 @@
</div> </div>
<div class="input-group mb-3"> <div class="input-group mb-3">
<span class="input-group-text" id="phonenumber"><i class="fa fa-fw fa-phone"></i></span> <span class="input-group-text" id="telephone"><i class="fa fa-fw fa-phone"></i></span>
<input class="form-control form-control-lg" <input class="form-control form-control-lg"
v-model="thirdparty.phonenumber" v-model="thirdparty.telephone"
v-bind:placeholder="$t('thirdparty.phonenumber')" v-bind:placeholder="$t('thirdparty.phonenumber')"
v-bind:aria-label="$t('thirdparty.phonenumber')" v-bind:aria-label="$t('thirdparty.phonenumber')"
aria-describedby="phonenumber" /> aria-describedby="telephone" />
</div> </div>
<div v-if="parent"> <div v-if="parent">
@ -266,10 +266,10 @@ export default {
this.thirdparty.name = query; this.thirdparty.name = query;
}, },
}, },
mounted() { mounted() {
let dependencies = []; let dependencies = [];
dependencies.push(this.loadProfessions()); dependencies.push(this.loadProfessions());
dependencies.push(this.loadCivilities()); dependencies.push(this.loadCivilities());
if (this.action !== 'create') { if (this.action !== 'create') {
if (this.id) { if (this.id) {
dependencies.push(this.loadData()); dependencies.push(this.loadData());

View File

@ -62,7 +62,7 @@ class ThirdPartyNormalizer implements NormalizerAwareInterface, NormalizerInterf
}, $thirdParty->getTypesAndCategories()), }, $thirdParty->getTypesAndCategories()),
'profession' => $this->normalizer->normalize($thirdParty->getProfession(), $format, $context), 'profession' => $this->normalizer->normalize($thirdParty->getProfession(), $format, $context),
'address' => $this->normalizer->normalize($thirdParty->getAddress(), $format, ['address_rendering' => 'short']), 'address' => $this->normalizer->normalize($thirdParty->getAddress(), $format, ['address_rendering' => 'short']),
'phonenumber' => $this->normalizer->normalize($thirdParty->getTelephone()), 'telephone' => $this->normalizer->normalize($thirdParty->getTelephone()),
'email' => $thirdParty->getEmail(), 'email' => $thirdParty->getEmail(),
'isChild' => $thirdParty->isChild(), 'isChild' => $thirdParty->isChild(),
'parent' => $this->normalizer->normalize($thirdParty->getParent(), $format, $context), 'parent' => $this->normalizer->normalize($thirdParty->getParent(), $format, $context),