website.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. <template>
  2. <LayoutContainer>
  3. <UiLoadingPanel v-if="pending" />
  4. <UiForm
  5. v-else
  6. :model="Parameters"
  7. :entity="parameters"
  8. >
  9. <v-row>
  10. <v-col cols="6">
  11. <div class="mb-6">
  12. <div>{{ $t('your_opentalent_website_address_is')}} : </div>
  13. <div class="ma-2 text-primary">
  14. <strong>{{ organizationProfile.website }}</strong>
  15. </div>
  16. </div>
  17. <div class="mb-6">
  18. <div>{{ $t('your_subdomains') }} : </div>
  19. <UiLoadingPanel v-if="subdomainsPending" />
  20. <div v-else>
  21. <v-table class="my-2">
  22. <tbody>
  23. <tr
  24. v-for="subdomain in subdomains.items"
  25. :key="subdomain.id"
  26. :title="subdomain.subdomain"
  27. class="subdomainItem"
  28. @click="goToEditPage(subdomain.id)"
  29. >
  30. <td>{{ subdomain.subdomain }}</td>
  31. <td>
  32. <span v-if="subdomain.active">
  33. <v-icon class="text-success icon">
  34. fa-solid fa-check
  35. </v-icon> {{ $t('active') }}
  36. </span>
  37. </td>
  38. </tr>
  39. </tbody>
  40. </v-table>
  41. <v-btn
  42. :disabled="!canAddNewSubdomain"
  43. class="my-2"
  44. @click="onAddSubdomainClick"
  45. >
  46. {{ $t('record_a_new_subdomain')}}
  47. </v-btn>
  48. </div>
  49. </div>
  50. </v-col>
  51. <v-col cols="6">
  52. <!-- les publicationDirectors sont des entités Access -->
  53. <UiInputAutocompleteAccesses
  54. v-model="parameters.publicationDirectors"
  55. field="publicationDirectors"
  56. multiple
  57. chips
  58. />
  59. <div class="my-8" v-if="!organizationProfile.isCmf">
  60. <v-btn
  61. v-if="!parameters.desactivateOpentalentSiteWeb"
  62. color="error"
  63. @click="showWebsiteDeactivationDialog=true"
  64. >
  65. {{ $t('deactivateOpentalentSiteWeb') }}
  66. </v-btn>
  67. <v-btn
  68. v-else
  69. color="primary"
  70. @click="reactivateWebsite"
  71. >
  72. {{ $t('reactivateOpentalentSiteWeb') }}
  73. </v-btn>
  74. <LazyLayoutDialog :show="showWebsiteDeactivationDialog">
  75. <template #dialogTitle>
  76. {{ $t('please_confirm')}}
  77. </template>
  78. <template #dialogText>
  79. <v-col>
  80. <div>{{ $t('yourOpentalentWebsiteWillBeDeactivatedOnceYouLlHaveSaved')}}.</div>
  81. <span>{{ $t('doYouWantToContinue')}} ?</span>
  82. </v-col>
  83. </template>
  84. <template #dialogBtn>
  85. <v-btn
  86. class="theme-neutral-soft mr-4"
  87. @click="showWebsiteDeactivationDialog=false"
  88. >
  89. {{ $t('cancel') }}
  90. </v-btn>
  91. <v-btn
  92. class="theme-primary"
  93. @click="showWebsiteDeactivationDialog=false; deactivateWebsite()"
  94. >
  95. {{ $t('yes') }}
  96. </v-btn>
  97. </template>
  98. </LazyLayoutDialog>
  99. </div>
  100. <div>
  101. <UiInputText
  102. v-model="parameters.otherWebsite"
  103. field="otherWebsite"
  104. />
  105. </div>
  106. </v-col>
  107. </v-row>
  108. </UiForm>
  109. </LayoutContainer>
  110. </template>
  111. <script setup lang="ts">
  112. import {useOrganizationProfileStore} from "~/stores/organizationProfile";
  113. import Parameters from "~/models/Organization/Parameters";
  114. import {useEntityFetch} from "~/composables/data/useEntityFetch";
  115. import {AsyncData} from "#app";
  116. import Subdomain from "~/models/Organization/Subdomain";
  117. const i18n = useI18n()
  118. const { fetch, fetchCollection } = useEntityFetch()
  119. const organizationProfile = useOrganizationProfileStore()
  120. if (organizationProfile.parametersId === null) {
  121. throw new Error('Missing organization parameters id')
  122. }
  123. const { data: parameters, pending } = fetch(Parameters, organizationProfile.parametersId) as AsyncData<Parameters, Parameters | true>
  124. const { data: subdomains, pending: subdomainsPending } = fetchCollection(Subdomain, null, ref({ 'organization' : organizationProfile.id }) )
  125. const canAddNewSubdomain: ComputedRef<boolean> = computed(() => subdomains.value && subdomains.value.items.length < 3)
  126. const goToEditPage = (id: number) => {
  127. console.log(parameters.value)
  128. navigateTo(`parameters/subdomains/${id}`)
  129. }
  130. const onAddSubdomainClick = () => {
  131. if (!canAddNewSubdomain) {
  132. throw new Error('Max number of subdomains reached')
  133. }
  134. navigateTo('/parameters/subdomains/new')
  135. }
  136. const showWebsiteDeactivationDialog: Ref<boolean> = ref(false)
  137. const deactivateWebsite = () => {
  138. parameters.value.desactivateOpentalentSiteWeb = true
  139. }
  140. const reactivateWebsite = () => {
  141. parameters.value.desactivateOpentalentSiteWeb = false
  142. }
  143. </script>
  144. <style scoped lang="scss">
  145. .v-table {
  146. background: transparent;
  147. }
  148. .subdomainItem {
  149. cursor: pointer;
  150. }
  151. .subdomainItem:hover {
  152. background: rgb(var(--v-theme-neutral));
  153. }
  154. .subdomainItem .icon {
  155. font-size: 12px;
  156. }
  157. </style>