ywana-core8 0.0.35 → 0.0.39
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/package.json
CHANGED
@@ -3,7 +3,6 @@
|
|
3
3
|
}
|
4
4
|
|
5
5
|
.content-editor>section {
|
6
|
-
|
7
6
|
margin-bottom: 1rem;
|
8
7
|
}
|
9
8
|
|
@@ -90,14 +89,12 @@
|
|
90
89
|
background-color: var(--paper-color) !important;
|
91
90
|
}
|
92
91
|
|
93
|
-
|
94
92
|
.collection-adder td.actions {
|
95
93
|
border: solid 0px red;
|
96
94
|
display: flex;
|
97
95
|
align-items: center;
|
98
96
|
}
|
99
97
|
|
100
|
-
|
101
98
|
.field-editor {
|
102
99
|
padding: 0;
|
103
100
|
}
|
@@ -31,9 +31,10 @@ export const CreateContentDialog = ({ label, type, value = {}, filter, validator
|
|
31
31
|
site.closeDialog();
|
32
32
|
}
|
33
33
|
|
34
|
-
function
|
35
|
-
|
36
|
-
|
34
|
+
function filterForm(field, content) {
|
35
|
+
console.log('------ filterForm------------', field.id, filter)
|
36
|
+
const visible = field.required === true || field.optional === true
|
37
|
+
return filter ? visible && filter(field, content) : visible
|
37
38
|
}
|
38
39
|
|
39
40
|
const actions = (
|
@@ -48,7 +49,7 @@ export const CreateContentDialog = ({ label, type, value = {}, filter, validator
|
|
48
49
|
const content = new Content(type, form)
|
49
50
|
return (
|
50
51
|
<Dialog title={title} open={true} onAction={onAction} actions={actions}>
|
51
|
-
<ContentEditor content={content} onChange={change} filter={
|
52
|
+
<ContentEditor content={content} onChange={change} filter={filterForm} />
|
52
53
|
{errors.map(error => <Text use="overline" tag="div" className="error">{error}</Text>)}
|
53
54
|
</Dialog>
|
54
55
|
)
|
@@ -31,6 +31,11 @@ export const EditContentDialog = ({ label, type, value = {}, filter, validator,
|
|
31
31
|
site.closeDialog();
|
32
32
|
}
|
33
33
|
|
34
|
+
function filterForm(field, content) {
|
35
|
+
const visible = field.required === true || field.optional === true
|
36
|
+
return filter ? visible && filter(field, content) : visible
|
37
|
+
}
|
38
|
+
|
34
39
|
const actions = (
|
35
40
|
<Fragment>
|
36
41
|
<Button label="CLOSE" action={() => onAction("CLOSE")} />
|
@@ -43,7 +48,7 @@ export const EditContentDialog = ({ label, type, value = {}, filter, validator,
|
|
43
48
|
const content = new Content(type, form)
|
44
49
|
return (
|
45
50
|
<Dialog title={title} open={true} onAction={onAction} actions={actions}>
|
46
|
-
<ContentEditor content={content} onChange={change} filter={
|
51
|
+
<ContentEditor content={content} onChange={change} filter={filterForm} />
|
47
52
|
{errors.map(error => <Text use="overline" tag="div" className="error">{error}</Text>)}
|
48
53
|
</Dialog>
|
49
54
|
)
|
package/src/domain/TablePage.js
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
import equal from 'deep-equal'
|
2
2
|
import React, { Fragment, useContext, useEffect, useMemo, useRef, useState } from 'react'
|
3
|
-
import { EditContentDialog } from './EditContentDialog'
|
4
|
-
import { Content } from './ContentType'
|
5
|
-
import { ContentEditor } from './ContentEditor'
|
6
|
-
import { HTTPClient, Session } from '../http'
|
7
|
-
import { SiteContext, PageContext } from '../site'
|
8
3
|
import { Button, DataTable, DropDown, Header, Icon, MenuIcon, MenuItem, Text } from '../html'
|
4
|
+
import { HTTPClient, Session } from '../http'
|
5
|
+
import { PageContext, SiteContext } from '../site'
|
6
|
+
import { ContentEditor } from './ContentEditor'
|
7
|
+
import { Content } from './ContentType'
|
8
|
+
import { CreateContentDialog } from './CreateContentDialog'
|
9
9
|
import "./TablePage.css"
|
10
10
|
|
11
11
|
const http = HTTPClient(window.API || process.env.REACT_APP_API, Session);
|
@@ -16,7 +16,7 @@ const http = HTTPClient(window.API || process.env.REACT_APP_API, Session);
|
|
16
16
|
export const TablePage = (props) => {
|
17
17
|
|
18
18
|
const site = useContext(SiteContext)
|
19
|
-
const { id = "table", icon, title, name = "table 1", schema, url, field, delay = 1000, actions, editable, canAdd = true, dev = false, autosave = true, groupBy, validator, scenario } = props
|
19
|
+
const { id = "table", icon, title, name = "table 1", schema, url, field, delay = 1000, actions, editable, canAdd = true, dev = false, autosave = true, groupBy, validator, scenario, formFilter } = props
|
20
20
|
const [pageContext, setPageContext] = useContext(PageContext)
|
21
21
|
const { selected } = pageContext
|
22
22
|
const timer = useRef(null)
|
@@ -46,7 +46,8 @@ export const TablePage = (props) => {
|
|
46
46
|
await pageContext.create(form);
|
47
47
|
setPageContext(Object.assign({}, pageContext))
|
48
48
|
}
|
49
|
-
site.openDialog(<EditContentDialog label={`Crear ${name}`} type={schema} onOK={onOK} validator={validator} />);
|
49
|
+
//site.openDialog(<EditContentDialog label={`Crear ${name}`} type={schema} onOK={onOK} validator={validator} />);
|
50
|
+
site.openDialog(<CreateContentDialog label={`Crearr ${name}`} type={schema} onOK={onOK} validator={validator} filter={formFilter}/>);
|
50
51
|
}
|
51
52
|
|
52
53
|
function change(next) {
|