forked from Shikaga/DamJS
-
Notifications
You must be signed in to change notification settings - Fork 2
/
PermUserElement.js
48 lines (46 loc) · 1.46 KB
/
PermUserElement.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
37
38
39
40
41
42
43
44
45
46
47
48
define(['lib/react', 'PermGroupListElement', 'PermContextPicker'], function(React, PermGroupListElement, PermContextPicker) {
return React.createClass({
getInitialState: function() {
return {
group: null,
permSelected: false
}
},
selectGroup: function(group) {
this.setState({
group: group
});
},
back: function() {
this.setState({
group: null,
permSelected: false
});
},
selectPerms: function() {
this.setState({
permSelected: true
})
},
render: function() {
if (this.state.permSelected == true) {
return PermContextPicker({back: this.back, contexts: this.props.user.m_mPermissions})
} else if (this.state.group == null) {
groupElements = [];
var groups = Object.keys(this.props.user.m_mGroups);
var permissionElements = [];
for (var i=0; i < groups.length; i++) {
groupElements.push(PermGroupListElement({selectGroup: this.selectGroup, group: groups[i]}));
}
return React.DOM.div({},
React.DOM.div({}, React.DOM.button({onClick: this.props.back}, "Back")),
React.DOM.div({}, React.DOM.button({onClick: this.selectPerms}, "Permissions")),
React.DOM.div({}, "Groups"),
groupElements
);
} else {
return PermContextPicker({back: this.back, contexts: this.props.user.m_mGroups[this.state.group].m_mPermissions})
}
}
});
});