ywana-core8 0.0.531 → 0.0.534
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/db/db.json +50 -0
- package/dist/index.cjs +25 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +6 -0
- package/dist/index.css.map +1 -1
- package/dist/index.modern.js +25 -6
- package/dist/index.modern.js.map +1 -1
- package/dist/index.umd.js +25 -6
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/domain/CollectionPage.css +6 -0
- package/src/domain/CollectionPage.js +34 -21
- package/src/site/site.test.js +36 -2
package/package.json
CHANGED
@@ -5,6 +5,7 @@ header.collection-page {
|
|
5
5
|
menu.collection-page {
|
6
6
|
display: flex;
|
7
7
|
flex-direction: column;
|
8
|
+
border: solid 3px red;
|
8
9
|
}
|
9
10
|
|
10
11
|
menu.collection-page>header {
|
@@ -20,6 +21,11 @@ menu.collection-page>main {
|
|
20
21
|
overflow:auto;
|
21
22
|
}
|
22
23
|
|
24
|
+
menu.collection-page>footer>.search-box {
|
25
|
+
border-top: dotted 1px var(--divider-color);
|
26
|
+
padding: 0 1rem 1rem 1rem;
|
27
|
+
}
|
28
|
+
|
23
29
|
main.collection-page {
|
24
30
|
display: flex;
|
25
31
|
flex-direction: column;
|
@@ -2,7 +2,7 @@ import equal from 'deep-equal'
|
|
2
2
|
import React, { Fragment, useContext, useEffect, useRef, useState, useMemo } from 'react'
|
3
3
|
import { HTTPClient, Session } from '../http'
|
4
4
|
import { PageContext } from '../site'
|
5
|
-
import { Button, Header, Icon, List, Menu, MenuIcon, MenuItem, Text, Tree, TreeItem, TreeNode } from '../html'
|
5
|
+
import { Button, Header, Icon, List, Menu, MenuIcon, MenuItem, Text, Tree, TreeItem, TreeNode, TextField } from '../html'
|
6
6
|
import { Content, TYPES } from './ContentType'
|
7
7
|
import { ContentEditor, TabbedContentEditor, TreededContentEditor } from './ContentEditor'
|
8
8
|
import { CreateContentDialog } from './CreateContentDialog'
|
@@ -15,16 +15,16 @@ import "./CollectionPage.css"
|
|
15
15
|
export const CollectionPage = (props) => {
|
16
16
|
|
17
17
|
const site = useContext(SiteContext)
|
18
|
-
const {
|
19
|
-
id = "collection",
|
18
|
+
const {
|
19
|
+
id = "collection",
|
20
20
|
icon, title, name = "Collection 1", className,
|
21
|
-
schema, url, field, host, page, fetching= false,
|
21
|
+
schema, url, field, host, page, fetching = false,
|
22
22
|
actions = [], onSelect,
|
23
23
|
canFilter = false, canAdd = false, canDelete = false, canEdit = false,
|
24
|
-
autosave = false, delay = 1000,
|
24
|
+
autosave = false, delay = 1000,
|
25
25
|
groupBy, levels, sorter,
|
26
|
-
editor,
|
27
|
-
children
|
26
|
+
editor,
|
27
|
+
children
|
28
28
|
} = props
|
29
29
|
|
30
30
|
const [pageContext, setPageContext] = useContext(PageContext)
|
@@ -51,24 +51,24 @@ export const CollectionPage = (props) => {
|
|
51
51
|
function renderActions() {
|
52
52
|
return actions.map(element => {
|
53
53
|
const action = () => element.props.action(pageContext)
|
54
|
-
const clone = React.cloneElement(element, {
|
54
|
+
const clone = React.cloneElement(element, { action })
|
55
55
|
return clone
|
56
56
|
})
|
57
57
|
}
|
58
|
-
|
58
|
+
|
59
59
|
return (
|
60
60
|
<Fragment>
|
61
61
|
<Header className={`collection-page ${className}`} title={<Text>{title}</Text>}>
|
62
|
-
{
|
62
|
+
{canAdd ? <Button icon="add" label="Add" action={add} /> : false}
|
63
63
|
|
64
64
|
<Button icon="refresh" label="Reload" action={reload} />
|
65
65
|
{renderActions()}
|
66
66
|
</Header>
|
67
67
|
<menu className={`collection-page ${className}`}>
|
68
|
-
<Header title={<Text>
|
68
|
+
<Header title={<Text>{name}</Text>} >
|
69
69
|
</Header>
|
70
|
-
{canFilter ? <CollectionFilters schema={schema}/> : null
|
71
|
-
{levels ? <CollectionTree icon={icon} levels={levels} onSelect={onSelect} sorter={sorter}/> : <CollectionList groupBy={groupBy} onSelect={onSelect}/>}
|
70
|
+
{canFilter ? <CollectionFilters schema={schema} /> : null}
|
71
|
+
{levels ? <CollectionTree icon={icon} levels={levels} onSelect={onSelect} sorter={sorter} /> : <CollectionList groupBy={groupBy} onSelect={onSelect} />}
|
72
72
|
</menu>
|
73
73
|
<main key={id} className={`collection-page ${className}`}>
|
74
74
|
<CollectionEditor icon={icon} schema={schema} layout={editor} autosave={autosave} delay={delay} />
|
@@ -83,7 +83,7 @@ export const CollectionPage = (props) => {
|
|
83
83
|
*/
|
84
84
|
export const CollectionFilters = (props) => {
|
85
85
|
|
86
|
-
const {
|
86
|
+
const { schema, onChange } = props
|
87
87
|
const [form, setForm] = useState({})
|
88
88
|
|
89
89
|
const filterSchema = useMemo(() => {
|
@@ -166,9 +166,10 @@ const CollectionList = (props) => {
|
|
166
166
|
*/
|
167
167
|
export const CollectionTree = (props) => {
|
168
168
|
|
169
|
-
const { icon="description", levels, onSelect, sorter } = props
|
169
|
+
const { icon = "description", levels, onSelect, sorter } = props
|
170
170
|
const [pageContext, setPageContext] = useContext(PageContext)
|
171
171
|
const { all = [] } = pageContext
|
172
|
+
const [filter, setFilter] = useState()
|
172
173
|
|
173
174
|
function clear() {
|
174
175
|
pageContext.clear()
|
@@ -182,6 +183,10 @@ export const CollectionTree = (props) => {
|
|
182
183
|
if (onSelect) onSelect(id)
|
183
184
|
}
|
184
185
|
|
186
|
+
function search(id, value) {
|
187
|
+
setFilter(value)
|
188
|
+
}
|
189
|
+
|
185
190
|
function group(items, by) {
|
186
191
|
return items.reduce((nodes, field) => {
|
187
192
|
let node = nodes.find(n => n.name === field[by])
|
@@ -214,13 +219,21 @@ export const CollectionTree = (props) => {
|
|
214
219
|
}
|
215
220
|
|
216
221
|
const items = sorter ? sorter(all) : all
|
217
|
-
const
|
222
|
+
const items2 = filter ? items.filter(item => item.name.toUpperCase().indexOf(filter.toUpperCase()) >= 0) : items
|
223
|
+
const nodes = generateNodes(levels, items2)
|
218
224
|
return (
|
219
|
-
|
220
|
-
<
|
221
|
-
|
222
|
-
|
223
|
-
|
225
|
+
<>
|
226
|
+
<main>
|
227
|
+
<Tree>
|
228
|
+
{renderNodes(nodes)}
|
229
|
+
</Tree>
|
230
|
+
</main>
|
231
|
+
<footer>
|
232
|
+
<div className='search-box'>
|
233
|
+
<TextField icon="search" label="Search" onChange={search} outlined className="search-box" />
|
234
|
+
</div>
|
235
|
+
</footer>
|
236
|
+
</>
|
224
237
|
)
|
225
238
|
}
|
226
239
|
|
package/src/site/site.test.js
CHANGED
@@ -10,6 +10,7 @@ import { UploadDialog } from '../widgets/upload/UploadDialog'
|
|
10
10
|
import { Uploader } from '../widgets/upload/Uploader'
|
11
11
|
import { TabbedTablePage } from '../domain/TabbedTablePage'
|
12
12
|
import { TablePage } from '../domain/TablePage'
|
13
|
+
import { CollectionPage } from '../domain/CollectionPage'
|
13
14
|
import { FORMATS, TYPES } from '../domain/ContentType'
|
14
15
|
import { TableTest } from '../html/table.test'
|
15
16
|
|
@@ -18,19 +19,22 @@ const SiteTest = (prop) => {
|
|
18
19
|
const footer = <div>FOOTER</div>
|
19
20
|
|
20
21
|
return (
|
21
|
-
<Site icon="star" title="Site Test" init={"
|
22
|
+
<Site icon="star" title="Site Test" init={"PAGE5"} footer={footer}>
|
22
23
|
<Page id="PAGE1" section="SECTION1" icon="description" title="Page 1" layout="workspace">
|
23
24
|
<Page1 />
|
24
25
|
</Page>
|
25
26
|
<Page id="PAGE2" section="SECTION1" icon="description" title="Page 2" layout="workspace">
|
26
27
|
<Page2 />
|
27
28
|
</Page>
|
28
|
-
<Page id="PAGE3" section="SECTION1" icon="description" title="
|
29
|
+
<Page id="PAGE3" section="SECTION1" icon="description" title="TablePage" layout="workspace">
|
29
30
|
<Page3 />
|
30
31
|
</Page>
|
31
32
|
<Page id="PAGE4" section="SECTION1" icon="description" title="Page 4" layout="workspace">
|
32
33
|
<Page4 />
|
33
34
|
</Page>
|
35
|
+
<Page id="PAGE5" section="SECTION1" icon="description" title="CollectionPage" layout="workspace">
|
36
|
+
<Page5 />
|
37
|
+
</Page>
|
34
38
|
</Site>
|
35
39
|
)
|
36
40
|
}
|
@@ -183,4 +187,34 @@ const Page4 = (props) => {
|
|
183
187
|
<TableTest />
|
184
188
|
</Fragment>
|
185
189
|
)
|
190
|
+
}
|
191
|
+
|
192
|
+
const Page5 = (props) => {
|
193
|
+
|
194
|
+
const ENTITYTYPE = {
|
195
|
+
name : { id: "name" , section: "", type: TYPES.STRING, format: FORMATS.NONE , required: true, tab: false, grouper: true , column: true , filter: true , like: true, label: "Name" },
|
196
|
+
field1: { id: "field1", section: "E-INFO1", type: TYPES.STRING, format: FORMATS.NONE , required: true, tab: false, grouper: true , column: true , filter: true , label: "E field1" },
|
197
|
+
field2: { id: "field2", section: "E-INFO2", type: TYPES.STRING, format: FORMATS.NONE , required: true, tab: false, grouper: true , column: true , filter: true , label: "E field2" },
|
198
|
+
field3: { id: "field3", section: "E-INFO2", type: TYPES.STRING, format: FORMATS.NONE , required: true, tab: false, grouper: true , column: true , filter: true , label: "E field3" },
|
199
|
+
|
200
|
+
}
|
201
|
+
|
202
|
+
const schema = {
|
203
|
+
name : { id: "name" , section: "A", type: TYPES.STRING, format: FORMATS.NONE , required: true, tab: false, grouper: true , column: true , filter: true , like: true, label: "Name" },
|
204
|
+
state : { id: "state" , section: "A", type: TYPES.STRING, format: FORMATS.NONE , required: true, tab: true , grouper: true , column: true , filter: false , label: "State" , options: [
|
205
|
+
{ label: "Pendiente", value: "NOT_CLASSIFIED" },
|
206
|
+
{ label: "Clasificada", value: "CLASSIFIED"},
|
207
|
+
]},
|
208
|
+
field1: { id: "field1", section: "A", type: TYPES.STRING , format: FORMATS.NONE , required: true, tab: false, grouper: true , column: true , filter: true , label: "field1" },
|
209
|
+
field2: { id: "field2", section: "B", type: TYPES.STRING , format: FORMATS.NONE , required: true, tab: false, grouper: true , column: true , filter: true , label: "field2" },
|
210
|
+
field4: { id: "field4", section: "B", type: TYPES.STRING , format: FORMATS.COLOR, required: true, tab: false, grouper: true , column: true , filter: true , label: "Color" },
|
211
|
+
field5: { id: "field5", section: "B", type: TYPES.ENTITY, item: ENTITYTYPE, format: FORMATS.NONE , editable: true, tab: false, grouper: false, column: true , filter: true , like: false, label: "Entity5"},
|
212
|
+
|
213
|
+
}
|
214
|
+
|
215
|
+
return (
|
216
|
+
<Fragment>
|
217
|
+
<CollectionPage title="Referencias" schema={schema} host="http://localhost:3000" url="/references" levels={["color"]} canAdd={true} />
|
218
|
+
</Fragment>
|
219
|
+
)
|
186
220
|
}
|