Browse Source

V8-4581 add online registration to create menu

Olivier Massot 2 years ago
parent
commit
f2ec844b62
2 changed files with 27 additions and 4 deletions
  1. 24 3
      components/Layout/Header/UniversalCreation/GenerateCardsSteps.vue
  2. 3 1
      lang/fr.json

+ 24 - 3
components/Layout/Header/UniversalCreation/GenerateCardsSteps.vue

@@ -130,6 +130,15 @@
         />
       </v-col>
 
+      <v-col cols="6" v-if="hasOnlineRegistrationModule">
+        <LayoutHeaderUniversalCreationTypeCard
+            title="online_registration"
+            text-content="online_registration_text_creation_card"
+            icon="fa fa-list-alt"
+            :link="makeAdminUrl('/online/registration/new_registration')"
+        />
+      </v-col>
+
       <v-col cols="6">
         <LayoutHeaderUniversalCreationTypeCard
             title="another_type_of_contact"
@@ -141,12 +150,13 @@
     </v-row>
 
     <v-row v-if="type === 'event'">
+      <!-- /?start=2023-06-12T08:00:00%2B0200&end=2023-06-12T09:00:00%2B0200 -->
       <v-col cols="6" v-if="ability.can('display', 'course_page')">
         <LayoutHeaderUniversalCreationTypeCard
             title="course"
             text-content="course_text_creation_card"
             icon="fa fa-users"
-            :link="makeAdminUrl('/calendar/create/courses')"
+            :link="makeAdminUrl('/calendar/create/courses', {'start': eventDefaultStart, 'end': eventDefaultEnd})"
         />
       </v-col>
 
@@ -215,6 +225,7 @@
   import {useAbility} from "@casl/vue";
   import {ComputedRef} from "vue";
   import UrlUtils from "~/services/utils/urlUtils";
+  import {add, formatISO, startOfHour} from "date-fns";
 
   const props = defineProps({
     step: {
@@ -231,6 +242,11 @@
   const organizationProfile = useOrganizationProfileStore()
   const runtimeConfig = useRuntimeConfig()
 
+  // Get the start of the next hour as a default event start
+  const now: Date = new Date()
+  const eventDefaultStart: string = formatISO(startOfHour(add(now, { 'hours': 1 })))
+  const eventDefaultEnd: string = formatISO(startOfHour(add(now, { 'hours': 2 })))
+
   const onTypeClick = (step: Number, Cardtype: String) => {
     type.value = Cardtype;
     emit('updateStep', { stepChoice: step, typeChoice: Cardtype });
@@ -238,8 +254,13 @@
 
   const adminLegacy: Ref<string> = ref(runtimeConfig.baseUrlAdminLegacy)
   const isLaw1901: ComputedRef<boolean> = organizationProfile.isAssociation
+  const hasOnlineRegistrationModule: ComputedRef<boolean> = computed(
+      () => organizationProfile.hasModule('IEL')
+  )
 
-  const makeAdminUrl = (tail: string) => {
-    return UrlUtils.join(runtimeConfig.baseUrlAdminLegacy, '#', tail)
+  const makeAdminUrl = (tail: string, query: Record<string, string> = {}) => {
+    let url = UrlUtils.join(runtimeConfig.baseUrlAdminLegacy, '#', tail)
+    url = UrlUtils.addQuery(url, query)
+    return url
   }
 </script>

+ 3 - 1
lang/fr.json

@@ -575,5 +575,7 @@
   "ERROR": "Erreur",
   "select": "Sélectionner",
   "Internal Server Error": "Erreur de serveur interne",
-  "cmf_licence_breadcrumbs": "Licence CMF"
+  "cmf_licence_breadcrumbs": "Licence CMF",
+  "online_registration": "Inscription en ligne",
+  "online_registration_text_creation_card": "Ajouter une nouvelle inscription"
 }