index.vue 25 KB

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