Skip to content

Commit ecd0cb7

Browse files
author
Aviad Lichtenstadt
authored
Merge pull request #3 from demisto/key_value_copy
added key value click recognizing
2 parents c087848 + 24b42e1 commit ecd0cb7

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

lib/leaf.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,27 +35,29 @@ var Leaf = React.createClass({
3535
DTPath: p.DTPath,
3636
};
3737

38-
var onLabelClick = this._onClick.bind(this, d);
38+
var onLabelClick = this._onClick.bind(this, d, true);
39+
var onValueClick = this._onClick.bind(this, d, false);
3940
var dataType = type(this.data());
4041
var isLeaf = dataType !== 'Array' && dataType !== 'Object';
4142

4243
return D.div({ className: this.getClassName(), id: 'leaf-' + this._rootPath() },
4344
D.input({ className: 'json-inspector__radio', type: 'radio', name: p.id, id: id, tabIndex: -1 }),
44-
D.label({ className: 'json-inspector__line', htmlFor: id, onClick: onLabelClick },
45+
D.label({ className: 'json-inspector__line', htmlFor: id, onClick: this.toggle },
4546
D.div({ className: 'json-inspector__flatpath' },
4647
d.path),
4748
isLeaf ?
4849
null :
4950
this.state.expanded ? D.i({ className: 'icon caret down' }) : D.i({ className: 'icon caret right' }),
50-
D.span({ className: isLeaf ? 'json-inspector__leafKey' : 'json-inspector__key' },
51+
D.span({ className: isLeaf ? 'json-inspector__leafKey' : 'json-inspector__key',
52+
onClick: isLeaf ? onLabelClick : undefined },
5153
this.format(d.key),
5254
':',
5355
this.renderInteractiveLabel(d.key, true)),
54-
this.renderTitle(),
56+
this.renderTitle(onValueClick),
5557
this.renderShowOriginalButton()),
5658
this.renderChildren());
5759
},
58-
renderTitle: function() {
60+
renderTitle: function(onValueClick) {
5961
var data = this.data();
6062
var t = type(data);
6163

@@ -67,7 +69,7 @@ var Leaf = React.createClass({
6769
return D.span({ className: 'json-inspector__value json-inspector__value_helper' },
6870
'{} ' + items(Object.keys(data).length));
6971
default:
70-
return D.span({ className: 'json-inspector__value json-inspector__value_' + t.toLowerCase() },
72+
return D.span({ className: 'json-inspector__value json-inspector__value_' + t.toLowerCase(), onClick: onValueClick },
7173
this.format(String(data)),
7274
this.renderInteractiveLabel(data, false));
7375
}
@@ -194,9 +196,9 @@ var Leaf = React.createClass({
194196
expanded: !this.state.expanded
195197
});
196198
},
197-
_onClick: function(data, e) {
199+
_onClick: function(data, isLabel, e) {
198200
this.toggle();
199-
this.props.onClick(data);
201+
this.props.onClick(data, isLabel);
200202

201203
e.stopPropagation();
202204
},

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "generic-react-json-inspector",
3-
"version": "6.1.8",
3+
"version": "6.1.9",
44
"description": "React JSON inspector component",
55
"main": "json-inspector.js",
66
"author": {

0 commit comments

Comments
 (0)