ywana-core8 0.0.706 → 0.0.707
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 +89 -82
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +1 -0
- package/dist/index.css.map +1 -1
- package/dist/index.modern.js +89 -82
- package/dist/index.modern.js.map +1 -1
- package/dist/index.umd.js +89 -82
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/domain2/CollectionContext.js +9 -8
- package/src/domain2/CollectionEditor.js +2 -4
- package/src/domain2/CollectionFilters.css +1 -0
- package/src/domain2/CollectionFilters.js +1 -1
- package/src/domain2/CollectionList.js +6 -1
- package/src/domain2/CollectionPage.js +6 -4
- package/src/domain2/CollectionPage.test.js +26 -2
package/package.json
CHANGED
@@ -39,7 +39,7 @@ export const CollectionContextProvider = (props) => {
|
|
39
39
|
|
40
40
|
async function select(id) {
|
41
41
|
if (fetching) {
|
42
|
-
const result = await
|
42
|
+
const result = await fetch(id)
|
43
43
|
setSelected(result)
|
44
44
|
} else {
|
45
45
|
const result = this.all.find(item => item.id === id);
|
@@ -56,13 +56,7 @@ export const CollectionContextProvider = (props) => {
|
|
56
56
|
delete next[id]
|
57
57
|
setCustomFilters(next)
|
58
58
|
}
|
59
|
-
|
60
|
-
/*
|
61
|
-
async function reloadSelection() {
|
62
|
-
const result = await this.fetch(this.selected.id)
|
63
|
-
this.selected = result
|
64
|
-
}
|
65
|
-
|
59
|
+
|
66
60
|
async function fetch(id) {
|
67
61
|
try {
|
68
62
|
const result = await API.find(id)
|
@@ -71,6 +65,13 @@ export const CollectionContextProvider = (props) => {
|
|
71
65
|
console.log(error)
|
72
66
|
}
|
73
67
|
}
|
68
|
+
|
69
|
+
/*
|
70
|
+
async function reloadSelection() {
|
71
|
+
const result = await this.fetch(this.selected.id)
|
72
|
+
this.selected = result
|
73
|
+
}
|
74
|
+
|
74
75
|
|
75
76
|
function clear() {
|
76
77
|
this.selected = null
|
@@ -1,17 +1,15 @@
|
|
1
1
|
import React, { useContext } from 'react'
|
2
|
-
import { CollectionContext } from './CollectionContext'
|
3
2
|
|
4
3
|
/**
|
5
4
|
* Collection Editor
|
6
5
|
*/
|
7
6
|
export const CollectionEditor = (props) => {
|
8
7
|
|
9
|
-
const
|
10
|
-
const { selected } = context
|
8
|
+
const { customEditor } = props
|
11
9
|
|
12
10
|
return (
|
13
11
|
<div className="collection-editor">
|
14
|
-
|
12
|
+
{customEditor}
|
15
13
|
</div>
|
16
14
|
)
|
17
15
|
}
|
@@ -14,8 +14,13 @@ export const CollectionList = (props) => {
|
|
14
14
|
context.load()
|
15
15
|
}, [filters, customFilters])
|
16
16
|
|
17
|
+
function select(id) {
|
18
|
+
context.select(id)
|
19
|
+
}
|
20
|
+
|
17
21
|
const items = all.map(item => {
|
18
22
|
return {
|
23
|
+
id: item.id,
|
19
24
|
icon: "folder",
|
20
25
|
line1: item.name,
|
21
26
|
meta: item.state,
|
@@ -24,7 +29,7 @@ export const CollectionList = (props) => {
|
|
24
29
|
|
25
30
|
return (
|
26
31
|
<div className="collection-list">
|
27
|
-
<List items={items} />
|
32
|
+
<List items={items} onSelect={select} />
|
28
33
|
</div>
|
29
34
|
)
|
30
35
|
}
|
@@ -13,17 +13,19 @@ export const CollectionPage = (props) => {
|
|
13
13
|
|
14
14
|
const {
|
15
15
|
host, url, schema,
|
16
|
-
layout,
|
17
|
-
|
16
|
+
layout,
|
17
|
+
title,
|
18
|
+
canFilter, customFilters,
|
19
|
+
customEditor
|
18
20
|
} = props
|
19
21
|
|
20
22
|
return (
|
21
23
|
<div className={`collection-page ${layout}`}>
|
22
24
|
<CollectionContextProvider host={host} url={url}>
|
23
|
-
<Header title=
|
25
|
+
<Header title={title} />
|
24
26
|
{canFilter ? <CollectionFilters schema={schema} >{customFilters}</CollectionFilters> : null}
|
25
27
|
<CollectionList />
|
26
|
-
<CollectionEditor />
|
28
|
+
<CollectionEditor customEditor={customEditor}/>
|
27
29
|
</CollectionContextProvider>
|
28
30
|
</div>
|
29
31
|
|
@@ -16,14 +16,15 @@ const CollectionPageTest = (prop) => {
|
|
16
16
|
}
|
17
17
|
}
|
18
18
|
|
19
|
-
|
20
19
|
const props = {
|
21
20
|
host: "http://localhost:3000",
|
22
21
|
url: "/references",
|
23
22
|
schema,
|
24
23
|
layout: "ide",
|
24
|
+
title: <CustomTitle />,
|
25
25
|
canFilter: true,
|
26
|
-
customFilters: [<CustomFilter1 />, <CustomFilter2 />]
|
26
|
+
customFilters: [<CustomFilter1 />, <CustomFilter2 />],
|
27
|
+
customEditor: <CustomEditor />
|
27
28
|
}
|
28
29
|
|
29
30
|
return (
|
@@ -33,6 +34,29 @@ const CollectionPageTest = (prop) => {
|
|
33
34
|
)
|
34
35
|
}
|
35
36
|
|
37
|
+
const CustomTitle = (props) => {
|
38
|
+
return (
|
39
|
+
<h1>Custom Title</h1>
|
40
|
+
)
|
41
|
+
}
|
42
|
+
|
43
|
+
const CustomEditor = () => {
|
44
|
+
|
45
|
+
const context = useContext(CollectionContext)
|
46
|
+
const { all, selected } = context
|
47
|
+
|
48
|
+
return (
|
49
|
+
<div>
|
50
|
+
<header>
|
51
|
+
CUSTOM EDITOR {all.length}
|
52
|
+
</header>
|
53
|
+
<main>
|
54
|
+
ID: {selected ? selected.id : null}
|
55
|
+
</main>
|
56
|
+
</div>
|
57
|
+
)
|
58
|
+
}
|
59
|
+
|
36
60
|
const CustomFilter1 = (props) => {
|
37
61
|
|
38
62
|
const context = useContext(CollectionContext)
|