forked from p15670423/monkey
UI: Fix reset button in AdvancedMultiSelect.js
Reset button will reset to all safe values
This commit is contained in:
parent
ed46538137
commit
20f091ff4e
|
@ -93,8 +93,6 @@ class AdvancedMultiSelect extends React.Component {
|
||||||
onChildCheckboxClick = (value) => {
|
onChildCheckboxClick = (value) => {
|
||||||
let selectValues = this.getSelectValuesAfterClick(value);
|
let selectValues = this.getSelectValuesAfterClick(value);
|
||||||
this.onChange(selectValues);
|
this.onChange(selectValues);
|
||||||
|
|
||||||
this.setHideResetState(selectValues);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getSelectValuesAfterClick(clickedValue) {
|
getSelectValuesAfterClick(clickedValue) {
|
||||||
|
@ -128,15 +126,7 @@ class AdvancedMultiSelect extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
onResetClick = () => {
|
onResetClick = () => {
|
||||||
this.onChange(this.defaultValues);
|
this.setPaneInfoToSafe();
|
||||||
this.setHideResetState(this.defaultValues);
|
|
||||||
this.setPaneInfoToSafe(this.isUnsafeOptionSelected(this.defaultValues));
|
|
||||||
}
|
|
||||||
|
|
||||||
setHideResetState(selectValues) {
|
|
||||||
this.setState(() => ({
|
|
||||||
hideReset: this.getHideResetState(selectValues)
|
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getHideResetState(selectValues) {
|
getHideResetState(selectValues) {
|
||||||
|
@ -168,9 +158,10 @@ class AdvancedMultiSelect extends React.Component {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
setPaneInfoToSafe(isUnsafeOptionSelected) {
|
setPaneInfoToSafe() {
|
||||||
let safePluginNames = this.state.allPluginNames.filter(pluginName => this.isSafe(pluginName));
|
let safePluginNames = this.state.allPluginNames.filter(pluginName => this.isSafe(pluginName));
|
||||||
this.setState({selectedPluginNames: safePluginNames});
|
this.setState({selectedPluginNames: safePluginNames});
|
||||||
|
this.onChange(safePluginNames);
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
@ -195,7 +186,7 @@ class AdvancedMultiSelect extends React.Component {
|
||||||
checkboxState={this.getMasterCheckboxState(
|
checkboxState={this.getMasterCheckboxState(
|
||||||
this.state.selectedPluginNames)}
|
this.state.selectedPluginNames)}
|
||||||
hideReset={this.getHideResetState(
|
hideReset={this.getHideResetState(
|
||||||
this.state.allPluginNames)}
|
this.state.selectedPluginNames)}
|
||||||
onResetClick={this.onResetClick}/>
|
onResetClick={this.onResetClick}/>
|
||||||
|
|
||||||
<ChildCheckboxContainer id={id} multiple={multiple} required={required}
|
<ChildCheckboxContainer id={id} multiple={multiple} required={required}
|
||||||
|
|
Loading…
Reference in New Issue