index.vue 25 KB

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