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