@zengenti/contensis-react-base 3.0.0-beta.2 → 3.0.0-beta.23
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/README.md +4 -4
- package/cjs/{App-581b6653.js → App-11c6a5dc.js} +45 -29
- package/cjs/App-11c6a5dc.js.map +1 -0
- package/cjs/{RouteLoader-282c03ab.js → RouteLoader-0f7fb3d8.js} +44 -30
- package/cjs/RouteLoader-0f7fb3d8.js.map +1 -0
- package/cjs/ToJs-5da8a85e.js +124 -0
- package/cjs/ToJs-5da8a85e.js.map +1 -0
- package/cjs/{actions-12871aca.js → actions-6b9ef168.js} +9 -8
- package/cjs/actions-6b9ef168.js.map +1 -0
- package/cjs/client.js +43 -22
- package/cjs/client.js.map +1 -1
- package/cjs/contensis-react-base.js +42 -46
- package/cjs/contensis-react-base.js.map +1 -1
- package/cjs/forms.js +275 -275
- package/cjs/forms.js.map +1 -1
- package/cjs/fromJSLeaveImmer-65d26804.js +28 -0
- package/cjs/fromJSLeaveImmer-65d26804.js.map +1 -0
- package/cjs/{login-81d7f9ef.js → login-7ddb9cd6.js} +86 -45
- package/cjs/login-7ddb9cd6.js.map +1 -0
- package/cjs/{reducers-fde41d6b.js → reducers-d6ffba6d.js} +9 -5
- package/cjs/reducers-d6ffba6d.js.map +1 -0
- package/cjs/redux.js +13 -14
- package/cjs/redux.js.map +1 -1
- package/cjs/routing.js +9 -8
- package/cjs/routing.js.map +1 -1
- package/cjs/search.js +179 -151
- package/cjs/search.js.map +1 -1
- package/cjs/{selectors-ed26ed97.js → selectors-2c1b1183.js} +8 -4
- package/cjs/selectors-2c1b1183.js.map +1 -0
- package/cjs/user.js +16 -16
- package/cjs/user.js.map +1 -1
- package/cjs/util.js +36 -40
- package/cjs/util.js.map +1 -1
- package/cjs/{version-0c190929.js → version-dcfdafd9.js} +5 -5
- package/cjs/{version-0c190929.js.map → version-dcfdafd9.js.map} +1 -1
- package/cjs/{version-f061e409.js → version-fd70dc68.js} +58 -52
- package/cjs/version-fd70dc68.js.map +1 -0
- package/esm/{App-122f28a3.js → App-20f2ee9b.js} +26 -29
- package/esm/App-20f2ee9b.js.map +1 -0
- package/esm/{RouteLoader-c2faac87.js → RouteLoader-31425b61.js} +37 -23
- package/esm/RouteLoader-31425b61.js.map +1 -0
- package/esm/ToJs-1f2e6395.js +93 -0
- package/esm/ToJs-1f2e6395.js.map +1 -0
- package/esm/{actions-3cc39599.js → actions-5437f43d.js} +8 -7
- package/esm/actions-5437f43d.js.map +1 -0
- package/esm/client.js +22 -20
- package/esm/client.js.map +1 -1
- package/esm/contensis-react-base.js +24 -28
- package/esm/contensis-react-base.js.map +1 -1
- package/esm/forms.js +5 -5
- package/esm/forms.js.map +1 -1
- package/esm/fromJSLeaveImmer-e2f0f331.js +26 -0
- package/esm/fromJSLeaveImmer-e2f0f331.js.map +1 -0
- package/esm/{login-92db44d1.js → login-c8661270.js} +70 -26
- package/esm/login-c8661270.js.map +1 -0
- package/esm/{reducers-d6c0edb1.js → reducers-c0747097.js} +9 -5
- package/esm/reducers-c0747097.js.map +1 -0
- package/esm/redux.js +14 -13
- package/esm/redux.js.map +1 -1
- package/esm/routing.js +9 -8
- package/esm/routing.js.map +1 -1
- package/esm/search.js +149 -139
- package/esm/search.js.map +1 -1
- package/esm/{selectors-82e71d8e.js → selectors-65f0f31c.js} +9 -6
- package/esm/selectors-65f0f31c.js.map +1 -0
- package/esm/user.js +15 -15
- package/esm/user.js.map +1 -1
- package/esm/util.js +5 -5
- package/esm/util.js.map +1 -1
- package/esm/{version-cb9cd09d.js → version-59e6b711.js} +38 -31
- package/esm/version-59e6b711.js.map +1 -0
- package/esm/version-696796d7.js +15 -0
- package/esm/{version-59c8f9be.js.map → version-696796d7.js.map} +1 -1
- package/models/redux/appstate.d.ts +0 -4
- package/models/redux/reducers/navigation.d.ts +1 -6
- package/models/redux/reducers/version.d.ts +1 -5
- package/models/redux/selectors/navigation.d.ts +2 -1
- package/models/routing/redux/actions.d.ts +1 -1
- package/models/routing/redux/reducers.d.ts +1 -21
- package/models/routing/redux/selectors.d.ts +1 -1
- package/models/search/hooks/useMinilist.hook.d.ts +2 -15
- package/models/search/models/Queries.d.ts +8 -5
- package/models/search/models/Search.d.ts +9 -8
- package/models/search/models/SearchActions.d.ts +1 -0
- package/models/search/models/SearchProps.d.ts +16 -2
- package/models/search/models/SearchState.d.ts +3 -0
- package/models/search/models/index.d.ts +3 -2
- package/models/search/redux/reducers.d.ts +226 -314
- package/models/search/redux/sagas.d.ts +2 -2
- package/models/search/redux/selectors.d.ts +5 -10
- package/models/search/search/expressions.d.ts +2 -6
- package/models/search/transformations/filter-to-filterexpression.mapper.d.ts +6 -0
- package/models/search/transformations/filters-to-filterexpressions.mapper.d.ts +3 -0
- package/models/testImmer/redux/reducer.d.ts +1 -7
- package/models/user/hocs/withLogin.d.ts +2 -2
- package/models/user/hooks/useChangePassword.d.ts +5 -5
- package/models/user/hooks/useForgotPassword.d.ts +6 -6
- package/models/user/hooks/useLogin.d.ts +7 -45
- package/models/user/hooks/useRegistration.d.ts +4 -4
- package/models/user/redux/reducers.d.ts +1 -27
- package/models/user/redux/sagas/login.d.ts +10 -5
- package/models/user/redux/selectors.d.ts +28 -71
- package/models/user/util/LoginHelper.class.d.ts +1 -0
- package/models/util/merge.d.ts +1 -0
- package/package-lock.json +1893 -4633
- package/package.json +46 -47
- package/cjs/App-581b6653.js.map +0 -1
- package/cjs/RouteLoader-282c03ab.js.map +0 -1
- package/cjs/ToJs-87edc45d.js +0 -230
- package/cjs/ToJs-87edc45d.js.map +0 -1
- package/cjs/actions-12871aca.js.map +0 -1
- package/cjs/fromJSLeaveImmer-9b550c8e.js +0 -40
- package/cjs/fromJSLeaveImmer-9b550c8e.js.map +0 -1
- package/cjs/login-81d7f9ef.js.map +0 -1
- package/cjs/reducers-fde41d6b.js.map +0 -1
- package/cjs/selectors-ed26ed97.js.map +0 -1
- package/cjs/version-f061e409.js.map +0 -1
- package/esm/App-122f28a3.js.map +0 -1
- package/esm/RouteLoader-c2faac87.js.map +0 -1
- package/esm/ToJs-52fee252.js +0 -199
- package/esm/ToJs-52fee252.js.map +0 -1
- package/esm/actions-3cc39599.js.map +0 -1
- package/esm/fromJSLeaveImmer-e44d1a91.js +0 -38
- package/esm/fromJSLeaveImmer-e44d1a91.js.map +0 -1
- package/esm/login-92db44d1.js.map +0 -1
- package/esm/reducers-d6c0edb1.js.map +0 -1
- package/esm/selectors-82e71d8e.js.map +0 -1
- package/esm/version-59c8f9be.js +0 -15
- package/esm/version-cb9cd09d.js.map +0 -1
- package/models/search/transformations/filters-to-filterexpression.d.ts +0 -1
- package/models/search/transformations/filters-to-filterexpression.mapper.d.ts +0 -2
package/esm/search.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import React, { useMemo, useEffect } from 'react';
|
|
2
2
|
import { connect, useDispatch, useSelector } from 'react-redux';
|
|
3
3
|
import mapJson, { jpath } from 'jsonpath-mapper';
|
|
4
|
-
import
|
|
4
|
+
import * as log from 'loglevel';
|
|
5
5
|
import { takeEvery, select, put, call, all } from '@redux-saga/core/effects';
|
|
6
6
|
import { Client } from 'contensis-delivery-api';
|
|
7
|
-
import
|
|
8
|
-
import { error } from 'loglevel';
|
|
9
|
-
import { createSelector } from 'reselect';
|
|
7
|
+
import { stringify, parse } from 'query-string';
|
|
10
8
|
import { Op, OrderBy, Query } from 'contensis-core-api';
|
|
11
9
|
import merge from 'deepmerge';
|
|
10
|
+
import { createSelector } from 'reselect';
|
|
11
|
+
import { produce } from 'immer';
|
|
12
12
|
import equals from 'deep-equal';
|
|
13
13
|
|
|
14
14
|
/* eslint-disable import/default */
|
|
15
|
-
const toJS = WrappedComponent => wrappedComponentProps => {
|
|
15
|
+
const toJS$1 = WrappedComponent => wrappedComponentProps => {
|
|
16
16
|
const KEY = 0;
|
|
17
17
|
const VALUE = 1;
|
|
18
18
|
const propsJS = Object.entries(wrappedComponentProps).reduce((newProps, wrappedComponentProp) => {
|
|
@@ -121,30 +121,30 @@ const navigate = (path, state) => {
|
|
|
121
121
|
state
|
|
122
122
|
};
|
|
123
123
|
};
|
|
124
|
-
const clearFilters = () => {
|
|
124
|
+
const clearFilters$1 = () => {
|
|
125
125
|
return {
|
|
126
126
|
type: CLEAR_FILTERS
|
|
127
127
|
};
|
|
128
128
|
};
|
|
129
|
-
const updatePageIndex = pageIndex => {
|
|
129
|
+
const updatePageIndex$1 = pageIndex => {
|
|
130
130
|
return {
|
|
131
131
|
type: UPDATE_PAGE_INDEX,
|
|
132
132
|
pageIndex
|
|
133
133
|
};
|
|
134
134
|
};
|
|
135
|
-
const updateCurrentFacet = facet => {
|
|
135
|
+
const updateCurrentFacet$1 = facet => {
|
|
136
136
|
return {
|
|
137
137
|
type: UPDATE_CURRENT_FACET,
|
|
138
138
|
facet
|
|
139
139
|
};
|
|
140
140
|
};
|
|
141
|
-
const updateCurrentTab = id => {
|
|
141
|
+
const updateCurrentTab$1 = id => {
|
|
142
142
|
return {
|
|
143
143
|
type: UPDATE_CURRENT_TAB,
|
|
144
144
|
id
|
|
145
145
|
};
|
|
146
146
|
};
|
|
147
|
-
const updateSearchTerm = term => {
|
|
147
|
+
const updateSearchTerm$1 = term => {
|
|
148
148
|
return {
|
|
149
149
|
type: UPDATE_SEARCH_TERM,
|
|
150
150
|
term
|
|
@@ -157,7 +157,7 @@ const updateSelectedFilters = (filter, key) => {
|
|
|
157
157
|
key
|
|
158
158
|
};
|
|
159
159
|
};
|
|
160
|
-
const updateSortOrder = (orderBy, facet) => {
|
|
160
|
+
const updateSortOrder$1 = (orderBy, facet) => {
|
|
161
161
|
return {
|
|
162
162
|
type: UPDATE_SORT_ORDER,
|
|
163
163
|
orderBy,
|
|
@@ -171,22 +171,22 @@ var actions = /*#__PURE__*/Object.freeze({
|
|
|
171
171
|
triggerSearch: triggerSearch,
|
|
172
172
|
initListing: initListing,
|
|
173
173
|
navigate: navigate,
|
|
174
|
-
clearFilters: clearFilters,
|
|
175
|
-
updatePageIndex: updatePageIndex,
|
|
176
|
-
updateCurrentFacet: updateCurrentFacet,
|
|
177
|
-
updateCurrentTab: updateCurrentTab,
|
|
178
|
-
updateSearchTerm: updateSearchTerm,
|
|
174
|
+
clearFilters: clearFilters$1,
|
|
175
|
+
updatePageIndex: updatePageIndex$1,
|
|
176
|
+
updateCurrentFacet: updateCurrentFacet$1,
|
|
177
|
+
updateCurrentTab: updateCurrentTab$1,
|
|
178
|
+
updateSearchTerm: updateSearchTerm$1,
|
|
179
179
|
updateSelectedFilters: updateSelectedFilters,
|
|
180
|
-
updateSortOrder: updateSortOrder
|
|
180
|
+
updateSortOrder: updateSortOrder$1
|
|
181
181
|
});
|
|
182
182
|
|
|
183
|
-
let Context; // export type Context = 'facets' | 'listings' | 'minilist';
|
|
183
|
+
let Context$1; // export type Context = 'facets' | 'listings' | 'minilist';
|
|
184
184
|
|
|
185
185
|
(function (Context) {
|
|
186
186
|
Context["facets"] = "facets";
|
|
187
187
|
Context["listings"] = "listings";
|
|
188
188
|
Context["minilist"] = "minilist";
|
|
189
|
-
})(Context || (Context = {}));
|
|
189
|
+
})(Context$1 || (Context$1 = {}));
|
|
190
190
|
|
|
191
191
|
// or replace with a stub function for non-immutable gets
|
|
192
192
|
|
|
@@ -217,12 +217,12 @@ const getImmutableOrJS = (state, stateKey, fallbackValue, returnType = globalThi
|
|
|
217
217
|
return result;
|
|
218
218
|
};
|
|
219
219
|
|
|
220
|
-
const getSearchContext = state => getImmutableOrJS(state, ['search', 'context'], Context.facets);
|
|
221
|
-
const getCurrent = (state, context = Context.facets) => context === Context.facets ? getCurrentFacet(state) : getCurrentListing(state);
|
|
220
|
+
const getSearchContext = state => getImmutableOrJS(state, ['search', 'context'], Context$1.facets);
|
|
221
|
+
const getCurrent = (state, context = Context$1.facets) => context === Context$1.facets ? getCurrentFacet(state) : getCurrentListing(state);
|
|
222
222
|
const getCurrentFacet = state => getImmutableOrJS(state, ['search', 'currentFacet']);
|
|
223
223
|
const getCurrentListing = state => getImmutableOrJS(state, ['search', 'currentListing']);
|
|
224
|
-
const getCurrentTab = state => getImmutableOrJS(state, ['search', Context.facets, getCurrentFacet(state), 'tabId'], 0);
|
|
225
|
-
const getFacets = (state, returnType) => getImmutableOrJS(state, ['search', Context.facets], {}, returnType);
|
|
224
|
+
const getCurrentTab = state => getImmutableOrJS(state, ['search', Context$1.facets, getCurrentFacet(state), 'tabId'], 0);
|
|
225
|
+
const getFacets = (state, returnType) => getImmutableOrJS(state, ['search', Context$1.facets], {}, returnType);
|
|
226
226
|
const getTabFacets = state => Object.fromEntries(Object.entries(getFacets(state, 'js')).filter(([key]) => getImmutableOrJS(getFacets(state), [key, 'tabId'], 0) === getCurrentTab(state)));
|
|
227
227
|
const getFacetTitles = state => Object.entries(getFacets(state, 'js')).map(([key, facet = {}]) => {
|
|
228
228
|
var _facet$pagingInfo;
|
|
@@ -233,19 +233,19 @@ const getFacetTitles = state => Object.entries(getFacets(state, 'js')).map(([key
|
|
|
233
233
|
totalCount: (_facet$pagingInfo = facet.pagingInfo) === null || _facet$pagingInfo === void 0 ? void 0 : _facet$pagingInfo.totalCount
|
|
234
234
|
};
|
|
235
235
|
});
|
|
236
|
-
const getFacet = (state, facetName = '', context = Context.facets, returnType) => {
|
|
236
|
+
const getFacet = (state, facetName = '', context = Context$1.facets, returnType) => {
|
|
237
237
|
const currentFacet = facetName || getCurrentFacet(state);
|
|
238
238
|
return getImmutableOrJS(state, ['search', context, currentFacet], {}, returnType);
|
|
239
239
|
};
|
|
240
240
|
const getListing = (state, listing = '') => {
|
|
241
241
|
const currentListing = listing || getCurrentListing(state);
|
|
242
|
-
return getImmutableOrJS(state, ['search', Context.listings, currentListing], {});
|
|
242
|
+
return getImmutableOrJS(state, ['search', Context$1.listings, currentListing], {});
|
|
243
243
|
};
|
|
244
|
-
const getFilters = (state, facet, context = Context.facets, returnType) => {
|
|
244
|
+
const getFilters = (state, facet, context = Context$1.facets, returnType) => {
|
|
245
245
|
return getImmutableOrJS(state, ['search', context, facet || getCurrent(state, context), 'filters'], {}, returnType);
|
|
246
246
|
};
|
|
247
|
-
const getRenderableFilters = (state, facet = '', context = Context.facets) => Object.fromEntries(Object.entries(getFilters(state, facet, context, 'js')).filter(([, f = {}]) => typeof f.renderable !== 'boolean' ? true : f.renderable));
|
|
248
|
-
const getFiltersToLoad = (state, facet, context = Context.facets, returnType) => {
|
|
247
|
+
const getRenderableFilters = (state, facet = '', context = Context$1.facets) => Object.fromEntries(Object.entries(getFilters(state, facet, context, 'js')).filter(([, f = {}]) => typeof f.renderable !== 'boolean' ? true : f.renderable));
|
|
248
|
+
const getFiltersToLoad = (state, facet, context = Context$1.facets, returnType) => {
|
|
249
249
|
const filters = getFilters(state, facet, context, returnType);
|
|
250
250
|
const loadedFilters = Object.entries(filters).map(([key, f = {}]) => [key, (f.items || []).filter(i => {
|
|
251
251
|
const title = i === null || i === void 0 ? void 0 : i.title;
|
|
@@ -254,7 +254,7 @@ const getFiltersToLoad = (state, facet, context = Context.facets, returnType) =>
|
|
|
254
254
|
return loadedFilters.map(([filterKey, isLoaded]) => !isLoaded ? filterKey : null).filter(f => !!f);
|
|
255
255
|
}; // We lowercase the filter key unless it's an ISO date string where the T must be uppercase
|
|
256
256
|
|
|
257
|
-
const getSelectedFilters = (state, facet = '', context = Context.facets, returnType) => {
|
|
257
|
+
const getSelectedFilters = (state, facet = '', context = Context$1.facets, returnType) => {
|
|
258
258
|
const filters = getFilters(state, facet, context, 'js');
|
|
259
259
|
const isoDateRegex = RegExp(/\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d/);
|
|
260
260
|
const selectedFilters = Object.fromEntries(Object.entries(filters).map(([key, filter = {}]) => [key, (filter.items || []).filter(item => !!(item.isSelected || false)).map(item => {
|
|
@@ -265,56 +265,56 @@ const getSelectedFilters = (state, facet = '', context = Context.facets, returnT
|
|
|
265
265
|
const fromJS = makeFromJS(returnType);
|
|
266
266
|
return fromJS(selectedFilters);
|
|
267
267
|
};
|
|
268
|
-
const getResults = (state, current = '', context = Context.facets, returnType) => {
|
|
268
|
+
const getResults = (state, current = '', context = Context$1.facets, returnType) => {
|
|
269
269
|
return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'results'], [], returnType);
|
|
270
270
|
};
|
|
271
|
-
const getIsInternalPaging = (state, current, context = Context.facets) => {
|
|
271
|
+
const getIsInternalPaging = (state, current, context = Context$1.facets) => {
|
|
272
272
|
return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'queryParams', 'internalPaging'], false);
|
|
273
273
|
};
|
|
274
|
-
const getIsLoaded = (state, context = Context.facets, facet) => {
|
|
274
|
+
const getIsLoaded = (state, context = Context$1.facets, facet) => {
|
|
275
275
|
return !!getImmutableOrJS(state, ['search', context, facet || getCurrent(state, context), 'queryDuration'], 0);
|
|
276
276
|
};
|
|
277
|
-
const getIsLoading = (state, context = Context.facets, facet) => {
|
|
277
|
+
const getIsLoading = (state, context = Context$1.facets, facet) => {
|
|
278
278
|
return getImmutableOrJS(state, ['search', context, facet || getCurrent(state, context), 'entries', 'isLoading']);
|
|
279
279
|
};
|
|
280
280
|
const getIsSsr = state => getImmutableOrJS(state, ['search', 'config', 'ssr'], false);
|
|
281
|
-
const getFeaturedResults = (state, current = '', context = Context.facets) => {
|
|
281
|
+
const getFeaturedResults = (state, current = '', context = Context$1.facets) => {
|
|
282
282
|
return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'featuredResults'], []);
|
|
283
283
|
};
|
|
284
|
-
const getPaging = (state, current = '', context = Context.facets, returnType) => {
|
|
284
|
+
const getPaging = (state, current = '', context = Context$1.facets, returnType) => {
|
|
285
285
|
return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'pagingInfo'], {}, returnType);
|
|
286
286
|
};
|
|
287
|
-
const getPageIndex = (state, current = '', context = Context.facets) => {
|
|
287
|
+
const getPageIndex = (state, current = '', context = Context$1.facets) => {
|
|
288
288
|
return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'pagingInfo', 'pageIndex']);
|
|
289
289
|
};
|
|
290
|
-
const getPrevPageIndex = (state, current = '', context = Context.facets) => {
|
|
290
|
+
const getPrevPageIndex = (state, current = '', context = Context$1.facets) => {
|
|
291
291
|
return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'pagingInfo', 'prevPageIndex']);
|
|
292
292
|
};
|
|
293
|
-
const getPageIsLoading = (state, current = '', context = Context.facets) => {
|
|
293
|
+
const getPageIsLoading = (state, current = '', context = Context$1.facets) => {
|
|
294
294
|
return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'pagingInfo', 'isLoading']);
|
|
295
295
|
};
|
|
296
|
-
const getPagesLoaded = (state, current = '', context = Context.facets) => {
|
|
296
|
+
const getPagesLoaded = (state, current = '', context = Context$1.facets) => {
|
|
297
297
|
return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'pagingInfo', 'pagesLoaded'], [], 'js');
|
|
298
298
|
};
|
|
299
|
-
const getTotalCount = (state, current = '', context = Context.facets) => {
|
|
299
|
+
const getTotalCount = (state, current = '', context = Context$1.facets) => {
|
|
300
300
|
return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'pagingInfo', 'totalCount']);
|
|
301
301
|
};
|
|
302
302
|
const getSearchTerm = state => getImmutableOrJS(state, ['search', 'term']);
|
|
303
303
|
const getSearchTabs = (state, returnType) => getImmutableOrJS(state, ['search', 'tabs'], [], returnType);
|
|
304
|
-
const getQueryParams = (state, current = '', context = Context.facets) => {
|
|
304
|
+
const getQueryParams = (state, current = '', context = Context$1.facets) => {
|
|
305
305
|
return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'queryParams'], {}, 'js');
|
|
306
306
|
};
|
|
307
307
|
const getQueryParameter = ({
|
|
308
308
|
state,
|
|
309
309
|
facet,
|
|
310
|
-
context = Context.facets
|
|
310
|
+
context = Context$1.facets
|
|
311
311
|
}, key, ifnull = null) => {
|
|
312
312
|
return getImmutableOrJS(getQueryParams(state, facet, context), key, ifnull, 'js');
|
|
313
313
|
};
|
|
314
|
-
const getCustomApi = (state, current, context = Context.facets, returnType) => {
|
|
314
|
+
const getCustomApi = (state, current, context = Context$1.facets, returnType) => {
|
|
315
315
|
return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'customApi'], null, returnType);
|
|
316
316
|
};
|
|
317
|
-
const getCustomEnv = (state, current, context = Context.facets) => {
|
|
317
|
+
const getCustomEnv = (state, current, context = Context$1.facets) => {
|
|
318
318
|
return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'env']);
|
|
319
319
|
};
|
|
320
320
|
const getTabsAndFacets = (state, returnType) => {
|
|
@@ -330,7 +330,7 @@ const getTabsAndFacets = (state, returnType) => {
|
|
|
330
330
|
return 0;
|
|
331
331
|
}).reduce((a, b) => a + b, 0);
|
|
332
332
|
return { ...tab,
|
|
333
|
-
[Context.facets]: Object.fromEntries(thisTabFacets),
|
|
333
|
+
[Context$1.facets]: Object.fromEntries(thisTabFacets),
|
|
334
334
|
totalCount: thisTabTotal
|
|
335
335
|
};
|
|
336
336
|
});
|
|
@@ -370,14 +370,14 @@ const selectFacets = {
|
|
|
370
370
|
getPageIsLoading,
|
|
371
371
|
getPagesLoaded,
|
|
372
372
|
getPaging,
|
|
373
|
-
getQueryParams: (state, facet) => getQueryParams(state, facet, Context.facets),
|
|
373
|
+
getQueryParams: (state, facet) => getQueryParams(state, facet, Context$1.facets),
|
|
374
374
|
getQueryParameter: ({
|
|
375
375
|
state,
|
|
376
376
|
facet
|
|
377
377
|
}, key, ifnull) => getQueryParameter({
|
|
378
378
|
state,
|
|
379
379
|
facet,
|
|
380
|
-
context: Context.facets
|
|
380
|
+
context: Context$1.facets
|
|
381
381
|
}, key, ifnull),
|
|
382
382
|
getRenderableFilters,
|
|
383
383
|
getResults,
|
|
@@ -392,32 +392,33 @@ const selectFacets = {
|
|
|
392
392
|
|
|
393
393
|
const selectListing = {
|
|
394
394
|
getCurrent: getCurrentListing,
|
|
395
|
-
getFeaturedResults: (state, listing = '') => getFeaturedResults(state, listing, Context.listings),
|
|
396
|
-
getFilters: (state, listing = '') => getFilters(state, listing, Context.listings),
|
|
397
|
-
getFiltersToLoad: (state, listing = '') => getFiltersToLoad(state, listing, Context.listings),
|
|
395
|
+
getFeaturedResults: (state, listing = '') => getFeaturedResults(state, listing, Context$1.listings),
|
|
396
|
+
getFilters: (state, listing = '') => getFilters(state, listing, Context$1.listings),
|
|
397
|
+
getFiltersToLoad: (state, listing = '') => getFiltersToLoad(state, listing, Context$1.listings),
|
|
398
398
|
getListing,
|
|
399
|
-
getIsLoaded: state => getIsLoaded(state, Context.listings),
|
|
400
|
-
getIsLoading: state => getIsLoading(state, Context.listings),
|
|
401
|
-
getPageIndex: (state, listing = '') => getPageIndex(state, listing, Context.listings),
|
|
402
|
-
getPaging: (state, listing = '') => getPaging(state, listing, Context.listings),
|
|
403
|
-
getPageIsLoading: (state, listing = '') => getPageIsLoading(state, listing, Context.listings),
|
|
404
|
-
getPagesLoaded: (state, listing = '') => getPagesLoaded(state, listing, Context.listings),
|
|
405
|
-
getQueryParams: (state, listing = '') => getQueryParams(state, listing, Context.listings),
|
|
399
|
+
getIsLoaded: state => getIsLoaded(state, Context$1.listings),
|
|
400
|
+
getIsLoading: state => getIsLoading(state, Context$1.listings),
|
|
401
|
+
getPageIndex: (state, listing = '') => getPageIndex(state, listing, Context$1.listings),
|
|
402
|
+
getPaging: (state, listing = '') => getPaging(state, listing, Context$1.listings),
|
|
403
|
+
getPageIsLoading: (state, listing = '') => getPageIsLoading(state, listing, Context$1.listings),
|
|
404
|
+
getPagesLoaded: (state, listing = '') => getPagesLoaded(state, listing, Context$1.listings),
|
|
405
|
+
getQueryParams: (state, listing = '') => getQueryParams(state, listing, Context$1.listings),
|
|
406
406
|
getQueryParameter: ({
|
|
407
407
|
state,
|
|
408
408
|
facet
|
|
409
409
|
}, key, ifnull) => getQueryParameter({
|
|
410
410
|
state,
|
|
411
411
|
facet,
|
|
412
|
-
context: Context.listings
|
|
412
|
+
context: Context$1.listings
|
|
413
413
|
}, key, ifnull),
|
|
414
|
-
getRenderableFilters: (state, listing = '') => getRenderableFilters(state, listing, Context.listings),
|
|
415
|
-
getResults: (state, listing = '') => getResults(state, listing, Context.listings),
|
|
414
|
+
getRenderableFilters: (state, listing = '') => getRenderableFilters(state, listing, Context$1.listings),
|
|
415
|
+
getResults: (state, listing = '') => getResults(state, listing, Context$1.listings),
|
|
416
416
|
getSearchTerm,
|
|
417
|
-
getTotalCount: (state, listing = '') => getTotalCount(state, listing, Context.listings),
|
|
418
|
-
getSelectedFilters: (state, listing = '') => getSelectedFilters(state, listing, Context.listings)
|
|
417
|
+
getTotalCount: (state, listing = '') => getTotalCount(state, listing, Context$1.listings),
|
|
418
|
+
getSelectedFilters: (state, listing = '') => getSelectedFilters(state, listing, Context$1.listings)
|
|
419
419
|
};
|
|
420
420
|
const selectCurrentPath = state => getImmutableOrJS(state, ['routing', 'currentPath']);
|
|
421
|
+
const selectCurrentProject = state => getImmutableOrJS(state, ['routing', 'currentProject']);
|
|
421
422
|
const selectVersionStatus = state => getImmutableOrJS(state, ['version', 'contensisVersionStatus']);
|
|
422
423
|
|
|
423
424
|
var selectors = /*#__PURE__*/Object.freeze({
|
|
@@ -460,6 +461,7 @@ var selectors = /*#__PURE__*/Object.freeze({
|
|
|
460
461
|
selectFacets: selectFacets,
|
|
461
462
|
selectListing: selectListing,
|
|
462
463
|
selectCurrentPath: selectCurrentPath,
|
|
464
|
+
selectCurrentProject: selectCurrentProject,
|
|
463
465
|
selectVersionStatus: selectVersionStatus
|
|
464
466
|
});
|
|
465
467
|
|
|
@@ -500,16 +502,16 @@ const withSearch = mappers => SearchComponent => {
|
|
|
500
502
|
};
|
|
501
503
|
|
|
502
504
|
const mapDispatchToProps = {
|
|
503
|
-
clearFilters: () => withMappers(clearFilters(), mappers),
|
|
504
|
-
updateCurrentFacet: facet => withMappers(updateCurrentFacet(facet), mappers),
|
|
505
|
-
updateCurrentTab: id => withMappers(updateCurrentTab(id), mappers),
|
|
506
|
-
updatePageIndex: pageIndex => withMappers(updatePageIndex(pageIndex), mappers),
|
|
507
|
-
updateSearchTerm: term => withMappers(updateSearchTerm(term), mappers),
|
|
505
|
+
clearFilters: () => withMappers(clearFilters$1(), mappers),
|
|
506
|
+
updateCurrentFacet: facet => withMappers(updateCurrentFacet$1(facet), mappers),
|
|
507
|
+
updateCurrentTab: id => withMappers(updateCurrentTab$1(id), mappers),
|
|
508
|
+
updatePageIndex: pageIndex => withMappers(updatePageIndex$1(pageIndex), mappers),
|
|
509
|
+
updateSearchTerm: term => withMappers(updateSearchTerm$1(term), mappers),
|
|
508
510
|
updateSelectedFilters: (filter, key) => withMappers(updateSelectedFilters(filter, key), mappers),
|
|
509
|
-
updateSortOrder: orderBy => withMappers(updateSortOrder(orderBy), mappers)
|
|
511
|
+
updateSortOrder: orderBy => withMappers(updateSortOrder$1(orderBy), mappers)
|
|
510
512
|
};
|
|
511
513
|
const connector = connect(mapStateToProps, mapDispatchToProps);
|
|
512
|
-
return connector(toJS(Wrapper));
|
|
514
|
+
return connector(toJS$1(Wrapper));
|
|
513
515
|
};
|
|
514
516
|
|
|
515
517
|
/* eslint-disable @typescript-eslint/naming-convention */
|
|
@@ -552,14 +554,14 @@ const withListing = mappers => ListingComponent => {
|
|
|
552
554
|
};
|
|
553
555
|
|
|
554
556
|
const mapDispatchToProps = {
|
|
555
|
-
clearFilters: () => withMappers(clearFilters(), mappers),
|
|
556
|
-
updateCurrentFacet: facet => withMappers(updateCurrentFacet(facet), mappers),
|
|
557
|
-
updatePageIndex: pageIndex => withMappers(updatePageIndex(pageIndex), mappers),
|
|
558
|
-
updateSearchTerm: term => withMappers(updateSearchTerm(term), mappers),
|
|
557
|
+
clearFilters: () => withMappers(clearFilters$1(), mappers),
|
|
558
|
+
updateCurrentFacet: facet => withMappers(updateCurrentFacet$1(facet), mappers),
|
|
559
|
+
updatePageIndex: pageIndex => withMappers(updatePageIndex$1(pageIndex), mappers),
|
|
560
|
+
updateSearchTerm: term => withMappers(updateSearchTerm$1(term), mappers),
|
|
559
561
|
updateSelectedFilters: (filter, key) => withMappers(updateSelectedFilters(filter, key), mappers),
|
|
560
|
-
updateSortOrder: orderBy => withMappers(updateSortOrder(orderBy), mappers)
|
|
562
|
+
updateSortOrder: orderBy => withMappers(updateSortOrder$1(orderBy), mappers)
|
|
561
563
|
};
|
|
562
|
-
return connect(mapStateToProps, mapDispatchToProps)(toJS(Wrapper));
|
|
564
|
+
return connect(mapStateToProps, mapDispatchToProps)(toJS$1(Wrapper));
|
|
563
565
|
};
|
|
564
566
|
|
|
565
567
|
const getClientConfig = (project, env) => {
|
|
@@ -768,7 +770,7 @@ const extractQuotedPhrases = searchTerm => {
|
|
|
768
770
|
return (searchTerm.match(pattern) || []).map(match => match.replace(/"/g, ''));
|
|
769
771
|
};
|
|
770
772
|
const buildUrl = (route, params) => {
|
|
771
|
-
const qs =
|
|
773
|
+
const qs = stringify(params);
|
|
772
774
|
const path = qs ? `${route}?${qs}` : route;
|
|
773
775
|
return path;
|
|
774
776
|
};
|
|
@@ -873,8 +875,17 @@ const contentTypeIdExpression = (contentTypeIds, webpageTemplates, assetTypes) =
|
|
|
873
875
|
const filterExpressions = filters => {
|
|
874
876
|
if (!filters) return [];
|
|
875
877
|
const expressions = [];
|
|
876
|
-
filters.map(
|
|
877
|
-
|
|
878
|
+
filters.map(selectedFilter => {
|
|
879
|
+
if (selectedFilter.logicOperator === 'and') // using 'and' logic operator we loop through each filter
|
|
880
|
+
// and loop through all values to add an expression for each filter value
|
|
881
|
+
selectedFilter.values.forEach(value => expressions.push(...fieldExpression(selectedFilter.key, value, selectedFilter.fieldOperator || 'equalTo')));else if (selectedFilter.logicOperator === 'not') {
|
|
882
|
+
const fieldExpressions = fieldExpression(selectedFilter.key, selectedFilter.values, selectedFilter.fieldOperator || 'in');
|
|
883
|
+
fieldExpressions.forEach(expr => {
|
|
884
|
+
expressions.push(Op.not(expr));
|
|
885
|
+
});
|
|
886
|
+
} // using 'or' logic operator we loop over each filter
|
|
887
|
+
// and simply add the array of values to an expression with an 'in' operator
|
|
888
|
+
else expressions.push(...fieldExpression(selectedFilter.key, selectedFilter.values, selectedFilter.fieldOperator || 'in'));
|
|
878
889
|
});
|
|
879
890
|
return expressions;
|
|
880
891
|
};
|
|
@@ -891,8 +902,8 @@ const dataFormatExpression = (contentTypeIds, dataFormat = DataFormats.entry) =>
|
|
|
891
902
|
const withExpr = fieldExpression(Fields.sys.contentTypeId, withContentTypeIds)[0];
|
|
892
903
|
const notExpr = Op.not(fieldExpression(Fields.sys.contentTypeId, notContentTypeIds)[0]);
|
|
893
904
|
andExpr.add(dataFormatExpr);
|
|
894
|
-
if (withContentTypeIds.length > 0) andExpr.add(withExpr);
|
|
895
|
-
if (notContentTypeIds.length > 0) andExpr.add(notExpr);
|
|
905
|
+
if (withContentTypeIds.length > 0 && withExpr) andExpr.add(withExpr);
|
|
906
|
+
if (notContentTypeIds.length > 0 && notExpr) andExpr.add(notExpr);
|
|
896
907
|
return [andExpr];
|
|
897
908
|
}
|
|
898
909
|
|
|
@@ -948,8 +959,8 @@ const equalToOrIn = (field, value, operator = 'equalTo') => {
|
|
|
948
959
|
if (value.length === 0) return [];
|
|
949
960
|
|
|
950
961
|
if (Array.isArray(value)) {
|
|
951
|
-
if (
|
|
952
|
-
return [Op.
|
|
962
|
+
if (operator === 'equalTo') return [Op.in(field, ...value)];
|
|
963
|
+
return [Op.or(...value.map(innerValue => Op[operator](field, innerValue, undefined, undefined)))];
|
|
953
964
|
}
|
|
954
965
|
|
|
955
966
|
return [];
|
|
@@ -1029,7 +1040,7 @@ const customWhereExpressions = where => {
|
|
|
1029
1040
|
if (idx === 1 && // operator !== 'and' &&
|
|
1030
1041
|
// operator !== 'or' &&
|
|
1031
1042
|
operator !== 'between' && operator !== 'distanceWithin') {
|
|
1032
|
-
expression = operator === 'freeText' || operator === 'contains' ? Op[operator](field, value) : operator === 'in' ? Op[operator](field, ...value) : Op[operator](field, value);
|
|
1043
|
+
expression = operator === 'freeText' || operator === 'contains' ? Op[operator](field, value) : operator === 'in' ? Op[operator](field, ...value) : operator === 'exists' ? Op[operator](field, value) : Op[operator](field, value);
|
|
1033
1044
|
if (typeof weight === 'number') expression = expression.weight(weight);
|
|
1034
1045
|
}
|
|
1035
1046
|
});
|
|
@@ -1142,7 +1153,7 @@ const searchUriTemplate = {
|
|
|
1142
1153
|
facet,
|
|
1143
1154
|
pageIndex
|
|
1144
1155
|
}) => {
|
|
1145
|
-
const currentFacet = getSearchContext(state) !== Context.listings && (facet || getCurrentFacet(state));
|
|
1156
|
+
const currentFacet = getSearchContext(state) !== Context$1.listings && (facet || getCurrentFacet(state));
|
|
1146
1157
|
const currentPath = selectCurrentPath(state) || '/search';
|
|
1147
1158
|
const newPath = currentFacet ? `${currentPath}/${currentFacet}` : currentPath;
|
|
1148
1159
|
if (pageIndex) return `${newPath}/${pageIndex + 1}`;
|
|
@@ -1159,7 +1170,7 @@ const searchUriTemplate = {
|
|
|
1159
1170
|
|
|
1160
1171
|
const stateFilters = term ? {} : Object.fromEntries(Object.entries(getSelectedFilters(state, facet, searchContext, 'js')).map(([key, f]) => [key, f === null || f === void 0 ? void 0 : f.join(',')]));
|
|
1161
1172
|
const currentSearch = !term && getImmutableOrJS(state, ['routing', 'location', 'search']);
|
|
1162
|
-
const currentQs = removeEmptyAttributes(
|
|
1173
|
+
const currentQs = removeEmptyAttributes(parse(currentSearch));
|
|
1163
1174
|
if (orderBy) currentQs.orderBy = orderBy;
|
|
1164
1175
|
const searchTerm = getSearchTerm(state); // Use Immutable's merge to merge the stateFilters with any current Qs
|
|
1165
1176
|
// to build the new Qs.
|
|
@@ -1167,7 +1178,7 @@ const searchUriTemplate = {
|
|
|
1167
1178
|
const mergedSearch = removeEmptyAttributes({ ...merge(currentQs, stateFilters),
|
|
1168
1179
|
term: searchTerm
|
|
1169
1180
|
});
|
|
1170
|
-
return
|
|
1181
|
+
return stringify(mergedSearch);
|
|
1171
1182
|
},
|
|
1172
1183
|
hash: {
|
|
1173
1184
|
$path: 'state',
|
|
@@ -1317,14 +1328,15 @@ const filterTemplate = {
|
|
|
1317
1328
|
const filterExpressionMapper = {
|
|
1318
1329
|
// Expression type: so we can identify how to build the query
|
|
1319
1330
|
expressionType: ({
|
|
1320
|
-
|
|
1321
|
-
}) =>
|
|
1331
|
+
contentTypeId
|
|
1332
|
+
}) => contentTypeId ? FilterExpressionTypes.contentType : FilterExpressionTypes.field,
|
|
1322
1333
|
// Key: so we can target the query to a specific field
|
|
1323
|
-
key: '
|
|
1334
|
+
key: 'fieldId',
|
|
1324
1335
|
// Value: so we can filter a specific field by an array of values
|
|
1325
1336
|
// e.g. taxonomy key or contentTypeId array
|
|
1326
|
-
|
|
1327
|
-
|
|
1337
|
+
values: 'selectedValues',
|
|
1338
|
+
fieldOperator: 'fieldOperator',
|
|
1339
|
+
logicOperator: 'logicOperator'
|
|
1328
1340
|
};
|
|
1329
1341
|
|
|
1330
1342
|
const mapFilterToFilterExpression = filter => mapJson(filter, filterExpressionMapper);
|
|
@@ -1334,18 +1346,15 @@ const mapFiltersToFilterExpression = (filters, selectedFilters) => {
|
|
|
1334
1346
|
const filterExpressions = []; // Iterate through the keys in selectedFilters and locate
|
|
1335
1347
|
// the items that are selected and queryable
|
|
1336
1348
|
|
|
1337
|
-
Object.entries(selectedFilters).map(([fkey,
|
|
1349
|
+
Object.entries(selectedFilters).map(([fkey, selectedValues]) => {
|
|
1338
1350
|
const filter = filters[fkey];
|
|
1339
1351
|
|
|
1340
|
-
if (
|
|
1341
|
-
|
|
1352
|
+
if (selectedValues && filter) {
|
|
1353
|
+
// Where we have a value for a selectedFilter
|
|
1342
1354
|
// and a filter is found for the current key
|
|
1343
1355
|
// map the filter to a filterExpression object
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
filter,
|
|
1347
|
-
selectedItems,
|
|
1348
|
-
selectedValue
|
|
1356
|
+
const expr = mapFilterToFilterExpression({ ...filter,
|
|
1357
|
+
selectedValues
|
|
1349
1358
|
});
|
|
1350
1359
|
filterExpressions.push(expr);
|
|
1351
1360
|
}
|
|
@@ -1424,9 +1433,9 @@ const queryParamsTemplate = {
|
|
|
1424
1433
|
}) => {
|
|
1425
1434
|
var _getFacet;
|
|
1426
1435
|
|
|
1427
|
-
return (_getFacet = getFacet(state, facet, context)) === null || _getFacet === void 0 ? void 0 : _getFacet.projectId;
|
|
1436
|
+
return ((_getFacet = getFacet(state, facet, context)) === null || _getFacet === void 0 ? void 0 : _getFacet.projectId) || selectCurrentProject(state);
|
|
1428
1437
|
},
|
|
1429
|
-
searchTerm: root => root.context !== Context.minilist || getQueryParameter(root, 'useSearchTerm', false) ? getSearchTerm(root.state) : '',
|
|
1438
|
+
searchTerm: root => root.context !== Context$1.minilist || getQueryParameter(root, 'useSearchTerm', false) ? getSearchTerm(root.state) : '',
|
|
1430
1439
|
selectedFilters: ({
|
|
1431
1440
|
state,
|
|
1432
1441
|
facet,
|
|
@@ -1489,7 +1498,7 @@ const runSearch = (action, state, queryParams) => {
|
|
|
1489
1498
|
stateParams.pageIndex = getPageIndex(ogState, facet, context);
|
|
1490
1499
|
stateParams.searchTerm = getSearchTerm(ogState);
|
|
1491
1500
|
|
|
1492
|
-
if (context === Context.facets && ssr || // context === Context.minilist ||
|
|
1501
|
+
if (context === Context$1.facets && ssr || // context === Context.minilist ||
|
|
1493
1502
|
preload || !facetIsLoaded || filterParamsChanged(action) || defaultLang) {
|
|
1494
1503
|
willRun = true;
|
|
1495
1504
|
} else {
|
|
@@ -1526,7 +1535,7 @@ const filterParamsChanged = (action, state) => {
|
|
|
1526
1535
|
params,
|
|
1527
1536
|
ogState = state
|
|
1528
1537
|
} = action;
|
|
1529
|
-
const selectedFilters = getSelectedFilters(ogState, facet, context);
|
|
1538
|
+
const selectedFilters = getSelectedFilters(ogState, facet, context, 'js');
|
|
1530
1539
|
const paramsChanged = Object.entries(selectedFilters).map(([filterKey, selectedValues]) => {
|
|
1531
1540
|
const inboundValues = params && params[filterKey] && params[filterKey].split(',') || [];
|
|
1532
1541
|
if (!areArraysEqualSets(selectedValues, inboundValues)) return true;
|
|
@@ -1538,11 +1547,12 @@ const filterParamsChanged = (action, state) => {
|
|
|
1538
1547
|
const debugExecuteSearch = (action, state) => {
|
|
1539
1548
|
const [queryParams, runSearch] = generateQueryParams(action, state);
|
|
1540
1549
|
console.log('runSearch', runSearch, 'action', action, 'filterParamsChanged', filterParamsChanged(action, state), 'getIsLoaded(state, context, facet)', getIsLoaded(state, action.context, action.facet));
|
|
1541
|
-
const stateParams = getQueryParams(action.ogState || state, action.facet, action.context)
|
|
1542
|
-
|
|
1543
|
-
|
|
1550
|
+
const stateParams = { ...getQueryParams(action.ogState || state, action.facet, action.context),
|
|
1551
|
+
pageIndex: getPageIndex(action.ogState || state, action.facet, action.context),
|
|
1552
|
+
searchTerm: getSearchTerm(action.ogState || state)
|
|
1553
|
+
};
|
|
1544
1554
|
console.log(stateParams, queryParams);
|
|
1545
|
-
console.log('getSelectedFilters', getSelectedFilters(action.ogState || state, action.facet, action.context), 'params', action.params);
|
|
1555
|
+
console.log('getSelectedFilters', getSelectedFilters(action.ogState || state, action.facet, action.context, 'js'), 'params', action.params);
|
|
1546
1556
|
};
|
|
1547
1557
|
|
|
1548
1558
|
// Base mapping, fields that are the same across all mappings
|
|
@@ -1570,9 +1580,9 @@ const mapEntriesToFilterItems = entries => {
|
|
|
1570
1580
|
});
|
|
1571
1581
|
};
|
|
1572
1582
|
|
|
1573
|
-
const searchSagas = [takeEvery(CLEAR_FILTERS, clearFilters
|
|
1583
|
+
const searchSagas = [takeEvery(CLEAR_FILTERS, clearFilters), takeEvery(DO_SEARCH, doSearch), takeEvery(SET_ROUTE_FILTERS, loadFilters), takeEvery(SET_SEARCH_ENTRIES, preloadOtherFacets), takeEvery(UPDATE_CURRENT_FACET, updateCurrentFacet), takeEvery(UPDATE_CURRENT_TAB, updateCurrentTab), takeEvery(UPDATE_PAGE_INDEX, updatePageIndex), takeEvery(UPDATE_SEARCH_TERM, updateSearchTerm), takeEvery(UPDATE_SORT_ORDER, updateSortOrder), takeEvery(UPDATE_SELECTED_FILTERS, applySearchFilter)];
|
|
1574
1584
|
|
|
1575
|
-
const toJS
|
|
1585
|
+
const toJS = obj => obj && 'toJS' in obj && typeof obj.toJS === 'function' ? obj.toJS() : obj;
|
|
1576
1586
|
|
|
1577
1587
|
function* setRouteFilters(action) {
|
|
1578
1588
|
const {
|
|
@@ -1582,8 +1592,8 @@ function* setRouteFilters(action) {
|
|
|
1582
1592
|
defaultLang,
|
|
1583
1593
|
debug
|
|
1584
1594
|
} = action;
|
|
1585
|
-
const context = listingType ? Context.listings : Context.facets;
|
|
1586
|
-
const state = toJS
|
|
1595
|
+
const context = listingType ? Context$1.listings : Context$1.facets;
|
|
1596
|
+
const state = toJS(yield select());
|
|
1587
1597
|
const ssr = getIsSsr(state); // Get current facet from params or state
|
|
1588
1598
|
|
|
1589
1599
|
let currentFacet = params && params.facet || listingType; // Pick the default facet from initialState
|
|
@@ -1613,7 +1623,7 @@ function* setRouteFilters(action) {
|
|
|
1613
1623
|
});
|
|
1614
1624
|
}
|
|
1615
1625
|
function* doSearch(action) {
|
|
1616
|
-
const state = toJS
|
|
1626
|
+
const state = toJS(yield select());
|
|
1617
1627
|
|
|
1618
1628
|
if (action.config) {
|
|
1619
1629
|
// If the action contains a config object, we can add this to the
|
|
@@ -1746,9 +1756,9 @@ function* ensureSearch(action) {
|
|
|
1746
1756
|
debug
|
|
1747
1757
|
});
|
|
1748
1758
|
}
|
|
1749
|
-
} catch (error
|
|
1759
|
+
} catch (error) {
|
|
1750
1760
|
// eslint-disable-next-line import/namespace
|
|
1751
|
-
error(...['Error running search saga:', error
|
|
1761
|
+
log.error(...['Error running search saga:', error, error.stack]);
|
|
1752
1762
|
}
|
|
1753
1763
|
}
|
|
1754
1764
|
|
|
@@ -1797,9 +1807,9 @@ function* executeSearch(action) {
|
|
|
1797
1807
|
};
|
|
1798
1808
|
const nextAction = mapJson(createStateFrom, facetTemplate);
|
|
1799
1809
|
yield put(nextAction);
|
|
1800
|
-
} catch (error
|
|
1810
|
+
} catch (error) {
|
|
1801
1811
|
// eslint-disable-next-line import/namespace
|
|
1802
|
-
error(...['Error running search saga:', error
|
|
1812
|
+
log.error(...['Error running search saga:', error, error.stack]);
|
|
1803
1813
|
}
|
|
1804
1814
|
}
|
|
1805
1815
|
|
|
@@ -1813,7 +1823,7 @@ function* preloadOtherFacets(action) {
|
|
|
1813
1823
|
const state = yield select();
|
|
1814
1824
|
const currentFacet = getCurrentFacet(state);
|
|
1815
1825
|
|
|
1816
|
-
if (!preload && facet === currentFacet && context !== Context.listings) {
|
|
1826
|
+
if (!preload && facet === currentFacet && context !== Context$1.listings) {
|
|
1817
1827
|
const allFacets = getFacets(state, 'js');
|
|
1818
1828
|
const otherFacets = Object.keys(allFacets).filter(f => f !== currentFacet);
|
|
1819
1829
|
yield all(otherFacets.map((preloadFacet = '') => {
|
|
@@ -1833,7 +1843,7 @@ function* preloadOtherFacets(action) {
|
|
|
1833
1843
|
}
|
|
1834
1844
|
}
|
|
1835
1845
|
|
|
1836
|
-
function* updateCurrentTab
|
|
1846
|
+
function* updateCurrentTab(action) {
|
|
1837
1847
|
const {
|
|
1838
1848
|
id,
|
|
1839
1849
|
mappers
|
|
@@ -1852,10 +1862,10 @@ function* updateCurrentTab$1(action) {
|
|
|
1852
1862
|
|
|
1853
1863
|
|
|
1854
1864
|
if (!nextFacet) nextFacet = Object.entries(facets).filter(([, f]) => f.tabId === id)[0][0];
|
|
1855
|
-
yield put(withMappers(updateCurrentFacet(nextFacet), mappers));
|
|
1865
|
+
yield put(withMappers(updateCurrentFacet$1(nextFacet), mappers));
|
|
1856
1866
|
}
|
|
1857
1867
|
|
|
1858
|
-
function* clearFilters
|
|
1868
|
+
function* clearFilters(action) {
|
|
1859
1869
|
const {
|
|
1860
1870
|
mappers
|
|
1861
1871
|
} = action;
|
|
@@ -1863,7 +1873,7 @@ function* clearFilters$1(action) {
|
|
|
1863
1873
|
yield put(navigate(uri));
|
|
1864
1874
|
}
|
|
1865
1875
|
|
|
1866
|
-
function* updateCurrentFacet
|
|
1876
|
+
function* updateCurrentFacet(action) {
|
|
1867
1877
|
const {
|
|
1868
1878
|
facet,
|
|
1869
1879
|
mappers
|
|
@@ -1876,7 +1886,7 @@ function* updateCurrentFacet$1(action) {
|
|
|
1876
1886
|
yield put(navigate(uri));
|
|
1877
1887
|
}
|
|
1878
1888
|
|
|
1879
|
-
function* updateSearchTerm
|
|
1889
|
+
function* updateSearchTerm(action) {
|
|
1880
1890
|
const {
|
|
1881
1891
|
term,
|
|
1882
1892
|
mappers
|
|
@@ -1887,7 +1897,7 @@ function* updateSearchTerm$1(action) {
|
|
|
1887
1897
|
yield put(navigate(uri));
|
|
1888
1898
|
}
|
|
1889
1899
|
|
|
1890
|
-
function* updateSortOrder
|
|
1900
|
+
function* updateSortOrder(action) {
|
|
1891
1901
|
const {
|
|
1892
1902
|
orderBy,
|
|
1893
1903
|
facet,
|
|
@@ -1900,7 +1910,7 @@ function* updateSortOrder$1(action) {
|
|
|
1900
1910
|
yield put(navigate(uri));
|
|
1901
1911
|
}
|
|
1902
1912
|
|
|
1903
|
-
function* updatePageIndex
|
|
1913
|
+
function* updatePageIndex(action) {
|
|
1904
1914
|
const {
|
|
1905
1915
|
pageIndex,
|
|
1906
1916
|
mappers
|
|
@@ -1939,11 +1949,11 @@ function* buildUri({
|
|
|
1939
1949
|
}
|
|
1940
1950
|
|
|
1941
1951
|
const makeSelectMinilistProps = () => createSelector(state => state, (_, id) => id, (state, id) => ({
|
|
1942
|
-
facet: getFacet(state, id, Context.minilist, 'js'),
|
|
1943
|
-
filters: getFilters(state, id, Context.minilist, 'js'),
|
|
1944
|
-
isLoading: getIsLoading(state, Context.minilist, id),
|
|
1945
|
-
pagingInfo: getPaging(state, id, Context.minilist, 'js'),
|
|
1946
|
-
results: getResults(state, id, Context.minilist, 'js'),
|
|
1952
|
+
facet: getFacet(state, id, Context$1.minilist, 'js'),
|
|
1953
|
+
filters: getFilters(state, id, Context$1.minilist, 'js'),
|
|
1954
|
+
isLoading: getIsLoading(state, Context$1.minilist, id),
|
|
1955
|
+
pagingInfo: getPaging(state, id, Context$1.minilist, 'js'),
|
|
1956
|
+
results: getResults(state, id, Context$1.minilist, 'js'),
|
|
1947
1957
|
searchTerm: getSearchTerm(state)
|
|
1948
1958
|
}));
|
|
1949
1959
|
|
|
@@ -1981,7 +1991,7 @@ const useMinilist = ({
|
|
|
1981
1991
|
if (id && (mapper || mappers && mappers.results)) {
|
|
1982
1992
|
dispatch(triggerSearch({
|
|
1983
1993
|
config,
|
|
1984
|
-
context: Context.minilist,
|
|
1994
|
+
context: Context$1.minilist,
|
|
1985
1995
|
defaultLang,
|
|
1986
1996
|
facet: id,
|
|
1987
1997
|
mapper,
|
|
@@ -2196,9 +2206,9 @@ var reducers = (config => {
|
|
|
2196
2206
|
// Add facets from SearchConfig to initialState
|
|
2197
2207
|
const initState = { ...initialState,
|
|
2198
2208
|
tabs: config.tabs,
|
|
2199
|
-
facets: generateSearchFacets(Context.facets, config),
|
|
2200
|
-
listings: generateSearchFacets(Context.listings, config),
|
|
2201
|
-
minilist: generateSearchFacets(Context.minilist, config)
|
|
2209
|
+
facets: generateSearchFacets(Context$1.facets, config),
|
|
2210
|
+
listings: generateSearchFacets(Context$1.listings, config),
|
|
2211
|
+
minilist: generateSearchFacets(Context$1.minilist, config)
|
|
2202
2212
|
};
|
|
2203
2213
|
return produce((state = initState, action) => {
|
|
2204
2214
|
const context = state.context;
|
|
@@ -2325,7 +2335,7 @@ var reducers = (config => {
|
|
|
2325
2335
|
}));
|
|
2326
2336
|
state.context = context;
|
|
2327
2337
|
state[context] = nextFacets;
|
|
2328
|
-
state[action.context === Context.facets ? 'currentFacet' : 'currentListing'] = facet;
|
|
2338
|
+
state[action.context === Context$1.facets ? 'currentFacet' : 'currentListing'] = facet;
|
|
2329
2339
|
state.term = term;
|
|
2330
2340
|
state.tabs[tabId].currentFacet = facet;
|
|
2331
2341
|
state[context][facet].pagingInfo.pageIndex = Number(pageIndex) - 1 || (state[context][facet].queryParams.loadMorePaging ? state[context][facet].pagingInfo.pageIndex || 0 : 0);
|
|
@@ -2358,9 +2368,9 @@ var reducers = (config => {
|
|
|
2358
2368
|
isCurrentFacet: true
|
|
2359
2369
|
}, state);
|
|
2360
2370
|
const term = action === null || action === void 0 ? void 0 : (_action$params = action.params) === null || _action$params === void 0 ? void 0 : _action$params.term;
|
|
2361
|
-
const useSearchTerm = state[action.context || Context.minilist][action.facet].queryParams.useSearchTerm || false;
|
|
2362
|
-
state[action.context || Context.minilist][action.facet].filters = filters;
|
|
2363
|
-
state[action.context || Context.minilist][action.facet].queryParams.excludeIds = action.excludeIds;
|
|
2371
|
+
const useSearchTerm = state[action.context || Context$1.minilist][action.facet].queryParams.useSearchTerm || false;
|
|
2372
|
+
state[action.context || Context$1.minilist][action.facet].filters = filters;
|
|
2373
|
+
state[action.context || Context$1.minilist][action.facet].queryParams.excludeIds = action.excludeIds;
|
|
2364
2374
|
state.term = useSearchTerm ? term : state.term;
|
|
2365
2375
|
state.config.ssr = typeof window === 'undefined';
|
|
2366
2376
|
return;
|
|
@@ -2433,11 +2443,11 @@ var reducers = (config => {
|
|
|
2433
2443
|
});
|
|
2434
2444
|
|
|
2435
2445
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
2436
|
-
const Context
|
|
2446
|
+
const Context = {
|
|
2437
2447
|
facets: 'facets',
|
|
2438
2448
|
listings: 'listings',
|
|
2439
2449
|
minilist: 'minilist'
|
|
2440
2450
|
};
|
|
2441
2451
|
|
|
2442
|
-
export { Context
|
|
2452
|
+
export { Context, actions, doSearch, queries, reducers as reducer, searchSagas as sagas, schema, selectors, setRouteFilters, types, useMinilist, withListing, withSearch };
|
|
2443
2453
|
//# sourceMappingURL=search.js.map
|