Commit b216ba61 authored by Viacheslav Pavlov's avatar Viacheslav Pavlov Committed by Oleksii Savran
Browse files

Fix: Number values aren`t swapped if user applies filters by Enter.

fixed for inherited filters
parent 37a3373d
......@@ -11,7 +11,7 @@ import { showSnackbar } from 'actions/snackbar';
import ExpandFiltersComponent from './ExpandFiltersComponent';
import Button from '@material-ui/core/Button';
import {cleanFilters} from 'utilities';
import { cleanFilters } from 'utilities';
const styles = (theme) => ({
filtersBlock: {
......@@ -93,6 +93,7 @@ class FiltersBlock extends React.Component<any> {
dataToSubmit.NOTNULL.forEach((key) => dataToSubmit[key] = null);
}
// fixNumberFilters(dataToSubmit);
const clean = cleanFilters(dataToSubmit);
log('Submitting filters', clean);
this.scrollToTop();
......
import * as cookies from 'es-cookie';
import * as _ from 'lodash';
import {log} from 'utilities/debug';
import { log } from 'utilities/debug';
import NumericListDimension from 'model/kpi/NumericListDimension';
import StringListDimension from 'model/kpi/StringListDimension';
......@@ -89,6 +89,9 @@ export function cleanFilters(filter, keysToSkip?): any {
result[k] = notUndefined;
}
} else {
if (val.ge && val.le) {
fixNumberFilter(val);
}
const sub = cleanFilters(val, keysToSkip);
if (Object.keys(sub).length) {
result[k] = sub;
......@@ -101,6 +104,14 @@ export function cleanFilters(filter, keysToSkip?): any {
return result;
}
const fixNumberFilter = (filter) => {
if (!!filter.ge && !isNaN(+filter.ge) && !!filter.le && !isNaN(+filter.le)) {
const sorted = [+filter.ge, +filter.le].sort((a, b) => a - b);
filter.ge = sorted[0];
filter.le = sorted[1];
}
};
export function saveCookies(resp, expireOn: number, apiUrl: string) {
const domain = apiUrl.includes('.') ? `.${apiUrl.split('.').filter((item, index, arr) => index > arr.length - 3).join('.')}` : 'localhost';
......
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