itizawa 6 лет назад
Родитель
Сommit
95b706a0fc

+ 8 - 22
src/client/js/components/Admin/UserGroupDetail/UserGroupUserFormByInput.jsx

@@ -16,7 +16,7 @@ class UserGroupUserFormByInput extends React.Component {
     super(props);
 
     this.state = {
-      input: '',
+      inputUser: '',
       applicableUsers: [],
       isLoading: false,
       searchError: null,
@@ -24,7 +24,6 @@ class UserGroupUserFormByInput extends React.Component {
 
     this.xss = window.xss;
 
-    this.onInputChange = this.onInputChange.bind(this);
     this.addUserBySubmit = this.addUserBySubmit.bind(this);
     this.validateForm = this.validateForm.bind(this);
     this.handleChange = this.handleChange.bind(this);
@@ -35,25 +34,13 @@ class UserGroupUserFormByInput extends React.Component {
     this.searhApplicableUsersDebounce = debounce(1000, this.searhApplicableUsers);
   }
 
-  /**
-   * input user name to add to the group
-   * @param {string} input
-   */
-  onInputChange(input) {
-    this.setState({ input });
-    if (input === '') {
-      this.setState({ applicableUsers: [] });
-    }
-  }
-
-
   async addUserBySubmit() {
-    const userName = this.state.input[0].username;
+    const userName = this.state.inputUser[0].username;
 
     try {
       await this.props.userGroupDetailContainer.addUserByUsername(userName);
       toastSuccess(`Added "${this.xss.process(userName)}" to "${this.xss.process(this.props.userGroupDetailContainer.state.userGroup.name)}"`);
-      this.setState({ input: '' });
+      this.setState({ inputUser: '' });
     }
     catch (err) {
       toastError(new Error(`Unable to add "${this.xss.process(userName)}" to "${this.xss.process(this.props.userGroupDetailContainer.state.userGroup.name)}"`));
@@ -61,12 +48,12 @@ class UserGroupUserFormByInput extends React.Component {
   }
 
   validateForm() {
-    return this.state.input !== '';
+    return this.state.inputUser !== '';
   }
 
   async searhApplicableUsers() {
     try {
-      const users = await this.props.userGroupDetailContainer.fetchApplicableUsers(this.state.input);
+      const users = await this.props.userGroupDetailContainer.fetchApplicableUsers(this.state.inputUser);
       this.setState({ applicableUsers: users, isLoading: false });
     }
     catch (err) {
@@ -76,10 +63,10 @@ class UserGroupUserFormByInput extends React.Component {
 
   /**
    * Reflect when forecast is clicked
-   * @param {string} input
+   * @param {string} inputUser
    */
-  handleChange(input) {
-    this.setState({ input });
+  handleChange(inputUser) {
+    this.setState({ inputUser });
   }
 
   handleSearch(keyword) {
@@ -138,7 +125,6 @@ class UserGroupUserFormByInput extends React.Component {
             align="left"
             onChange={this.handleChange}
             onSearch={this.handleSearch}
-            onInputChange={this.onInputChange}
             onKeyDown={this.onKeyDown}
             caseSensitive={false}
           />