_id.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  1. <template>
  2. <LayoutContainer>
  3. <header class="mb-4">
  4. <v-layout>
  5. <v-btn
  6. :to="{path: '/structures', query: { parent: parent, view: view, theme: theme }}"
  7. nuxt
  8. plain
  9. >
  10. <font-awesome-icon class="icon mr-1" :icon="['fas', 'chevron-left']" />
  11. {{ $t('go_back') }}
  12. </v-btn>
  13. </v-layout>
  14. </header>
  15. <v-container class="content">
  16. <v-layout class="flex-row align-center mb-4">
  17. <nuxt-img
  18. v-if="structure.logoId"
  19. :src="'https://api.opentalent.fr/app.php/_internal/secure/files/' + structure.logoId + '/0x60'"
  20. alt="logo"
  21. />
  22. <h2 class="flex mx-4 d-flex align-center">
  23. {{ structure.name }}
  24. </h2>
  25. <div class="d-flex flex-row align-center">
  26. <a v-if="structure.facebook" :href="structure.facebook" class="facebook" target="_blank" :title="$t('find_us_on') + ' Facebook'">
  27. <font-awesome-icon class="icon social-icon" :icon="['fab', 'facebook']" />
  28. </a>
  29. <a v-if="structure.instagram" :href="structure.instagram" class="instagram" target="_blank" :title="$t('find_us_on') + ' Instagram'">
  30. <font-awesome-icon class="icon social-icon" :icon="['fab', 'instagram-square']" />
  31. </a>
  32. <a v-if="structure.twitter" :href="structure.twitter" class="twitter" target="_blank" title="$t('find_us_on') + ' Twitter'">
  33. <font-awesome-icon class="icon social-icon" :icon="['fab', 'twitter']" />
  34. </a>
  35. </div>
  36. </v-layout>
  37. <v-row>
  38. <v-col class="d-flex justify-center" cols="12">
  39. <nuxt-img
  40. v-if="structure.imageId"
  41. :src="'https://api.opentalent.fr/app.php/_internal/secure/files/' + structure.imageId + '/raw'"
  42. alt="banner"
  43. style="max-height: 300px"
  44. />
  45. </v-col>
  46. </v-row>
  47. <v-row>
  48. <v-col cols="12">
  49. <v-chip-group v-if="structure.practices" :max="0" active-class="primary--text" class="justify-center">
  50. <v-chip v-for="practice in structure.practices" :key="practice">
  51. {{ $t(practice) }}
  52. </v-chip>
  53. </v-chip-group>
  54. </v-col>
  55. </v-row>
  56. <v-row class="mb-4">
  57. <v-col cols="12" class="d-flex flex-row justify-center">
  58. <v-btn
  59. v-for="article in structure.articles"
  60. :key="article.id"
  61. :href="(article.link.match(/https?:\/\/.*/) ? '' : 'https://') + article.link "
  62. target="_blank"
  63. small
  64. color="primary"
  65. class="ma-2"
  66. :title="article.title"
  67. >
  68. <font-awesome-icon class="icon mr-1" :icon="['fas', 'star']" />
  69. {{ $t('spot_on_from') + ' ' + new Date(article.date).toLocaleDateString($i18n.locale) }}
  70. </v-btn>
  71. </v-col>
  72. </v-row>
  73. <v-divider class="my-2" />
  74. <v-row class="my-2 py-2">
  75. <v-col
  76. cols="12"
  77. sm="6"
  78. class="description"
  79. >
  80. <div class="d-flex flex-row mb-3">
  81. <h4>{{ $t('descriptive') }}</h4>
  82. <v-spacer />
  83. </div>
  84. <div class="pa-2">
  85. <p v-if="structure.description" class="text-justify">
  86. {{ structure.description }}
  87. </p>
  88. <i v-else>({{ $t('no_description') }})</i>
  89. </div>
  90. </v-col>
  91. <v-col
  92. cols="12"
  93. sm="6"
  94. class="contact"
  95. >
  96. <div class="d-flex flex-row mb-3">
  97. <h4>{{ $t('contact') }}</h4>
  98. <v-spacer />
  99. </div>
  100. <table>
  101. <tr>
  102. <td>
  103. <font-awesome-icon class="icon" :icon="['fas', 'map-marker-alt']" />
  104. </td>
  105. <td class="mx-2">
  106. <span v-if="structure.streetAddress">{{ structure.streetAddress }}<br></span>
  107. <span v-if="structure.postalCode">{{ structure.postalCode }} </span>
  108. {{ structure.addressCity }}
  109. </td>
  110. </tr>
  111. <tr>
  112. <td>
  113. <font-awesome-icon class="icon" :icon="['fas', 'phone-alt']" />
  114. </td>
  115. <td class="phone">
  116. <div v-if="structure.telphone">
  117. <a v-if="showTel" :href="'tel:' + structure.telphone" class="neutral">
  118. {{ formatPhoneNumber(structure.telphone) }}
  119. </a>
  120. <v-btn v-else small @click="showTel = 1">
  121. {{ $t('show_tel') }}
  122. </v-btn>
  123. </div>
  124. <span v-else>-</span>
  125. </td>
  126. </tr>
  127. <tr>
  128. <td>
  129. <font-awesome-icon class="icon" :icon="['fas', 'at']" />
  130. </td>
  131. <td class="mail">
  132. <div v-if="structure.email">
  133. <a v-if="showMail" :href="'mailto:' + structure.email" class="neutral">
  134. {{ structure.email }}
  135. </a>
  136. <v-btn v-else small @click="showMail = 1">
  137. {{ $t('show_email') }}
  138. </v-btn>
  139. </div>
  140. <span v-else>-</span>
  141. </td>
  142. </tr>
  143. <tr>
  144. <td>
  145. <font-awesome-icon class="icon" :icon="['fas', 'globe-europe']" />
  146. </td>
  147. <td class="website">
  148. <a class="neutral" :href="structure.website" target="_blank">{{ structure.website }}</a>
  149. </td>
  150. </tr>
  151. <tr>
  152. <td>
  153. <font-awesome-icon class="icon" :icon="['fas', 'project-diagram']" />
  154. </td>
  155. <td class="network">
  156. <NuxtLink
  157. v-if="structure.n1Id !== parent"
  158. class="neutral"
  159. :to="{path: '/structures/' + structure.n1Id, query: { parent: parent, view: view, theme: theme }}"
  160. nuxt
  161. >
  162. {{ structure.n1Name }}
  163. </NuxtLink>
  164. <div v-else>
  165. {{ structure.n1Name }}
  166. </div>
  167. </td>
  168. </tr>
  169. </table>
  170. </v-col>
  171. </v-row>
  172. <v-row v-if="structure.latitude && structure.longitude">
  173. <v-col cols="12">
  174. <v-responsive width="100%" height="450px">
  175. <no-ssr>
  176. <l-map
  177. id="map"
  178. :zoom="13"
  179. :center="[structure.latitude, structure.longitude]"
  180. :options="{ scrollWheelZoom: false, zoomSnap: 0.25 }"
  181. >
  182. <l-tile-layer
  183. url="http://{s}.tile.osm.org/{z}/{x}/{y}.png"
  184. attribution="&copy; <a href='http://osm.org/copyright'>OpenStreetMap</a> contributors"
  185. />
  186. <l-marker
  187. :key="structure.id"
  188. :lat-lng="[structure.latitude, structure.longitude]"
  189. >
  190. <l-popup>
  191. <b>{{ structure.name }}</b><br>
  192. {{ structure.postalCode }} {{ structure.addressCity }}<br>
  193. <a :href="structure.website" target="_blank">{{ structure.website }}</a>
  194. </l-popup>
  195. </l-marker>
  196. </l-map>
  197. </no-ssr>
  198. </v-responsive>
  199. </v-col>
  200. </v-row>
  201. </v-container>
  202. </LayoutContainer>
  203. </template>
  204. <script lang="ts">
  205. import Vue from 'vue'
  206. // eslint-disable-next-line import/no-named-as-default
  207. import parsePhoneNumber from 'libphonenumber-js'
  208. import StructuresProvider from '~/services/data/StructuresProvider'
  209. export default Vue.extend({
  210. validate ({ query }) {
  211. if (!/^\d+$/.test(query.parent as string ?? '')) {
  212. // eslint-disable-next-line no-console
  213. console.error('Missing parameter: parent')
  214. return false
  215. }
  216. return true
  217. },
  218. async asyncData ({
  219. params, $axios
  220. }): Promise<{ structure: Structure }> {
  221. return await new StructuresProvider($axios).getById(Number(params.id)).then((res) => {
  222. return { structure: res }
  223. })
  224. },
  225. data (): object {
  226. return {
  227. parent: parseInt(this.$route.query.parent as string),
  228. view: this.$route.query.view ?? 'map',
  229. theme: this.$route.query.theme ?? 'orange',
  230. showTel: false,
  231. showMail: false
  232. }
  233. },
  234. methods: {
  235. formatPhoneNumber (number: string): string {
  236. const parsed = parsePhoneNumber(number)
  237. return parsed ? parsed.formatNational() : ''
  238. }
  239. }
  240. })
  241. </script>
  242. <style scoped lang="scss">
  243. @import 'assets/style/variables.scss';
  244. .content {
  245. margin: 18px 10%;
  246. max-width: 80%;
  247. }
  248. h2 {
  249. color: var(--v-primary-base);
  250. font-size: 22px;
  251. }
  252. h4 {
  253. color: #666;
  254. border-bottom: solid 1px var(--v-primary-base);
  255. font-size: 22px;
  256. }
  257. .social-icon {
  258. font-size: 22px;
  259. color: gray;
  260. margin: auto 8px;
  261. }
  262. .content {
  263. color: #666666;
  264. }
  265. @media screen and (min-width: 600px) {
  266. .description {
  267. border-right: solid 2px #e4611b;
  268. width: 45%;
  269. padding-right: 5%;
  270. }
  271. .contact {
  272. width: 45%;
  273. padding-left: 5%;
  274. }
  275. }
  276. .contact td {
  277. padding: 6px 12px;
  278. }
  279. .contact .icon {
  280. color: var(--v-primary-base);
  281. }
  282. </style>