@@ -4,29 +4,38 @@ import ButtonToolbar from "react-bootstrap/lib/ButtonToolbar";
44
55import { CONTROLLER_NAME , getFilterString , submitSearch } from "./utils" ;
66import FormFilter from "./FormFilter" ;
7+ import AdvancedSearchFilter from "./AdvancedSearchFilter" ;
78
89class Filters extends React . Component {
910 constructor ( props ) {
1011 super ( ) ;
1112
12- const { selectedFormIds} = props ;
13+ const {
14+ selectedFormIds,
15+ advancedSearchText,
16+ } = props ;
1317
1418 /*
1519 * The state for all filters is held here.
1620 * Individual filters invoke callbacks to notify this parent component of changes.
1721 */
18- this . state = { selectedFormIds} ;
22+ this . state = {
23+ selectedFormIds,
24+ advancedSearchText,
25+ } ;
1926
2027 this . handleSubmit = this . handleSubmit . bind ( this ) ;
2128 this . handleSelectForm = this . handleSelectForm . bind ( this ) ;
2229 this . handleClearFormSelection = this . handleClearFormSelection . bind ( this ) ;
30+ this . handleChangeAdvancedSearch = this . handleChangeAdvancedSearch . bind ( this ) ;
31+ this . handleClearFilters = this . handleClearFilters . bind ( this ) ;
2332 this . renderFilterButtons = this . renderFilterButtons . bind ( this ) ;
2433 }
2534
2635 handleSubmit ( ) {
2736 const { allForms} = this . props ;
2837 const { selectedFormIds} = this . state ;
29- const filterString = getFilterString ( selectedFormIds , allForms ) ;
38+ const filterString = getFilterString ( allForms , this . state ) ;
3039 submitSearch ( filterString ) ;
3140 }
3241
@@ -38,12 +47,20 @@ class Filters extends React.Component {
3847 this . setState ( { selectedFormIds : [ ] } ) ;
3948 }
4049
50+ handleChangeAdvancedSearch ( event ) {
51+ this . setState ( { advancedSearchText : event . target . value } ) ;
52+ }
53+
54+ handleClearFilters ( ) {
55+ submitSearch ( null ) ;
56+ }
57+
4158 renderFilterButtons ( ) {
4259 const { allForms, selectedFormIds : originalFormIds } = this . props ;
4360 const { selectedFormIds} = this . state ;
4461
4562 return (
46- < ButtonToolbar className = "filters" >
63+ < ButtonToolbar >
4764 < FormFilter
4865 allForms = { allForms }
4966 onClearSelection = { this . handleClearFormSelection }
@@ -57,23 +74,36 @@ class Filters extends React.Component {
5774
5875 render ( ) {
5976 const { controllerName} = this . props ;
77+ const { advancedSearchText} = this . state ;
6078 const shouldRenderButtons = controllerName === CONTROLLER_NAME . RESPONSES ;
6179
6280 return (
63- < React . Fragment >
81+ < div className = "filters" >
6482 { shouldRenderButtons ? this . renderFilterButtons ( ) : null }
65- </ React . Fragment >
83+
84+ < AdvancedSearchFilter
85+ advancedSearchText = { advancedSearchText }
86+ onChangeAdvancedSearch = { this . handleChangeAdvancedSearch }
87+ onClear = { this . handleClearFilters }
88+ onSubmit = { this . handleSubmit } />
89+ </ div >
6690 ) ;
6791 }
6892}
6993
7094Filters . propTypes = {
95+ advancedSearchText : PropTypes . string . isRequired ,
7196 allForms : PropTypes . arrayOf ( PropTypes . shape ( {
7297 id : PropTypes . string ,
7398 name : PropTypes . string
7499 } ) ) . isRequired ,
75- controllerName : PropTypes . string . isRequired ,
100+ controllerName : PropTypes . string ,
76101 selectedFormIds : PropTypes . arrayOf ( PropTypes . string ) . isRequired
77102} ;
78103
104+ Filters . defaultProps = {
105+ // This is expected to be null if the feature flag is disabled.
106+ controllerName : null ,
107+ } ;
108+
79109export default Filters ;
0 commit comments