@bytebrand/fe-ui-core 4.2.33 → 4.2.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import _get from 'lodash/get';
|
|
3
3
|
import _startsWith from 'lodash/startsWith';
|
|
4
|
+
import _debounce from 'lodash/debounce';
|
|
4
5
|
import qs from 'qs';
|
|
5
6
|
import { observer } from 'mobx-react';
|
|
6
7
|
import { toJS } from 'mobx';
|
|
7
8
|
import { checkRangeValuesOnEqual, getGroupValuesForQuery } from '../../../../framework/utils/CommonUtils';
|
|
8
9
|
import { FilterBlockFactory } from '../../../SearchFilters/common/FilterBlock/FilterBlockFactory';
|
|
9
10
|
import { FilterGroups, IFilters } from '../../../SearchFilters/FiltersFactory';
|
|
10
|
-
import { MANUFACTURER_KEY, MM_GROUPS_EXCLUDE_KEY, MODEL_KEY, RANGE_FILTERS, SERIES_KEY, SUPER_ADMIN_FILTER_NAME } from '../../../../framework/constants/Search';
|
|
11
|
+
import { MANUFACTURER_KEY, MM_GROUPS_EXCLUDE_KEY, MODEL_KEY, RANGE_FILTERS, SERIES_KEY, SUPER_ADMIN_FILTER_NAME, SUB_MODEL_KEY } from '../../../../framework/constants/Search';
|
|
11
12
|
import { MMS_GROUPS_KEY, OBJECT_FILTERS } from '../../../../framework/constants/SearchWidget';
|
|
12
13
|
import { resolveMmsValue } from '../../../../framework/utils/FiltersUtils';
|
|
13
14
|
import FilterBlock from '../../../SearchFilters/common/FilterBlock/FilterBlock';
|
|
@@ -59,6 +60,8 @@ interface IFiltersContainerProps extends IRouteComponentProps<PathParamsType> {
|
|
|
59
60
|
Link?: any;
|
|
60
61
|
}
|
|
61
62
|
|
|
63
|
+
const DEBOUNCE_TIME: number = 500;
|
|
64
|
+
|
|
62
65
|
@observer
|
|
63
66
|
class FiltersContainer extends React.Component<IFiltersContainerProps, {}> {
|
|
64
67
|
componentDidMount() {
|
|
@@ -100,6 +103,13 @@ class FiltersContainer extends React.Component<IFiltersContainerProps, {}> {
|
|
|
100
103
|
resetFiltersToDefault();
|
|
101
104
|
}
|
|
102
105
|
|
|
106
|
+
debaunceOnFilterChange = _debounce( // is used for the text field to add a delay and not make a search request for each key stroke
|
|
107
|
+
() => {
|
|
108
|
+
this.props.onFilterChange();
|
|
109
|
+
},
|
|
110
|
+
DEBOUNCE_TIME
|
|
111
|
+
);
|
|
112
|
+
|
|
103
113
|
onFilterChange = (field: string, value: any, index?: number, isSeries?: boolean) => {
|
|
104
114
|
const { addModelsToFilters, changeFilterValue, changeSeries, getModelsInfoByMaker } = this.props;
|
|
105
115
|
let newValue = _get(value, 'value') || value;
|
|
@@ -137,7 +147,12 @@ class FiltersContainer extends React.Component<IFiltersContainerProps, {}> {
|
|
|
137
147
|
}
|
|
138
148
|
|
|
139
149
|
changeFilterValue(field, newValue, index);
|
|
140
|
-
|
|
150
|
+
|
|
151
|
+
if (field === SUB_MODEL_KEY) {
|
|
152
|
+
this.debaunceOnFilterChange();
|
|
153
|
+
} else {
|
|
154
|
+
this.props.onFilterChange();
|
|
155
|
+
}
|
|
141
156
|
};
|
|
142
157
|
|
|
143
158
|
onChangeFilterControls = (field: string, value: any) => {
|