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 class="theme-primary" @click="onDialogYesBtnClick">
  119. {{ $t('yes') }}
  120. </v-btn>
  121. </template>
  122. </LazyLayoutDialog>
  123. </div>
  124. </div>
  125. </v-col>
  126. </v-row>
  127. </UiForm>
  128. </LayoutContainer>
  129. </template>
  130. <script setup lang="ts">
  131. import type { AsyncData } from '#app'
  132. import type { ComputedRef, Ref } from 'vue'
  133. import { useOrganizationProfileStore } from '~/stores/organizationProfile'
  134. import Parameters from '~/models/Organization/Parameters'
  135. import { useEntityFetch } from '~/composables/data/useEntityFetch'
  136. import Subdomain from '~/models/Organization/Subdomain'
  137. import ApiResource from '~/models/ApiResource'
  138. const { fetch, fetchCollection } = useEntityFetch()
  139. const organizationProfile = useOrganizationProfileStore()
  140. if (organizationProfile.parametersId === null) {
  141. throw new Error('Missing organization parameters id')
  142. }
  143. const { data: parameters, pending } = fetch(
  144. Parameters,
  145. organizationProfile.parametersId,
  146. ) as AsyncData<ApiResource | null, Error | null>
  147. const { data: subdomains, pending: subdomainsPending } = fetchCollection(
  148. Subdomain,
  149. null,
  150. ref({ organization: organizationProfile.id }),
  151. )
  152. const canAddNewSubdomain: ComputedRef<boolean> = computed(
  153. () => subdomains.value !== null && subdomains.value.items.length < 3,
  154. )
  155. const goToEditPage = (id: number) => {
  156. console.log(parameters.value)
  157. navigateTo(`/parameters/subdomains/${id}`)
  158. }
  159. const onAddSubdomainClick = () => {
  160. if (!canAddNewSubdomain) {
  161. throw new Error('Max number of subdomains reached')
  162. }
  163. navigateTo('/parameters/subdomains/new')
  164. }
  165. const showWebsiteDeactivationDialog: Ref<boolean> = ref(false)
  166. const deactivateWebsite = () => {
  167. parameters.value!.desactivateOpentalentSiteWeb = true
  168. }
  169. const reactivateWebsite = () => {
  170. parameters.value!.desactivateOpentalentSiteWeb = false
  171. }
  172. const onDialogYesBtnClick = () => {
  173. showWebsiteDeactivationDialog.value = false
  174. deactivateWebsite()
  175. }
  176. </script>
  177. <style scoped lang="scss">
  178. .subdomains-table {
  179. max-width: 450px;
  180. }
  181. .subdomainItem {
  182. cursor: pointer;
  183. border: solid 1px rgb(var(--v-theme-neutral-strong));
  184. }
  185. .subdomainItem:hover {
  186. background: rgb(var(--v-theme-neutral));
  187. }
  188. .subdomainItem .icon {
  189. font-size: 12px;
  190. }
  191. .subdomainItem td:first-child {
  192. border-left: solid 2px rgb(var(--v-theme-neutral));
  193. }
  194. .subdomainItem.active td:first-child {
  195. border-left: solid 2px rgb(var(--v-theme-primary));
  196. }
  197. </style>