website.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  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. 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. class="my-4"
  116. />
  117. </div>
  118. </v-col>
  119. </v-row>
  120. </UiForm>
  121. </LayoutContainer>
  122. </template>
  123. <script setup lang="ts">
  124. import type { AsyncData } from '#app'
  125. import type { ComputedRef, Ref } from 'vue'
  126. import { useOrganizationProfileStore } from '~/stores/organizationProfile'
  127. import Parameters from '~/models/Organization/Parameters'
  128. import { useEntityFetch } from '~/composables/data/useEntityFetch'
  129. import Subdomain from '~/models/Organization/Subdomain'
  130. import ApiResource from '~/models/ApiResource'
  131. import EqualFilter from '~/services/data/Filters/EqualFilter'
  132. import Query from '~/services/data/Query'
  133. definePageMeta({
  134. name: 'parameters_website_page',
  135. })
  136. const { fetch, fetchCollection } = useEntityFetch()
  137. const organizationProfile = useOrganizationProfileStore()
  138. if (organizationProfile.parametersId === null) {
  139. throw new Error('Missing organization parameters id')
  140. }
  141. const { data: parameters, pending } = fetch(
  142. Parameters,
  143. organizationProfile.parametersId,
  144. ) as AsyncData<ApiResource | null, Error | null>
  145. const query = new Query(new EqualFilter('organization', organizationProfile.id))
  146. const { data: subdomains, pending: subdomainsPending } = fetchCollection(
  147. Subdomain,
  148. null,
  149. query,
  150. )
  151. const canAddNewSubdomain: ComputedRef<boolean> = computed(
  152. () => subdomains.value !== null && subdomains.value.items.length < 3,
  153. )
  154. const goToEditPage = (id: number) => {
  155. navigateTo(`/parameters/subdomains/${id}`)
  156. }
  157. const onAddSubdomainClick = () => {
  158. if (!canAddNewSubdomain.value) {
  159. throw new Error('Max number of subdomains reached')
  160. }
  161. navigateTo('/parameters/subdomains/new')
  162. }
  163. const showWebsiteDeactivationDialog: Ref<boolean> = ref(false)
  164. const deactivateWebsite = () => {
  165. parameters.value!.desactivateOpentalentSiteWeb = true
  166. }
  167. const reactivateWebsite = () => {
  168. parameters.value!.desactivateOpentalentSiteWeb = false
  169. }
  170. const onDialogYesBtnClick = () => {
  171. showWebsiteDeactivationDialog.value = false
  172. deactivateWebsite()
  173. }
  174. </script>
  175. <style scoped lang="scss">
  176. .section-header {
  177. margin: 10px 0;
  178. display: flex;
  179. flex-direction: row;
  180. @media (max-width: 600px) {
  181. flex-direction: column;
  182. :deep(.v-btn) {
  183. height: auto;
  184. margin: 15px 0;
  185. white-space: normal;
  186. }
  187. }
  188. }
  189. .subdomainItem {
  190. cursor: pointer;
  191. border: solid 1px rgb(var(--v-theme-neutral-strong));
  192. }
  193. .subdomainItem:hover {
  194. background: rgb(var(--v-theme-neutral));
  195. }
  196. .subdomainItem .icon {
  197. font-size: 12px;
  198. }
  199. .subdomainItem td:first-child {
  200. border-top: solid 1px rgb(var(--v-theme-neutral));
  201. border-bottom: solid 1px rgb(var(--v-theme-neutral));
  202. border-left: solid 2px rgb(var(--v-theme-neutral));
  203. }
  204. .subdomainItem td:last-child {
  205. border-top: solid 1px rgb(var(--v-theme-neutral));
  206. border-bottom: solid 1px rgb(var(--v-theme-neutral));
  207. border-right: solid 1px rgb(var(--v-theme-neutral));
  208. }
  209. .subdomainItem.active td:first-child {
  210. border-left: solid 2px rgb(var(--v-theme-primary));
  211. }
  212. </style>