ywana-core8 0.0.533 → 0.0.536
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 +34 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +1 -1
- package/dist/index.css.map +1 -1
- package/dist/index.modern.js +34 -15
- package/dist/index.modern.js.map +1 -1
- package/dist/index.umd.js +34 -15
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/domain/CollectionPage.css +1 -1
- package/src/domain/CollectionPage.js +46 -27
- package/src/site/site.test.js +36 -2
package/package.json
CHANGED
@@ -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(() => {
|
@@ -136,6 +136,7 @@ const CollectionList = (props) => {
|
|
136
136
|
const { groupBy, onSelect } = props
|
137
137
|
const [pageContext, setPageContext] = useContext(PageContext)
|
138
138
|
const { all = [] } = pageContext
|
139
|
+
const [filter, setFilter] = useState()
|
139
140
|
|
140
141
|
function clear() {
|
141
142
|
pageContext.clear()
|
@@ -149,15 +150,29 @@ const CollectionList = (props) => {
|
|
149
150
|
if (onSelect) onSelect(id)
|
150
151
|
}
|
151
152
|
|
152
|
-
|
153
|
+
function search(id, value) {
|
154
|
+
setFilter(value)
|
155
|
+
}
|
156
|
+
|
157
|
+
const items = filter ? all.filter(item => item.name.toUpperCase().indexOf(filter.toUpperCase()) >= 0) : all
|
158
|
+
const items2 = items.map(content => ({
|
153
159
|
id: content.id,
|
154
160
|
line1: content.name || content.centre || content.tag, // centre: Signflow legacy
|
155
161
|
line2: content.description,
|
156
162
|
content
|
157
|
-
}))
|
163
|
+
}))
|
158
164
|
|
159
165
|
return (
|
160
|
-
|
166
|
+
<>
|
167
|
+
<main>
|
168
|
+
<List items={items2} onSelect={select} groupBy={groupBy} />
|
169
|
+
</main>
|
170
|
+
<footer>
|
171
|
+
<div className='search-box'>
|
172
|
+
<TextField icon="search" label="Search" onChange={search} outlined className="search-box" />
|
173
|
+
</div>
|
174
|
+
</footer>
|
175
|
+
</>
|
161
176
|
)
|
162
177
|
}
|
163
178
|
|
@@ -166,10 +181,10 @@ const CollectionList = (props) => {
|
|
166
181
|
*/
|
167
182
|
export const CollectionTree = (props) => {
|
168
183
|
|
169
|
-
const { icon="description", levels, onSelect, sorter } = props
|
184
|
+
const { icon = "description", levels, onSelect, sorter } = props
|
170
185
|
const [pageContext, setPageContext] = useContext(PageContext)
|
171
186
|
const { all = [] } = pageContext
|
172
|
-
const [
|
187
|
+
const [filter, setFilter] = useState()
|
173
188
|
|
174
189
|
function clear() {
|
175
190
|
pageContext.clear()
|
@@ -219,17 +234,21 @@ export const CollectionTree = (props) => {
|
|
219
234
|
}
|
220
235
|
|
221
236
|
const items = sorter ? sorter(all) : all
|
222
|
-
const items2 = filter ? items.filter(item => item.name.toUpperCase().indexOf(filter.toUpperCase())>= 0) : items
|
237
|
+
const items2 = filter ? items.filter(item => item.name.toUpperCase().indexOf(filter.toUpperCase()) >= 0) : items
|
223
238
|
const nodes = generateNodes(levels, items2)
|
224
239
|
return (
|
225
|
-
|
226
|
-
<
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
240
|
+
<>
|
241
|
+
<main>
|
242
|
+
<Tree>
|
243
|
+
{renderNodes(nodes)}
|
244
|
+
</Tree>
|
245
|
+
</main>
|
246
|
+
<footer>
|
247
|
+
<div className='search-box'>
|
248
|
+
<TextField icon="search" label="Search" onChange={search} outlined className="search-box" />
|
249
|
+
</div>
|
250
|
+
</footer>
|
251
|
+
</>
|
233
252
|
)
|
234
253
|
}
|
235
254
|
|
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" canAdd={true} />
|
218
|
+
</Fragment>
|
219
|
+
)
|
186
220
|
}
|