index.vue.off 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580
  1. <!--
  2. Contenu de la page pages/organization.vue
  3. Contient toutes les informations sur l'organization courante
  4. -->
  5. <template>
  6. <LayoutContainer>
  7. <UiForm
  8. v-if="!pending"
  9. :model="models().Organization"
  10. :entity="organization"
  11. >
  12. <template #form.input="{ model, entity: organization }">
  13. <v-expansion-panels :value="panel" focusable accordion>
  14. <!-- Description -->
  15. <UiExpansionPanel id="description" icon="fa-info">
  16. <v-container fluid class="container">
  17. <v-row>
  18. <v-col cols="12" sm="6">
  19. <UiInputText
  20. v-model="organization.name"
  21. field="name"
  22. :rules="rules.name"
  23. />
  24. </v-col>
  25. <v-col cols="12" sm="6">
  26. <UiInputText v-model="organization.acronym" field="acronym" />
  27. </v-col>
  28. <v-col
  29. v-if="organizationProfile.isInsideNetwork()"
  30. cols="12"
  31. sm="6"
  32. >
  33. <UiInputText
  34. v-model="organization.identifier"
  35. :label="
  36. organizationProfile.isCmf()
  37. ? 'identifierCmf'
  38. : 'identifierFfec'
  39. "
  40. field="identifier"
  41. />
  42. </v-col>
  43. <v-col v-if="organizationProfile.isFfec()" cols="12" sm="6">
  44. <UiInputText
  45. v-model="organization.ffecApproval"
  46. field="ffecApproval"
  47. />
  48. </v-col>
  49. <v-col cols="12" sm="6">
  50. <UiInputText
  51. v-model="organization.description"
  52. field="description"
  53. />
  54. </v-col>
  55. <v-col cols="12" sm="6">
  56. <div>
  57. <span>{{ $t('logo') }}</span>
  58. <UiHelp right>
  59. <p v-html="$t('logo_upload')" />
  60. </UiHelp>
  61. </div>
  62. <UiImage
  63. :image-id="getIdFromUri(organization.logo)"
  64. :width="200"
  65. field="logo"
  66. :owner-id="id"
  67. ></UiImage>
  68. </v-col>
  69. <v-col
  70. v-if="!organizationProfile.isManagerProduct()"
  71. cols="12"
  72. sm="6"
  73. >
  74. <!-- <UiInputEnum field="principalType" v-model="organization.principalType" enum-type="organization_principal_type"/>-->
  75. </v-col>
  76. <!-- <v-col v-if="!organizationProfile.isFfec() && !organizationProfile.isManagerProduct() && !organizationProfile.isArtist()" cols="12" sm="6">-->
  77. <!-- <UiInputEnum field="schoolCategory" v-model="organization.schoolCategory" enum-type="organization_school_cat"/>-->
  78. <!-- </v-col>-->
  79. <!-- <v-col v-if="organizationProfile.isFfec()" cols="12" sm="6">-->
  80. <!-- <UiInputEnum field="typeEstablishment" v-model="organization.typeEstablishment" enum-type="organization_type_establishment"/>-->
  81. <!-- </v-col>-->
  82. <!-- <v-col v-if="organization.typeEstablishment === 'MULTIPLE'" cols="12" sm="6">-->
  83. <!-- <UiInputEnum field="typeEstablishmentDetail" v-model="organization.typeEstablishmentDetail" enum-type="organization_type_establishment_detail" />-->
  84. <!-- </v-col>-->
  85. <v-col v-if="organizationProfile.isCmf()" cols="12" sm="6">
  86. <div class="d-flex flex-row">
  87. <!-- <UiInputAutocomplete-->
  88. <!-- field="typeOfPractices"-->
  89. <!-- :items="typeOfPractices"-->
  90. <!-- :isLoading="typeOfPracticesFetchingState.pending"-->
  91. <!-- :item-text="['name']"-->
  92. <!-- :data="getIdsFromUris(organization.typeOfPractices)"-->
  93. <!-- :translate="true"-->
  94. <!-- :multiple="true"-->
  95. <!-- group="category"-->
  96. <!-- :rules="rules.typeOfPractice"-->
  97. <!-- @update="updateRepository($event.map((id) => `/api/type_of_practices/${id}`), 'typeOfPractices')"-->
  98. <!-- class="flex"-->
  99. <!-- />-->
  100. <UiHelp>
  101. {{ $t('type_of_practices_autocomplete') }}
  102. </UiHelp>
  103. </div>
  104. </v-col>
  105. <!-- TODO: essayer de faire une condition plus explicite pour le v-if -->
  106. <!-- <v-col cols="12" sm="6" v-if="getIdsFromUris(organization.typeOfPractices).indexOf(37) >= 0">-->
  107. <!-- <UiInputTextArea field="otherPractice" v-model="organization.otherPractice" />-->
  108. <!-- </v-col>-->
  109. </v-row>
  110. </v-container>
  111. </UiExpansionPanel>
  112. <!-- Adresses -->
  113. <!-- <UiExpansionPanel id="address_postal" icon="fa-globe-europe">-->
  114. <!-- <v-container fluid class="container">-->
  115. <!-- <v-row>-->
  116. <!-- <v-col cols="12" sm="12">-->
  117. <!-- <UiCollection-->
  118. <!-- :model="models().OrganizationAddressPostal"-->
  119. <!-- :parent="entity"-->
  120. <!-- loaderType="image"-->
  121. <!-- newLink="/organization/address/new"-->
  122. <!-- >-->
  123. <!-- <template #list.item="{items}">-->
  124. <!-- <v-container fluid>-->
  125. <!-- <v-row dense>-->
  126. <!-- <v-col-->
  127. <!-- v-for="item in items"-->
  128. <!-- :key="item.id"-->
  129. <!-- cols="4"-->
  130. <!-- >-->
  131. <!-- <UiCard-->
  132. <!-- :link="`/organization/address/${item.id}`"-->
  133. <!-- :model="models().OrganizationAddressPostal"-->
  134. <!-- :entity="item"-->
  135. <!-- >-->
  136. <!-- <template #card.title>-->
  137. <!-- {{ $t(item.type) }}-->
  138. <!-- </template>-->
  139. <!-- <template #card.text>-->
  140. <!-- {{ item.addressPostal.streetAddress }} <br>-->
  141. <!-- <span v-if="item.addressPostal.streetAddressSecond">{{ item.addressPostal.streetAddressSecond }} <br></span>-->
  142. <!-- <span v-if="item.addressPostal.streetAddressThird">{{ item.addressPostal.streetAddressThird }} <br></span>-->
  143. <!-- {{ item.addressPostal.postalCode }} {{ item.addressPostal.addressCity }}<br>-->
  144. <!-- <span v-if="item.addressPostal.addressCountry">-->
  145. <!-- <UiItemFromUri-->
  146. <!-- :model="models().Country"-->
  147. <!-- :query="repositories().countryRepository.query()"-->
  148. <!-- :uri="item.addressPostal.addressCountry"-->
  149. <!-- >-->
  150. <!-- <template #item.text="{item}">-->
  151. <!-- {{item.name}}-->
  152. <!-- </template>-->
  153. <!-- </UiItemFromUri>-->
  154. <!-- </span>-->
  155. <!-- </template>-->
  156. <!-- </UiCard>-->
  157. <!-- </v-col>-->
  158. <!-- </v-row>-->
  159. <!-- </v-container>-->
  160. <!-- </template>-->
  161. <!-- </UiCollection>-->
  162. <!-- </v-col>-->
  163. <!-- </v-row>-->
  164. <!-- </v-container>-->
  165. <!-- </UiExpansionPanel>-->
  166. <!-- &lt;!&ndash; Point de Contact&ndash;&gt;-->
  167. <!-- <UiExpansionPanel id="contact_point" icon="fa-phone">-->
  168. <!-- <v-container class="container">-->
  169. <!-- <v-row>-->
  170. <!-- <v-col cols="12" sm="12">-->
  171. <!-- <UiCollection-->
  172. <!-- :model="models().ContactPoint"-->
  173. <!-- :parent="entity"-->
  174. <!-- loaderType="image"-->
  175. <!-- newLink="/organization/contact_points/new"-->
  176. <!-- >-->
  177. <!-- <template #list.item="{items}">-->
  178. <!-- <v-container fluid>-->
  179. <!-- <v-row :dense="true">-->
  180. <!-- <v-col-->
  181. <!-- v-for="item in items"-->
  182. <!-- :key="item.id"-->
  183. <!-- cols="4"-->
  184. <!-- >-->
  185. <!-- <UiCard-->
  186. <!-- :link="`/organization/contact_points/${item.id}`"-->
  187. <!-- :model="models().ContactPoint"-->
  188. <!-- :entity="item"-->
  189. <!-- >-->
  190. <!-- <template #card.title>-->
  191. <!-- {{ $t(item.contactType) }}-->
  192. <!-- </template>-->
  193. <!-- <template #card.text>-->
  194. <!-- <span v-if="item.email"><strong>{{ $t('email') }}</strong> : {{ item.email }} <br></span>-->
  195. <!-- <span v-if="item.emailInvalid" class="danger&#45;&#45;text"><v-icon class="danger&#45;&#45;text">mdi-alert</v-icon> <strong>{{ $t('emailInvalid') }}</strong> : {{ item.emailInvalid }} <br></span>-->
  196. <!-- <span v-if="item.telphone"><strong>{{ $t('telphone') }}</strong> : {{ formatPhoneNumber(item.telphone) }} <br></span>-->
  197. <!-- <span v-if="item.telphoneInvalid" class="danger&#45;&#45;text"><v-icon class="danger&#45;&#45;text">mdi-alert</v-icon> <strong>{{ $t('telphoneInvalid') }}</strong> : {{ formatPhoneNumber(item.telphoneInvalid) }} <br></span>-->
  198. <!-- <span v-if="item.mobilPhone"><strong>{{ $t('mobilPhone') }}</strong> : {{ formatPhoneNumber(item.mobilPhone) }} <br></span>-->
  199. <!-- <span v-if="item.mobilPhoneInvalid" class="danger&#45;&#45;text"><v-icon class="danger&#45;&#45;text">mdi-alert</v-icon> <strong>{{ $t('mobilPhoneInvalid') }}</strong> : {{ formatPhoneNumber(item.mobilPhoneInvalid) }} </span>-->
  200. <!-- </template>-->
  201. <!-- </UiCard>-->
  202. <!-- </v-col>-->
  203. <!-- </v-row>-->
  204. <!-- </v-container>-->
  205. <!-- </template>-->
  206. <!-- </UiCollection>-->
  207. <!-- </v-col>-->
  208. <!-- </v-row>-->
  209. <!-- </v-container>-->
  210. <!-- </UiExpansionPanel>-->
  211. <!-- &lt;!&ndash; Informations légales &ndash;&gt;-->
  212. <!-- <UiExpansionPanel id="legalInformation" icon="fa-gavel">-->
  213. <!-- <v-container fluid class="container">-->
  214. <!-- <v-row>-->
  215. <!-- <v-col cols="12" sm="6">-->
  216. <!-- <UiInputText-->
  217. <!-- field="siretNumber"-->
  218. <!-- :data="entity['siretNumber']"-->
  219. <!-- :error="siretError"-->
  220. <!-- :error-message="siretErrorMessage"-->
  221. <!-- :rules="rules.siretRule"-->
  222. <!-- @update="checkSiretHook($event, 'siretNumber')"-->
  223. <!-- />-->
  224. <!-- </v-col>-->
  225. <!-- <v-col cols="12" sm="6">-->
  226. <!-- <UiInputText field="apeNumber" :data="entity['apeNumber']"/>-->
  227. <!-- </v-col>-->
  228. <!-- <v-col v-if="entity['legalStatus'] === 'ASSOCIATION_LAW_1901'" cols="12" sm="6">-->
  229. <!-- <UiInputText field="waldecNumber" :data="entity['waldecNumber']"/>-->
  230. <!-- </v-col>-->
  231. <!-- <v-col cols="12" sm="6">-->
  232. <!-- <UiInputDatePicker field="creationDate" :data="entity['creationDate']"/>-->
  233. <!-- </v-col>-->
  234. <!-- <v-col cols="12" sm="6">-->
  235. <!-- <UiInputText field="prefectureName" :data="entity['prefectureName']"/>-->
  236. <!-- </v-col>-->
  237. <!-- <v-col cols="12" sm="6">-->
  238. <!-- <UiInputText field="prefectureNumber" :data="entity['prefectureNumber']"/>-->
  239. <!-- </v-col>-->
  240. <!-- <v-col cols="12" sm="6">-->
  241. <!-- <UiInputDatePicker field="declarationDate" :data="entity['declarationDate']"/>-->
  242. <!-- </v-col>-->
  243. <!-- <v-col cols="12" sm="6">-->
  244. <!-- <UiInputText field="tvaNumber" :data="entity['tvaNumber']"/>-->
  245. <!-- </v-col>-->
  246. <!-- <v-col cols="12" sm="6">-->
  247. <!-- <UiInputEnum field="legalStatus" :data="entity['legalStatus']" enum-type="organization_legal"/>-->
  248. <!-- </v-col>-->
  249. <!-- </v-row>-->
  250. <!-- </v-container>-->
  251. <!-- </UiExpansionPanel>-->
  252. <!-- &lt;!&ndash; Agréments &ndash;&gt;-->
  253. <!-- <UiExpansionPanel id="agrements" icon="fa-certificate">-->
  254. <!-- <v-container class="container">-->
  255. <!-- <v-row>-->
  256. <!-- <v-col cols="12" sm="6">-->
  257. <!-- <UiInputText field="youngApproval" :data="entity['youngApproval']"/>-->
  258. <!-- </v-col>-->
  259. <!-- <v-col cols="12" sm="6">-->
  260. <!-- <UiInputText field="trainingApproval" :data="entity['trainingApproval']"/>-->
  261. <!-- </v-col>-->
  262. <!-- <v-col cols="12" sm="6">-->
  263. <!-- <UiInputText field="otherApproval" :data="entity['otherApproval']"/>-->
  264. <!-- </v-col>-->
  265. <!-- </v-row>-->
  266. <!-- </v-container>-->
  267. <!-- </UiExpansionPanel>-->
  268. <!-- &lt;!&ndash; Salariés &ndash;&gt;-->
  269. <!-- <UiExpansionPanel id="salary" icon="fa-users">-->
  270. <!-- <v-container class="container">-->
  271. <!-- <v-row>-->
  272. <!-- <v-col cols="12" sm="6">-->
  273. <!-- <UiInputText field="collectiveAgreement" :data="entity['collectiveAgreement']"/>-->
  274. <!-- </v-col>-->
  275. <!-- <v-col cols="12" sm="6">-->
  276. <!-- <UiInputEnum field="opca" :data="entity['opca']" enum-type="organization_opca"/>-->
  277. <!-- </v-col>-->
  278. <!-- <v-col cols="12" sm="6">-->
  279. <!-- <UiInputText field="icomNumber" :data="entity['icomNumber']"/>-->
  280. <!-- </v-col>-->
  281. <!-- <v-col cols="12" sm="6">-->
  282. <!-- <UiInputText field="urssafNumber" :data="entity['urssafNumber']"/>-->
  283. <!-- </v-col>-->
  284. <!-- </v-row>-->
  285. <!-- </v-container>-->
  286. <!-- </UiExpansionPanel>-->
  287. <!-- &lt;!&ndash; Réseaux &ndash;&gt;-->
  288. <!-- <UiExpansionPanel v-if="organizationProfile.isInsideNetwork()" id="network" icon="fa-share-alt">-->
  289. <!-- <v-container class="container">-->
  290. <!-- <v-row>-->
  291. <!-- <v-col cols="12" sm="12">-->
  292. <!-- <UiCollection-->
  293. <!-- :model="models().NetworkOrganization"-->
  294. <!-- :parent="entity"-->
  295. <!-- loaderType="text"-->
  296. <!-- >-->
  297. <!-- <template #list.item="{items}">-->
  298. <!-- <div v-for="item in items" :key="item.id">-->
  299. <!-- <span>{{ item.network.name }}</span> - <span>{{$t('first_subscription')}} : <UiTemplateDate :data="item.startDate" /></span>-->
  300. <!-- </div>-->
  301. <!-- </template>-->
  302. <!-- </UiCollection>-->
  303. <!-- </v-col>-->
  304. <!-- <v-col v-if="organizationProfile.isFfec()" cols="12" sm="6">-->
  305. <!-- <UiInputText field="budget" :data="entity['budget']" type="number" />-->
  306. <!-- </v-col>-->
  307. <!-- <v-col v-if="organizationProfile.isFfec()" cols="12" sm="6">-->
  308. <!-- <UiInputCheckbox field="isPedagogicIsPrincipalActivity" :data="entity['isPedagogicIsPrincipalActivity']"/>-->
  309. <!-- </v-col>-->
  310. <!-- <v-col v-if="organizationProfile.isFfec()" cols="12" sm="6">-->
  311. <!-- <UiInputText field="pedagogicBudget" :data="entity['pedagogicBudget']" type="number"/>-->
  312. <!-- </v-col>-->
  313. <!-- </v-row>-->
  314. <!-- </v-container>-->
  315. <!-- </UiExpansionPanel>-->
  316. <!-- &lt;!&ndash; Communication &ndash;&gt;-->
  317. <!-- <UiExpansionPanel id="communication" icon="fa-rss">-->
  318. <!-- <v-container class="container">-->
  319. <!-- <v-row>-->
  320. <!-- <v-col cols="12" sm="6">-->
  321. <!-- <UiInputText field="twitter" :data="entity['twitter']"/>-->
  322. <!-- </v-col>-->
  323. <!-- <v-col cols="12" sm="6">-->
  324. <!-- <UiInputText field="youtube" :data="entity['youtube']"/>-->
  325. <!-- </v-col>-->
  326. <!-- <v-col cols="12" sm="6">-->
  327. <!-- <UiInputText field="facebook" :data="entity['facebook']"/>-->
  328. <!-- </v-col>-->
  329. <!-- <v-col cols="12" sm="6">-->
  330. <!-- <UiInputText field="instagram" :data="entity['instagram']"/>-->
  331. <!-- </v-col>-->
  332. <!-- <v-col cols="12" sm="6">-->
  333. <!-- <UiInputCheckbox field="portailVisibility" :data="entity['portailVisibility']"/>-->
  334. <!-- </v-col>-->
  335. <!-- <v-col cols="12" sm="6">-->
  336. <!-- <div class="d-flex flex-column">-->
  337. <!-- <UiHelp class="d-flex flex-row">-->
  338. <!-- <span>{{ $t('image') }}</span>-->
  339. <!-- <p v-html="$t('communication_image_upload')"/>-->
  340. <!-- </UiHelp>-->
  341. <!-- <UiImage-->
  342. <!-- :id="getIdFromUri(entity['image'])"-->
  343. <!-- :upload="true"-->
  344. <!-- :width="200"-->
  345. <!-- field="image"-->
  346. <!-- :ownerId="id"-->
  347. <!-- ></UiImage>-->
  348. <!-- </div>-->
  349. <!-- </v-col>-->
  350. <!-- <v-col cols="12" sm="12">-->
  351. <!-- <UiCollection-->
  352. <!-- :model="models().OrganizationArticle"-->
  353. <!-- :parent="entity"-->
  354. <!-- loaderType="text"-->
  355. <!-- >-->
  356. <!-- <template #list.item="{items}">-->
  357. <!-- <h4 class="neutral-strong&#45;&#45;text font-weight-regular">{{$t('organizationArticle')}}</h4>-->
  358. <!-- <UiTemplateDataTable-->
  359. <!-- :headers="[-->
  360. <!-- { text: $t('title'), value: 'title' },-->
  361. <!-- { text: $t('link'), value: 'link' },-->
  362. <!-- { text: $t('date'), value: 'date' },-->
  363. <!-- ]"-->
  364. <!-- :items="items"-->
  365. <!-- >-->
  366. <!-- <template #item.date="{item}">-->
  367. <!-- <UiTemplateDate :data="item.date" />-->
  368. <!-- </template>-->
  369. <!-- </UiTemplateDataTable>-->
  370. <!-- </template>-->
  371. <!-- </UiCollection>-->
  372. <!-- </v-col>-->
  373. <!-- </v-row>-->
  374. <!-- </v-container>-->
  375. <!-- </UiExpansionPanel>-->
  376. <!-- &lt;!&ndash; IBAN &ndash;&gt;-->
  377. <!-- <UiExpansionPanel id="bank_account" icon="fa-euro-sign">-->
  378. <!-- <v-container class="container">-->
  379. <!-- <v-row>-->
  380. <!-- <v-col cols="12" sm="12">-->
  381. <!-- <UiCollection-->
  382. <!-- :model="models().BankAccount"-->
  383. <!-- :parent="entity"-->
  384. <!-- loaderType="image"-->
  385. <!-- newLink="/organization/bank_account/new"-->
  386. <!-- >-->
  387. <!-- <template #list.item="{items}">-->
  388. <!-- <v-container fluid>-->
  389. <!-- <v-row :dense="true">-->
  390. <!-- <v-col-->
  391. <!-- v-for="item in items"-->
  392. <!-- :key="item.id"-->
  393. <!-- cols="4"-->
  394. <!-- >-->
  395. <!-- <UiCard-->
  396. <!-- :id="item.id"-->
  397. <!-- :link="`/organization/bank_account/${item.id}`"-->
  398. <!-- :model="models().BankAccount"-->
  399. <!-- >-->
  400. <!-- <template #card.text>-->
  401. <!-- <span v-if="item.bankName"><strong>{{ $t('bankName') }}</strong> : {{ item.bankName }} <br></span>-->
  402. <!-- <span v-if="item.bic"><strong>{{ $t('bic') }}</strong> : {{ item.bic }} <br></span>-->
  403. <!-- <span v-if="item.bicInvalid" class="danger&#45;&#45;text"><v-icon class="danger&#45;&#45;text">mdi-alert</v-icon> <strong>{{ $t('bicInvalid') }}</strong> : {{ item.bicInvalid }} <br></span>-->
  404. <!-- <span v-if="item.iban"><strong>{{ $t('iban') }}</strong> : {{ item.iban }} <br></span>-->
  405. <!-- <span v-if="item.ibanInvalid" class="danger&#45;&#45;text"><v-icon class="danger&#45;&#45;text">mdi-alert</v-icon> <strong>{{ $t('ibanInvalid') }}</strong> : {{ item.ibanInvalid }} <br></span>-->
  406. <!-- </template>-->
  407. <!-- </UiCard>-->
  408. <!-- </v-col>-->
  409. <!-- </v-row>-->
  410. <!-- </v-container>-->
  411. <!-- </template>-->
  412. <!-- </UiCollection>-->
  413. <!-- </v-col>-->
  414. <!-- </v-row>-->
  415. <!-- </v-container>-->
  416. <!-- </UiExpansionPanel>-->
  417. </v-expansion-panels>
  418. </template>
  419. </UiForm>
  420. </LayoutContainer>
  421. </template>
  422. <script setup lang="ts">
  423. import { computed, reactive, ref } from 'vue'
  424. import type { ComputedRef } from 'vue'
  425. import { useRoute } from '#app'
  426. import { useI18n } from 'vue-i18n'
  427. import { useEntityFetch } from '~/composables/data/useEntityFetch'
  428. import TypeOfPractice from '~/models/Organization/TypeOfPractice'
  429. import { useExtensionPanel } from '~/composables/layout/useExtensionPanel'
  430. import { useValidation } from '~/composables/form/useValidation'
  431. import { useEntityManager } from '~/composables/data/useEntityManager'
  432. import UrlUtils from '~/services/utils/urlUtils'
  433. import Organization from '~/models/Organization/Organization'
  434. import { useI18nUtils } from '~/composables/utils/useI18nUtils'
  435. import ContactPoint from '~/models/Core/ContactPoint'
  436. import BankAccount from '~/models/Core/BankAccount'
  437. import OrganizationAddressPostal from '~/models/Organization/OrganizationAddressPostal'
  438. import Country from '~/models/Core/Country'
  439. import NetworkOrganization from '~/models/Network/NetworkOrganization'
  440. import OrganizationArticle from '~/models/Organization/OrganizationArticle'
  441. const id: number | null = useOrganizationProfileStore().id
  442. if (id === null) {
  443. throw new Error('Missing organization id')
  444. }
  445. const organizationProfile = reactive($organizationProfile())
  446. const { em } = useEntityManager()
  447. const { fetch, fetchCollection } = useEntityFetch()
  448. const { pending } = fetch(Organization, id)
  449. const organization: ComputedRef<Organization> = computed(() => {
  450. return em.find(Organization, id)
  451. })
  452. const { data: typeOfPractices, pending: typeOfPracticesPending } =
  453. fetchCollection(TypeOfPractice)
  454. const route = ref(useRoute())
  455. const { panel } = useExtensionPanel(route)
  456. const { siretError, siretErrorMessage, validateSiret } =
  457. useValidation().useValidateSiret()
  458. const validateSiretHook = async (
  459. siret: string,
  460. field: string,
  461. updateRepository: any,
  462. ) => {
  463. await validateSiret(siret)
  464. if (!siretError.value) {
  465. em.save(Organization, organization.value)
  466. }
  467. }
  468. const formatPhoneNumber = (number: string): string => {
  469. return useI18nUtils().formatPhoneNumber(number)
  470. }
  471. // TODO: voir si l'extraction de cette id ne pourrait pas être faite en amont, au niveau des post-processors
  472. const getIdsFromUris = (uris: Array<string>) => {
  473. const ids: Array<any> = []
  474. for (const uri of uris) {
  475. ids.push(UrlUtils.extractIdFromUri(uri))
  476. }
  477. return ids
  478. }
  479. // TODO: voir si l'extraction de cette id ne pourrait pas être faite en amont, au niveau des post-processors
  480. const getIdFromUri = (uri: string) => UrlUtils.extractIdFromUri(uri)
  481. const models = () => {
  482. return {
  483. Organization,
  484. ContactPoint,
  485. BankAccount,
  486. OrganizationAddressPostal,
  487. Country,
  488. NetworkOrganization,
  489. OrganizationArticle,
  490. }
  491. }
  492. const i18n = useI18n()
  493. const rules = {
  494. name: [
  495. (nameValue: string) => !!nameValue || i18n.t('required'),
  496. (nameValue: string) =>
  497. (nameValue || '').length <= 128 || i18n.t('name_length_rule'),
  498. ],
  499. siret: [
  500. (siretValue: string) =>
  501. /^([0-9]{9}|[0-9]{14})$/.test(siretValue) || i18n.t('siret_error'),
  502. ],
  503. typeOfPractice: [
  504. (typeOfPracticeValue: Array<number>) => {
  505. if (!$organizationProfile().isManagerProduct())
  506. return typeOfPracticeValue.length > 0 || i18n.t('required')
  507. return true
  508. },
  509. ],
  510. }
  511. </script>
  512. <style scoped>
  513. .v-icon.v-icon {
  514. font-size: 14px;
  515. }
  516. </style>