ywana-core8 0.0.197 → 0.0.198

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.198",
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 } 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,7 @@ 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} />
154
155
  default: return cell
155
156
  }
156
157
  }
@@ -172,9 +173,12 @@ const BooleanCellViewer = ({ id, value = false }) => {
172
173
  /**
173
174
  * String Cell Viewer
174
175
  */
175
- const StringCellViewer = ({ id, value, options }) => {
176
+ const StringCellViewer = ({ id, value, format, options }) => {
176
177
  const option = options ? options.find(o => o.value === value) : null
177
- const text = option ? option.label : value
178
+ let text = option ? option.label : value
179
+ switch (format) {
180
+ case FORMATS.DATE: text = new Date(text).toLocaleDateString(); break;
181
+ }
178
182
  return (<div className="field-editor string-viewer">{text}</div>)
179
183
  }
180
184