Website.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  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. <v-row>
  53. <!-- les publicationDirectors sont des entités Access -->
  54. <UiInputAutocompleteAccesses
  55. v-model="parameters.publicationDirectors"
  56. field="publicationDirectors"
  57. multiple
  58. chips
  59. />
  60. </v-row>
  61. <v-row class="my-8" v-if="!organizationProfile.isCmf">
  62. <v-btn
  63. v-if="!parameters.desactivateOpentalentSiteWeb"
  64. color="error"
  65. @click="showWebsiteDeactivationDialog=true"
  66. >
  67. {{ $t('deactivateOpentalentSiteWeb') }}
  68. </v-btn>
  69. <v-btn
  70. v-else
  71. color="primary"
  72. @click="reactivateWebsite"
  73. >
  74. {{ $t('reactivateOpentalentSiteWeb') }}
  75. </v-btn>
  76. <LazyLayoutDialog :show="showWebsiteDeactivationDialog">
  77. <template #dialogTitle>
  78. {{ $t('please_confirm')}}
  79. </template>
  80. <template #dialogText>
  81. <v-col>
  82. <div>{{ $t('yourOpentalentWebsiteWillBeDeactivatedOnceYouLlHaveSaved')}}.</div>
  83. <span>{{ $t('doYouWantToContinue')}} ?</span>
  84. </v-col>
  85. </template>
  86. <template #dialogBtn>
  87. <v-btn
  88. class="theme-neutral-soft mr-4"
  89. @click="showWebsiteDeactivationDialog=false"
  90. >
  91. {{ $t('cancel') }}
  92. </v-btn>
  93. <v-btn
  94. class="theme-primary"
  95. @click="showWebsiteDeactivationDialog=false; deactivateWebsite()"
  96. >
  97. {{ $t('yes') }}
  98. </v-btn>
  99. </template>
  100. </LazyLayoutDialog>
  101. </v-row>
  102. <v-row>
  103. <UiInputText
  104. v-model="parameters.otherWebsite"
  105. field="otherWebsite"
  106. />
  107. </v-row>
  108. </v-col>
  109. </v-row>
  110. </UiForm>
  111. </LayoutContainer>
  112. </template>
  113. <script setup lang="ts">
  114. import {useOrganizationProfileStore} from "~/stores/organizationProfile";
  115. import Parameters from "~/models/Organization/Parameters";
  116. import {useEntityFetch} from "~/composables/data/useEntityFetch";
  117. import {AsyncData} from "#app";
  118. import Subdomain from "~/models/Organization/Subdomain";
  119. const i18n = useI18n()
  120. const { fetch, fetchCollection } = useEntityFetch()
  121. const organizationProfile = useOrganizationProfileStore()
  122. if (organizationProfile.parametersId === null) {
  123. throw new Error('Missing organization parameters id')
  124. }
  125. const { data: parameters, pending } = fetch(Parameters, organizationProfile.parametersId) as AsyncData<Parameters, Parameters | true>
  126. const { data: subdomains, pending: subdomainsPending } = fetchCollection(Subdomain, null, ref({ 'organization' : organizationProfile.id }) )
  127. const canAddNewSubdomain: ComputedRef<boolean> = computed(() => subdomains.value && subdomains.value.items.length < 3)
  128. const goToEditPage = (id: number) => {
  129. console.log(parameters.value)
  130. navigateTo(`parameters/subdomains/${id}`)
  131. }
  132. const onAddSubdomainClick = () => {
  133. if (!canAddNewSubdomain) {
  134. throw new Error('Max number of subdomains reached')
  135. }
  136. navigateTo('/parameters/subdomains/new')
  137. }
  138. const showWebsiteDeactivationDialog: Ref<boolean> = ref(false)
  139. const deactivateWebsite = () => {
  140. parameters.value.desactivateOpentalentSiteWeb = true
  141. }
  142. const reactivateWebsite = () => {
  143. parameters.value.desactivateOpentalentSiteWeb = false
  144. }
  145. </script>
  146. <style scoped lang="scss">
  147. .v-table {
  148. background: transparent;
  149. }
  150. .subdomainItem {
  151. cursor: pointer;
  152. }
  153. .subdomainItem:hover {
  154. background: rgb(var(--v-theme-neutral));
  155. }
  156. .subdomainItem .icon {
  157. font-size: 12px;
  158. }
  159. </style>