Skip to content

Commit bb878d2

Browse files
committed
filter-and-or: "Clear Filters" button now properly clears operators AND values in filters.
1 parent 6c52246 commit bb878d2

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

app/view/netcreate/components/filter/NumberFilter.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ class NumberFilter extends React.Component {
7474
onChangeHandler
7575
}) {
7676
super();
77+
this.m_ClearFilters = this.m_ClearFilters.bind(this);
7778
this.OnChangeOperator = this.OnChangeOperator.bind(this);
7879
this.OnChangeValue = this.OnChangeValue.bind(this);
7980
this.TriggerChangeHandler = this.TriggerChangeHandler.bind(this);
@@ -87,12 +88,24 @@ class NumberFilter extends React.Component {
8788

8889
/// Initialize UNISYS DATA LINK for REACT
8990
UDATA = UNISYS.NewDataLink(this);
91+
UDATA.HandleMessage('FILTER_CLEAR', this.m_ClearFilters);
92+
}
93+
94+
componentWillUnmount() {
95+
UDATA.UnhandleMessage('FILTER_CLEAR', this.m_ClearFilters);
96+
}
97+
98+
m_ClearFilters() {
99+
this.setState({ inputval: '' });
90100
}
91101

92102
OnChangeOperator(e) {
93103
const newstate = { operator: e.target.value };
94104
// clear value if NO_OP
95-
if (e.target.value === FILTER.OPERATORS.NO_OP.key) newstate.value = '';
105+
if (e.target.value === FILTER.OPERATORS.NO_OP.key) {
106+
newstate.inputval = '';
107+
newstate.value = '';
108+
}
96109
this.setState(newstate, this.TriggerChangeHandler);
97110
}
98111

app/view/netcreate/components/filter/StringFilter.jsx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ class StringFilter extends React.Component {
6666
onChangeHandler
6767
}) {
6868
super();
69+
this.m_ClearFilters = this.m_ClearFilters.bind(this);
6970
this.OnChangeOperator = this.OnChangeOperator.bind(this);
7071
this.OnChangeValue = this.OnChangeValue.bind(this);
7172
this.TriggerChangeHandler = this.TriggerChangeHandler.bind(this);
@@ -79,12 +80,24 @@ class StringFilter extends React.Component {
7980

8081
/// Initialize UNISYS DATA LINK for REACT
8182
UDATA = UNISYS.NewDataLink(this);
83+
UDATA.HandleMessage('FILTER_CLEAR', this.m_ClearFilters);
84+
}
85+
86+
componentWillUnmount() {
87+
UDATA.UnhandleMessage('FILTER_CLEAR', this.m_ClearFilters);
88+
}
89+
90+
m_ClearFilters() {
91+
this.setState({ inputval: '' });
8292
}
8393

8494
OnChangeOperator(e) {
8595
const newstate = { operator: e.target.value };
8696
// clear value if NO_OP
87-
if (e.target.value === FILTER.OPERATORS.NO_OP.key) newstate.value = '';
97+
if (e.target.value === FILTER.OPERATORS.NO_OP.key) {
98+
newstate.inputval = '';
99+
newstate.value = '';
100+
}
88101
this.setState(newstate, this.TriggerChangeHandler);
89102
}
90103

@@ -126,6 +139,7 @@ class StringFilter extends React.Component {
126139
const { inputval } = this.state;
127140
const { filterAction } = this.props;
128141
const { id, key, keylabel, operator, value } = this.props.filter;
142+
129143
return (
130144
<Form inline className="filter-item" key={id} onSubmit={this.OnSubmit}>
131145
{/* FormGroup needs to unset flexFlow or fields will overflow

0 commit comments

Comments
 (0)