1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/web/ synced 2025-03-09 00:00:01 +01:00

human names and consisting roles with back-end

This commit is contained in:
Ricardo Hernandez-Montoya 2017-05-03 11:44:08 +02:00
parent 703fa92d2f
commit 8fb0166059
3 changed files with 13 additions and 5 deletions

View file

@ -98,8 +98,9 @@ class EditUserDialog extends Component {
<FormGroup controlId="role" validationState={this.validateForm('role')}>
<ControlLabel>Role</ControlLabel>
<FormControl componentClass="select" placeholder="Select role" value={this.state.role} onChange={(e) => this.handleChange(e)}>
<option key='1' value='admin'>Admin</option>
<option key='2' disabled value='operator'>Operator</option>
<option key='1' value='admin'>Administrator</option>
<option key='2' value='user'>User</option>
<option key='3' value='guest'>Guest</option>
</FormControl>
</FormGroup>
</form>

View file

@ -95,8 +95,9 @@ class NewUserDialog extends Component {
<FormGroup controlId="role" validationState={this.validateForm('role')}>
<ControlLabel>Role</ControlLabel>
<FormControl componentClass="select" placeholder="Select role" value={this.state.role} onChange={(e) => this.handleChange(e)}>
<option key='1' value='admin'>Admin</option>
<option key='2' disabled value='operator'>Operator</option>
<option key='1' value='admin'>Administrator</option>
<option key='2' value='user'>User</option>
<option key='3' value='guest'>Guest</option>
</FormControl>
</FormGroup>
</form>

View file

@ -94,6 +94,12 @@ class Users extends Component {
}
}
getHumanRoleName(role_key) {
const HUMAN_ROLE_NAMES = {admin: 'Administrator', user: 'User', guest: 'Guest'};
return HUMAN_ROLE_NAMES.hasOwnProperty(role_key)? HUMAN_ROLE_NAMES[role_key] : '';
}
render() {
return (
@ -103,7 +109,7 @@ class Users extends Component {
<Table data={this.state.users}>
<TableColumn title='Username' width='150' dataKey='username' />
<TableColumn title='E-mail' dataKey='mail' />
<TableColumn title='Role' dataKey='role' />
<TableColumn title='Role' dataKey='role' modifier={(role) => this.getHumanRoleName(role)} />
<TableColumn width='70' editButton deleteButton onEdit={index => this.setState({ editModal: true, modalData: this.state.users[index] })} onDelete={index => this.setState({ deleteModal: true, modalData: this.state.users[index] })} />
</Table>