website.vue 7.1 KB

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