website.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. <template>
  2. <LayoutContainer>
  3. <UiLoadingPanel v-if="pending" />
  4. <UiForm
  5. v-else-if="parameters !== null"
  6. :model="Parameters"
  7. :entity="parameters"
  8. action-position="bottom"
  9. >
  10. <v-row>
  11. <v-col cols="12">
  12. <div class="my-5">
  13. <span>{{ $t('your_opentalent_website_address_is') }} : </span>
  14. <strong class="ml-2">
  15. <a :href="organizationProfile.website ?? '#'" target="_blank">
  16. {{ organizationProfile.website }}
  17. </a>
  18. </strong>
  19. </div>
  20. <!-- les publicationDirectors sont des entités Access -->
  21. <UiInputAutocompleteAccesses
  22. v-model="parameters.publicationDirectors"
  23. field="publicationDirectors"
  24. multiple
  25. chips
  26. variant="underlined"
  27. class="my-4"
  28. />
  29. <div>
  30. <UiInputText
  31. v-model="parameters.otherWebsite"
  32. field="otherWebsite"
  33. variant="underlined"
  34. class="my-4"
  35. />
  36. </div>
  37. <v-divider class="my-10" />
  38. <div class="mb-6">
  39. <div>
  40. <h4>{{ $t('your_subdomains') }} :</h4>
  41. </div>
  42. <UiLoadingPanel v-if="subdomainsPending" />
  43. <div v-else>
  44. <v-table v-if="subdomains" class="subdomains-table my-2">
  45. <tbody>
  46. <tr
  47. v-for="subdomain in subdomains.items"
  48. :key="subdomain.id"
  49. :title="subdomain.subdomain"
  50. :class="
  51. 'subdomainItem' + (subdomain.active ? ' active' : '')
  52. "
  53. @click="goToEditPage(subdomain.id)"
  54. >
  55. <td>{{ subdomain.subdomain }}</td>
  56. <td>
  57. <span v-if="subdomain.active">
  58. <v-icon class="text-success icon">
  59. fa-solid fa-check
  60. </v-icon>
  61. {{ $t('active') }}
  62. </span>
  63. </td>
  64. </tr>
  65. </tbody>
  66. </v-table>
  67. <span v-else>{{ $t('no_recorded_subdomain') }}</span>
  68. <div class="d-flex flex-row justify-center w-100">
  69. <v-btn
  70. :disabled="!canAddNewSubdomain"
  71. class="my-5"
  72. @click="onAddSubdomainClick"
  73. >
  74. {{ $t('record_a_new_subdomain') }}
  75. </v-btn>
  76. </div>
  77. </div>
  78. </div>
  79. <div v-if="!organizationProfile.isCmf">
  80. <v-divider class="my-10" />
  81. <div
  82. v-if="!organizationProfile.isCmf"
  83. class="my-8 d-flex flex-row justify-center w-100"
  84. >
  85. <v-btn
  86. v-if="!parameters.desactivateOpentalentSiteWeb"
  87. color="error"
  88. @click="showWebsiteDeactivationDialog = true"
  89. >
  90. {{ $t('deactivateOpentalentSiteWeb') }}
  91. </v-btn>
  92. <v-btn v-else color="primary" @click="reactivateWebsite">
  93. {{ $t('reactivateOpentalentSiteWeb') }}
  94. </v-btn>
  95. <LazyLayoutDialog :show="showWebsiteDeactivationDialog">
  96. <template #dialogTitle>
  97. {{ $t('please_confirm') }}
  98. </template>
  99. <template #dialogText>
  100. <v-col>
  101. <div>
  102. {{
  103. $t(
  104. 'yourOpentalentWebsiteWillBeDeactivatedOnceYouLlHaveSaved',
  105. )
  106. }}.
  107. </div>
  108. <span>{{ $t('doYouWantToContinue') }} ?</span>
  109. </v-col>
  110. </template>
  111. <template #dialogBtn>
  112. <v-btn
  113. class="theme-neutral-soft mr-4"
  114. @click="showWebsiteDeactivationDialog = false"
  115. >
  116. {{ $t('cancel') }}
  117. </v-btn>
  118. <v-btn
  119. class="theme-primary"
  120. @click="
  121. showWebsiteDeactivationDialog = false
  122. deactivateWebsite()
  123. "
  124. >
  125. {{ $t('yes') }}
  126. </v-btn>
  127. </template>
  128. </LazyLayoutDialog>
  129. </div>
  130. </div>
  131. </v-col>
  132. </v-row>
  133. </UiForm>
  134. </LayoutContainer>
  135. </template>
  136. <script setup lang="ts">
  137. import type { AsyncData } from '#app'
  138. import type { ComputedRef, Ref } from 'vue'
  139. import { useOrganizationProfileStore } from '~/stores/organizationProfile'
  140. import Parameters from '~/models/Organization/Parameters'
  141. import { useEntityFetch } from '~/composables/data/useEntityFetch'
  142. import Subdomain from '~/models/Organization/Subdomain'
  143. import ApiResource from '~/models/ApiResource'
  144. const { fetch, fetchCollection } = useEntityFetch()
  145. const organizationProfile = useOrganizationProfileStore()
  146. if (organizationProfile.parametersId === null) {
  147. throw new Error('Missing organization parameters id')
  148. }
  149. const { data: parameters, pending } = fetch(
  150. Parameters,
  151. organizationProfile.parametersId,
  152. ) as AsyncData<ApiResource | null, Error | null>
  153. const { data: subdomains, pending: subdomainsPending } = fetchCollection(
  154. Subdomain,
  155. null,
  156. ref({ organization: organizationProfile.id }),
  157. )
  158. const canAddNewSubdomain: ComputedRef<boolean> = computed(
  159. () => subdomains.value !== null && subdomains.value.items.length < 3,
  160. )
  161. const goToEditPage = (id: number) => {
  162. console.log(parameters.value)
  163. navigateTo(`/parameters/subdomains/${id}`)
  164. }
  165. const onAddSubdomainClick = () => {
  166. if (!canAddNewSubdomain) {
  167. throw new Error('Max number of subdomains reached')
  168. }
  169. navigateTo('/parameters/subdomains/new')
  170. }
  171. const showWebsiteDeactivationDialog: Ref<boolean> = ref(false)
  172. const deactivateWebsite = () => {
  173. parameters.value!.desactivateOpentalentSiteWeb = true
  174. }
  175. const reactivateWebsite = () => {
  176. parameters.value!.desactivateOpentalentSiteWeb = false
  177. }
  178. </script>
  179. <style scoped lang="scss">
  180. .subdomains-table {
  181. max-width: 450px;
  182. }
  183. .subdomainItem {
  184. cursor: pointer;
  185. border: solid 1px rgb(var(--v-theme-neutral-strong));
  186. }
  187. .subdomainItem:hover {
  188. background: rgb(var(--v-theme-neutral));
  189. }
  190. .subdomainItem .icon {
  191. font-size: 12px;
  192. }
  193. .subdomainItem td:first-child {
  194. border-left: solid 2px rgb(var(--v-theme-neutral));
  195. }
  196. .subdomainItem.active td:first-child {
  197. border-left: solid 2px rgb(var(--v-theme-primary));
  198. }
  199. </style>