index.vue 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. definePageMeta({
  59. name: 'parameters_education_timings_page',
  60. })
  61. const organizationProfile = useOrganizationProfileStore()
  62. if (organizationProfile.parametersId === null) {
  63. throw new Error('Missing organization parameters id')
  64. }
  65. const { fetchCollection } = useEntityFetch()
  66. const { data: educationTimings, pending } = fetchCollection(EducationTiming)
  67. const goToEditPage = (id: number) => {
  68. navigateTo(UrlUtils.join('/parameters/education_timings', id))
  69. }
  70. const goToCreatePage = () => {
  71. navigateTo('/parameters/education_timings/new')
  72. }
  73. </script>
  74. <style scoped lang="scss">
  75. .v-table {
  76. width: 100%;
  77. max-width: 800px;
  78. }
  79. // TODO: voir à factoriser ces styles, ptêt en faisant un component de ces boutons?
  80. :deep(.cycle-edit-icon .v-icon) {
  81. color: rgb(var(--v-theme-primary));
  82. font-size: 18px;
  83. }
  84. </style>