Skip to content

Commit 14deae0

Browse files
committed
Add metaType property
1 parent dcdc1e5 commit 14deae0

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

src/components/AutoForm.vue

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@
9595
</template>
9696

9797
<script setup lang="ts">
98-
import type { ApiRequest, ResponseStatus, ModalProvider, InputProp } from '@/types'
98+
import type { MetadataType, ApiRequest, ResponseStatus, ModalProvider, InputProp } from '@/types'
9999
import { computed, provide, ref, getCurrentInstance, watch, onMounted, onUnmounted, nextTick } from 'vue'
100100
import { ApiResult, HttpMethods, humanize, map, omitEmpty } from '@servicestack/client'
101101
import { useClient } from '@/use/client'
@@ -111,6 +111,7 @@ const props = withDefaults(defineProps<{
111111
showLoading?: boolean
112112
jsconfig?: string
113113
formStyle?: "slideOver" | "card"
114+
metaType?: MetadataType
114115
configureField?: (field:InputProp) => void
115116
configureFormLayout?: (field:InputProp[]) => void
116117
@@ -190,11 +191,11 @@ const subHeadingClass = computed(() => props.subHeadingClass || form.subHeadingC
190191
const buttonsClass = computed(() => typeof props.buttonsClass == 'string' ? props.buttonsClass : form.buttonsClass)
191192
192193
const typeName = computed(() => props.type ? getTypeName(props.type) : props.modelValue?.['getTypeName'] ? props.modelValue.getTypeName() : null)
193-
const metaType = computed(() => typeOf(typeName.value))
194+
const metaType = computed(() => props.metaType ?? typeOf(typeName.value))
194195
const resolveModel = () => props.modelValue || newDto()
195196
const model = ref(resolveModel())
196197
const loading = computed(() => client.loading.value)
197-
const title = computed(() => props.heading != null ? props.heading : (typeOf(typeName.value)?.description || humanize(typeName.value)))
198+
const title = computed(() => props.heading != null ? props.heading : (metaType.value?.description || humanize(typeName.value)))
198199
199200
function newDto() {
200201
return typeof props.type == 'string' ? createDto(props.type) : props.type ? new props.type() : props.modelValue

src/components/AutoFormFields.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
</template>
2121

2222
<script setup lang="ts">
23-
import type { InputInfo, ApiRequest, ResponseStatus, InputProp } from '@/types'
23+
import type { MetadataType, InputInfo, ApiRequest, ResponseStatus, InputProp } from '@/types'
2424
import { computed, getCurrentInstance } from 'vue'
2525
import { typeForInput, typeProperties, useMetadata } from '@/use/metadata'
2626
import { getTypeName } from '@/use/utils'
@@ -29,6 +29,7 @@ import { mapGet } from "@servicestack/client"
2929
const props = withDefaults(defineProps<{
3030
modelValue: ApiRequest
3131
type?: string
32+
metaType?: MetadataType
3233
api: {error?:ResponseStatus}|null
3334
formLayout?: InputInfo[]
3435
configureField?: (field:InputProp) => void
@@ -68,7 +69,7 @@ const { metadataApi, apiOf, typeOf, typeOfRef, createFormLayout, Crud } = useMet
6869
6970
const typeName = computed(() => props.type || getTypeName(props.modelValue))
7071
71-
const type = computed(() => typeOf(typeName.value))
72+
const type = computed(() => props.metaType ?? typeOf(typeName.value))
7273
const dataModelType = computed(() =>
7374
typeOfRef(metadataApi.value?.operations.find(x => x.request.name == typeName.value)?.dataModel) || type.value)
7475

0 commit comments

Comments
 (0)