ywana-core8 0.0.595 → 0.0.598

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.595",
3
+ "version": "0.0.598",
4
4
  "description": "ywana-core8",
5
5
  "homepage": "https://ywana.github.io/workspace",
6
6
  "author": "Ernesto Roldan Garcia",
@@ -20,7 +20,7 @@ export const CollectionPage = (props) => {
20
20
  icon, title, name = "Collection 1", className,
21
21
  schema, url, field, host, page, fetching = false,
22
22
  actions = [], onSelect,
23
- canFilter = false, canAdd = false, canDelete = false, canEdit = false, searchBy,
23
+ canFilter = false, canAdd = false, canDelete = false, canEdit = false, searchBy, addValidator,
24
24
  autosave = false, delay = 1000,
25
25
  groupBy, levels, sorter,
26
26
  editor,
@@ -55,7 +55,7 @@ export const CollectionPage = (props) => {
55
55
  await pageContext.create(form);
56
56
  setPageContext(Object.assign({}, pageContext))
57
57
  }
58
- site.openDialog(<CreateContentDialog label={`${name}`} type={schema} onOK={onOK} />);
58
+ site.openDialog(<CreateContentDialog label={`${name}`} type={schema} onOK={onOK} validator={addValidator} />);
59
59
  }
60
60
 
61
61
  function renderActions() {
@@ -1,6 +1,6 @@
1
1
  import React from 'react'
2
2
  import { Property } from '../html'
3
- import { Content, TYPES } from './ContentType'
3
+ import { Content, FORMATS, TYPES } from './ContentType'
4
4
  import './ContentViewer.css'
5
5
 
6
6
  /**
@@ -45,14 +45,15 @@ export const ContentViewer = (props) => {
45
45
  const FieldViewer = (props) => {
46
46
 
47
47
  const { field, value } = props
48
- const { type, item, label, visible = true, optional } = field
48
+ const { type, item, label, visible = true, optional, hidden = false } = field
49
49
 
50
50
  if (!visible) return null
51
- if (optional && value === undefined ) return null;
51
+ if (optional && value === undefined) return null;
52
+ if (hidden) return null;
52
53
 
53
54
  switch (type) {
54
55
  case TYPES.STRING:
55
- return <Property label={label} value={value} options={field.options}/>
56
+ return <StringViewer field={field} value={value} />
56
57
  case TYPES.ENTITY:
57
58
  return <EntityViewer field={field} value={value} />
58
59
  case TYPES.ARRAY:
@@ -83,6 +84,24 @@ const EntityViewer = (props) => {
83
84
  )
84
85
  }
85
86
 
87
+ /**
88
+ * StringViewer
89
+ */
90
+ const StringViewer = (props) => {
91
+ const { field, value } = props
92
+ const { id, format, label, options, editable = true, predictive = false, multivalue = false, Editor } = field
93
+ switch (format) {
94
+ case FORMATS.IMG:
95
+ return (
96
+ <div className='img-field'>
97
+ <img src={value} />
98
+ </div>
99
+ )
100
+ default:
101
+ return <Property label={label} value={value} options={options} />
102
+ }
103
+ }
104
+
86
105
 
87
106
  /**
88
107
  * Array Viewer
@@ -102,7 +121,7 @@ const ArrayViewer = (props) => {
102
121
  <tbody>
103
122
  {value.map(v => (
104
123
  <tr>
105
- { Object.keys(item).map(key => <td key={v[key]}>{v[key]}</td>) }
124
+ {Object.keys(item).map(key => <td key={v[key]}>{v[key]}</td>)}
106
125
  </tr>
107
126
  ))}
108
127
  </tbody>