website.vue 6.1 KB

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