website.vue 7.1 KB

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