ywana-core8 0.0.475 → 0.0.478
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 +86 -38
- package/dist/index.cjs.map +1 -1
- package/dist/index.modern.js +86 -38
- package/dist/index.modern.js.map +1 -1
- package/dist/index.umd.js +86 -38
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/domain/CollectionPage.js +49 -8
- package/src/html/textfield.test.js +2 -1
- package/src/html/tokenfield.js +1 -1
package/package.json
CHANGED
@@ -15,9 +15,20 @@ import "./CollectionPage.css"
|
|
15
15
|
export const CollectionPage = (props) => {
|
16
16
|
|
17
17
|
const site = useContext(SiteContext)
|
18
|
-
const {
|
18
|
+
const {
|
19
|
+
id = "collection",
|
20
|
+
icon, title, name = "Collection 1",
|
21
|
+
schema, url, field, host, page, fetching= false,
|
22
|
+
actions = [], onSelect,
|
23
|
+
canFilter = false, canAdd = false, canDelete = false, canEdit = false,
|
24
|
+
autosave = false, delay = 1000,
|
25
|
+
groupBy, levels,
|
26
|
+
editor,
|
27
|
+
children
|
28
|
+
} = props
|
29
|
+
|
19
30
|
const [pageContext, setPageContext] = useContext(PageContext)
|
20
|
-
const context = CollectionContext(url, field, host, page)
|
31
|
+
const context = CollectionContext(url, field, host, page, fetching)
|
21
32
|
|
22
33
|
useEffect(async () => {
|
23
34
|
await context.load()
|
@@ -48,13 +59,15 @@ export const CollectionPage = (props) => {
|
|
48
59
|
return (
|
49
60
|
<Fragment>
|
50
61
|
<Header className="collection-page" title={<Text>{title}</Text>}>
|
51
|
-
<Button icon="add" label="Add" action={add} />
|
62
|
+
{ canAdd ? <Button icon="add" label="Add" action={add} /> : false }
|
63
|
+
|
52
64
|
<Button icon="refresh" label="Reload" action={reload} />
|
53
65
|
{renderActions()}
|
54
66
|
</Header>
|
55
67
|
<menu className="collection-page">
|
56
68
|
<Header title={<Text>Lista de {name}</Text>} >
|
57
69
|
</Header>
|
70
|
+
{canFilter ? <CollectionFilters schema={schema}/> : null }
|
58
71
|
{levels ? <CollectionTree levels={levels} onSelect={onSelect}/> : <CollectionList groupBy={groupBy} onSelect={onSelect}/>}
|
59
72
|
</menu>
|
60
73
|
<main key={id} className="collection-page">
|
@@ -65,6 +78,20 @@ export const CollectionPage = (props) => {
|
|
65
78
|
)
|
66
79
|
}
|
67
80
|
|
81
|
+
/**
|
82
|
+
* Collection Filters
|
83
|
+
*/
|
84
|
+
const CollectionFilters = (props) => {
|
85
|
+
|
86
|
+
const { schema } = props
|
87
|
+
|
88
|
+
return (
|
89
|
+
<div className="collection-filters">
|
90
|
+
TODO: filters
|
91
|
+
</div>
|
92
|
+
)
|
93
|
+
}
|
94
|
+
|
68
95
|
/**
|
69
96
|
* Collection List
|
70
97
|
*/
|
@@ -88,7 +115,7 @@ const CollectionList = (props) => {
|
|
88
115
|
|
89
116
|
const items = all ? all.map(content => ({
|
90
117
|
id: content.id,
|
91
|
-
line1: content.name,
|
118
|
+
line1: content.name || content.centre, // centre: Signflow legacy
|
92
119
|
line2: content.description,
|
93
120
|
content
|
94
121
|
})) : []
|
@@ -237,7 +264,7 @@ const CollectionEditor = (props) => {
|
|
237
264
|
/**
|
238
265
|
* Collection Context
|
239
266
|
*/
|
240
|
-
export const CollectionContext = (url, field, host, page) => {
|
267
|
+
export const CollectionContext = (url, field, host, page, fetching) => {
|
241
268
|
|
242
269
|
const API = CollectionAPI(url, host)
|
243
270
|
|
@@ -256,9 +283,23 @@ export const CollectionContext = (url, field, host, page) => {
|
|
256
283
|
return
|
257
284
|
},
|
258
285
|
|
259
|
-
select(id) {
|
260
|
-
|
261
|
-
|
286
|
+
async select(id) {
|
287
|
+
if (fetching) {
|
288
|
+
const result = await this.fetch(id)
|
289
|
+
this.selected = result
|
290
|
+
} else {
|
291
|
+
const result = this.all.find(item => item.id === id);
|
292
|
+
this.selected = result;
|
293
|
+
}
|
294
|
+
},
|
295
|
+
|
296
|
+
async fetch(id) {
|
297
|
+
try {
|
298
|
+
const result = await API.find(id)
|
299
|
+
return result
|
300
|
+
} catch (error) {
|
301
|
+
console.log(error)
|
302
|
+
}
|
262
303
|
},
|
263
304
|
|
264
305
|
clear() {
|
@@ -25,10 +25,11 @@ const TextFieldTest = (prop) => {
|
|
25
25
|
{ label: "NO", value: "false" },
|
26
26
|
]
|
27
27
|
|
28
|
+
console.log(form)
|
28
29
|
return (
|
29
30
|
<>
|
30
31
|
<DropDown id="b1" label="Boolean1" onChange={change} options={options2} value={form.b1} />
|
31
|
-
<TokenField id="token1" label="Tokens" onChange={change}
|
32
|
+
<TokenField id="token1" label="Tokens" onChange={change} />
|
32
33
|
<TextField id="name" label="Name" value={form.name} onChange={change} />
|
33
34
|
<DropDown id="gender1" label="Dropdown 1" value={form.gender1} onChange={change} options={options} predictive={false}/>
|
34
35
|
<DropDown id="gender2" label="Dropdown 2" value={form.gender2} onChange={change} options={options} predictive={true}/>
|
package/src/html/tokenfield.js
CHANGED
@@ -33,7 +33,7 @@ export const TokenField = ({ id, label, tokens = [], readOnly, options, onChange
|
|
33
33
|
event.preventDefault()
|
34
34
|
event.stopPropagation()
|
35
35
|
const token = event.target.value
|
36
|
-
const next = tokens.concat(token)
|
36
|
+
const next = tokens.concat(token.trim())
|
37
37
|
if (onChange) onChange(id, next)
|
38
38
|
setValue('')
|
39
39
|
}
|