GenerateCardsSteps.vue 12 KB

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