website.vue 7.1 KB

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