@robsun/create-keystone-app 0.2.2 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -54,29 +54,37 @@ export function ExampleItemsPage() {
|
|
|
54
54
|
|
|
55
55
|
const openCreate = useCallback(() => {
|
|
56
56
|
setEditingItem(null)
|
|
57
|
-
form.resetFields()
|
|
58
|
-
form.setFieldsValue({ status: 'active' })
|
|
59
57
|
setModalOpen(true)
|
|
60
|
-
}, [
|
|
58
|
+
}, [])
|
|
61
59
|
|
|
62
60
|
const openEdit = useCallback(
|
|
63
61
|
(item: ExampleItem) => {
|
|
64
62
|
setEditingItem(item)
|
|
65
|
-
form.setFieldsValue({
|
|
66
|
-
title: item.title,
|
|
67
|
-
description: item.description,
|
|
68
|
-
status: item.status,
|
|
69
|
-
})
|
|
70
63
|
setModalOpen(true)
|
|
71
64
|
},
|
|
72
|
-
[
|
|
65
|
+
[]
|
|
73
66
|
)
|
|
74
67
|
|
|
75
68
|
const closeModal = useCallback(() => {
|
|
76
69
|
setModalOpen(false)
|
|
77
70
|
setEditingItem(null)
|
|
71
|
+
}, [])
|
|
72
|
+
|
|
73
|
+
useEffect(() => {
|
|
74
|
+
if (!modalOpen) {
|
|
75
|
+
return
|
|
76
|
+
}
|
|
78
77
|
form.resetFields()
|
|
79
|
-
|
|
78
|
+
if (editingItem) {
|
|
79
|
+
form.setFieldsValue({
|
|
80
|
+
title: editingItem.title,
|
|
81
|
+
description: editingItem.description,
|
|
82
|
+
status: editingItem.status,
|
|
83
|
+
})
|
|
84
|
+
} else {
|
|
85
|
+
form.setFieldsValue({ status: 'active' })
|
|
86
|
+
}
|
|
87
|
+
}, [editingItem, form, modalOpen])
|
|
80
88
|
|
|
81
89
|
const handleSubmit = useCallback(async () => {
|
|
82
90
|
let values: ExampleItemFormValues
|
|
@@ -184,7 +192,7 @@ export function ExampleItemsPage() {
|
|
|
184
192
|
</Space>
|
|
185
193
|
}
|
|
186
194
|
>
|
|
187
|
-
<Space
|
|
195
|
+
<Space orientation="vertical" size="middle" style={{ width: '100%' }}>
|
|
188
196
|
<Typography.Text type="secondary">
|
|
189
197
|
This page demonstrates a full CRUD workflow wired to the Example module API.
|
|
190
198
|
</Typography.Text>
|
|
@@ -204,7 +212,7 @@ export function ExampleItemsPage() {
|
|
|
204
212
|
onOk={handleSubmit}
|
|
205
213
|
confirmLoading={saving}
|
|
206
214
|
okText={editingItem ? 'Save' : 'Create'}
|
|
207
|
-
|
|
215
|
+
destroyOnHidden
|
|
208
216
|
>
|
|
209
217
|
<Form form={form} layout="vertical" initialValues={{ status: 'active' }}>
|
|
210
218
|
<Form.Item
|