Skip to content

Commit

Permalink
expose model in Auto Create/Edit forms
Browse files Browse the repository at this point in the history
  • Loading branch information
mythz committed Aug 8, 2024
1 parent 5ccd604 commit ebbe08c
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 13 deletions.
21 changes: 13 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/components/AutoCreateForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ const emit = defineEmits<{
const formFields = ref()
const formFieldsKey = ref(1)
defineExpose({ forceUpdate, props, setModel, formFields })
function forceUpdate() {
formFieldsKey.value++ //required to force revalidation
formFields.value?.forceUpdate()
Expand Down Expand Up @@ -163,6 +162,7 @@ const typeName = computed(() => getTypeName(props.type))
const metaType = computed(() => typeOf(typeName.value))
const resolveModel = () => typeof props.type == 'string' ? createDto(props.type) : props.type ? new props.type() : null
const model = ref(resolveModel())
defineExpose({ forceUpdate, props, setModel, formFields, model })
const panelClass = computed(() => props.panelClass || form.panelClass(props.formStyle))
const formClass = computed(() => props.formClass || form.formClass(props.formStyle))
Expand Down
2 changes: 1 addition & 1 deletion src/components/AutoEditForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ const emit = defineEmits<{
const formFields = ref()
const formFieldsKey = ref(1)
defineExpose({ forceUpdate, props, setModel, formFields })
function forceUpdate() {
formFieldsKey.value++ //required to force revalidation
model.value = resolveModel()
Expand Down Expand Up @@ -173,6 +172,7 @@ const resolveModel = () => typeof props.type == 'string'
? createDto(props.type, toFormValues(props.modelValue))
: (props.type ? new props.type(toFormValues(props.modelValue)) : null)
const model = ref(resolveModel())
defineExpose({ forceUpdate, props, setModel, formFields, model })
const panelClass = computed(() => props.panelClass || form.panelClass(props.formStyle))
const formClass = computed(() => props.formClass || form.formClass(props.formStyle))
Expand Down
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -908,9 +908,9 @@ camelcase-css@^2.0.1:
integrity sha512-QOSvevhslijgYwRx6Rv7zKdMF8lbRmx+uQGx2+vDc+KI/eBnsy9kit5aj23AgGu3pa4t9AgwbnXWqS+iOY+2aA==

caniuse-lite@^1.0.30001400, caniuse-lite@^1.0.30001426:
version "1.0.30001442"
resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001442.tgz"
integrity sha512-239m03Pqy0hwxYPYR5JwOIxRJfLTWtle9FV8zosfV5pHg+/51uD4nxcUlM8+mWWGfwKtt8lJNHnD3cWw9VZ6ow==
version "1.0.30001651"
resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001651.tgz"
integrity sha512-9Cf+Xv1jJNe1xPZLGuUXLNkE1BoDkqRqYyFJ9TDYSqhduqA4hu4oR9HluGoWYQC/aj8WHjsGVV+bwkh0+tegRg==

chai@^4.3.10:
version "4.3.10"
Expand Down

0 comments on commit ebbe08c

Please sign in to comment.