website.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. <template>
  2. <LayoutContainer>
  3. <UiLoadingPanel v-if="pending" />
  4. <UiForm
  5. v-else
  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><h4>{{ $t('your_subdomains') }} : </h4></div>
  40. <UiLoadingPanel v-if="subdomainsPending" />
  41. <div v-else>
  42. <v-table v-if="subdomains" class="subdomains-table my-2">
  43. <tbody>
  44. <tr
  45. v-for="subdomain in subdomains.items"
  46. :key="subdomain.id"
  47. :title="subdomain.subdomain"
  48. :class="'subdomainItem' + (subdomain.active ? ' active' : '')"
  49. @click="goToEditPage(subdomain.id)"
  50. >
  51. <td>{{ subdomain.subdomain }}</td>
  52. <td>
  53. <span v-if="subdomain.active">
  54. <v-icon class="text-success icon">
  55. fa-solid fa-check
  56. </v-icon> {{ $t('active') }}
  57. </span>
  58. </td>
  59. </tr>
  60. </tbody>
  61. </v-table>
  62. <span v-else>{{ $t('no_recorded_subdomain') }}</span>
  63. <div class="d-flex flex-row justify-center w-100">
  64. <v-btn
  65. :disabled="!canAddNewSubdomain"
  66. class="my-5"
  67. @click="onAddSubdomainClick"
  68. >
  69. {{ $t('record_a_new_subdomain')}}
  70. </v-btn>
  71. </div>
  72. </div>
  73. </div>
  74. <div v-if="!organizationProfile.isCmf">
  75. <v-divider class="my-10"/>
  76. <div class="my-8 d-flex flex-row justify-center w-100" v-if="!organizationProfile.isCmf">
  77. <v-btn
  78. v-if="!parameters.desactivateOpentalentSiteWeb"
  79. color="error"
  80. @click="showWebsiteDeactivationDialog=true"
  81. >
  82. {{ $t('deactivateOpentalentSiteWeb') }}
  83. </v-btn>
  84. <v-btn
  85. v-else
  86. color="primary"
  87. @click="reactivateWebsite"
  88. >
  89. {{ $t('reactivateOpentalentSiteWeb') }}
  90. </v-btn>
  91. <LazyLayoutDialog :show="showWebsiteDeactivationDialog">
  92. <template #dialogTitle>
  93. {{ $t('please_confirm')}}
  94. </template>
  95. <template #dialogText>
  96. <v-col>
  97. <div>{{ $t('yourOpentalentWebsiteWillBeDeactivatedOnceYouLlHaveSaved')}}.</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
  109. class="theme-primary"
  110. @click="showWebsiteDeactivationDialog=false; deactivateWebsite()"
  111. >
  112. {{ $t('yes') }}
  113. </v-btn>
  114. </template>
  115. </LazyLayoutDialog>
  116. </div>
  117. </div>
  118. </v-col>
  119. </v-row>
  120. </UiForm>
  121. </LayoutContainer>
  122. </template>
  123. <script setup lang="ts">
  124. import {useOrganizationProfileStore} from "~/stores/organizationProfile";
  125. import Parameters from "~/models/Organization/Parameters";
  126. import {useEntityFetch} from "~/composables/data/useEntityFetch";
  127. import type {AsyncData} from "#app";
  128. import Subdomain from "~/models/Organization/Subdomain";
  129. const i18n = useI18n()
  130. const { fetch, fetchCollection } = useEntityFetch()
  131. const organizationProfile = useOrganizationProfileStore()
  132. if (organizationProfile.parametersId === null) {
  133. throw new Error('Missing organization parameters id')
  134. }
  135. const { data: parameters, pending } = fetch(Parameters, organizationProfile.parametersId) as AsyncData<Parameters, Parameters | true>
  136. const { data: subdomains, pending: subdomainsPending } = fetchCollection(Subdomain, null, ref({ 'organization' : organizationProfile.id }) )
  137. const canAddNewSubdomain: ComputedRef<boolean> = computed(() => subdomains.value && subdomains.value.items.length < 3)
  138. const goToEditPage = (id: number) => {
  139. console.log(parameters.value)
  140. navigateTo(`/parameters/subdomains/${id}`)
  141. }
  142. const onAddSubdomainClick = () => {
  143. if (!canAddNewSubdomain) {
  144. throw new Error('Max number of subdomains reached')
  145. }
  146. navigateTo('/parameters/subdomains/new')
  147. }
  148. const showWebsiteDeactivationDialog: Ref<boolean> = ref(false)
  149. const deactivateWebsite = () => {
  150. parameters.value.desactivateOpentalentSiteWeb = true
  151. }
  152. const reactivateWebsite = () => {
  153. parameters.value.desactivateOpentalentSiteWeb = false
  154. }
  155. </script>
  156. <style scoped lang="scss">
  157. .subdomains-table {
  158. max-width: 450px;
  159. }
  160. .subdomainItem {
  161. cursor: pointer;
  162. border: solid 1px rgb(var(--v-theme-neutral-strong));
  163. }
  164. .subdomainItem:hover {
  165. background: rgb(var(--v-theme-neutral));
  166. }
  167. .subdomainItem .icon {
  168. font-size: 12px;
  169. }
  170. .subdomainItem td:first-child {
  171. border-left: solid 2px rgb(var(--v-theme-neutral));
  172. }
  173. .subdomainItem.active td:first-child {
  174. border-left: solid 2px rgb(var(--v-theme-primary));
  175. }
  176. </style>