GenerateCardsSteps.vue 12 KB

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