website.vue 7.0 KB

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