new.vue 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <template>
  2. <LayoutContainer>
  3. <UiLoadingPanel v-if="pending" />
  4. <div v-else>
  5. <h2>Créer Nouvelle Résidence Area</h2>
  6. <UiForm
  7. ref="form"
  8. :model="ResidenceArea"
  9. :entity="residence_areas"
  10. :submitActions="submitActions"
  11. >
  12. <v-container :fluid="true" class="container">
  13. <v-row>
  14. <v-col cols="12" sm="6">
  15. <div>{{ $t('pleaseEnterYourNewSubdomain') }} :</div>
  16. </v-col>
  17. </v-row>
  18. <v-row>
  19. <v-col cols="12" sm="6">
  20. <UiInputText
  21. v-model="residence_areas.label"
  22. field="residence Areas"
  23. type="string"
  24. :rules="rules()"
  25. />
  26. </v-col>
  27. </v-row>
  28. </v-container>
  29. </UiForm>
  30. </div>
  31. </LayoutContainer>
  32. </template>
  33. <script setup lang="ts">
  34. import { ref, onMounted, computed } from 'vue'
  35. import { Ref } from '@vue/reactivity'
  36. import { useEntityFetch } from '~/composables/data/useEntityFetch'
  37. import { AnyJson } from '~/types/data'
  38. import { SUBMIT_TYPE } from '~/types/enum/enums'
  39. import ResidenceArea from '~/models/Billing/ResidenceArea'
  40. import { useI18n } from 'vue-i18n'
  41. import { useEntityManager } from '~/composables/data/useEntityManager'
  42. const i18n = useI18n()
  43. const { em } = useEntityManager()
  44. const residence_areas: Ref<ResidenceArea> = ref(
  45. em.newInstance(ResidenceArea) as ResidenceArea
  46. )
  47. const goBackRoute = { path: `/parameters`, query: { tab: 'residenceAreas' } }
  48. const submitActions = computed(() => {
  49. let actions: AnyJson = {}
  50. actions[SUBMIT_TYPE.SAVE_AND_BACK] = goBackRoute
  51. return actions
  52. })
  53. const rules = () => [
  54. (label: string | null) =>
  55. (label !== null && label.length > 0) || i18n.t('please_enter_a_value'),
  56. ]
  57. </script>