forked from JTMCaplin/DamJS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PermContextPicker.js
36 lines (34 loc) · 1.1 KB
/
PermContextPicker.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
32
33
34
35
36
define(['lib/react', 'PermContextPickerListElement', 'PermPermissionGroupPicker'], function(React, PermContextPickerListElement, PermPermissionGroupPicker) {
return React.createClass({
getInitialState: function() {
return {
context: null
}
},
selectContext: function(context) {
this.setState({
context: context
});
},
back: function() {
this.setState({
context: null
});
},
render: function() {
if (this.state.context == null) {
var contexts = Object.keys(this.props.contexts);
var contextElements = [];
for (var i=0; i < contexts.length; i++) {
contextElements.push(PermContextPickerListElement({selectContext: this.selectContext, context: contexts[i]}));
}
return React.DOM.div({},
React.DOM.button({onClick: this.props.back}, "Back"),
contextElements
);
} else {
return PermPermissionGroupPicker({back: this.back, contextPermissions: this.props.contexts[this.state.context].m_mPermissions, context: this.state.context})
}
}
});
});