diff --git a/src/common/table.js b/src/common/table.js index ebcbea2..dfaba74 100644 --- a/src/common/table.js +++ b/src/common/table.js @@ -119,49 +119,47 @@ class CustomTable extends Component { ); } - if (child.props.dataIndex) { cell.push(index); } // add buttons - let showEditButton = true - if (child.props.showEditButton !== null) - { - showEditButton = child.props.showEditButton(index) - } - if(showEditButton){ - if (child.props.editButton) { - cell.push( - Edit }> - - ); - } - } + let showEditButton = child.props.showEditButton !== null + ? child.props.showEditButton(index) + : true; + if (child.props.editButton && showEditButton) { + cell.push( + Edit } + > + + + ); + } if (child.props.checkbox) { const checkboxKey = child.props.checkboxKey; - let isDisabled = false; - if (child.props.checkboxDisabled != null){ - isDisabled = child.props.checkboxDisabled(index) - } + let isDisabled = child.props.checkboxDisabled != null + ? child.props.checkboxDisabled(index) + : false; + cell.push( child.props.onChecked(data, e)} - />); + /> + ); } if (child.props.exportButton) { @@ -225,29 +223,28 @@ class CustomTable extends Component { disabled={child.props.onDownloadAll == null}> - ); + + ); } - let showDeleteButton = true; - if (child.props.showDeleteButton !== null){ - showDeleteButton = child.props.showDeleteButton(index) - } + let showDeleteButton = child.props.showDeleteButton !== null + ? child.props.showDeleteButton(index) + : true; - if (showDeleteButton){ - if (child.props.deleteButton) { - cell.push( - Delete } > - - ); - } + if (child.props.deleteButton && showDeleteButton) { + cell.push( + Delete } > + + + ); } return cell; diff --git a/src/scenario/scenario.js b/src/scenario/scenario.js index 98346d6..cd451e8 100644 --- a/src/scenario/scenario.js +++ b/src/scenario/scenario.js @@ -63,6 +63,7 @@ class Scenario extends React.Component { if (prevState == null) { prevState = {}; } + // get selected scenario const sessionToken = localStorage.getItem("token"); diff --git a/src/user/edit-own-user.js b/src/user/edit-own-user.js index d093ec7..ee2abdd 100644 --- a/src/user/edit-own-user.js +++ b/src/user/edit-own-user.js @@ -55,7 +55,7 @@ class EditOwnUserDialog extends React.Component { let mail = true; let pw = true; let oldPassword = true; - let confirmpassword = true; + let confirmPassword = true; if (this.state.username === '') { username = false; @@ -73,12 +73,12 @@ class EditOwnUserDialog extends React.Component { oldPassword = false; } - if (this.state.confirmpassword === '') { - confirmpassword = false; + if (this.state.confirmPassword === '') { + confirmPassword = false; } // form is valid if the following condition is met - this.valid = username || mail || (oldPassword && pw && confirmpassword); + this.valid = username || mail || (oldPassword && pw && confirmPassword); } resetState() { @@ -86,7 +86,7 @@ class EditOwnUserDialog extends React.Component { username: '', mail: '', oldPassword: '', - confirmpassword: '', + confirmPassword: '', password: '', id: this.props.user.id, }); diff --git a/src/user/edit-user.js b/src/user/edit-user.js index a137562..a97b9de 100644 --- a/src/user/edit-user.js +++ b/src/user/edit-user.js @@ -57,8 +57,8 @@ class EditUserDialog extends React.Component { var mail = true; var pw = true; var active = true; - var confirmpassword = true; - var oldPW = true; + var confirmPassword = true; + var oldPassword = true; if (this.state.username === '') { username = false; @@ -68,29 +68,28 @@ class EditUserDialog extends React.Component { role = false; } - if(this.state.mail === ''){ + if (this.state.mail === '') { mail = false; } - if(this.state.password === ''){ + if (this.state.password === '') { pw = false; } - if(this.state.active === ''){ + if (this.state.active === '') { active = false; } - if(this.state.confirmpassword === ''){ - confirmpassword = false; + if (this.state.confirmPassword === '') { + confirmPassword = false; } - if(this.state.oldPassword === ''){ - oldPW = false; + if (this.state.oldPassword === '') { + oldPassword = false; } // form is valid if any of the fields contain somethig - this.valid = username || role || mail || pw || active || confirmpassword || oldPW; - + this.valid = username || role || mail || pw || active || confirmPassword || oldPassword; } resetState() { diff --git a/src/user/user.js b/src/user/user.js index cc0271e..53b1627 100644 --- a/src/user/user.js +++ b/src/user/user.js @@ -56,9 +56,7 @@ class User extends Component { } closeEditModal(data) { - this.setState({ - editModal: false - }); + this.setState({ editModal: false }); let updatedData = {} updatedData.id = this.state.currentUser.id; @@ -66,52 +64,41 @@ class User extends Component { let hasChanged = false; let pwChanged = false; - if(data){ - if (data.username !== ''){ - hasChanged = true; - updatedData.username = data.username; - updatedUser.username = data.username - } - if (data.mail !== ''){ - hasChanged = true; - updatedData.mail = data.mail; - updatedUser.mail = data.mail; - } - if (data.password !== '' && data.oldPassword !== '' && data.password === data.confirmpassword ){ - pwChanged = true; - updatedData.password = data.password; - updatedData.oldPassword = data.oldPassword; - } else if (data.password !== '' && data.password !== data.confirmpassword) { - NotificationsDataManager.addNotification(NotificationsFactory.UPDATE_ERROR('New password not correctly confirmed')); - return - } - - if (hasChanged || pwChanged) { - if (hasChanged){ - this.setState({currentUser: updatedUser}) + if (data) { + if (data.username !== '') { + hasChanged = true; + updatedData.username = data.username; + updatedUser.username = data.username + } + if (data.mail !== '') { + hasChanged = true; + updatedData.mail = data.mail; + updatedUser.mail = data.mail; + } + if (data.password !== '' && data.oldPassword !== '' && data.password === data.confirmPassword ) { + pwChanged = true; + updatedData.password = data.password; + updatedData.oldPassword = data.oldPassword; + } else if (data.password !== '' && data.password !== data.confirmPassword) { + NotificationsDataManager.addNotification(NotificationsFactory.UPDATE_ERROR('New password not correctly confirmed')); + return } - AppDispatcher.dispatch({ - type: 'users/start-edit', - data: updatedData, - token: this.state.token - }); - } else { - NotificationsDataManager.addNotification(NotificationsFactory.UPDATE_WARNING('No update requested, no input data')); + if (hasChanged || pwChanged) { + if (hasChanged){ + this.setState({ currentUser: updatedUser }) + } + + AppDispatcher.dispatch({ + type: 'users/start-edit', + data: updatedData, + token: this.state.token + }); + } else { + NotificationsDataManager.addNotification(NotificationsFactory.UPDATE_WARNING('No update requested, no input data')); + } } } - } - - 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() { diff --git a/src/user/users.js b/src/user/users.js index e83bccf..8585ce0 100644 --- a/src/user/users.js +++ b/src/user/users.js @@ -38,7 +38,6 @@ class Users extends Component { } static calculateState(prevState, props) { - let token = localStorage.getItem("token"); // If there is a token available and this method was called as a result of loading users @@ -90,26 +89,19 @@ class Users extends Component { this.setState({ editModal: false }); if (data) { - if(data.password === data.confirmpassword) { + if(data.password === data.confirmPassword) { AppDispatcher.dispatch({ type: 'users/start-edit', data: data, token: this.state.token }); - } else{ - + } else { NotificationsDataManager.addNotification(NotificationsFactory.UPDATE_ERROR("New password not correctly confirmed")) } } } - 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] : ''; - } - onModalKeyPress = (event) => { if (event.key === 'Enter') { event.preventDefault(); @@ -118,14 +110,8 @@ class Users extends Component { } }; - modifyActiveColumn(active){ - - if(active){ - return - } else { - return - } - + modifyActiveColumn(active) { + return } render() { @@ -142,13 +128,24 @@ class Users extends Component {

Users - Add User } > - - - + Add User } + > + + +

@@ -169,7 +166,6 @@ class Users extends Component { this.getHumanRoleName(role)} />