From 39939b5ec9ac170e0d7c596020a0b0646db81438 Mon Sep 17 00:00:00 2001 From: Fiona Lawrence Date: Fri, 26 May 2017 16:22:31 +1000 Subject: [PATCH 1/4] allow enabled to be passed to actions as bool or fn of object (per row enabled) --- .DS_Store | Bin 0 -> 6148 bytes src/object-row.jsx | 10 ++++++++-- src/object-table.sass | 7 +++++++ 3 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..a7574367137eaf86dfb24bd892733aee2987bdbe GIT binary patch literal 6148 zcmeHKyG{c^3>?E1k)TLPxxc_4oTBgr`2Z+_5K_2Egiv3{Z!>;?NbYDU&{(o(?X`Ec zQ=HELY<1k;0!si3sv|z!OvU$ICvs5{NAok@H?PBPKRl&B$)5{&ZHFzMalqSI{WS*c zx%Y^Byu|8=9lgU@-rTv0i2*Sn2E>3E5CiiJuxGn0t`cR%fEW-1-wgQop-~aCNm>A`ZM>$bH0?vy>4EzNHpY=x@p#T5? literal 0 HcmV?d00001 diff --git a/src/object-row.jsx b/src/object-row.jsx index 30ecfd1..c5f6407 100644 --- a/src/object-row.jsx +++ b/src/object-row.jsx @@ -165,11 +165,17 @@ class ObjectRow extends React.Component { var actions = []; for (var actionId = 0; actionId < this.props.actions.length; actionId++) { var action = this.props.actions[actionId]; + var actionEnabled = action.enabled + if (!(actionEnabled === undefined)) { + if (typeof(actionEnabled) === 'function') actionEnabled = actionEnabled(this.props.object) + } else { + actionEnabled = true + } actions.push(
  • {action.label} diff --git a/src/object-table.sass b/src/object-table.sass index 7ba7c4d..8a4ee5a 100644 --- a/src/object-table.sass +++ b/src/object-table.sass @@ -96,6 +96,13 @@ div.object-table-container &:hover background: $selection-colour color: #fff + &.disabled + cursor: not-allowed + color: $border-colour + &:hover + background: #fff + color: $border-colour + td.uneditable background: #fafafa From 6a3b6350fde99d1429a3ecb8fa5d84f7eebef4c7 Mon Sep 17 00:00:00 2001 From: Jarek Glowacki Date: Tue, 17 Oct 2017 11:39:56 +1100 Subject: [PATCH 2/4] Don't include .DS_Store --- .DS_Store | Bin 6148 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index a7574367137eaf86dfb24bd892733aee2987bdbe..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHKyG{c^3>?E1k)TLPxxc_4oTBgr`2Z+_5K_2Egiv3{Z!>;?NbYDU&{(o(?X`Ec zQ=HELY<1k;0!si3sv|z!OvU$ICvs5{NAok@H?PBPKRl&B$)5{&ZHFzMalqSI{WS*c zx%Y^Byu|8=9lgU@-rTv0i2*Sn2E>3E5CiiJuxGn0t`cR%fEW-1-wgQop-~aCNm>A`ZM>$bH0?vy>4EzNHpY=x@p#T5? From d05f8ff0a9361cdff52ee457142b95a2d6e03a7f Mon Sep 17 00:00:00 2001 From: Fiona Lawrence Date: Wed, 11 Jul 2018 12:40:34 +1000 Subject: [PATCH 3/4] Allow passing of tooltip to disabled actions --- src/object-row.jsx | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/object-row.jsx b/src/object-row.jsx index ef578e5..32b447c 100644 --- a/src/object-row.jsx +++ b/src/object-row.jsx @@ -176,25 +176,30 @@ class ObjectRow extends React.Component { } if (this.props.actionsOpen && !this.props.object.disabled) { let actions = [] - for (var actionId = 0; actionId < this.props.actions.length; actionId++) { - const action = this.props.actions[actionId] + this.props.actions.map((action, index) => { let actionEnabled = action.enabled + let tooltip if (!(actionEnabled === undefined)) { - if (typeof(actionEnabled) === 'function') actionEnabled = actionEnabled(this.props.object) + if (typeof actionEnabled === 'function') actionEnabled = actionEnabled(this.props.object) + if (Array.isArray(actionEnabled) && actionEnabled.length === 2) { + tooltip = actionEnabled[1] + actionEnabled = actionEnabled[0] + } } else { actionEnabled = true } actions.push(
  • + data-action={index} + > {action.label}
  • - ) - } + ) + }) cells.push( Date: Wed, 11 Jul 2018 13:16:27 +1000 Subject: [PATCH 4/4] Neater --- src/object-row.jsx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/object-row.jsx b/src/object-row.jsx index 32b447c..8824e31 100644 --- a/src/object-row.jsx +++ b/src/object-row.jsx @@ -181,9 +181,8 @@ class ObjectRow extends React.Component { let tooltip if (!(actionEnabled === undefined)) { if (typeof actionEnabled === 'function') actionEnabled = actionEnabled(this.props.object) - if (Array.isArray(actionEnabled) && actionEnabled.length === 2) { - tooltip = actionEnabled[1] - actionEnabled = actionEnabled[0] + if (Array.isArray(actionEnabled)) { + [actionEnabled, tooltip] = actionEnabled } } else { actionEnabled = true