ywana-core8 0.0.486 → 0.0.489
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 +473 -366
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +25 -18
- package/dist/index.css.map +1 -1
- package/dist/index.modern.js +478 -372
- package/dist/index.modern.js.map +1 -1
- package/dist/index.umd.js +473 -366
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/domain/CollectionPage.js +41 -5
- package/src/domain/ContentEditor.js +1 -0
- package/src/domain/ContentType.js +1 -1
- package/src/domain/index.js +1 -1
- package/src/html/table.css +7 -0
- package/src/html/table.js +19 -7
- package/src/html/table.test.js +13 -12
- package/src/html/textfield.js +3 -4
- package/src/site/site.test.js +36 -2
package/package.json
CHANGED
@@ -81,14 +81,50 @@ export const CollectionPage = (props) => {
|
|
81
81
|
/**
|
82
82
|
* Collection Filters
|
83
83
|
*/
|
84
|
-
const CollectionFilters = (props) => {
|
84
|
+
export const CollectionFilters = (props) => {
|
85
85
|
|
86
|
-
const { schema } = props
|
86
|
+
const { schema, onChange } = props
|
87
|
+
const [form, setForm] = useState({})
|
87
88
|
|
89
|
+
const filterSchema = useMemo(() => {
|
90
|
+
const filterSchema = Object.assign({}, schema)
|
91
|
+
for (var key in filterSchema) {
|
92
|
+
if (filterSchema[key].filter === false) {
|
93
|
+
delete filterSchema[key]
|
94
|
+
} else {
|
95
|
+
if (filterSchema[key].type === TYPES.ENTITY) {
|
96
|
+
const fs = filterSchema[key].item
|
97
|
+
for (var key in fs) {
|
98
|
+
if (fs[key].filter === false) delete fs[key]
|
99
|
+
}
|
100
|
+
}
|
101
|
+
}
|
102
|
+
}
|
103
|
+
return filterSchema
|
104
|
+
}, [schema])
|
105
|
+
|
106
|
+
useEffect(() => {
|
107
|
+
if (onChange) onChange(form)
|
108
|
+
}, [form])
|
109
|
+
|
110
|
+
async function change(next) {
|
111
|
+
setForm(next)
|
112
|
+
}
|
113
|
+
|
114
|
+
function clear() {
|
115
|
+
change({})
|
116
|
+
}
|
117
|
+
|
118
|
+
const content = new Content(filterSchema, form)
|
88
119
|
return (
|
89
|
-
<
|
90
|
-
|
91
|
-
|
120
|
+
<Fragment>
|
121
|
+
<Header className="table-filters" title={<Text>Filters</Text>} >
|
122
|
+
<Icon icon="filter_list_off" size="small" clickable action={clear} />
|
123
|
+
</Header>
|
124
|
+
<main className="table-filters">
|
125
|
+
<ContentEditor content={content} onChange={change} />
|
126
|
+
</main>
|
127
|
+
</Fragment>
|
92
128
|
)
|
93
129
|
}
|
94
130
|
|
package/src/domain/index.js
CHANGED
@@ -3,6 +3,6 @@ export { ContentForm } from './ContentForm'
|
|
3
3
|
export { ContentEditor, TabbedContentEditor, CollectionEditor, TreededContentEditor, FieldEditor, ListEditor } from './ContentEditor'
|
4
4
|
export { CreateContentDialog } from './CreateContentDialog'
|
5
5
|
export { EditContentDialog } from './EditContentDialog'
|
6
|
-
export { CollectionPage, CollectionContext, CollectionTree } from './CollectionPage'
|
6
|
+
export { CollectionPage, CollectionContext, CollectionTree, CollectionFilters } from './CollectionPage'
|
7
7
|
export { TablePage, TableEditor } from './TablePage'
|
8
8
|
export { TabbedTablePage } from './TabbedTablePage'
|
package/src/html/table.css
CHANGED
package/src/html/table.js
CHANGED
@@ -1,11 +1,10 @@
|
|
1
|
-
import React, { Fragment, useState } from 'react'
|
1
|
+
import React, { Fragment, useState, useEffect } from 'react'
|
2
|
+
import { FORMATS, TYPES } from '../domain/ContentType'
|
2
3
|
import { DropDown, TextField } from './textfield'
|
3
4
|
import { CheckBox } from './checkbox'
|
4
5
|
import { Icon } from './icon'
|
5
6
|
import { Text } from './text'
|
6
7
|
import './table.css'
|
7
|
-
import { FORMATS, TYPES } from '../domain/ContentType'
|
8
|
-
import { ColorField } from './color'
|
9
8
|
|
10
9
|
const isFunction = value => value && (Object.prototype.toString.call(value) === "[object Function]" || "function" === typeof value || value instanceof Function);
|
11
10
|
|
@@ -18,8 +17,19 @@ export const DataTable = (props) => {
|
|
18
17
|
const [sortDir, setSortDir] = useState({})
|
19
18
|
const [allChecked, setAllChecked] = useState(false)
|
20
19
|
|
20
|
+
useEffect(() => {
|
21
|
+
console.log(sortDir)
|
22
|
+
}, [sortDir])
|
23
|
+
|
24
|
+
function changeSort(id) {
|
25
|
+
const nextDir = sortDir[id] ? sortDir[id] * -1 : 1
|
26
|
+
const next = Object.assign({}, sortDir, { [id]: nextDir })
|
27
|
+
setSortDir(next)
|
28
|
+
}
|
29
|
+
|
21
30
|
function multiSort(array, sortObject = {}) {
|
22
31
|
|
32
|
+
console.log('multisort', sortObject)
|
23
33
|
const sortKeys = Object.keys(sortObject);
|
24
34
|
|
25
35
|
if (!sortKeys.length) {
|
@@ -61,7 +71,7 @@ export const DataTable = (props) => {
|
|
61
71
|
}
|
62
72
|
}
|
63
73
|
|
64
|
-
function
|
74
|
+
function moveRow(dragged, dropped) {
|
65
75
|
if (onSort) onSort(dragged, dropped)
|
66
76
|
}
|
67
77
|
|
@@ -82,8 +92,10 @@ export const DataTable = (props) => {
|
|
82
92
|
const [rowspan, colspan] = type === TYPES.ENTITY ? [1, Object.values(item).filter(v=>v.column===true).length] : [2, 1]
|
83
93
|
return (
|
84
94
|
<th key={id} rowSpan={rowspan} colSpan={colspan}>
|
85
|
-
|
86
|
-
|
95
|
+
<div>
|
96
|
+
{id === "checked" ? <CheckBox onChange={checkAll} value={allChecked} /> : <Text key={`th_${id}`}>{label}</Text>}
|
97
|
+
{sortable ? <Icon icon="expand_less" size="small" clickable action={() => changeSort(id)}/> : null}
|
98
|
+
</div>
|
87
99
|
</th>
|
88
100
|
)
|
89
101
|
})}
|
@@ -106,7 +118,7 @@ export const DataTable = (props) => {
|
|
106
118
|
<tbody>
|
107
119
|
{
|
108
120
|
multiSort(rows, sortDir).map(row => (
|
109
|
-
<DataTableRow key={row.id} row={row} columns={columns} onSelect={select} onDrop={
|
121
|
+
<DataTableRow key={row.id} row={row} columns={columns} onSelect={select} onDrop={moveRow} editable={editable} expanded={expanded} />
|
110
122
|
))
|
111
123
|
}
|
112
124
|
</tbody>
|
package/src/html/table.test.js
CHANGED
@@ -2,19 +2,19 @@ import React, { useState } from 'react'
|
|
2
2
|
import { FORMATS } from '../domain/ContentType'
|
3
3
|
import { DataTable } from './table'
|
4
4
|
|
5
|
-
const TableTest = (prop) => {
|
5
|
+
export const TableTest = (prop) => {
|
6
6
|
|
7
7
|
const [rows, setRows] = useState(
|
8
8
|
[
|
9
|
-
{ id: 1, checked: false, name: "John Smith", thumb: "https://w7.pngwing.com/pngs/881/826/png-transparent-pikachu-ash-ketchum-pokemon-vrste-pikachu-leaf-flower-meme-thumbnail.png"},
|
10
|
-
{ id: 2, checked: false, name: "Ann Martin", color: "#CCFFFF" },
|
11
|
-
{ id: 3, checked: false, name: "Ann Martin", color: "#CCFFFF" },
|
12
|
-
{ id: 4, checked: false, name: "Ann Martin", color: "#CCFFFF" },
|
13
|
-
{ id: 5, checked: false, name: "Ann Martin", color: "#CCFFFF" },
|
14
|
-
{ id: 6, checked: false, name: "
|
15
|
-
{ id: 7, checked: false, name: "Ann Martin", color: "#CCFFFF" },
|
16
|
-
{ id: 8, checked: false, name: "
|
17
|
-
{ id: 9, checked: false, name: "Ann Martin", color: "#CCFFFF" },
|
9
|
+
{ id: 1, checked: false, name: "John Smith" , thumb: "https://w7.pngwing.com/pngs/881/826/png-transparent-pikachu-ash-ketchum-pokemon-vrste-pikachu-leaf-flower-meme-thumbnail.png"},
|
10
|
+
{ id: 2, checked: false, name: "Ann Martin" , color: "#CCFFFF" },
|
11
|
+
{ id: 3, checked: false, name: "Ann Martin" , color: "#CCFFFF" },
|
12
|
+
{ id: 4, checked: false, name: "Ann Martin" , color: "#CCFFFF" },
|
13
|
+
{ id: 5, checked: false, name: "Ann Martin" , color: "#CCFFFF" },
|
14
|
+
{ id: 6, checked: false, name: "John Smith" , color: "#CCFFFF" },
|
15
|
+
{ id: 7, checked: false, name: "Ann Martin" , color: "#CCFFFF" },
|
16
|
+
{ id: 8, checked: false, name: "Martin Freeman", color: "#CCFFFF" },
|
17
|
+
{ id: 9, checked: false, name: "Ann Martin" , color: "#CCFFFF" },
|
18
18
|
]
|
19
19
|
)
|
20
20
|
|
@@ -40,12 +40,13 @@ const TableTest = (prop) => {
|
|
40
40
|
editable: true,
|
41
41
|
columns : [
|
42
42
|
{ id: "checked", onChange: check },
|
43
|
-
{ id: "name", label: "Name", type: "String", onChange: editCell},
|
43
|
+
{ id: "name", label: "Name", type: "String", onChange: editCell },
|
44
|
+
{ id: "name", label: "Name", type: "String", sortable: true },
|
44
45
|
{ id: "thumb", label: "Thumb", type: "String", format: FORMATS.IMG },
|
45
46
|
{ id: "color", label: "Color", type: "String", format: FORMATS.COLOR },
|
46
47
|
],
|
47
48
|
rows
|
48
|
-
}
|
49
|
+
}
|
49
50
|
|
50
51
|
return (
|
51
52
|
<>
|
package/src/html/textfield.js
CHANGED
@@ -187,7 +187,7 @@ export const DropDown = (props) => {
|
|
187
187
|
|
188
188
|
export const DateRange = (props) => {
|
189
189
|
|
190
|
-
const { id, label, value, onChange
|
190
|
+
const { id, label, value, onChange } = props
|
191
191
|
const [form, setForm] = useState({})
|
192
192
|
|
193
193
|
useEffect(() => {
|
@@ -199,10 +199,9 @@ export const DateRange = (props) => {
|
|
199
199
|
setForm(next)
|
200
200
|
}
|
201
201
|
|
202
|
-
return
|
203
|
-
<TextField id={id} type="date" label={label} value={value} readOnly={true} />
|
204
|
-
) : (
|
202
|
+
return (
|
205
203
|
<div className="date-range">
|
204
|
+
{ label ? <label>{label}</label> : null }
|
206
205
|
<TextField id="from" type="date" label="From" value={form.from} onChange={change} />
|
207
206
|
<TextField id="to" type="date" label="To" value={form.to} onChange={change} />
|
208
207
|
</div>
|
package/src/site/site.test.js
CHANGED
@@ -11,13 +11,14 @@ import { Uploader } from '../widgets/upload/Uploader'
|
|
11
11
|
import { TabbedTablePage } from '../domain/TabbedTablePage'
|
12
12
|
import { TablePage } from '../domain/TablePage'
|
13
13
|
import { FORMATS, TYPES } from '../domain/ContentType'
|
14
|
+
import { TableTest } from '../html/table.test'
|
14
15
|
|
15
16
|
const SiteTest = (prop) => {
|
16
17
|
|
17
18
|
const footer = <div>FOOTER</div>
|
18
19
|
|
19
20
|
return (
|
20
|
-
<Site icon="star" title="Site Test" init={"
|
21
|
+
<Site icon="star" title="Site Test" init={"PAGE4"} footer={footer}>
|
21
22
|
<Page id="PAGE1" section="SECTION1" icon="description" title="Page 1" layout="workspace">
|
22
23
|
<Page1 />
|
23
24
|
</Page>
|
@@ -27,6 +28,9 @@ const SiteTest = (prop) => {
|
|
27
28
|
<Page id="PAGE3" section="SECTION1" icon="description" title="Page 3" layout="workspace">
|
28
29
|
<Page3 />
|
29
30
|
</Page>
|
31
|
+
<Page id="PAGE4" section="SECTION1" icon="description" title="Page 4" layout="workspace">
|
32
|
+
<Page4 />
|
33
|
+
</Page>
|
30
34
|
</Site>
|
31
35
|
)
|
32
36
|
}
|
@@ -123,7 +127,6 @@ const Page3 = (props) => {
|
|
123
127
|
|
124
128
|
}
|
125
129
|
|
126
|
-
|
127
130
|
const schema = {
|
128
131
|
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" },
|
129
132
|
state : { id: "state" , section: "A", type: TYPES.STRING, format: FORMATS.NONE , required: true, tab: true , grouper: true , column: true , filter: false , label: "State" , options: [
|
@@ -142,4 +145,35 @@ const Page3 = (props) => {
|
|
142
145
|
<TablePage title="Referencias" schema={schema} host="http://localhost:3000" url="/references" canFilter={true} tableClassName="condensed"/>
|
143
146
|
</Fragment>
|
144
147
|
)
|
148
|
+
}
|
149
|
+
|
150
|
+
|
151
|
+
const Page4 = (props) => {
|
152
|
+
|
153
|
+
const ENTITYTYPE = {
|
154
|
+
name : { id: "name" , section: "", type: TYPES.STRING, format: FORMATS.NONE , required: true, tab: false, grouper: true , column: true , filter: true , like: true, label: "Name" },
|
155
|
+
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" },
|
156
|
+
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" },
|
157
|
+
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" },
|
158
|
+
|
159
|
+
}
|
160
|
+
|
161
|
+
const schema = {
|
162
|
+
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" },
|
163
|
+
state : { id: "state" , section: "A", type: TYPES.STRING, format: FORMATS.NONE , required: true, tab: true , grouper: true , column: true , filter: false , label: "State" , options: [
|
164
|
+
{ label: "Pendiente", value: "NOT_CLASSIFIED" },
|
165
|
+
{ label: "Clasificada", value: "CLASSIFIED"},
|
166
|
+
]},
|
167
|
+
field1: { id: "field1", section: "A", type: TYPES.STRING , format: FORMATS.NONE , required: true, tab: false, grouper: true , column: true , filter: true , label: "field1" },
|
168
|
+
field2: { id: "field2", section: "B", type: TYPES.STRING , format: FORMATS.NONE , required: true, tab: false, grouper: true , column: true , filter: true , label: "field2" },
|
169
|
+
field4: { id: "field4", section: "B", type: TYPES.STRING , format: FORMATS.COLOR, required: true, tab: false, grouper: true , column: true , filter: true , label: "Color" },
|
170
|
+
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"},
|
171
|
+
|
172
|
+
}
|
173
|
+
|
174
|
+
return (
|
175
|
+
<Fragment>
|
176
|
+
<TableTest />
|
177
|
+
</Fragment>
|
178
|
+
)
|
145
179
|
}
|