ywana-core8 0.0.196 → 0.0.200
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/dist/index.cjs +267 -241
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +8 -0
- package/dist/index.css.map +1 -1
- package/dist/index.modern.js +267 -241
- package/dist/index.modern.js.map +1 -1
- package/dist/index.umd.js +267 -241
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/domain/ContentEditor.js +1 -1
- package/src/domain/ContentViewer.css +6 -1
- package/src/domain/ContentViewer.js +1 -0
- package/src/domain/TablePage.js +1 -0
- package/src/html/table.js +17 -4
package/package.json
CHANGED
package/src/domain/TablePage.js
CHANGED
@@ -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,14 @@ const DataTableCell = ({ row, column, cell, editable }) => {
|
|
161
163
|
)
|
162
164
|
}
|
163
165
|
|
166
|
+
const EntityCellViewer = ({ id, value }) => {
|
167
|
+
return (
|
168
|
+
<div className='entity-cell-viewer'>
|
169
|
+
{value.map(v => <div>{v}</div>)}
|
170
|
+
</div>
|
171
|
+
)
|
172
|
+
}
|
173
|
+
|
164
174
|
/**
|
165
175
|
* Boolean Cell Viewer
|
166
176
|
*/
|
@@ -172,9 +182,12 @@ const BooleanCellViewer = ({ id, value = false }) => {
|
|
172
182
|
/**
|
173
183
|
* String Cell Viewer
|
174
184
|
*/
|
175
|
-
const StringCellViewer = ({ id, value, options }) => {
|
185
|
+
const StringCellViewer = ({ id, value, format, options }) => {
|
176
186
|
const option = options ? options.find(o => o.value === value) : null
|
177
|
-
|
187
|
+
let text = option ? option.label : value
|
188
|
+
switch (format) {
|
189
|
+
case FORMATS.DATE: text = new Date(text).toLocaleString(); break;
|
190
|
+
}
|
178
191
|
return (<div className="field-editor string-viewer">{text}</div>)
|
179
192
|
}
|
180
193
|
|