ywana-core8 0.0.36 → 0.0.37

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ywana-core8",
3
- "version": "0.0.36",
3
+ "version": "0.0.37",
4
4
  "description": "ywana-core8",
5
5
  "author": "Ernesto Roldan Garcia",
6
6
  "license": "MIT",
@@ -31,7 +31,7 @@ export const CreateContentDialog = ({ label, type, value = {}, filter, validator
31
31
  site.closeDialog();
32
32
  }
33
33
 
34
- function createFilter(field, content) {
34
+ function filterForm(field, content) {
35
35
  const visible = field.required === true || field.optional === true
36
36
  return filter ? visible && filter(field, content) : visible
37
37
  }
@@ -48,7 +48,7 @@ export const CreateContentDialog = ({ label, type, value = {}, filter, validator
48
48
  const content = new Content(type, form)
49
49
  return (
50
50
  <Dialog title={title} open={true} onAction={onAction} actions={actions}>
51
- <ContentEditor content={content} onChange={change} filter={createFilter} />
51
+ <ContentEditor content={content} onChange={change} filter={filterForm} />
52
52
  {errors.map(error => <Text use="overline" tag="div" className="error">{error}</Text>)}
53
53
  </Dialog>
54
54
  )
@@ -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={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
  )
@@ -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={`Crear ${name}`} type={schema} onOK={onOK} validator={validator} filter={formFilter}/>);
50
51
  }
51
52
 
52
53
  function change(next) {