Commit 167a63d9 authored by Oleksii Savran's avatar Oleksii Savran

Autocomplete on the permission pop-up

parent 437aaefb
......@@ -21,6 +21,7 @@ interface IPermissionsTableFormProps extends React.ClassAttributes<any>, WithTra
removePermission: (sid: string) => Promise<AclObjectIdentity>;
autocomplete: (e) => void;
inherits?: boolean;
change: (field: string, value: string) => void;
}
const styles = {
......@@ -52,6 +53,12 @@ const styles = {
class PermissionsTableForm extends React.Component<IPermissionsTableFormProps, any> {
private onSuggestionSelected = (entry) => (e, data) => {
if (data && data.suggestion && data.suggestion.label) {
this.props.change(`${entry}.sid`, data.suggestion.label);
}
}
protected renderRows = ({ fields, autocomplete, inherits = false }) => fields.map((entry, index) => (
<SidRow
key={ `sid-${index}` }
......@@ -64,6 +71,7 @@ class PermissionsTableForm extends React.Component<IPermissionsTableFormProps, a
removePermission={ this.props.removePermission }
addPermission={ this.props.addPermission }
classes={ {textField: this.props.classes.textField} }
onSuggestionSelected={ this.onSuggestionSelected(entry) }
/>
))
......
......@@ -21,6 +21,7 @@ interface ISidRowProps extends React.ClassAttributes<any>, WithTranslation {
classes: any;
removePermission: any;
addPermission: any;
onSuggestionSelected: (e: any, data: any) => void;
}
......@@ -78,7 +79,7 @@ class SidRow extends React.Component<ISidRowProps> {
}
public render() {
const {entry, inherits, index, fields, ownerSid, classes, t} = this.props;
const {entry, inherits, index, fields, ownerSid, classes, t, onSuggestionSelected} = this.props;
const isNewEntry = index === fields.length - 1;
let {sid} = fields.get(index);
......@@ -99,6 +100,7 @@ class SidRow extends React.Component<ISidRowProps> {
suggestions={ Object.keys(this.state.autocompleteObj).map((key) => ({label: key})) }
suggestionLabel="label"
classes={ {textField: classes.textField} }
onSuggestionSelected={ onSuggestionSelected }
/>
)
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment