ywana-core8 0.0.476 → 0.0.477
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/dist/index.cjs +58 -28
- package/dist/index.cjs.map +1 -1
- package/dist/index.modern.js +58 -28
- package/dist/index.modern.js.map +1 -1
- package/dist/index.umd.js +58 -28
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/domain/CollectionPage.js +20 -6
package/package.json
CHANGED
@@ -15,9 +15,9 @@ import "./CollectionPage.css"
|
|
15
15
|
export const CollectionPage = (props) => {
|
16
16
|
|
17
17
|
const site = useContext(SiteContext)
|
18
|
-
const { id = "collection", icon, title, name = "Collection 1", schema, url,
|
18
|
+
const { id = "collection", icon, title, name = "Collection 1", schema, url, field, host, page, fetching= false, groupBy, editor, autosave = false, delay = 1000, actions, levels, onSelect, children } = props
|
19
19
|
const [pageContext, setPageContext] = useContext(PageContext)
|
20
|
-
const context = CollectionContext(url, field, host, page)
|
20
|
+
const context = CollectionContext(url, field, host, page, fetching)
|
21
21
|
|
22
22
|
useEffect(async () => {
|
23
23
|
await context.load()
|
@@ -237,7 +237,7 @@ const CollectionEditor = (props) => {
|
|
237
237
|
/**
|
238
238
|
* Collection Context
|
239
239
|
*/
|
240
|
-
export const CollectionContext = (url, field, host, page) => {
|
240
|
+
export const CollectionContext = (url, field, host, page, fetching) => {
|
241
241
|
|
242
242
|
const API = CollectionAPI(url, host)
|
243
243
|
|
@@ -256,9 +256,23 @@ export const CollectionContext = (url, field, host, page) => {
|
|
256
256
|
return
|
257
257
|
},
|
258
258
|
|
259
|
-
select(id) {
|
260
|
-
|
261
|
-
|
259
|
+
async select(id) {
|
260
|
+
if (fetching) {
|
261
|
+
const result = await this.fetch(id)
|
262
|
+
this.selected = result
|
263
|
+
} else {
|
264
|
+
const result = this.all.find(item => item.id === id);
|
265
|
+
this.selected = result;
|
266
|
+
}
|
267
|
+
},
|
268
|
+
|
269
|
+
async fetch(id) {
|
270
|
+
try {
|
271
|
+
const result = await API.find(id)
|
272
|
+
return result
|
273
|
+
} catch (error) {
|
274
|
+
console.log(error)
|
275
|
+
}
|
262
276
|
},
|
263
277
|
|
264
278
|
clear() {
|