ywana-core8 0.0.197 → 0.0.201

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.197",
3
+ "version": "0.0.201",
4
4
  "description": "ywana-core8",
5
5
  "author": "Ernesto Roldan Garcia",
6
6
  "license": "MIT",
@@ -221,7 +221,7 @@ const EntityEditor = ({ field, value = {}, onChange }) => {
221
221
 
222
222
  return (
223
223
  <div className='entity-editor'>
224
- <header>∂
224
+ <header>
225
225
  <Text use='caption'>{label}</Text>
226
226
  </header>
227
227
  <main>
@@ -1,6 +1,7 @@
1
1
  import React from 'react'
2
2
  import { Property } from '../html'
3
3
  import { Content, TYPES } from './ContentType'
4
+ import './ContentViewer.css'
4
5
 
5
6
  /**
6
7
  * Content Viewer
@@ -334,6 +334,7 @@ const TableEditor = (props) => {
334
334
  id: field.id,
335
335
  label: field.label,
336
336
  type: field.type,
337
+ format: field.format,
337
338
  onChange: field.id === "checked" ? checkOne : field.editable ? change : null, /* checked has it´s own handler */
338
339
  options
339
340
  }
package/src/html/table.js CHANGED
@@ -4,6 +4,7 @@ import { CheckBox } from './checkbox'
4
4
  import { Icon } from './icon'
5
5
  import { Text } from './text'
6
6
  import './table.css'
7
+ import { FORMATS, TYPES } from '../domain/ContentType'
7
8
 
8
9
  const isFunction = value => value && (Object.prototype.toString.call(value) === "[object Function]" || "function" === typeof value || value instanceof Function);
9
10
 
@@ -130,7 +131,7 @@ const DataTableRow = (props) => {
130
131
  const DataTableCell = ({ row, column, cell, editable }) => {
131
132
 
132
133
  const render = (type) => {
133
- const { id, disabled = false, min, max, onChange, options } = column
134
+ const { id, disabled = false, min, max, onChange, format, options } = column
134
135
  if (id === "checked") {
135
136
  return <CheckBox id={id} value={cell} onChange={(id, value) => onChange(row.id, id, value)} />
136
137
  } else if (editable && onChange) {
@@ -150,7 +151,8 @@ const DataTableCell = ({ row, column, cell, editable }) => {
150
151
  switch (type) {
151
152
  case "ICON": return <Icon icon={cell} />
152
153
  case "Boolean": return <BooleanCellViewer id={id} value={cell} />
153
- case "String": return <StringCellViewer id={id} value={cell} options={options} />
154
+ case "String": return <StringCellViewer id={id} value={cell} format={format} options={options} />
155
+ case TYPES.ENTITY: return <EntityCellViewer id={id} value={cell} />
154
156
  default: return cell
155
157
  }
156
158
  }
@@ -161,6 +163,16 @@ const DataTableCell = ({ row, column, cell, editable }) => {
161
163
  )
162
164
  }
163
165
 
166
+ const EntityCellViewer = ({ id, value }) => {
167
+ console.log(id, value)
168
+ const subcells = value ? Object.values(value) : [1,2,3]
169
+ return (
170
+ <div className='entity-cell-viewer'>
171
+ {subcells.map(v => <div>{v}</div>)}
172
+ </div>
173
+ )
174
+ }
175
+
164
176
  /**
165
177
  * Boolean Cell Viewer
166
178
  */
@@ -172,9 +184,12 @@ const BooleanCellViewer = ({ id, value = false }) => {
172
184
  /**
173
185
  * String Cell Viewer
174
186
  */
175
- const StringCellViewer = ({ id, value, options }) => {
187
+ const StringCellViewer = ({ id, value, format, options }) => {
176
188
  const option = options ? options.find(o => o.value === value) : null
177
- const text = option ? option.label : value
189
+ let text = option ? option.label : value
190
+ switch (format) {
191
+ case FORMATS.DATE: text = new Date(text).toLocaleString(); break;
192
+ }
178
193
  return (<div className="field-editor string-viewer">{text}</div>)
179
194
  }
180
195