|
@@ -29,7 +29,6 @@ class UserGroupUserFormByInput extends React.Component {
|
|
|
this.handleChange = this.handleChange.bind(this);
|
|
this.handleChange = this.handleChange.bind(this);
|
|
|
this.handleSearch = this.handleSearch.bind(this);
|
|
this.handleSearch = this.handleSearch.bind(this);
|
|
|
this.onKeyDown = this.onKeyDown.bind(this);
|
|
this.onKeyDown = this.onKeyDown.bind(this);
|
|
|
- this.renderMenuItemChildren = this.renderMenuItemChildren.bind(this);
|
|
|
|
|
|
|
|
|
|
this.searhApplicableUsersDebounce = debounce(1000, this.searhApplicableUsers);
|
|
this.searhApplicableUsersDebounce = debounce(1000, this.searhApplicableUsers);
|
|
|
}
|
|
}
|
|
@@ -46,9 +45,7 @@ class UserGroupUserFormByInput extends React.Component {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
- async addUserBySubmit(e) {
|
|
|
|
|
- e.preventDefault();
|
|
|
|
|
- const { input } = this.state;
|
|
|
|
|
|
|
+ async addUserBySubmit(input) {
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
await this.props.userGroupDetailContainer.addUserByUsername(input);
|
|
await this.props.userGroupDetailContainer.addUserByUsername(input);
|
|
@@ -93,9 +90,10 @@ class UserGroupUserFormByInput extends React.Component {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
onKeyDown(event) {
|
|
onKeyDown(event) {
|
|
|
|
|
+ const input = event.target.defaultValue;
|
|
|
// 13 is Enter key
|
|
// 13 is Enter key
|
|
|
if (event.keyCode === 13) {
|
|
if (event.keyCode === 13) {
|
|
|
- this.addUserBySubmit();
|
|
|
|
|
|
|
+ this.addUserBySubmit(input);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -103,23 +101,14 @@ class UserGroupUserFormByInput extends React.Component {
|
|
|
return (this.state.searchError !== null) && 'Error on searching.';
|
|
return (this.state.searchError !== null) && 'Error on searching.';
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- renderMenuItemChildren(option, props, index) {
|
|
|
|
|
- const user = option;
|
|
|
|
|
- return (
|
|
|
|
|
- <span>
|
|
|
|
|
- {user}
|
|
|
|
|
- </span>
|
|
|
|
|
- );
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
render() {
|
|
render() {
|
|
|
const { t } = this.props;
|
|
const { t } = this.props;
|
|
|
|
|
|
|
|
const inputProps = { autoComplete: 'off' };
|
|
const inputProps = { autoComplete: 'off' };
|
|
|
|
|
|
|
|
return (
|
|
return (
|
|
|
- <form className="form-inline" onSubmit={this.addUserBySubmit}>
|
|
|
|
|
- <div className="form-group">
|
|
|
|
|
|
|
+ <div className="row">
|
|
|
|
|
+ <div className="col-xs-8 pr-0">
|
|
|
<AsyncTypeahead
|
|
<AsyncTypeahead
|
|
|
{...this.props}
|
|
{...this.props}
|
|
|
id="name-typeahead-asynctypeahead"
|
|
id="name-typeahead-asynctypeahead"
|
|
@@ -129,19 +118,26 @@ class UserGroupUserFormByInput extends React.Component {
|
|
|
labelKey="name"
|
|
labelKey="name"
|
|
|
minLength={0}
|
|
minLength={0}
|
|
|
options={this.state.applicableUsers} // Search result
|
|
options={this.state.applicableUsers} // Search result
|
|
|
- emptyLabel={this.getEmptyLabel()}
|
|
|
|
|
searchText={(this.state.isLoading ? 'Searching...' : this.getEmptyLabel())}
|
|
searchText={(this.state.isLoading ? 'Searching...' : this.getEmptyLabel())}
|
|
|
align="left"
|
|
align="left"
|
|
|
onChange={this.handleChange}
|
|
onChange={this.handleChange}
|
|
|
onSearch={this.handleSearch}
|
|
onSearch={this.handleSearch}
|
|
|
onInputChange={this.onInputChange}
|
|
onInputChange={this.onInputChange}
|
|
|
onKeyDown={this.onKeyDown}
|
|
onKeyDown={this.onKeyDown}
|
|
|
- renderMenuItemChildren={this.renderMenuItemChildren}
|
|
|
|
|
caseSensitive={false}
|
|
caseSensitive={false}
|
|
|
/>
|
|
/>
|
|
|
</div>
|
|
</div>
|
|
|
- <button type="submit" className="btn btn-sm btn-success" disabled={!this.validateForm()}>{t('add')}</button>
|
|
|
|
|
- </form>
|
|
|
|
|
|
|
+ <div className="col-xs-2 pl-0">
|
|
|
|
|
+ <button
|
|
|
|
|
+ type="button"
|
|
|
|
|
+ className="btn btn-sm btn-success"
|
|
|
|
|
+ disabled={!this.validateForm()}
|
|
|
|
|
+ onClick={event => this.addUserBySubmit(event.target.value)}
|
|
|
|
|
+ >
|
|
|
|
|
+ {t('add')}
|
|
|
|
|
+ </button>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|
|
|
|
|
|