forked from JTMCaplin/DamJS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMatcherListElement.js
31 lines (31 loc) · 1.03 KB
/
MatcherListElement.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
define(['lib/react', 'MatcherConfigElement', 'SubjectAdder', 'MatcherElement'], function(React, MatcherConfigElement, SubjectAdder, MatcherElement) {
return React.createClass({
getInitialState: function() {
return {selectedMatcher: null}
},
selectMatcher: function(matcher) {
this.setState({selectedMatcher: matcher});
},
deselectMatcher: function() {
this.setState({selectedMatcher: null})
},
render: function() {
var style = {
width: "1250px"
}
var returnedElements = [];
if (this.state.selectedMatcher) {
return React.DOM.div({style: columnStyle},
MatcherConfigElement({matcher: this.state.selectedMatcher, deselectMatcher: this.deselectMatcher}));
} else {
var matchersList = [];
this.props.matchers.forEach(function(matcher) {
matchersList.push(MatcherElement({selectMatcher: this.selectMatcher, matcher: matcher}));
}.bind(this));
return React.DOM.div({style: columnStyle},
SubjectAdder({damJS: this.props.damJS}),
React.DOM.div(null, matchersList));
}
}
});
});