ywana-core8 0.0.954 → 0.0.956

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.954",
3
+ "version": "0.0.956",
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
@@ -236,7 +236,7 @@ const DataTableCell = ({ index, row, column, cell, editable }) => {
236
236
  case "TEXTFIELD": return <TextField id={id} value={cell} onChange={(id, value) => onChange(row.id, id, value)} />
237
237
  case "String": return <StringCellEditor id={id} value={cell} options={options} onChange={(id, value) => onChange(row.id, id, value)} />
238
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} />
239
+ case "Image": return <ImageCellViewer id={id} value={cell} uploadURL={column.uploadURL} onUpload={column.onUpload} />
240
240
  default: return cell
241
241
  }
242
242
  } else {
@@ -260,15 +260,23 @@ const DataTableCell = ({ index, row, column, cell, editable }) => {
260
260
  /**
261
261
  * Image Cell Viewer
262
262
  */
263
- const ImageCellViewer = ({ id, value, uploadURL }) => {
263
+ const ImageCellViewer = ({ id, value, uploadURL, onChange }) => {
264
264
 
265
- const canUpload = uploadURL ? true : false
265
+ function success(file, message) {
266
+ if (onChange) onChange(id, file, message)
267
+ }
266
268
 
267
- return canUpload ? (
268
- <Uploader view="icon" icon="cloud_upload" target={uploadURL} />
269
- ) : (
270
- <img src={value} />
271
- )
269
+ function error(file, message) {
270
+ if (onChange) onChange(id, file, message)
271
+ console.error(message)
272
+ }
273
+
274
+ return (
275
+ <div className="image-cell">
276
+ <img src={value} />
277
+ { uploadURL ? <Uploader view="icon" icon="cloud_upload" target={uploadURL} onSuccess={success} onError={error} /> : null }
278
+ </div>
279
+ )
272
280
  }
273
281
 
274
282
  /**