Skip to content

Commit 9db6fea

Browse files
committed
Add updateModel to createForm header/footer
1 parent c8d8a3c commit 9db6fea

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

src/components/AutoQueryGrid.vue

+8-2
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
<slot v-else-if="slots.createform" name="createform" :type="apis.Create.request.name" :configure="configureField" :done="createDone" :save="createSave"></slot>
1212
<AutoCreateForm ref="createForm" v-else :type="apis.Create.request.name" :configure="configureField" @done="createDone" @save="createSave">
1313
<template #header>
14-
<slot name="formheader" form="create" :formInstance="createForm" :apis="apis" :type="dataModelName"></slot>
14+
<slot name="formheader" form="create" :formInstance="createForm" :apis="apis" :type="dataModelName" :updateModel="setCreate"></slot>
1515
</template>
1616
<template #footer>
17-
<slot name="formfooter" form="create" :formInstance="createForm" :apis="apis" :type="dataModelName"></slot>
17+
<slot name="formfooter" form="create" :formInstance="createForm" :apis="apis" :type="dataModelName" :updateModel="setCreate"></slot>
1818
</template>
1919
</AutoCreateForm>
2020
</div>
@@ -461,6 +461,12 @@ async function saveApiPrefs(prefs:ApiPrefs) {
461461
await update()
462462
}
463463
464+
function setCreate(props:any) {
465+
if (!createForm.value) return
466+
Object.assign(createForm.value?.model, props)
467+
forceUpdate()
468+
}
469+
464470
function setEdit(props:any) {
465471
Object.assign(edit.value, props)
466472
forceUpdate()

src/demo/App.vue

+6-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,11 @@
105105
<MarkdownInput id="richtext" v-model="richtext" />
106106

107107
<h1 class="my-8 text-3xl">AutoQueryGrid</h1>
108-
<AutoQueryGrid class="mb-3" type="Tracks" modelTitle="Record" newButtonLabel="New CD" />
108+
<AutoQueryGrid class="mb-3" type="Tracks" modelTitle="Record" newButtonLabel="New CD">
109+
<template #formfooter="{ updateModel }">
110+
<SecondaryButton @click="updateModel({ name:'Go' })">Go</SecondaryButton>
111+
</template>
112+
</AutoQueryGrid>
109113

110114
<AutoQueryGrid class="mb-3" type="Customer" />
111115

@@ -656,6 +660,7 @@ import { AllTypes, Authenticate,
656660
GameItem, CreateGameItem, QueryGameItem, QueryCoupons
657661
} from './dtos'
658662
import Combobox from '../components/Combobox.vue'
663+
import SecondaryButton from '../components/SecondaryButton.vue'
659664
660665
function classes(type:'array'|'object', tag:'div'|'table'|'thead'|'th'|'tr'|'td',depth:number,cls:string,index?:number) {
661666
if (type == 'array') {

0 commit comments

Comments
 (0)