index.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. :model="EducationTiming"
  26. :entity="timing"
  27. :flat="true"
  28. class="cycle-edit-icon"
  29. />
  30. </td>
  31. </tr>
  32. </tbody>
  33. <tbody v-else>
  34. <tr class="theme-neutral">
  35. <td>
  36. <i>{{ $t('nothing_to_show') }}</i>
  37. </td>
  38. <td></td>
  39. </tr>
  40. </tbody>
  41. </v-table>
  42. <v-btn
  43. :flat="true"
  44. prepend-icon="fa fa-plus"
  45. class="theme-primary mt-4"
  46. @click="goToCreatePage"
  47. >
  48. {{ $t('add') }}
  49. </v-btn>
  50. </div>
  51. </LayoutContainer>
  52. </template>
  53. <script setup lang="ts">
  54. import { useEntityFetch } from '~/composables/data/useEntityFetch'
  55. import EducationTiming from '~/models/Education/EducationTiming'
  56. import { useOrganizationProfileStore } from '~/stores/organizationProfile'
  57. import UrlUtils from '~/services/utils/urlUtils'
  58. const organizationProfile = useOrganizationProfileStore()
  59. if (organizationProfile.parametersId === null) {
  60. throw new Error('Missing organization parameters id')
  61. }
  62. const { fetchCollection } = useEntityFetch()
  63. const { data: educationTimings, pending } = fetchCollection(EducationTiming)
  64. const goToEditPage = (id: number) => {
  65. navigateTo(UrlUtils.join('/parameters/education_timings', id))
  66. }
  67. const goToCreatePage = () => {
  68. navigateTo('/parameters/education_timings/new')
  69. }
  70. </script>
  71. <style scoped lang="scss">
  72. .v-table {
  73. width: 100%;
  74. max-width: 800px;
  75. }
  76. // TODO: voir à factoriser ces styles, ptêt en faisant un component de ces boutons?
  77. :deep(.cycle-edit-icon .v-icon) {
  78. color: rgb(var(--v-theme-primary));
  79. font-size: 18px;
  80. }
  81. </style>