Parcourir la source

post MR fixes

Olivier Massot il y a 1 an
Parent
commit
c93bffded9

+ 1 - 12
components/Ui/Form.vue

@@ -161,15 +161,6 @@ const props = defineProps({
     type: String as PropType<'top' | 'bottom' | 'both'>,
     required: false,
     default: 'both'
-  },
-  /**
-   * Cette méthode sera exécutée avant la soumission des données à l'API
-   * Elle prends l'entité en paramètre, permet de la modifier et retourne l'entité qui en résulte.
-   */
-  preProcess: {
-    type: Function as PropType<(instance: ApiModel) => ApiModel>,
-    required: false,
-    default: (instance: ApiModel) => instance
   }
 })
 
@@ -228,10 +219,8 @@ const submit = async (next: string|null = null) => {
   try {
     usePageStore().loading = true
 
-    const entity = props.preProcess(props.entity)
-
     // TODO: est-ce qu'il faut re-fetch l'entité après le persist?
-    const updatedEntity = await em.persist(props.model, entity)
+    const updatedEntity = await em.persist(props.model, props.entity)
 
     if (props.refreshProfile) {
       await refreshProfile()

+ 0 - 10
components/Ui/Form/Creation.vue

@@ -3,7 +3,6 @@
       :model="model"
       :entity="entity"
       :submitActions="submitActions"
-      :preProcess="preProcess"
   >
     <template #form.button>
       <v-btn v-if="goBackRoute" class="theme-neutral mr-3" @click="quit">
@@ -56,15 +55,6 @@ const props = defineProps({
     required: false,
     default: false
   },
-  /**
-   * Cette méthode sera exécutée avant la soumission des données à l'API
-   * Elle prends l'entité en paramètre, permet de la modifier et retourne l'entité qui en résulte.
-   */
-  preProcess: {
-    type: Function as PropType<(instance: ApiModel) => ApiModel>,
-    required: false,
-    default: (instance: ApiModel) => instance
-  }
 })
 
 const router = useRouter()

+ 0 - 4
models/Booking/AttendanceBookingReason.ts

@@ -14,10 +14,6 @@ export default class AttendanceBookingReason extends ApiModel {
     @Uid()
     declare id: number | string
 
-    @Attr(null)
-    @IriEncoded(Organization)
-    declare organization: number | null
-
     @Str(null)
     declare reason: string|null
 }

+ 0 - 100
pages/parameters/attendance_booking_reasons/index.vue

@@ -1,100 +0,0 @@
-<template>
-  <LayoutContainer>
-    <UiLoadingPanel v-if="pending" />
-    <div v-else>
-      <v-table>
-        <thead>
-          <tr>
-            <td>{{ $t('educationTimings') }}</td>
-            <td></td>
-          </tr>
-        </thead>
-        <tbody>
-          <tr v-if="educationTimings.length > 0" v-for="timing in educationTimings" :key="timing.id">
-            <td class="cycle-editable-cell">
-              {{ timing.timing }}
-            </td>
-            <td class="d-flex flex-row">
-              <v-btn
-                  :flat="true"
-                  icon="fa fa-pen"
-                  class="cycle-edit-icon mr-3"
-                  @click="goToEditPage(timing.id as number)"
-              />
-              <UiButtonDelete
-                  :model="EducationTiming"
-                  :entity="timing"
-                  :flat="true"
-                  class="cycle-edit-icon"
-              />
-            </td>
-          </tr>
-          <tr v-else class="theme-neutral">
-            <td><i>{{ $t('nothing_to_show')}}</i></td>
-            <td></td>
-          </tr>
-        </tbody>
-      </v-table>
-      <v-btn
-          :flat="true"
-          prepend-icon="fa fa-plus"
-          class="theme-primary mt-4"
-          @click="goToCreatePage"
-      >
-        {{ $t('add') }}
-      </v-btn>
-    </div>
-  </LayoutContainer>
-
-</template>
-
-<script setup lang="ts">
-import { useEntityFetch } from '~/composables/data/useEntityFetch'
-import EducationTiming from '~/models/Education/EducationTiming'
-import { useRepo } from 'pinia-orm'
-import EducationTimingsRepository from '~/stores/repositories/EducationTimingsRepository'
-import type {ComputedRef} from "vue";
-import {useOrganizationProfileStore} from "~/stores/organizationProfile";
-import UrlUtils from "~/services/utils/urlUtils";
-
-const organizationProfile = useOrganizationProfileStore()
-
-if (organizationProfile.parametersId === null) {
-  throw new Error('Missing organization parameters id')
-}
-
-const { fetchCollection } = useEntityFetch()
-
-const { pending } = fetchCollection(EducationTiming)
-
-const educationTimingRepo = useRepo(EducationTimingsRepository)
-
-/**
- * On récupère les timings via le store
- * (sans ça, les mises à jour SSE ne seront pas prises en compte)
- */
-const educationTimings: ComputedRef<Array<EducationTiming>> = computed(() => {
-  return educationTimingRepo.getEducationTimings()
-})
-
-const goToEditPage = (id: number) => {
-  navigateTo(UrlUtils.join('/parameters/education_timings', id))
-}
-
-const goToCreatePage = () => {
-  navigateTo('/parameters/education_timings/new')
-}
-</script>
-
-<style scoped lang="scss">
-.v-table {
-  width: 100%;
-  max-width: 800px;
-}
-
-// TODO: voir à factoriser ces styles, ptêt en faisant un component de ces boutons?
-:deep(.cycle-edit-icon .v-icon) {
-  color: rgb(var(--v-theme-primary));
-  font-size: 18px;
-}
-</style>

+ 0 - 9
pages/parameters/attendance_booking_reasons/new.vue

@@ -5,7 +5,6 @@
       <UiFormCreation
         :model="AttendanceBookingReason"
         go-back-route="/parameters/attendances"
-        :pre-process="preProcess"
       >
         <template v-slot="{ entity }">
           <v-container :fluid="true" class="container">
@@ -31,17 +30,9 @@
 <script setup lang="ts">
 import { useI18n } from 'vue-i18n'
 import AttendanceBookingReason from "~/models/Booking/AttendanceBookingReason";
-import {useOrganizationProfileStore} from "#imports";
 
 const i18n = useI18n()
 
-const organizationProfile = useOrganizationProfileStore()
-
-const preProcess = (entity: AttendanceBookingReason) => {
-  entity.organization = organizationProfile.id
-  return entity
-}
-
 const rules = () => [
   (reason: string | null) =>
       (reason !== null && reason.length > 0) || i18n.t('please_enter_a_value'),