GenerateCardsSteps.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  1. <!--
  2. Contenu de la boite de dialogue "Assistant de création"
  3. -->
  4. <template>
  5. <!-- Menu Accueil -->
  6. <v-container v-if="location === 'home'">
  7. <v-row>
  8. <!-- Une personne -->
  9. <v-col cols="6" v-if="ability.can('manage', 'users')">
  10. <LayoutHeaderUniversalCreationCard
  11. to="access"
  12. title="a_person"
  13. text-content="add_new_person_student"
  14. icon="fa fa-user"
  15. @click="onCardClick"
  16. />
  17. </v-col>
  18. <!-- Un évènement -->
  19. <v-col
  20. cols="6"
  21. v-if="
  22. ability.can('display', 'agenda_page') &&
  23. (ability.can('display', 'course_page') ||
  24. ability.can('display', 'exam_page') ||
  25. ability.can('display', 'pedagogics_project_page'))
  26. "
  27. >
  28. <LayoutHeaderUniversalCreationCard
  29. to="event"
  30. title="an_event"
  31. text-content="add_an_event_course"
  32. icon="fa fa-calendar-alt"
  33. @click="onCardClick"
  34. />
  35. </v-col>
  36. <!-- Autre évènement -->
  37. <v-col
  38. cols="6"
  39. v-else-if="
  40. ability.can('display', 'agenda_page') &&
  41. ability.can('manage', 'events')
  42. "
  43. >
  44. <LayoutHeaderUniversalCreationCard
  45. to="event-params"
  46. title="other_event"
  47. text-content="other_event_text_creation_card"
  48. icon="far fa-calendar"
  49. href="/calendar/create/events"
  50. @click="onCardClick"
  51. />
  52. </v-col>
  53. <!-- Une correspondance -->
  54. <v-col
  55. cols="6"
  56. v-if="
  57. ability.can('display', 'message_send_page') &&
  58. (ability.can('manage', 'emails') ||
  59. ability.can('manage', 'mails') ||
  60. ability.can('manage', 'texto'))
  61. "
  62. >
  63. <LayoutHeaderUniversalCreationCard
  64. to="message"
  65. title="a_correspondence"
  66. text-content="send_email_letter"
  67. icon="fa fa-comment"
  68. type="message"
  69. @click="onCardClick"
  70. />
  71. </v-col>
  72. <!-- Un matériel (direct link) -->
  73. <v-col cols="6" v-if="ability.can('manage', 'equipments')">
  74. <LayoutHeaderUniversalCreationCard
  75. title="a_materiel"
  76. text-content="add_any_type_material"
  77. icon="fa fa-cube"
  78. href="/list/create/equipment"
  79. @click="onCardClick"
  80. />
  81. </v-col>
  82. </v-row>
  83. </v-container>
  84. <!-- Menu "Créer une personne" -->
  85. <v-container v-if="location === 'access'">
  86. <v-row>
  87. <!-- Un adhérent -->
  88. <v-col cols="6" v-if="isLaw1901">
  89. <LayoutHeaderUniversalCreationCard
  90. title="an_adherent"
  91. text-content="adherent_text_creation_card"
  92. icon="fa fa-user"
  93. href="/universal_creation_person/adherent"
  94. @click="onCardClick"
  95. />
  96. </v-col>
  97. <!-- Un membre du CA -->
  98. <v-col cols="6" v-if="isLaw1901">
  99. <LayoutHeaderUniversalCreationCard
  100. title="a_ca_member"
  101. text-content="ca_member_text_creation_card"
  102. icon="fa fa-users"
  103. href="/universal_creation_person/ca_member"
  104. @click="onCardClick"
  105. />
  106. </v-col>
  107. <!-- Un élève -->
  108. <v-col cols="6">
  109. <LayoutHeaderUniversalCreationCard
  110. title="a_student"
  111. text-content="student_text_creation_card"
  112. icon="fa fa-user"
  113. href="/universal_creation_person/student"
  114. @click="onCardClick"
  115. />
  116. </v-col>
  117. <!-- Un tuteur -->
  118. <v-col cols="6">
  119. <LayoutHeaderUniversalCreationCard
  120. title="a_guardian"
  121. text-content="guardian_text_creation_card"
  122. icon="fa fa-female"
  123. href="/universal_creation_person/guardian"
  124. @click="onCardClick"
  125. />
  126. </v-col>
  127. <!-- Un professeur -->
  128. <v-col cols="6">
  129. <LayoutHeaderUniversalCreationCard
  130. title="a_teacher"
  131. text-content="teacher_text_creation_card"
  132. icon="fa fa-graduation-cap"
  133. href="/universal_creation_person/teacher"
  134. @click="onCardClick"
  135. />
  136. </v-col>
  137. <!-- Un membre du personnel -->
  138. <v-col cols="6">
  139. <LayoutHeaderUniversalCreationCard
  140. title="a_member_of_staff"
  141. text-content="personnel_text_creation_card"
  142. icon="fa fa-suitcase"
  143. href="/universal_creation_person/personnel"
  144. @click="onCardClick"
  145. />
  146. </v-col>
  147. <!-- Une entité légale -->
  148. <v-col cols="6">
  149. <LayoutHeaderUniversalCreationCard
  150. title="a_legal_entity"
  151. text-content="moral_text_creation_card"
  152. icon="fa fa-building"
  153. href="/universal_creation_person/company"
  154. @click="onCardClick"
  155. />
  156. </v-col>
  157. <!-- Une inscription en ligne -->
  158. <v-col cols="6" v-if="hasOnlineRegistrationModule">
  159. <LayoutHeaderUniversalCreationCard
  160. title="online_registration"
  161. text-content="online_registration_text_creation_card"
  162. icon="fa fa-list-alt"
  163. href="/online/registration/new_registration"
  164. @click="onCardClick"
  165. />
  166. </v-col>
  167. <!-- Un autre type de contact -->
  168. <v-col cols="6">
  169. <LayoutHeaderUniversalCreationCard
  170. title="another_type_of_contact"
  171. text-content="other_contact_text_creation_card"
  172. icon="fa fa-plus"
  173. href="/universal_creation_person/other_contact"
  174. @click="onCardClick"
  175. />
  176. </v-col>
  177. </v-row>
  178. </v-container>
  179. <!-- Menu Évènement -->
  180. <v-container v-if="location === 'event'">
  181. <v-row>
  182. <!-- Un cours -->
  183. <v-col cols="6" v-if="ability.can('display', 'course_page')">
  184. <LayoutHeaderUniversalCreationCard
  185. to="event-params"
  186. href="/calendar/create/courses"
  187. title="course"
  188. text-content="course_text_creation_card"
  189. icon="fa fa-users"
  190. @click="onCardClick"
  191. />
  192. </v-col>
  193. <!-- Un examen -->
  194. <v-col cols="6" v-if="ability.can('display', 'exam_page')">
  195. <LayoutHeaderUniversalCreationCard
  196. to="event-params"
  197. href="/calendar/create/examens"
  198. title="exam"
  199. text-content="exam_text_creation_card"
  200. icon="fa fa-graduation-cap"
  201. @click="onCardClick"
  202. />
  203. </v-col>
  204. <!-- Un projet pédagogique -->
  205. <v-col cols="6" v-if="ability.can('display', 'pedagogics_project_page')">
  206. <LayoutHeaderUniversalCreationCard
  207. to="event-params"
  208. href="/calendar/create/educational_projects"
  209. title="educational_services"
  210. text-content="educational_services_text_creation_card"
  211. icon="fa fa-suitcase"
  212. @click="onCardClick"
  213. />
  214. </v-col>
  215. <!-- Un autre évènement -->
  216. <v-col cols="6" v-if="ability.can('manage', 'events')">
  217. <LayoutHeaderUniversalCreationCard
  218. to="event-params"
  219. href="/calendar/create/events"
  220. title="other_event"
  221. text-content="other_event_text_creation_card"
  222. icon="far fa-calendar"
  223. @click="onCardClick"
  224. />
  225. </v-col>
  226. </v-row>
  227. </v-container>
  228. <!-- Une correspondance -->
  229. <v-container v-if="location === 'message'">
  230. <v-row>
  231. <!-- Un email -->
  232. <v-col cols="6" v-if="ability.can('manage', 'emails')">
  233. <LayoutHeaderUniversalCreationCard
  234. title="an_email"
  235. text-content="email_text_creation_card"
  236. icon="far fa-envelope"
  237. href="/list/create/emails"
  238. @click="onCardClick"
  239. />
  240. </v-col>
  241. <!-- Un courrier -->
  242. <v-col cols="6" v-if="ability.can('manage', 'mails')">
  243. <LayoutHeaderUniversalCreationCard
  244. title="a_letter"
  245. text-content="letter_text_creation_card"
  246. icon="far fa-file-alt"
  247. href="/list/create/mails"
  248. @click="onCardClick"
  249. />
  250. </v-col>
  251. <!-- Un SMS -->
  252. <v-col cols="6" v-if="ability.can('manage', 'texto')">
  253. <LayoutHeaderUniversalCreationCard
  254. title="a_sms"
  255. text-content="sms_text_creation_card"
  256. icon="fa fa-mobile-alt"
  257. href="/list/create/sms"
  258. @click="onCardClick"
  259. />
  260. </v-col>
  261. </v-row>
  262. </v-container>
  263. <!-- Page de pré-paramétrage des évènements -->
  264. <LayoutHeaderUniversalCreationEventParams
  265. v-if="location === 'event-params'"
  266. @params-updated="onEventParamsUpdated"
  267. />
  268. </template>
  269. <script setup lang="ts">
  270. import type { Ref } from '@vue/reactivity'
  271. import { useOrganizationProfileStore } from '~/stores/organizationProfile'
  272. import { useAbility } from '@casl/vue'
  273. import type { ComputedRef } from 'vue'
  274. import UrlUtils from '~/services/utils/urlUtils'
  275. const props = defineProps({
  276. /**
  277. * The path that the user followed troughout the wizard
  278. */
  279. path: {
  280. type: Array<string>,
  281. required: true,
  282. },
  283. })
  284. const location: ComputedRef<string> = computed(() => {
  285. return props.path.at(-1) ?? 'home'
  286. })
  287. const ability = useAbility()
  288. const organizationProfile = useOrganizationProfileStore()
  289. const isLaw1901: ComputedRef<boolean> = organizationProfile.isAssociation
  290. const hasOnlineRegistrationModule: Ref<boolean> = ref(
  291. organizationProfile.hasModule('IEL'),
  292. )
  293. const baseUrl: Ref<string | null> = ref(null)
  294. const query: Ref<Record<string, string>> = ref({})
  295. const url: ComputedRef<string | null> = computed(() => {
  296. if (baseUrl.value === null) {
  297. return null
  298. }
  299. return UrlUtils.addQuery(baseUrl.value, query.value)
  300. })
  301. const emit = defineEmits(['cardClick', 'urlUpdate'])
  302. /**
  303. * Called when a card is clicked
  304. * @param to Target location in the wizard
  305. * @param href Target absolute url
  306. */
  307. const onCardClick = (to: string | null, href: string | null) => {
  308. if (href !== null) {
  309. baseUrl.value = href
  310. }
  311. emit('cardClick', to, url.value)
  312. }
  313. /**
  314. * Called when the event parameters page is updated
  315. * @param event
  316. */
  317. const onEventParamsUpdated = (event: { start: string; end: string }) => {
  318. query.value = event
  319. }
  320. const unwatch = watch(url, (newUrl: string | null) => {
  321. emit('urlUpdate', newUrl)
  322. })
  323. onUnmounted(() => {
  324. unwatch()
  325. })
  326. </script>