GenerateCardsSteps.vue 12 KB

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