index.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <template>
  2. <LayoutContainer>
  3. <UiLoadingPanel v-if="pending" />
  4. <div v-else>
  5. <v-table>
  6. <thead>
  7. <tr>
  8. <td>{{ $t('educationTimings') }}</td>
  9. <td></td>
  10. </tr>
  11. </thead>
  12. <tbody v-if="educationTimings!.items.length > 0">
  13. <tr v-for="timing in educationTimings!.items" :key="timing.id">
  14. <td class="cycle-editable-cell">
  15. {{ timing.timing }}
  16. </td>
  17. <td class="d-flex flex-row">
  18. <v-btn
  19. :flat="true"
  20. icon="fa fa-pen"
  21. class="cycle-edit-icon mr-3"
  22. @click="goToEditPage(timing.id as number)"
  23. />
  24. <UiButtonDelete
  25. :entity="timing"
  26. :flat="true"
  27. class="cycle-edit-icon"
  28. />
  29. </td>
  30. </tr>
  31. </tbody>
  32. <tbody v-else>
  33. <tr class="theme-neutral">
  34. <td>
  35. <i>{{ $t('nothing_to_show') }}</i>
  36. </td>
  37. <td></td>
  38. </tr>
  39. </tbody>
  40. </v-table>
  41. <v-btn
  42. :flat="true"
  43. prepend-icon="fa fa-plus"
  44. class="theme-primary mt-4"
  45. @click="goToCreatePage"
  46. >
  47. {{ $t('add') }}
  48. </v-btn>
  49. </div>
  50. </LayoutContainer>
  51. </template>
  52. <script setup lang="ts">
  53. import { useEntityFetch } from '~/composables/data/useEntityFetch'
  54. import EducationTiming from '~/models/Education/EducationTiming'
  55. import { useOrganizationProfileStore } from '~/stores/organizationProfile'
  56. import UrlUtils from '~/services/utils/urlUtils'
  57. definePageMeta({
  58. name: 'parameters_education_timings_page',
  59. })
  60. const organizationProfile = useOrganizationProfileStore()
  61. if (organizationProfile.parametersId === null) {
  62. throw new Error('Missing organization parameters id')
  63. }
  64. const { fetchCollection } = useEntityFetch()
  65. const { data: educationTimings, pending } = fetchCollection(EducationTiming)
  66. const goToEditPage = (id: number) => {
  67. navigateTo(UrlUtils.join('/parameters/education_timings', id))
  68. }
  69. const goToCreatePage = () => {
  70. navigateTo('/parameters/education_timings/new')
  71. }
  72. </script>
  73. <style scoped lang="scss">
  74. .v-table {
  75. width: 100%;
  76. max-width: 800px;
  77. }
  78. // TODO: voir à factoriser ces styles, ptêt en faisant un component de ces boutons?
  79. :deep(.cycle-edit-icon .v-icon) {
  80. color: rgb(var(--v-theme-primary));
  81. font-size: 18px;
  82. }
  83. </style>