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/dist/index.cjs +270 -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 +270 -241
- package/dist/index.modern.js.map +1 -1
- package/dist/index.umd.js +270 -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.js +1 -0
- package/src/domain/TablePage.js +1 -0
- package/src/html/table.js +19 -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,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
|
-
|
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
|
|