ywana-core8 0.0.953 → 0.0.955

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.953",
3
+ "version": "0.0.955",
4
4
  "description": "ywana-core8",
5
5
  "homepage": "https://ywana.github.io/workspace",
6
6
  "author": "Ernesto Roldan Garcia",
package/src/html/table.js CHANGED
@@ -5,6 +5,7 @@ import { CheckBox } from './checkbox'
5
5
  import { Icon } from './icon'
6
6
  import { Text } from './text'
7
7
  import './table.css'
8
+ import { Uploader } from '../widgets/upload/Uploader'
8
9
 
9
10
  const isFunction = value => value && (Object.prototype.toString.call(value) === "[object Function]" || "function" === typeof value || value instanceof Function);
10
11
 
@@ -235,6 +236,7 @@ const DataTableCell = ({ index, row, column, cell, editable }) => {
235
236
  case "TEXTFIELD": return <TextField id={id} value={cell} onChange={(id, value) => onChange(row.id, id, value)} />
236
237
  case "String": return <StringCellEditor id={id} value={cell} options={options} onChange={(id, value) => onChange(row.id, id, value)} />
237
238
  case "Number": return <TextField id={id} type="number" value={cell} min={min} max={max} maxDecimals={column.maxDecimals} onChange={(id, value) => onChange(row.id, id, value)} />
239
+ case "Image": return <ImageCellViewer id={id} value={cell} uploadURL={column.uploadURL} onUpload={column.onUpload} />
238
240
  default: return cell
239
241
  }
240
242
  } else {
@@ -255,6 +257,29 @@ const DataTableCell = ({ index, row, column, cell, editable }) => {
255
257
  )
256
258
  }
257
259
 
260
+ /**
261
+ * Image Cell Viewer
262
+ */
263
+ const ImageCellViewer = ({ id, value, uploadURL, onUpload }) => {
264
+
265
+ const canUpload = uploadURL ? true : false
266
+
267
+ function success(file, message) {
268
+ if (onUpload) onUpload(id, file, message)
269
+ }
270
+
271
+ function error(file, message) {
272
+ if (onUpload) onUpload(id, file, message)
273
+ console.error(message)
274
+ }
275
+
276
+ return canUpload ? (
277
+ <Uploader view="icon" icon="cloud_upload" target={uploadURL} onSuccess={success} onError={error} />
278
+ ) : (
279
+ <img src={value} />
280
+ )
281
+ }
282
+
258
283
  /**
259
284
  * Entity Cell Viewer
260
285
  * @param {*} param0