CycleEditForm.vue 901 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <template>
  2. <UiForm
  3. ref="form"
  4. :model="Cycle"
  5. :entity="cycle"
  6. :submitActions="submitActions"
  7. >
  8. <UiInputText field="label" v-model="cycle.label" :rules="rules()" />
  9. </UiForm>
  10. </template>
  11. <script setup lang="ts">
  12. import Cycle from "~/models/Education/Cycle";
  13. import {AnyJson} from "~/types/data";
  14. import {SUBMIT_TYPE} from "~/types/enum/enums";
  15. const props = defineProps({
  16. cycle: {
  17. type: Object as () => Cycle,
  18. required: true
  19. }
  20. })
  21. const i18n = useI18n()
  22. const goBackRoute = { path: `/parameters`, query: { tab: 'teaching' } }
  23. const submitActions = computed(() => {
  24. let actions: AnyJson = {}
  25. actions[SUBMIT_TYPE.SAVE_AND_BACK] = goBackRoute
  26. return actions
  27. })
  28. const rules = () => [
  29. (label: string | null) => (label !== null && label.length > 0) || i18n.t('please_enter_a_value'),
  30. ]
  31. </script>
  32. <style scoped lang="scss">
  33. </style>