From b720aa15e9196e6e38c701dfdf0eb761f9029835 Mon Sep 17 00:00:00 2001 From: Fiona Lawrence Date: Fri, 8 Jun 2018 11:00:25 +1000 Subject: [PATCH] Passes full object to readonly function on a cell --- src/object-cell.jsx | 8 ++++---- src/utilities.js | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/object-cell.jsx b/src/object-cell.jsx index 5a658af..87978b0 100644 --- a/src/object-cell.jsx +++ b/src/object-cell.jsx @@ -78,11 +78,11 @@ class ObjectCell extends React.Component { handleDoubleClick = (event) => { this.beginEdit() } - editable(objectId) { - return cellIsEditable(objectId, this.props.column) + editable(object) { + return cellIsEditable(object, this.props.column) } beginEdit = (editReplaceOverride) => { - if (!this.props.disabled && this.editable(this.getCellRef().objectId)) { + if (!this.props.disabled && this.editable(this.props.object)) { this.props.beginEdit(this.getCellRef(), editReplaceOverride) } } @@ -137,7 +137,7 @@ class ObjectCell extends React.Component { let cellProps = { className: classNames(classes + ' drawer ' + drawer.className, { - uneditable: (!this.editable(this.getCellRef().objectId)), + uneditable: (!this.editable(this.props.object)), }), } if (!this.props.column.disableInteraction) { diff --git a/src/utilities.js b/src/utilities.js index 53782b4..32f05ea 100644 --- a/src/utilities.js +++ b/src/utilities.js @@ -13,10 +13,10 @@ function dictFirstKey(dict) { return undefined } -function cellIsEditable(objectId, column) { +function cellIsEditable(object, column) { const { isReadOnly, editor } = column const editorIsSet = editor !== false - const readOnly = typeof isReadOnly === 'function' ? isReadOnly(objectId) : (isReadOnly === true) + const readOnly = typeof isReadOnly === 'function' ? isReadOnly(object) : (isReadOnly === true) return editorIsSet && !readOnly }