|
|
@@ -1,10 +1,100 @@
|
|
|
<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">
|
|
|
-/** Redirect to /parameters?tab=educationTimings */
|
|
|
-const router = useRouter()
|
|
|
-router.push(
|
|
|
- { path: `/parameters`, query: { tab: 'educationTimings' } }
|
|
|
-)
|
|
|
+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 { fetch, 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>
|