X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=skyquake%2Fplugins%2Fuser-management%2Fsrc%2Fdashboard%2Fdashboard.jsx;h=c997e15bcfb8e262848742751133f0f0203594a2;hb=c637db2bc817cb1cd1a4a20655bf7e01b1c490bd;hp=b5924ae0880f0eacadb6c9d5f5cf6185ae93e773;hpb=ba19ffdfd442c7ebe66f482b90f6bc65a0e9b8be;p=osm%2FUI.git diff --git a/skyquake/plugins/user-management/src/dashboard/dashboard.jsx b/skyquake/plugins/user-management/src/dashboard/dashboard.jsx index b5924ae08..c997e15bc 100644 --- a/skyquake/plugins/user-management/src/dashboard/dashboard.jsx +++ b/skyquake/plugins/user-management/src/dashboard/dashboard.jsx @@ -29,8 +29,12 @@ class UserManagementDashboard extends React.Component { this.actions = this.state.actions; } componentDidUpdate() { - - ReactDOM.findDOMNode(this.UserList).addEventListener('transitionend', this.onTransitionEnd, false); + let self = this; + ReactDOM.findDOMNode(this.UserList).addEventListener('transitionend', this.onTransitionEnd, false); + setTimeout(function() { + let element = self[`user-ref-${self.state.activeIndex}`] + element && !isElementInView(element) && element.scrollIntoView({block: 'end', behavior: 'smooth'}); + }) } componentWillMount() { this.Store.listen(this.updateState); @@ -66,18 +70,23 @@ class UserManagementDashboard extends React.Component { this.actions.handleAddUser(); } viewUser = (un, index) => { - console.log(un) this.actions.viewUser(un, index); } + editUser = () => { + this.actions.editUser(false); + } + cancelEditUser = () => { + this.actions.editUser(true) + } closePanel = () => { this.actions.handleCloseUserPanel(); } - updateUser = (e) => { - e.preventDefault(); - e.stopPropagation(); + // updateUser = (e) => { + // e.preventDefault(); + // e.stopPropagation(); - this.Store.updateUser(); - } + // this.Store.updateUser(); + // } deleteUser = (e) => { e.preventDefault(); e.stopPropagation(); @@ -100,16 +109,109 @@ class UserManagementDashboard extends React.Component { }); } } - + updateUser = (e) => { + let self = this; + e.preventDefault(); + e.stopPropagation(); + let validatedPasswords = validatePasswordFields(this.state); + if(validatedPasswords) { + this.Store.updateUser(_.merge({ + 'user-name': this.state['user-name'], + 'user-domain': this.state['user-domain'], + 'password': this.state['new-password'] + })); + } + function validatePasswordFields(state) { + let oldOne = state['old-password']; + let newOne = state['new-password']; + let confirmOne = state['confirm-password']; + if(true) { + if(oldOne == newOne) { + self.props.actions.showNotification('Your new password must not match your old one'); + return false; + } + if(newOne != confirmOne) { + self.props.actions.showNotification('Passwords do not match'); + return false; + } + return { + // 'old-password': oldOne, + 'new-password': newOne, + 'confirm-password': confirmOne + } + } else { + return {}; + } + } + } + evaluateSubmit = (e) => { + if (e.keyCode == 13) { + if (this.props.isEdit) { + this.updateUser(e); + } else { + this.createUser(e); + } + e.preventDefault(); + e.stopPropagation(); + } + } onTransitionEnd = (e) => { this.actions.handleHideColumns(e); console.log('transition end') } + disableChange = (e) => { + let value = e.target.value; + value = value.toUpperCase(); + if (value=="TRUE") { + value = true; + } else { + value = false; + } + console.log(value) + } render() { let self = this; let html; let props = this.props; let state = this.state; + let passwordSectionHTML = null; + let formButtonsHTML = ( + +