Skip to content

Commit 9cd62c1

Browse files
author
tabby-or-not
authored
Merge pull request #14 from uptick/enhance/pass-obj-to-readonly
Passes full object to readonly function on a cell
2 parents 74ebe7a + b720aa1 commit 9cd62c1

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

src/object-cell.jsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,11 @@ class ObjectCell extends React.Component {
7878
handleDoubleClick = (event) => {
7979
this.beginEdit()
8080
}
81-
editable(objectId) {
82-
return cellIsEditable(objectId, this.props.column)
81+
editable(object) {
82+
return cellIsEditable(object, this.props.column)
8383
}
8484
beginEdit = (editReplaceOverride) => {
85-
if (!this.props.disabled && this.editable(this.getCellRef().objectId)) {
85+
if (!this.props.disabled && this.editable(this.props.object)) {
8686
this.props.beginEdit(this.getCellRef(), editReplaceOverride)
8787
}
8888
}
@@ -137,7 +137,7 @@ class ObjectCell extends React.Component {
137137

138138
let cellProps = {
139139
className: classNames(classes + ' drawer ' + drawer.className, {
140-
uneditable: (!this.editable(this.getCellRef().objectId)),
140+
uneditable: (!this.editable(this.props.object)),
141141
}),
142142
}
143143
if (!this.props.column.disableInteraction) {

src/utilities.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ function dictFirstKey(dict) {
1313
return undefined
1414
}
1515

16-
function cellIsEditable(objectId, column) {
16+
function cellIsEditable(object, column) {
1717
const { isReadOnly, editor } = column
1818
const editorIsSet = editor !== false
19-
const readOnly = typeof isReadOnly === 'function' ? isReadOnly(objectId) : (isReadOnly === true)
19+
const readOnly = typeof isReadOnly === 'function' ? isReadOnly(object) : (isReadOnly === true)
2020
return editorIsSet && !readOnly
2121
}
2222

0 commit comments

Comments
 (0)