Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Genesys PGR
Genesys Website
Commits
7b9e180b
Commit
7b9e180b
authored
Jan 23, 2019
by
Oleksii Savran
Browse files
Unable to apply filters after reset
parent
cbe43c57
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/ui/common/filter/FiltersBlock.tsx
View file @
7b9e180b
...
...
@@ -3,6 +3,7 @@ import {translate} from 'react-i18next';
import
{
connect
}
from
'
react-redux
'
;
import
{
bindActionCreators
}
from
'
redux
'
;
import
{
withStyles
}
from
'
@material-ui/core/styles
'
;
import
{
getFormValues
}
from
'
redux-form
'
;
import
{
log
}
from
'
utilities/debug
'
;
import
{
showSnackbar
}
from
'
actions/snackbar
'
;
...
...
@@ -31,7 +32,7 @@ const styles = (theme) => ({
//
// Renders a standard filters block
const
FiltersBlock
=
({
title
,
children
,
handleSubmit
,
onSubmit
,
initialize
,
classes
,
showSnackbar
,
t
})
=>
{
const
FiltersBlock
=
({
title
,
children
,
handleSubmit
,
onSubmit
,
initialize
,
classes
,
showSnackbar
,
values
,
t
})
=>
{
const
scrollToTop
=
()
=>
{
if
(
window
)
{
window
.
scrollTo
(
0
,
0
);
...
...
@@ -41,7 +42,11 @@ const FiltersBlock = ({ title, children, handleSubmit, onSubmit, initialize, cla
const
onReset
=
(
e
)
=>
{
showSnackbar
(
'
Resetting filters...
'
);
log
(
'
Clearing form
'
);
initialize
({});
const
initialValues
=
{};
Object
.
keys
(
values
).
forEach
((
key
)
=>
{
initialValues
[
key
]
=
null
;
});
initialize
(
initialValues
);
setTimeout
(
handleSubmit
,
100
);
scrollToTop
();
};
...
...
@@ -68,8 +73,12 @@ const FiltersBlock = ({ title, children, handleSubmit, onSubmit, initialize, cla
);
};
const
mapStateToProps
=
(
state
,
ownProps
)
=>
({
values
:
getFormValues
(
ownProps
.
form
)(
state
),
});
const
mapDispatchToProps
=
(
dispatch
)
=>
bindActionCreators
({
showSnackbar
,
},
dispatch
);
export
default
translate
()(
connect
(
null
,
mapDispatchToProps
)(
withStyles
(
styles
)
<
any
>
(
FiltersBlock
)));
export
default
translate
()(
connect
(
mapStateToProps
,
mapDispatchToProps
)(
withStyles
(
styles
)
<
any
>
(
FiltersBlock
)));
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment