residence_areas.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <template>
  2. <NuxtLayout name="parameters">
  3. <LayoutContainer>
  4. <UiLoadingPanel v-if="pending" />
  5. <v-container v-else style="width: 500px;">
  6. <v-col cols="12">
  7. <v-row class="justify-center">
  8. <v-table class="w-100">
  9. <thead>
  10. <tr>
  11. <td>{{ $t('residenceAreas') }}</td>
  12. <td></td>
  13. </tr>
  14. </thead>
  15. <tbody>
  16. <tr v-if="residenceAreas.length > 0" v-for="residenceArea in residenceAreas" :key="residenceArea.id">
  17. <td class="cycle-editable-cell">
  18. {{ residenceArea.label }}
  19. </td>
  20. <td class="d-flex flex-row">
  21. <v-btn
  22. :flat="true"
  23. icon="fa fa-pen"
  24. class="cycle-edit-icon mr-3"
  25. @click="goToEditPage(residenceArea.id as number)"
  26. />
  27. <UiButtonDelete
  28. :model="ResidenceArea"
  29. :entity="residenceArea"
  30. :flat="true"
  31. class="cycle-edit-icon"
  32. />
  33. </td>
  34. </tr>
  35. <tr v-else class="theme-neutral">
  36. <td><i>{{ $t('nothing_to_show')}}</i></td>
  37. <td></td>
  38. </tr>
  39. </tbody>
  40. </v-table>
  41. </v-row>
  42. <v-row class="justify-end">
  43. <v-btn
  44. :flat="true"
  45. prepend-icon="fa fa-plus"
  46. class="theme-primary mt-2"
  47. @click="goToCreatePage"
  48. >
  49. {{ $t('add') }}
  50. </v-btn>
  51. </v-row>
  52. </v-col>
  53. </v-container>
  54. </LayoutContainer>
  55. </NuxtLayout>
  56. </template>
  57. <script setup lang="ts">
  58. import { useEntityFetch } from '~/composables/data/useEntityFetch'
  59. import ResidenceArea from '~/models/Billing/ResidenceArea'
  60. import { useRepo } from 'pinia-orm'
  61. import ResidenceAreasRepository from '~/stores/repositories/ResidenceAreasRepository'
  62. import { useRouter } from 'vue-router'
  63. import UrlUtils from "~/services/utils/urlUtils";
  64. /**
  65. * Disable the default layout, the page will use the layout defined with <NuxtLayout />
  66. * @see https://nuxt.com/docs/guide/directory-structure/layouts#overriding-a-layout-on-a-per-page-basis
  67. */
  68. definePageMeta({
  69. layout: false,
  70. });
  71. const residenceAreasRepo = useRepo(ResidenceAreasRepository)
  72. const router = useRouter()
  73. const { fetchCollection } = useEntityFetch()
  74. const i18n = useI18n()
  75. const { pending } = fetchCollection(ResidenceArea)
  76. /**
  77. * On récupère les Residence Area via le store
  78. * (sans ça, les mises à jour SSE ne seront pas prises en compte)
  79. */
  80. const residenceAreas: ComputedRef<Array<ResidenceArea>> = computed(() => {
  81. return residenceAreasRepo.getResidenceAreas()
  82. })
  83. const goToEditPage = (id: number) => {
  84. navigateTo(UrlUtils.join('/parameters/residence_areas', id))
  85. }
  86. const goToCreatePage = () => {
  87. navigateTo(`/parameters/residence_areas/new`)
  88. }
  89. </script>
  90. <style scoped lang="scss">
  91. // TODO: voir à factoriser ces styles, ptêt en faisant un component de ces boutons?
  92. :deep(.cycle-edit-icon .v-icon) {
  93. color: rgb(var(--v-theme-primary));
  94. font-size: 18px;
  95. }
  96. </style>