Browse Source

Better handling of phone links

Some Weboob backends were returning multiple phone numbers
(comma-separated) or phone numbers in different formats (with or without
spaces, with or without separating dots, etc).

This commit harmonizes all of this so that all phone links will be
rendered correctly and be usable to call in a single click.

Related, https://git.weboob.org/weboob/devel/merge_requests/42.
merge-requests/8/head
Lucas Verney 5 years ago
parent
commit
78b9ebf04e
  1. 12
      flatisfy/web/js_src/views/details.vue

12
flatisfy/web/js_src/views/details.vue

@ -118,7 +118,11 @@ @@ -118,7 +118,11 @@
<h3>{{ $t("flatsDetails.Contact") }}</h3>
<div class="contact">
<p>
<a v-if="flat.phone" :href="'tel:+33' + flat.phone">{{ flat.phone }}</a>
<template v-if="flat.phone">
<template v-for="phoneNumber in flat.phone.split(',')">
<a :href="'tel:+33' + normalizePhoneNumber(phoneNumber)">{{ phoneNumber }}</a><br/>
</template>
</template>
<template v-else>
{{ $t("flatsDetails.no_phone_found") }}
</template>
@ -305,6 +309,12 @@ export default { @@ -305,6 +309,12 @@ export default {
this.overloadNotation = null
},
normalizePhoneNumber (phoneNumber) {
phoneNumber = phoneNumber.replace(/ /g, '')
phoneNumber = phoneNumber.replace(/\./g, '')
return phoneNumber
},
capitalize: capitalize,
range: range

Loading…
Cancel
Save