website.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  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="mb-6">
  13. <div>{{ $t('your_opentalent_website_address_is')}} : </div>
  14. <div class="ma-2 text-primary">
  15. <strong>{{ organizationProfile.website }}</strong>
  16. </div>
  17. </div>
  18. <div class="mb-6">
  19. <div>{{ $t('your_subdomains') }} : </div>
  20. <UiLoadingPanel v-if="subdomainsPending" />
  21. <div v-else>
  22. <v-table class="my-2">
  23. <tbody>
  24. <tr
  25. v-for="subdomain in subdomains.items"
  26. :key="subdomain.id"
  27. :title="subdomain.subdomain"
  28. class="subdomainItem"
  29. @click="goToEditPage(subdomain.id)"
  30. >
  31. <td>{{ subdomain.subdomain }}</td>
  32. <td>
  33. <span v-if="subdomain.active">
  34. <v-icon class="text-success icon">
  35. fa-solid fa-check
  36. </v-icon> {{ $t('active') }}
  37. </span>
  38. </td>
  39. </tr>
  40. </tbody>
  41. </v-table>
  42. <v-btn
  43. :disabled="!canAddNewSubdomain"
  44. class="my-2"
  45. @click="onAddSubdomainClick"
  46. >
  47. {{ $t('record_a_new_subdomain')}}
  48. </v-btn>
  49. </div>
  50. </div>
  51. <!-- les publicationDirectors sont des entités Access -->
  52. <UiInputAutocompleteAccesses
  53. v-model="parameters.publicationDirectors"
  54. field="publicationDirectors"
  55. multiple
  56. chips
  57. variant="underlined"
  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. variant="underlined"
  105. />
  106. </div>
  107. </v-col>
  108. </v-row>
  109. </UiForm>
  110. </LayoutContainer>
  111. </template>
  112. <script setup lang="ts">
  113. import {useOrganizationProfileStore} from "~/stores/organizationProfile";
  114. import Parameters from "~/models/Organization/Parameters";
  115. import {useEntityFetch} from "~/composables/data/useEntityFetch";
  116. import {AsyncData} from "#app";
  117. import Subdomain from "~/models/Organization/Subdomain";
  118. const i18n = useI18n()
  119. const { fetch, fetchCollection } = useEntityFetch()
  120. const organizationProfile = useOrganizationProfileStore()
  121. if (organizationProfile.parametersId === null) {
  122. throw new Error('Missing organization parameters id')
  123. }
  124. const { data: parameters, pending } = fetch(Parameters, organizationProfile.parametersId) as AsyncData<Parameters, Parameters | true>
  125. const { data: subdomains, pending: subdomainsPending } = fetchCollection(Subdomain, null, ref({ 'organization' : organizationProfile.id }) )
  126. const canAddNewSubdomain: ComputedRef<boolean> = computed(() => subdomains.value && subdomains.value.items.length < 3)
  127. const goToEditPage = (id: number) => {
  128. console.log(parameters.value)
  129. navigateTo(`parameters/subdomains/${id}`)
  130. }
  131. const onAddSubdomainClick = () => {
  132. if (!canAddNewSubdomain) {
  133. throw new Error('Max number of subdomains reached')
  134. }
  135. navigateTo('/parameters/subdomains/new')
  136. }
  137. const showWebsiteDeactivationDialog: Ref<boolean> = ref(false)
  138. const deactivateWebsite = () => {
  139. parameters.value.desactivateOpentalentSiteWeb = true
  140. }
  141. const reactivateWebsite = () => {
  142. parameters.value.desactivateOpentalentSiteWeb = false
  143. }
  144. </script>
  145. <style scoped lang="scss">
  146. .v-table {
  147. background: transparent;
  148. }
  149. .subdomainItem {
  150. cursor: pointer;
  151. }
  152. .subdomainItem:hover {
  153. background: rgb(var(--v-theme-neutral));
  154. }
  155. .subdomainItem .icon {
  156. font-size: 12px;
  157. }
  158. </style>