Cycle.vue 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <!-- Component d'un formulaire d'un cycle -->
  2. <template>
  3. <main>
  4. <LayoutContainer>
  5. <v-card class="mb-5 mt-4">
  6. <FormToolbar title="cycle" icon="fa-bars"/>
  7. <UiForm
  8. :id="id"
  9. :model="model"
  10. :query="query()"
  11. :submitActions="submitActions">
  12. <template #form.input="{entry, updateRepository}">
  13. <v-container fluid class="container">
  14. <v-row>
  15. <v-col cols="12" sm="6">
  16. <UiInputText field="label" label="title" :data="entry['label']" @update="updateRepository" />
  17. </v-col>
  18. </v-row>
  19. </v-container>
  20. </template>
  21. <template #form.button>
  22. <NuxtLink :to="{ path: '/parameters/education'}" class="no-decoration">
  23. <v-btn class="mr-4 ot_light_grey ot_grey--text">
  24. {{ $t('back') }}
  25. </v-btn>
  26. </NuxtLink>
  27. </template>
  28. </UiForm>
  29. </v-card>
  30. </LayoutContainer>
  31. </main>
  32. </template>
  33. <script lang="ts">
  34. import { defineComponent, computed} from '@nuxtjs/composition-api'
  35. import { Repository as VuexRepository } from '@vuex-orm/core/dist/src/repository/Repository'
  36. import { Query, Model } from '@vuex-orm/core'
  37. import { SUBMIT_TYPE} from '~/types/enums'
  38. import { repositoryHelper } from '~/services/store/repository'
  39. import {AnyJson} from "~/types/interfaces";
  40. import {Cycle} from "~/models/Education/Cycle";
  41. export default defineComponent({
  42. props: {
  43. id:{
  44. type: [Number, String],
  45. required: true
  46. }
  47. },
  48. setup () {
  49. const repository: VuexRepository<Model> = repositoryHelper.getRepository(Cycle)
  50. const query: Query = repository.query()
  51. const submitActions = computed(() => {
  52. let actions:AnyJson = {}
  53. actions[SUBMIT_TYPE.SAVE_AND_BACK] = { path: `/parameters/education` }
  54. actions[SUBMIT_TYPE.SAVE] = { path: `/parameters/education/cycle/` }
  55. return actions
  56. })
  57. /** Computed properties needs to be returned as functions until nuxt3 : https://github.com/nuxt-community/composition-api/issues/207 **/
  58. return {
  59. model: Cycle,
  60. query: () => query,
  61. panel: 0,
  62. submitActions
  63. }
  64. },
  65. beforeDestroy() {
  66. repositoryHelper.cleanRepository(Cycle)
  67. }
  68. })
  69. </script>