website.vue 6.2 KB

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