website.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. <template>
  2. <LayoutContainer>
  3. <h3>{{ $t("parameters_website_page")}}</h3>
  4. <UiLoadingPanel v-if="pending" />
  5. <UiForm
  6. v-else-if="parameters !== null"
  7. :model="Parameters"
  8. v-model="parameters"
  9. >
  10. <v-row>
  11. <v-col cols="12">
  12. <h4 class="flex-grow-1 align-self-center">
  13. {{ $t('your_opentalent_website') }}
  14. </h4>
  15. <div class="section-header">
  16. <div class="flex-grow-1 align-self-center">
  17. <span>{{ $t('your_opentalent_website_address_is') }} : </span>
  18. <strong class="ml-2">
  19. <a :href="organizationProfile.website ?? '#'" target="_blank">
  20. {{ organizationProfile.website }}
  21. </a>
  22. </strong>
  23. </div>
  24. </div>
  25. <div v-if="!organizationProfile.isCmf" class="my-6">
  26. <v-btn
  27. v-if="!parameters.desactivateOpentalentSiteWeb"
  28. color="error"
  29. @click="showWebsiteDeactivationDialog = true"
  30. >
  31. {{ $t('deactivateOpentalentSiteWeb') }}
  32. </v-btn>
  33. <v-btn v-else color="primary" @click="reactivateWebsite">
  34. {{ $t('reactivateOpentalentSiteWeb') }}
  35. </v-btn>
  36. <LazyLayoutDialog :show="showWebsiteDeactivationDialog">
  37. <template #dialogTitle>
  38. {{ $t('please_confirm') }}
  39. </template>
  40. <template #dialogText>
  41. <v-col>
  42. <div>
  43. {{
  44. $t(
  45. 'yourOpentalentWebsiteWillBeDeactivatedOnceYouLlHaveSaved',
  46. )
  47. }}.
  48. </div>
  49. <span>{{ $t('doYouWantToContinue') }} ?</span>
  50. </v-col>
  51. </template>
  52. <template #dialogBtn>
  53. <v-btn
  54. class="theme-neutral-soft mr-4"
  55. @click="showWebsiteDeactivationDialog = false"
  56. >
  57. {{ $t('cancel') }}
  58. </v-btn>
  59. <v-btn class="theme-primary" @click="onDialogYesBtnClick">
  60. {{ $t('yes') }}
  61. </v-btn>
  62. </template>
  63. </LazyLayoutDialog>
  64. </div>
  65. <!-- les publicationDirectors sont des entités Access -->
  66. <UiInputAutocompleteAccesses
  67. v-model="parameters.publicationDirectors"
  68. field="publicationDirectors"
  69. multiple
  70. chips
  71. class="my-4"
  72. />
  73. <div class="mb-6">
  74. <div class="section-header">
  75. <h4 class="flex-grow-1 align-self-center">
  76. {{ $t('your_subdomains') }}
  77. </h4>
  78. </div>
  79. <UiLoadingPanel v-if="subdomainsPending" />
  80. <div v-else>
  81. <v-table v-if="subdomains!.items" class="subdomains-table my-2">
  82. <tbody>
  83. <tr
  84. v-for="subdomain in subdomains!.items"
  85. :key="subdomain.id"
  86. :title="subdomain.subdomain"
  87. :class="
  88. 'subdomainItem' + (subdomain.active ? ' active' : '')
  89. "
  90. @click="goToEditPage(subdomain.id)"
  91. >
  92. <td>{{ subdomain.subdomain }}</td>
  93. <td>
  94. <span v-if="subdomain.active">
  95. <v-icon class="text-success icon">
  96. fa-solid fa-check
  97. </v-icon>
  98. {{ $t('active') }}
  99. </span>
  100. </td>
  101. </tr>
  102. </tbody>
  103. </v-table>
  104. <span v-else>{{ $t('no_recorded_subdomain') }}</span>
  105. <div>
  106. <v-btn
  107. :disabled="!canAddNewSubdomain"
  108. class="my-5"
  109. @click="onAddSubdomainClick"
  110. >
  111. {{ $t('record_a_new_subdomain') }}
  112. </v-btn>
  113. </div>
  114. </div>
  115. </div>
  116. <div class="mt-6">
  117. <h4 class="flex-grow-1 align-self-center">
  118. {{ $t('other_website') }}
  119. </h4>
  120. <UiInputText
  121. v-model="parameters.otherWebsite"
  122. field="otherWebsite"
  123. class="my-4"
  124. />
  125. </div>
  126. </v-col>
  127. </v-row>
  128. </UiForm>
  129. </LayoutContainer>
  130. </template>
  131. <script setup lang="ts">
  132. import type { AsyncData } from '#app'
  133. import type { ComputedRef, Ref } from 'vue'
  134. import { useOrganizationProfileStore } from '~/stores/organizationProfile'
  135. import Parameters from '~/models/Organization/Parameters'
  136. import { useEntityFetch } from '~/composables/data/useEntityFetch'
  137. import Subdomain from '~/models/Organization/Subdomain'
  138. import ApiResource from '~/models/ApiResource'
  139. import EqualFilter from '~/services/data/Filters/EqualFilter'
  140. import Query from '~/services/data/Query'
  141. definePageMeta({
  142. name: 'parameters_website_page',
  143. })
  144. const { fetch, fetchCollection } = useEntityFetch()
  145. const organizationProfile = useOrganizationProfileStore()
  146. if (organizationProfile.parametersId === null) {
  147. throw new Error('Missing organization parameters id')
  148. }
  149. const { data: parameters, pending } = fetch(
  150. Parameters,
  151. organizationProfile.parametersId,
  152. ) as AsyncData<ApiResource | null, Error | null>
  153. const query = new Query(new EqualFilter('organization', organizationProfile.id))
  154. const { data: subdomains, pending: subdomainsPending } = fetchCollection(
  155. Subdomain,
  156. null,
  157. query,
  158. )
  159. const canAddNewSubdomain: ComputedRef<boolean> = computed(
  160. () => subdomains.value !== null && subdomains.value.items.length < 3,
  161. )
  162. const goToEditPage = (id: number) => {
  163. navigateTo(`/parameters/subdomains/${id}`)
  164. }
  165. const onAddSubdomainClick = () => {
  166. if (!canAddNewSubdomain.value) {
  167. throw new Error('Max number of subdomains reached')
  168. }
  169. navigateTo('/parameters/subdomains/new')
  170. }
  171. const showWebsiteDeactivationDialog: Ref<boolean> = ref(false)
  172. const deactivateWebsite = () => {
  173. parameters.value!.desactivateOpentalentSiteWeb = true
  174. }
  175. const reactivateWebsite = () => {
  176. parameters.value!.desactivateOpentalentSiteWeb = false
  177. }
  178. const onDialogYesBtnClick = () => {
  179. showWebsiteDeactivationDialog.value = false
  180. deactivateWebsite()
  181. }
  182. </script>
  183. <style scoped lang="scss">
  184. .section-header {
  185. margin: 10px 0;
  186. display: flex;
  187. flex-direction: row;
  188. @media (max-width: 600px) {
  189. flex-direction: column;
  190. :deep(.v-btn) {
  191. height: auto;
  192. margin: 15px 0;
  193. white-space: normal;
  194. }
  195. }
  196. }
  197. .subdomainItem {
  198. cursor: pointer;
  199. border: solid 1px rgb(var(--v-theme-neutral-strong));
  200. }
  201. .subdomainItem:hover {
  202. background: rgb(var(--v-theme-neutral));
  203. }
  204. .subdomainItem .icon {
  205. font-size: 12px;
  206. }
  207. .subdomainItem td:first-child {
  208. border-top: solid 1px rgb(var(--v-theme-neutral));
  209. border-bottom: solid 1px rgb(var(--v-theme-neutral));
  210. border-left: solid 2px rgb(var(--v-theme-neutral));
  211. }
  212. .subdomainItem td:last-child {
  213. border-top: solid 1px rgb(var(--v-theme-neutral));
  214. border-bottom: solid 1px rgb(var(--v-theme-neutral));
  215. border-right: solid 1px rgb(var(--v-theme-neutral));
  216. }
  217. .subdomainItem.active td:first-child {
  218. border-left: solid 2px rgb(var(--v-theme-primary));
  219. }
  220. </style>