GenerateCardsSteps.vue 10 KB

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