@zengenti/contensis-react-base 3.0.0-beta.4 → 3.0.0-beta.43
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-2ff001f6.js} +139 -124
- package/cjs/App-2ff001f6.js.map +1 -0
- package/cjs/{RouteLoader-282c03ab.js → RouteLoader-2ed14766.js} +44 -30
- package/cjs/RouteLoader-2ed14766.js.map +1 -0
- package/cjs/ToJs-09204afd.js +129 -0
- package/cjs/ToJs-09204afd.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 +46 -49
- 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-d67b82aa.js} +113 -79
- package/cjs/login-d67b82aa.js.map +1 -0
- package/cjs/{reducers-fde41d6b.js → reducers-3a4f8971.js} +26 -25
- package/cjs/reducers-3a4f8971.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 +418 -256
- 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 +32 -23
- package/cjs/user.js.map +1 -1
- package/cjs/util.js +49 -46
- package/cjs/util.js.map +1 -1
- package/cjs/{version-f061e409.js → version-951bc80c.js} +58 -52
- package/cjs/version-951bc80c.js.map +1 -0
- package/cjs/{version-0c190929.js → version-dcfdafd9.js} +5 -5
- package/cjs/{version-0c190929.js.map → version-dcfdafd9.js.map} +1 -1
- package/esm/{App-122f28a3.js → App-7b3aee16.js} +120 -124
- package/esm/App-7b3aee16.js.map +1 -0
- package/esm/{RouteLoader-c2faac87.js → RouteLoader-d4b4d320.js} +37 -23
- package/esm/RouteLoader-d4b4d320.js.map +1 -0
- package/esm/ToJs-2627ce21.js +99 -0
- package/esm/ToJs-2627ce21.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 +28 -31
- 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-f6dfbe1b.js} +97 -60
- package/esm/login-f6dfbe1b.js.map +1 -0
- package/esm/{reducers-d6c0edb1.js → reducers-8e5d6232.js} +26 -25
- package/esm/reducers-8e5d6232.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 +387 -244
- 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 +31 -22
- package/esm/user.js.map +1 -1
- package/esm/util.js +18 -11
- package/esm/util.js.map +1 -1
- package/esm/version-696796d7.js +15 -0
- package/esm/{version-59c8f9be.js.map → version-696796d7.js.map} +1 -1
- package/esm/{version-cb9cd09d.js → version-b2ca1dab.js} +38 -31
- package/esm/version-b2ca1dab.js.map +1 -0
- package/models/redux/appstate.d.ts +5 -10
- 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/routing/routes.d.ts +3 -2
- package/models/routing/util/expressions.d.ts +3 -2
- package/models/routing/util/queries.d.ts +1 -1
- package/models/search/containers/withListing.d.ts +1 -1
- package/models/search/containers/withSearch.d.ts +1 -1
- package/models/search/hooks/useListing.hook.d.ts +3 -0
- package/models/search/hooks/useMinilist.hook.d.ts +2 -9
- package/models/search/index.d.ts +1 -0
- package/models/search/models/Queries.d.ts +8 -5
- package/models/search/models/Search.d.ts +58 -26
- package/models/search/models/SearchActions.d.ts +4 -3
- package/models/search/models/SearchProps.d.ts +25 -2
- package/models/search/models/SearchState.d.ts +5 -1
- package/models/search/models/index.d.ts +2 -1
- package/models/search/redux/actions.d.ts +2 -1
- package/models/search/redux/reducers.d.ts +230 -314
- package/models/search/redux/sagas.d.ts +5 -5
- package/models/search/redux/selectors.d.ts +5 -10
- package/models/search/search/expressions.d.ts +2 -6
- package/models/search/transformations/entry-to-filteritem.mapper.d.ts +2 -1
- 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/search/transformations/index.d.ts +3 -0
- package/models/search/transformations/state-to-searchuri.d.ts +2 -13
- package/models/server/util/headers.d.ts +3 -2
- package/models/testImmer/redux/reducer.d.ts +1 -7
- package/models/user/components/Login.d.ts +1 -2
- package/models/user/components/LoginForm.d.ts +1 -2
- 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 +9 -45
- package/models/user/hooks/useRegistration.d.ts +4 -4
- package/models/user/redux/reducers.d.ts +5 -32
- package/models/user/redux/sagas/login.d.ts +11 -8
- package/models/user/redux/selectors.d.ts +33 -71
- package/models/user/util/LoginHelper.class.d.ts +4 -3
- package/models/util/json-mapper.d.ts +9 -3
- package/models/util/merge.d.ts +1 -0
- package/package-lock.json +2006 -4796
- package/package.json +47 -48
- 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/models/server/features/caching/cacheHashing.d.ts +0 -1
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,43 +121,44 @@ 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
|
|
151
151
|
};
|
|
152
152
|
};
|
|
153
|
-
const updateSelectedFilters = (filter, key) => {
|
|
153
|
+
const updateSelectedFilters = (filter, key, isUnknownItem = false) => {
|
|
154
154
|
return {
|
|
155
155
|
type: UPDATE_SELECTED_FILTERS,
|
|
156
156
|
filter,
|
|
157
|
-
key
|
|
157
|
+
key,
|
|
158
|
+
isUnknownItem
|
|
158
159
|
};
|
|
159
160
|
};
|
|
160
|
-
const updateSortOrder = (orderBy, facet) => {
|
|
161
|
+
const updateSortOrder$1 = (orderBy, facet) => {
|
|
161
162
|
return {
|
|
162
163
|
type: UPDATE_SORT_ORDER,
|
|
163
164
|
orderBy,
|
|
@@ -171,22 +172,22 @@ var actions = /*#__PURE__*/Object.freeze({
|
|
|
171
172
|
triggerSearch: triggerSearch,
|
|
172
173
|
initListing: initListing,
|
|
173
174
|
navigate: navigate,
|
|
174
|
-
clearFilters: clearFilters,
|
|
175
|
-
updatePageIndex: updatePageIndex,
|
|
176
|
-
updateCurrentFacet: updateCurrentFacet,
|
|
177
|
-
updateCurrentTab: updateCurrentTab,
|
|
178
|
-
updateSearchTerm: updateSearchTerm,
|
|
175
|
+
clearFilters: clearFilters$1,
|
|
176
|
+
updatePageIndex: updatePageIndex$1,
|
|
177
|
+
updateCurrentFacet: updateCurrentFacet$1,
|
|
178
|
+
updateCurrentTab: updateCurrentTab$1,
|
|
179
|
+
updateSearchTerm: updateSearchTerm$1,
|
|
179
180
|
updateSelectedFilters: updateSelectedFilters,
|
|
180
|
-
updateSortOrder: updateSortOrder
|
|
181
|
+
updateSortOrder: updateSortOrder$1
|
|
181
182
|
});
|
|
182
183
|
|
|
183
|
-
let Context; // export type Context = 'facets' | 'listings' | 'minilist';
|
|
184
|
+
let Context$1; // export type Context = 'facets' | 'listings' | 'minilist';
|
|
184
185
|
|
|
185
186
|
(function (Context) {
|
|
186
187
|
Context["facets"] = "facets";
|
|
187
188
|
Context["listings"] = "listings";
|
|
188
189
|
Context["minilist"] = "minilist";
|
|
189
|
-
})(Context || (Context = {}));
|
|
190
|
+
})(Context$1 || (Context$1 = {}));
|
|
190
191
|
|
|
191
192
|
// or replace with a stub function for non-immutable gets
|
|
192
193
|
|
|
@@ -217,12 +218,12 @@ const getImmutableOrJS = (state, stateKey, fallbackValue, returnType = globalThi
|
|
|
217
218
|
return result;
|
|
218
219
|
};
|
|
219
220
|
|
|
220
|
-
const getSearchContext = state => getImmutableOrJS(state, ['search', 'context'], Context.facets);
|
|
221
|
-
const getCurrent = (state, context = Context.facets) => context === Context.facets ? getCurrentFacet(state) : getCurrentListing(state);
|
|
221
|
+
const getSearchContext = state => getImmutableOrJS(state, ['search', 'context'], Context$1.facets);
|
|
222
|
+
const getCurrent$1 = (state, context = Context$1.facets) => context === Context$1.facets ? getCurrentFacet(state) : getCurrentListing(state);
|
|
222
223
|
const getCurrentFacet = state => getImmutableOrJS(state, ['search', 'currentFacet']);
|
|
223
224
|
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);
|
|
225
|
+
const getCurrentTab = state => getImmutableOrJS(state, ['search', Context$1.facets, getCurrentFacet(state), 'tabId'], 0);
|
|
226
|
+
const getFacets = (state, returnType) => getImmutableOrJS(state, ['search', Context$1.facets], {}, returnType);
|
|
226
227
|
const getTabFacets = state => Object.fromEntries(Object.entries(getFacets(state, 'js')).filter(([key]) => getImmutableOrJS(getFacets(state), [key, 'tabId'], 0) === getCurrentTab(state)));
|
|
227
228
|
const getFacetTitles = state => Object.entries(getFacets(state, 'js')).map(([key, facet = {}]) => {
|
|
228
229
|
var _facet$pagingInfo;
|
|
@@ -233,19 +234,19 @@ const getFacetTitles = state => Object.entries(getFacets(state, 'js')).map(([key
|
|
|
233
234
|
totalCount: (_facet$pagingInfo = facet.pagingInfo) === null || _facet$pagingInfo === void 0 ? void 0 : _facet$pagingInfo.totalCount
|
|
234
235
|
};
|
|
235
236
|
});
|
|
236
|
-
const getFacet = (state, facetName = '', context = Context.facets, returnType) => {
|
|
237
|
+
const getFacet = (state, facetName = '', context = Context$1.facets, returnType) => {
|
|
237
238
|
const currentFacet = facetName || getCurrentFacet(state);
|
|
238
239
|
return getImmutableOrJS(state, ['search', context, currentFacet], {}, returnType);
|
|
239
240
|
};
|
|
240
|
-
const getListing = (state, listing = '') => {
|
|
241
|
+
const getListing$1 = (state, listing = '') => {
|
|
241
242
|
const currentListing = listing || getCurrentListing(state);
|
|
242
|
-
return getImmutableOrJS(state, ['search', Context.listings, currentListing], {});
|
|
243
|
+
return getImmutableOrJS(state, ['search', Context$1.listings, currentListing], {});
|
|
243
244
|
};
|
|
244
|
-
const getFilters = (state, facet, context = Context.facets, returnType) => {
|
|
245
|
-
return getImmutableOrJS(state, ['search', context, facet || getCurrent(state, context), 'filters'], {}, returnType);
|
|
245
|
+
const getFilters = (state, facet, context = Context$1.facets, returnType) => {
|
|
246
|
+
return getImmutableOrJS(state, ['search', context, facet || getCurrent$1(state, context), 'filters'], {}, returnType);
|
|
246
247
|
};
|
|
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) => {
|
|
248
|
+
const getRenderableFilters$1 = (state, facet = '', context = Context$1.facets) => Object.fromEntries(Object.entries(getFilters(state, facet, context, 'js')).filter(([, f = {}]) => typeof f.renderable !== 'boolean' ? true : f.renderable));
|
|
249
|
+
const getFiltersToLoad = (state, facet, context = Context$1.facets, returnType) => {
|
|
249
250
|
const filters = getFilters(state, facet, context, returnType);
|
|
250
251
|
const loadedFilters = Object.entries(filters).map(([key, f = {}]) => [key, (f.items || []).filter(i => {
|
|
251
252
|
const title = i === null || i === void 0 ? void 0 : i.title;
|
|
@@ -254,68 +255,68 @@ const getFiltersToLoad = (state, facet, context = Context.facets, returnType) =>
|
|
|
254
255
|
return loadedFilters.map(([filterKey, isLoaded]) => !isLoaded ? filterKey : null).filter(f => !!f);
|
|
255
256
|
}; // We lowercase the filter key unless it's an ISO date string where the T must be uppercase
|
|
256
257
|
|
|
257
|
-
const getSelectedFilters = (state, facet = '', context = Context.facets, returnType) => {
|
|
258
|
+
const getSelectedFilters = (state, facet = '', context = Context$1.facets, returnType) => {
|
|
258
259
|
const filters = getFilters(state, facet, context, 'js');
|
|
259
260
|
const isoDateRegex = RegExp(/\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d/);
|
|
260
261
|
const selectedFilters = Object.fromEntries(Object.entries(filters).map(([key, filter = {}]) => [key, (filter.items || []).filter(item => !!(item.isSelected || false)).map(item => {
|
|
261
262
|
const key = (item === null || item === void 0 ? void 0 : item.key) || '';
|
|
262
263
|
const isIsoDate = isoDateRegex.test(key);
|
|
263
|
-
return isIsoDate ? key : key.toLowerCase();
|
|
264
|
+
return isIsoDate ? key : typeof key.toLowerCase !== 'undefined' ? key.toLowerCase() : key;
|
|
264
265
|
})]));
|
|
265
266
|
const fromJS = makeFromJS(returnType);
|
|
266
267
|
return fromJS(selectedFilters);
|
|
267
268
|
};
|
|
268
|
-
const getResults = (state, current = '', context = Context.facets, returnType) => {
|
|
269
|
-
return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'results'], [], returnType);
|
|
269
|
+
const getResults$1 = (state, current = '', context = Context$1.facets, returnType) => {
|
|
270
|
+
return getImmutableOrJS(state, ['search', context, current || getCurrent$1(state, context), 'results'], [], returnType);
|
|
270
271
|
};
|
|
271
|
-
const getIsInternalPaging = (state, current, context = Context.facets) => {
|
|
272
|
-
return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'queryParams', 'internalPaging'], false);
|
|
272
|
+
const getIsInternalPaging = (state, current, context = Context$1.facets) => {
|
|
273
|
+
return getImmutableOrJS(state, ['search', context, current || getCurrent$1(state, context), 'queryParams', 'internalPaging'], false);
|
|
273
274
|
};
|
|
274
|
-
const getIsLoaded = (state, context = Context.facets, facet) => {
|
|
275
|
-
return !!getImmutableOrJS(state, ['search', context, facet || getCurrent(state, context), 'queryDuration'], 0);
|
|
275
|
+
const getIsLoaded = (state, context = Context$1.facets, facet) => {
|
|
276
|
+
return !!getImmutableOrJS(state, ['search', context, facet || getCurrent$1(state, context), 'queryDuration'], 0);
|
|
276
277
|
};
|
|
277
|
-
const getIsLoading = (state, context = Context.facets, facet) => {
|
|
278
|
-
return getImmutableOrJS(state, ['search', context, facet || getCurrent(state, context), 'entries', 'isLoading']);
|
|
278
|
+
const getIsLoading$1 = (state, context = Context$1.facets, facet) => {
|
|
279
|
+
return getImmutableOrJS(state, ['search', context, facet || getCurrent$1(state, context), 'entries', 'isLoading']);
|
|
279
280
|
};
|
|
280
281
|
const getIsSsr = state => getImmutableOrJS(state, ['search', 'config', 'ssr'], false);
|
|
281
|
-
const getFeaturedResults = (state, current = '', context = Context.facets) => {
|
|
282
|
-
return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'featuredResults'], []);
|
|
282
|
+
const getFeaturedResults$1 = (state, current = '', context = Context$1.facets) => {
|
|
283
|
+
return getImmutableOrJS(state, ['search', context, current || getCurrent$1(state, context), 'featuredResults'], []);
|
|
283
284
|
};
|
|
284
|
-
const getPaging = (state, current = '', context = Context.facets, returnType) => {
|
|
285
|
-
return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'pagingInfo'], {}, returnType);
|
|
285
|
+
const getPaging$1 = (state, current = '', context = Context$1.facets, returnType) => {
|
|
286
|
+
return getImmutableOrJS(state, ['search', context, current || getCurrent$1(state, context), 'pagingInfo'], {}, returnType);
|
|
286
287
|
};
|
|
287
|
-
const getPageIndex = (state, current = '', context = Context.facets) => {
|
|
288
|
-
return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'pagingInfo', 'pageIndex']);
|
|
288
|
+
const getPageIndex$1 = (state, current = '', context = Context$1.facets) => {
|
|
289
|
+
return getImmutableOrJS(state, ['search', context, current || getCurrent$1(state, context), 'pagingInfo', 'pageIndex']);
|
|
289
290
|
};
|
|
290
|
-
const getPrevPageIndex = (state, current = '', context = Context.facets) => {
|
|
291
|
-
return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'pagingInfo', 'prevPageIndex']);
|
|
291
|
+
const getPrevPageIndex = (state, current = '', context = Context$1.facets) => {
|
|
292
|
+
return getImmutableOrJS(state, ['search', context, current || getCurrent$1(state, context), 'pagingInfo', 'prevPageIndex']);
|
|
292
293
|
};
|
|
293
|
-
const getPageIsLoading = (state, current = '', context = Context.facets) => {
|
|
294
|
-
return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'pagingInfo', 'isLoading']);
|
|
294
|
+
const getPageIsLoading$1 = (state, current = '', context = Context$1.facets) => {
|
|
295
|
+
return getImmutableOrJS(state, ['search', context, current || getCurrent$1(state, context), 'pagingInfo', 'isLoading']);
|
|
295
296
|
};
|
|
296
|
-
const getPagesLoaded = (state, current = '', context = Context.facets) => {
|
|
297
|
-
return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'pagingInfo', 'pagesLoaded'], [], 'js');
|
|
297
|
+
const getPagesLoaded = (state, current = '', context = Context$1.facets) => {
|
|
298
|
+
return getImmutableOrJS(state, ['search', context, current || getCurrent$1(state, context), 'pagingInfo', 'pagesLoaded'], [], 'js');
|
|
298
299
|
};
|
|
299
|
-
const getTotalCount = (state, current = '', context = Context.facets) => {
|
|
300
|
-
return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'pagingInfo', 'totalCount']);
|
|
300
|
+
const getTotalCount = (state, current = '', context = Context$1.facets) => {
|
|
301
|
+
return getImmutableOrJS(state, ['search', context, current || getCurrent$1(state, context), 'pagingInfo', 'totalCount']);
|
|
301
302
|
};
|
|
302
|
-
const getSearchTerm = state => getImmutableOrJS(state, ['search', 'term']);
|
|
303
|
+
const getSearchTerm$1 = state => getImmutableOrJS(state, ['search', 'term']);
|
|
303
304
|
const getSearchTabs = (state, returnType) => getImmutableOrJS(state, ['search', 'tabs'], [], returnType);
|
|
304
|
-
const getQueryParams = (state, current = '', context = Context.facets) => {
|
|
305
|
-
return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'queryParams'], {}, 'js');
|
|
305
|
+
const getQueryParams = (state, current = '', context = Context$1.facets) => {
|
|
306
|
+
return getImmutableOrJS(state, ['search', context, current || getCurrent$1(state, context), 'queryParams'], {}, 'js');
|
|
306
307
|
};
|
|
307
|
-
const getQueryParameter = ({
|
|
308
|
+
const getQueryParameter$1 = ({
|
|
308
309
|
state,
|
|
309
310
|
facet,
|
|
310
|
-
context = Context.facets
|
|
311
|
+
context = Context$1.facets
|
|
311
312
|
}, key, ifnull = null) => {
|
|
312
313
|
return getImmutableOrJS(getQueryParams(state, facet, context), key, ifnull, 'js');
|
|
313
314
|
};
|
|
314
|
-
const getCustomApi = (state, current, context = Context.facets, returnType) => {
|
|
315
|
-
return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'customApi'], null, returnType);
|
|
315
|
+
const getCustomApi = (state, current, context = Context$1.facets, returnType) => {
|
|
316
|
+
return getImmutableOrJS(state, ['search', context, current || getCurrent$1(state, context), 'customApi'], null, returnType);
|
|
316
317
|
};
|
|
317
|
-
const getCustomEnv = (state, current, context = Context.facets) => {
|
|
318
|
-
return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'env']);
|
|
318
|
+
const getCustomEnv = (state, current, context = Context$1.facets) => {
|
|
319
|
+
return getImmutableOrJS(state, ['search', context, current || getCurrent$1(state, context), 'env']);
|
|
319
320
|
};
|
|
320
321
|
const getTabsAndFacets = (state, returnType) => {
|
|
321
322
|
const tabs = getSearchTabs(state, 'js');
|
|
@@ -330,7 +331,7 @@ const getTabsAndFacets = (state, returnType) => {
|
|
|
330
331
|
return 0;
|
|
331
332
|
}).reduce((a, b) => a + b, 0);
|
|
332
333
|
return { ...tab,
|
|
333
|
-
[Context.facets]: Object.fromEntries(thisTabFacets),
|
|
334
|
+
[Context$1.facets]: Object.fromEntries(thisTabFacets),
|
|
334
335
|
totalCount: thisTabTotal
|
|
335
336
|
};
|
|
336
337
|
});
|
|
@@ -361,69 +362,70 @@ const selectFacets = {
|
|
|
361
362
|
getFacetTitles,
|
|
362
363
|
getFacets,
|
|
363
364
|
getFacetsTotalCount,
|
|
364
|
-
getFeaturedResults,
|
|
365
|
+
getFeaturedResults: getFeaturedResults$1,
|
|
365
366
|
getFilters,
|
|
366
367
|
getFiltersToLoad,
|
|
367
368
|
getIsLoaded,
|
|
368
|
-
getIsLoading,
|
|
369
|
-
getPageIndex,
|
|
370
|
-
getPageIsLoading,
|
|
369
|
+
getIsLoading: getIsLoading$1,
|
|
370
|
+
getPageIndex: getPageIndex$1,
|
|
371
|
+
getPageIsLoading: getPageIsLoading$1,
|
|
371
372
|
getPagesLoaded,
|
|
372
|
-
getPaging,
|
|
373
|
-
getQueryParams: (state, facet) => getQueryParams(state, facet, Context.facets),
|
|
373
|
+
getPaging: getPaging$1,
|
|
374
|
+
getQueryParams: (state, facet) => getQueryParams(state, facet, Context$1.facets),
|
|
374
375
|
getQueryParameter: ({
|
|
375
376
|
state,
|
|
376
377
|
facet
|
|
377
|
-
}, key, ifnull) => getQueryParameter({
|
|
378
|
+
}, key, ifnull) => getQueryParameter$1({
|
|
378
379
|
state,
|
|
379
380
|
facet,
|
|
380
|
-
context: Context.facets
|
|
381
|
+
context: Context$1.facets
|
|
381
382
|
}, key, ifnull),
|
|
382
|
-
getRenderableFilters,
|
|
383
|
-
getResults,
|
|
383
|
+
getRenderableFilters: getRenderableFilters$1,
|
|
384
|
+
getResults: getResults$1,
|
|
384
385
|
getTabFacets,
|
|
385
386
|
getTabsAndFacets,
|
|
386
387
|
getTotalCount,
|
|
387
388
|
getSearchTabs,
|
|
388
|
-
getSearchTerm,
|
|
389
|
+
getSearchTerm: getSearchTerm$1,
|
|
389
390
|
getSearchTotalCount,
|
|
390
391
|
getSelectedFilters
|
|
391
392
|
}; // An exported copy of the relevant selectors pre-scoped to a listing context
|
|
392
393
|
|
|
393
394
|
const selectListing = {
|
|
394
395
|
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),
|
|
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),
|
|
396
|
+
getFeaturedResults: (state, listing = '') => getFeaturedResults$1(state, listing, Context$1.listings),
|
|
397
|
+
getFilters: (state, listing = '') => getFilters(state, listing, Context$1.listings),
|
|
398
|
+
getFiltersToLoad: (state, listing = '') => getFiltersToLoad(state, listing, Context$1.listings),
|
|
399
|
+
getListing: getListing$1,
|
|
400
|
+
getIsLoaded: state => getIsLoaded(state, Context$1.listings),
|
|
401
|
+
getIsLoading: state => getIsLoading$1(state, Context$1.listings),
|
|
402
|
+
getPageIndex: (state, listing = '') => getPageIndex$1(state, listing, Context$1.listings),
|
|
403
|
+
getPaging: (state, listing = '') => getPaging$1(state, listing, Context$1.listings),
|
|
404
|
+
getPageIsLoading: (state, listing = '') => getPageIsLoading$1(state, listing, Context$1.listings),
|
|
405
|
+
getPagesLoaded: (state, listing = '') => getPagesLoaded(state, listing, Context$1.listings),
|
|
406
|
+
getQueryParams: (state, listing = '') => getQueryParams(state, listing, Context$1.listings),
|
|
406
407
|
getQueryParameter: ({
|
|
407
408
|
state,
|
|
408
409
|
facet
|
|
409
|
-
}, key, ifnull) => getQueryParameter({
|
|
410
|
+
}, key, ifnull) => getQueryParameter$1({
|
|
410
411
|
state,
|
|
411
412
|
facet,
|
|
412
|
-
context: Context.listings
|
|
413
|
+
context: Context$1.listings
|
|
413
414
|
}, key, ifnull),
|
|
414
|
-
getRenderableFilters: (state, listing = '') => getRenderableFilters(state, listing, Context.listings),
|
|
415
|
-
getResults: (state, listing = '') => getResults(state, listing, Context.listings),
|
|
416
|
-
getSearchTerm,
|
|
417
|
-
getTotalCount: (state, listing = '') => getTotalCount(state, listing, Context.listings),
|
|
418
|
-
getSelectedFilters: (state, listing = '') => getSelectedFilters(state, listing, Context.listings)
|
|
415
|
+
getRenderableFilters: (state, listing = '') => getRenderableFilters$1(state, listing, Context$1.listings),
|
|
416
|
+
getResults: (state, listing = '') => getResults$1(state, listing, Context$1.listings),
|
|
417
|
+
getSearchTerm: getSearchTerm$1,
|
|
418
|
+
getTotalCount: (state, listing = '') => getTotalCount(state, listing, Context$1.listings),
|
|
419
|
+
getSelectedFilters: (state, listing = '') => getSelectedFilters(state, listing, Context$1.listings)
|
|
419
420
|
};
|
|
420
421
|
const selectCurrentPath = state => getImmutableOrJS(state, ['routing', 'currentPath']);
|
|
422
|
+
const selectCurrentProject = state => getImmutableOrJS(state, ['routing', 'currentProject']);
|
|
421
423
|
const selectVersionStatus = state => getImmutableOrJS(state, ['version', 'contensisVersionStatus']);
|
|
422
424
|
|
|
423
425
|
var selectors = /*#__PURE__*/Object.freeze({
|
|
424
426
|
__proto__: null,
|
|
425
427
|
getSearchContext: getSearchContext,
|
|
426
|
-
getCurrent: getCurrent,
|
|
428
|
+
getCurrent: getCurrent$1,
|
|
427
429
|
getCurrentFacet: getCurrentFacet,
|
|
428
430
|
getCurrentListing: getCurrentListing,
|
|
429
431
|
getCurrentTab: getCurrentTab,
|
|
@@ -431,27 +433,27 @@ var selectors = /*#__PURE__*/Object.freeze({
|
|
|
431
433
|
getTabFacets: getTabFacets,
|
|
432
434
|
getFacetTitles: getFacetTitles,
|
|
433
435
|
getFacet: getFacet,
|
|
434
|
-
getListing: getListing,
|
|
436
|
+
getListing: getListing$1,
|
|
435
437
|
getFilters: getFilters,
|
|
436
|
-
getRenderableFilters: getRenderableFilters,
|
|
438
|
+
getRenderableFilters: getRenderableFilters$1,
|
|
437
439
|
getFiltersToLoad: getFiltersToLoad,
|
|
438
440
|
getSelectedFilters: getSelectedFilters,
|
|
439
|
-
getResults: getResults,
|
|
441
|
+
getResults: getResults$1,
|
|
440
442
|
getIsInternalPaging: getIsInternalPaging,
|
|
441
443
|
getIsLoaded: getIsLoaded,
|
|
442
|
-
getIsLoading: getIsLoading,
|
|
444
|
+
getIsLoading: getIsLoading$1,
|
|
443
445
|
getIsSsr: getIsSsr,
|
|
444
|
-
getFeaturedResults: getFeaturedResults,
|
|
445
|
-
getPaging: getPaging,
|
|
446
|
-
getPageIndex: getPageIndex,
|
|
446
|
+
getFeaturedResults: getFeaturedResults$1,
|
|
447
|
+
getPaging: getPaging$1,
|
|
448
|
+
getPageIndex: getPageIndex$1,
|
|
447
449
|
getPrevPageIndex: getPrevPageIndex,
|
|
448
|
-
getPageIsLoading: getPageIsLoading,
|
|
450
|
+
getPageIsLoading: getPageIsLoading$1,
|
|
449
451
|
getPagesLoaded: getPagesLoaded,
|
|
450
452
|
getTotalCount: getTotalCount,
|
|
451
|
-
getSearchTerm: getSearchTerm,
|
|
453
|
+
getSearchTerm: getSearchTerm$1,
|
|
452
454
|
getSearchTabs: getSearchTabs,
|
|
453
455
|
getQueryParams: getQueryParams,
|
|
454
|
-
getQueryParameter: getQueryParameter,
|
|
456
|
+
getQueryParameter: getQueryParameter$1,
|
|
455
457
|
getCustomApi: getCustomApi,
|
|
456
458
|
getCustomEnv: getCustomEnv,
|
|
457
459
|
getTabsAndFacets: getTabsAndFacets,
|
|
@@ -460,12 +462,12 @@ var selectors = /*#__PURE__*/Object.freeze({
|
|
|
460
462
|
selectFacets: selectFacets,
|
|
461
463
|
selectListing: selectListing,
|
|
462
464
|
selectCurrentPath: selectCurrentPath,
|
|
465
|
+
selectCurrentProject: selectCurrentProject,
|
|
463
466
|
selectVersionStatus: selectVersionStatus
|
|
464
467
|
});
|
|
465
468
|
|
|
466
469
|
// eslint-disable-next-line import/default
|
|
467
470
|
|
|
468
|
-
/* eslint-disable @typescript-eslint/naming-convention */
|
|
469
471
|
const withSearch = mappers => SearchComponent => {
|
|
470
472
|
const Wrapper = props => {
|
|
471
473
|
return /*#__PURE__*/React.createElement(SearchComponent, props);
|
|
@@ -476,22 +478,22 @@ const withSearch = mappers => SearchComponent => {
|
|
|
476
478
|
const mapStateToProps = state => {
|
|
477
479
|
return {
|
|
478
480
|
currentFacet: getCurrentFacet(state),
|
|
479
|
-
currentPageIndex: getPageIndex(state),
|
|
481
|
+
currentPageIndex: getPageIndex$1(state),
|
|
480
482
|
currentTabIndex: getCurrentTab(state),
|
|
481
483
|
facet: getFacet(state),
|
|
482
484
|
facets: getTabFacets(state),
|
|
483
485
|
facetsTotalCount: getFacetsTotalCount(state),
|
|
484
486
|
facetTitles: getFacetTitles(state),
|
|
485
|
-
featuredResults: getFeaturedResults(state),
|
|
486
|
-
filters: getRenderableFilters(state),
|
|
487
|
-
isLoading: getIsLoading(state),
|
|
488
|
-
paging: getPaging(state),
|
|
489
|
-
pageIsLoading: getPageIsLoading(state),
|
|
490
|
-
results: getResults(state),
|
|
487
|
+
featuredResults: getFeaturedResults$1(state),
|
|
488
|
+
filters: getRenderableFilters$1(state),
|
|
489
|
+
isLoading: getIsLoading$1(state),
|
|
490
|
+
paging: getPaging$1(state),
|
|
491
|
+
pageIsLoading: getPageIsLoading$1(state),
|
|
492
|
+
results: getResults$1(state),
|
|
491
493
|
resultsInfo: (mappers === null || mappers === void 0 ? void 0 : mappers.resultsInfo) && mappers.resultsInfo(state),
|
|
492
|
-
searchTerm: getSearchTerm(state),
|
|
494
|
+
searchTerm: getSearchTerm$1(state),
|
|
493
495
|
searchTotalCount: getSearchTotalCount(state),
|
|
494
|
-
sortOrder: getQueryParameter({
|
|
496
|
+
sortOrder: getQueryParameter$1({
|
|
495
497
|
state
|
|
496
498
|
}, 'dynamicOrderBy', []),
|
|
497
499
|
tabsAndFacets: getTabsAndFacets(state),
|
|
@@ -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),
|
|
508
|
-
updateSelectedFilters: (filter, key) => withMappers(updateSelectedFilters(filter, key), mappers),
|
|
509
|
-
updateSortOrder: orderBy => withMappers(updateSortOrder(orderBy), 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),
|
|
510
|
+
updateSelectedFilters: (filter, key, isUnknownItem = false) => withMappers(updateSelectedFilters(filter, key, isUnknownItem), 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),
|
|
559
|
-
updateSelectedFilters: (filter, key) => withMappers(updateSelectedFilters(filter, key), mappers),
|
|
560
|
-
updateSortOrder: orderBy => withMappers(updateSortOrder(orderBy), 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),
|
|
561
|
+
updateSelectedFilters: (filter, key, isUnknownItem = false) => withMappers(updateSelectedFilters(filter, key, isUnknownItem), 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
|
};
|
|
@@ -849,7 +851,7 @@ const fieldExpression = (field, value, operator = 'equalTo', weight) => {
|
|
|
849
851
|
// to generate expressions that are combined with an 'or' operator
|
|
850
852
|
return [Op.or(...field.map(fieldId => fieldExpression(fieldId, value, operator, weight)).flat())];
|
|
851
853
|
if (operator === 'between') return between(field, value);
|
|
852
|
-
if (Array.isArray(value)) return equalToOrIn(field, value, operator);else return !weight ?
|
|
854
|
+
if (Array.isArray(value)) return equalToOrIn(field, value, operator);else return !weight ? equalToOrIn(field, value, operator) : [equalToOrIn(field, value, operator)[0].weight(weight)];
|
|
853
855
|
};
|
|
854
856
|
const contentTypeIdExpression = (contentTypeIds, webpageTemplates, assetTypes) => {
|
|
855
857
|
const expressions = [];
|
|
@@ -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,19 +959,45 @@ 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 => {
|
|
964
|
+
switch (operator) {
|
|
965
|
+
case 'between':
|
|
966
|
+
case 'distanceWithin':
|
|
967
|
+
// Not implemented
|
|
968
|
+
return Op.equalTo(field, innerValue);
|
|
969
|
+
|
|
970
|
+
case 'freeText':
|
|
971
|
+
// TODO: Potentially needs further implementation of new options
|
|
972
|
+
return Op[operator](field, innerValue, false, undefined);
|
|
973
|
+
|
|
974
|
+
default:
|
|
975
|
+
return Op[operator](field, innerValue);
|
|
976
|
+
}
|
|
977
|
+
}))];
|
|
953
978
|
}
|
|
954
979
|
|
|
955
|
-
|
|
980
|
+
switch (operator) {
|
|
981
|
+
case 'between':
|
|
982
|
+
case 'distanceWithin':
|
|
983
|
+
// Not implemented
|
|
984
|
+
return [Op.equalTo(field, value)];
|
|
985
|
+
|
|
986
|
+
case 'freeText':
|
|
987
|
+
// TODO: Potentially needs further implementation of new options
|
|
988
|
+
return [Op[operator](field, value, false, undefined)];
|
|
989
|
+
|
|
990
|
+
default:
|
|
991
|
+
return [Op[operator](field, value)];
|
|
992
|
+
}
|
|
956
993
|
};
|
|
957
994
|
|
|
958
995
|
const between = (field, value) => {
|
|
959
996
|
const handle = betweenValue => {
|
|
960
|
-
const valArr = betweenValue.split('
|
|
997
|
+
const valArr = betweenValue.split('--');
|
|
961
998
|
|
|
962
999
|
if (valArr.length > 1) {
|
|
963
|
-
const [minimum, maximum
|
|
1000
|
+
const [minimum, maximum] = valArr;
|
|
964
1001
|
return Op.between(field, minimum, maximum);
|
|
965
1002
|
} else {
|
|
966
1003
|
// eslint-disable-next-line no-console
|
|
@@ -970,10 +1007,9 @@ const between = (field, value) => {
|
|
|
970
1007
|
};
|
|
971
1008
|
|
|
972
1009
|
if (value.length === 0) return [];
|
|
973
|
-
if (Array.isArray(value)) return [Op.or(...value.map(handle).filter(bc => bc !== false))];
|
|
974
|
-
|
|
1010
|
+
if (Array.isArray(value)) return [Op.or(...value.map(handle).filter(bc => bc !== false))];
|
|
975
1011
|
const op = handle(value);
|
|
976
|
-
return op ? [op] : [];
|
|
1012
|
+
return op ? [op] : [];
|
|
977
1013
|
};
|
|
978
1014
|
/**
|
|
979
1015
|
* Accept HTTP style objects and map them to
|
|
@@ -1016,7 +1052,7 @@ const customWhereExpressions = where => {
|
|
|
1016
1052
|
// the second property inside the clause
|
|
1017
1053
|
|
|
1018
1054
|
if (notIdx === 1) {
|
|
1019
|
-
expression = Op.not(Op[innerOperator](innerField, innerValue));
|
|
1055
|
+
expression = innerOperator === 'between' ? Op.not(Op[innerOperator](innerField, innerValue[0], innerValue[1])) : Op.not(Op[innerOperator](innerField, innerValue));
|
|
1020
1056
|
}
|
|
1021
1057
|
});
|
|
1022
1058
|
}
|
|
@@ -1028,8 +1064,9 @@ const customWhereExpressions = where => {
|
|
|
1028
1064
|
|
|
1029
1065
|
if (idx === 1 && // operator !== 'and' &&
|
|
1030
1066
|
// operator !== 'or' &&
|
|
1031
|
-
operator !== 'between' &&
|
|
1032
|
-
|
|
1067
|
+
// operator !== 'between' &&
|
|
1068
|
+
operator !== 'distanceWithin') {
|
|
1069
|
+
expression = operator === 'freeText' || operator === 'contains' ? Op[operator](field, value) : operator === 'in' ? Op[operator](field, ...value) : operator === 'exists' ? Op[operator](field, value) : operator === 'between' ? Op[operator](field, value[0], value[1]) : Op[operator](field, value);
|
|
1033
1070
|
if (typeof weight === 'number') expression = expression.weight(weight);
|
|
1034
1071
|
}
|
|
1035
1072
|
});
|
|
@@ -1142,7 +1179,7 @@ const searchUriTemplate = {
|
|
|
1142
1179
|
facet,
|
|
1143
1180
|
pageIndex
|
|
1144
1181
|
}) => {
|
|
1145
|
-
const currentFacet = getSearchContext(state) !== Context.listings && (facet || getCurrentFacet(state));
|
|
1182
|
+
const currentFacet = getSearchContext(state) !== Context$1.listings && (facet || getCurrentFacet(state));
|
|
1146
1183
|
const currentPath = selectCurrentPath(state) || '/search';
|
|
1147
1184
|
const newPath = currentFacet ? `${currentPath}/${currentFacet}` : currentPath;
|
|
1148
1185
|
if (pageIndex) return `${newPath}/${pageIndex + 1}`;
|
|
@@ -1159,20 +1196,16 @@ const searchUriTemplate = {
|
|
|
1159
1196
|
|
|
1160
1197
|
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
1198
|
const currentSearch = !term && getImmutableOrJS(state, ['routing', 'location', 'search']);
|
|
1162
|
-
const currentQs = removeEmptyAttributes(
|
|
1199
|
+
const currentQs = removeEmptyAttributes(parse(currentSearch));
|
|
1163
1200
|
if (orderBy) currentQs.orderBy = orderBy;
|
|
1164
|
-
const searchTerm = getSearchTerm(state); //
|
|
1165
|
-
// to build the new Qs.
|
|
1201
|
+
const searchTerm = getSearchTerm$1(state); // Merge the stateFilters with any current qs to build the new qs
|
|
1166
1202
|
|
|
1167
1203
|
const mergedSearch = removeEmptyAttributes({ ...merge(currentQs, stateFilters),
|
|
1168
1204
|
term: searchTerm
|
|
1169
1205
|
});
|
|
1170
|
-
return
|
|
1206
|
+
return stringify(mergedSearch);
|
|
1171
1207
|
},
|
|
1172
|
-
hash:
|
|
1173
|
-
$path: 'state',
|
|
1174
|
-
$formatting: state => getImmutableOrJS(state, ['routing', 'location', 'hash'], '').replace('#', '')
|
|
1175
|
-
}
|
|
1208
|
+
hash: state => getImmutableOrJS(state, ['routing', 'location', 'hash'], '').replace('#', '')
|
|
1176
1209
|
};
|
|
1177
1210
|
|
|
1178
1211
|
const mapStateToSearchUri = params => mapJson(params, searchUriTemplate);
|
|
@@ -1317,14 +1350,15 @@ const filterTemplate = {
|
|
|
1317
1350
|
const filterExpressionMapper = {
|
|
1318
1351
|
// Expression type: so we can identify how to build the query
|
|
1319
1352
|
expressionType: ({
|
|
1320
|
-
|
|
1321
|
-
}) =>
|
|
1353
|
+
contentTypeId
|
|
1354
|
+
}) => contentTypeId ? FilterExpressionTypes.contentType : FilterExpressionTypes.field,
|
|
1322
1355
|
// Key: so we can target the query to a specific field
|
|
1323
|
-
key: '
|
|
1356
|
+
key: 'fieldId',
|
|
1324
1357
|
// Value: so we can filter a specific field by an array of values
|
|
1325
1358
|
// e.g. taxonomy key or contentTypeId array
|
|
1326
|
-
|
|
1327
|
-
|
|
1359
|
+
values: 'selectedValues',
|
|
1360
|
+
fieldOperator: 'fieldOperator',
|
|
1361
|
+
logicOperator: 'logicOperator'
|
|
1328
1362
|
};
|
|
1329
1363
|
|
|
1330
1364
|
const mapFilterToFilterExpression = filter => mapJson(filter, filterExpressionMapper);
|
|
@@ -1334,18 +1368,15 @@ const mapFiltersToFilterExpression = (filters, selectedFilters) => {
|
|
|
1334
1368
|
const filterExpressions = []; // Iterate through the keys in selectedFilters and locate
|
|
1335
1369
|
// the items that are selected and queryable
|
|
1336
1370
|
|
|
1337
|
-
Object.entries(selectedFilters).map(([fkey,
|
|
1371
|
+
Object.entries(selectedFilters).map(([fkey, selectedValues]) => {
|
|
1338
1372
|
const filter = filters[fkey];
|
|
1339
1373
|
|
|
1340
|
-
if (
|
|
1341
|
-
|
|
1374
|
+
if (selectedValues && filter) {
|
|
1375
|
+
// Where we have a value for a selectedFilter
|
|
1342
1376
|
// and a filter is found for the current key
|
|
1343
1377
|
// map the filter to a filterExpression object
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
filter,
|
|
1347
|
-
selectedItems,
|
|
1348
|
-
selectedValue
|
|
1378
|
+
const expr = mapFilterToFilterExpression({ ...filter,
|
|
1379
|
+
selectedValues
|
|
1349
1380
|
});
|
|
1350
1381
|
filterExpressions.push(expr);
|
|
1351
1382
|
}
|
|
@@ -1354,10 +1385,10 @@ const mapFiltersToFilterExpression = (filters, selectedFilters) => {
|
|
|
1354
1385
|
};
|
|
1355
1386
|
|
|
1356
1387
|
const queryParamsTemplate = {
|
|
1357
|
-
assetTypes: root => getQueryParameter(root, 'assetTypes', []),
|
|
1358
|
-
contentTypeIds: root => getQueryParameter(root, 'contentTypeIds', []),
|
|
1359
|
-
customWhere: root => getQueryParameter(root, 'customWhere', []),
|
|
1360
|
-
dynamicOrderBy: root => getQueryParameter(root, 'dynamicOrderBy', []),
|
|
1388
|
+
assetTypes: root => getQueryParameter$1(root, 'assetTypes', []),
|
|
1389
|
+
contentTypeIds: root => getQueryParameter$1(root, 'contentTypeIds', []),
|
|
1390
|
+
customWhere: root => getQueryParameter$1(root, 'customWhere', []),
|
|
1391
|
+
dynamicOrderBy: root => getQueryParameter$1(root, 'dynamicOrderBy', []),
|
|
1361
1392
|
env: ({
|
|
1362
1393
|
state,
|
|
1363
1394
|
facet,
|
|
@@ -1372,8 +1403,8 @@ const queryParamsTemplate = {
|
|
|
1372
1403
|
if (excludeIds) return Array.isArray(excludeIds) ? excludeIds : excludeIds.split(',').map(id => id.trim());
|
|
1373
1404
|
return null;
|
|
1374
1405
|
},
|
|
1375
|
-
featuredResults: root => getQueryParameter(root, 'featuredResults', null),
|
|
1376
|
-
fields: root => getQueryParameter(root, 'fields', []),
|
|
1406
|
+
featuredResults: root => getQueryParameter$1(root, 'featuredResults', null),
|
|
1407
|
+
fields: root => getQueryParameter$1(root, 'fields', []),
|
|
1377
1408
|
filters: ({
|
|
1378
1409
|
state,
|
|
1379
1410
|
facet,
|
|
@@ -1385,28 +1416,28 @@ const queryParamsTemplate = {
|
|
|
1385
1416
|
const filterParams = mapFiltersToFilterExpression(stateFilters, selectedFilters);
|
|
1386
1417
|
return filterParams;
|
|
1387
1418
|
},
|
|
1388
|
-
includeInSearchFields: root => getQueryParameter(root, 'includeInSearch', []),
|
|
1419
|
+
includeInSearchFields: root => getQueryParameter$1(root, 'includeInSearch', []),
|
|
1389
1420
|
internalPageIndex: ({
|
|
1390
1421
|
action,
|
|
1391
1422
|
state
|
|
1392
|
-
}) => getPageIndex(state, '', action.context),
|
|
1393
|
-
internalPaging: root => getQueryParameter(root, 'internalPaging', false),
|
|
1423
|
+
}) => getPageIndex$1(state, '', action.context),
|
|
1424
|
+
internalPaging: root => getQueryParameter$1(root, 'internalPaging', false),
|
|
1394
1425
|
languages: ({
|
|
1395
1426
|
action
|
|
1396
1427
|
}) => action.defaultLang ? [action.defaultLang] : [],
|
|
1397
|
-
linkDepth: root => getQueryParameter(root, 'linkDepth', 0),
|
|
1398
|
-
loadMorePaging: root => getQueryParameter(root, 'loadMorePaging', false),
|
|
1399
|
-
orderBy: root => getQueryParameter(root, 'orderBy', []),
|
|
1428
|
+
linkDepth: root => getQueryParameter$1(root, 'linkDepth', 0),
|
|
1429
|
+
loadMorePaging: root => getQueryParameter$1(root, 'loadMorePaging', false),
|
|
1430
|
+
orderBy: root => getQueryParameter$1(root, 'orderBy', []),
|
|
1400
1431
|
pageIndex: root => {
|
|
1401
1432
|
const {
|
|
1402
1433
|
action,
|
|
1403
1434
|
state
|
|
1404
1435
|
} = root;
|
|
1405
|
-
if (getQueryParameter(root, 'internalPaging', false)) return 0;
|
|
1436
|
+
if (getQueryParameter$1(root, 'internalPaging', false)) return 0;
|
|
1406
1437
|
if (action.type === UPDATE_PAGE_INDEX) return action.params.pageIndex;
|
|
1407
|
-
return !action.preload ? getPageIndex(state,
|
|
1438
|
+
return !action.preload ? getPageIndex$1(state, action.facet, action.context) : 0;
|
|
1408
1439
|
},
|
|
1409
|
-
pageSize: root => getQueryParameter(root, 'pageSize'),
|
|
1440
|
+
pageSize: root => getQueryParameter$1(root, 'pageSize'),
|
|
1410
1441
|
pagesLoaded: ({
|
|
1411
1442
|
state,
|
|
1412
1443
|
facet,
|
|
@@ -1424,9 +1455,9 @@ const queryParamsTemplate = {
|
|
|
1424
1455
|
}) => {
|
|
1425
1456
|
var _getFacet;
|
|
1426
1457
|
|
|
1427
|
-
return (_getFacet = getFacet(state, facet, context)) === null || _getFacet === void 0 ? void 0 : _getFacet.projectId;
|
|
1458
|
+
return ((_getFacet = getFacet(state, facet, context)) === null || _getFacet === void 0 ? void 0 : _getFacet.projectId) || selectCurrentProject(state);
|
|
1428
1459
|
},
|
|
1429
|
-
searchTerm: root => root.context !== Context.minilist || getQueryParameter(root, 'useSearchTerm', false) ? getSearchTerm(root.state) : '',
|
|
1460
|
+
searchTerm: root => root.context !== Context$1.minilist || getQueryParameter$1(root, 'useSearchTerm', false) ? getSearchTerm$1(root.state) : '',
|
|
1430
1461
|
selectedFilters: ({
|
|
1431
1462
|
state,
|
|
1432
1463
|
facet,
|
|
@@ -1436,11 +1467,11 @@ const queryParamsTemplate = {
|
|
|
1436
1467
|
state
|
|
1437
1468
|
}) => selectVersionStatus(state),
|
|
1438
1469
|
weightedSearchFields: root => {
|
|
1439
|
-
const wsf = getQueryParameter(root, 'weightedSearchFields', []);
|
|
1470
|
+
const wsf = getQueryParameter$1(root, 'weightedSearchFields', []);
|
|
1440
1471
|
const deduped = wsf.filter((v, i, a) => a.findIndex(t => t.fieldId === v.fieldId) === i);
|
|
1441
1472
|
return deduped; // return wsf;
|
|
1442
1473
|
},
|
|
1443
|
-
webpageTemplates: root => getQueryParameter(root, 'webpageTemplates', [])
|
|
1474
|
+
webpageTemplates: root => getQueryParameter$1(root, 'webpageTemplates', [])
|
|
1444
1475
|
};
|
|
1445
1476
|
|
|
1446
1477
|
const mapStateToQueryParams = sourceJson => mapJson(sourceJson, queryParamsTemplate);
|
|
@@ -1486,10 +1517,10 @@ const runSearch = (action, state, queryParams) => {
|
|
|
1486
1517
|
const facetIsLoaded = defaultLang ? false : getIsLoaded(state, context, facet);
|
|
1487
1518
|
const stateParams = { ...getQueryParams(ogState, facet, context)
|
|
1488
1519
|
};
|
|
1489
|
-
stateParams.pageIndex = getPageIndex(ogState, facet, context);
|
|
1490
|
-
stateParams.searchTerm = getSearchTerm(ogState);
|
|
1520
|
+
stateParams.pageIndex = getPageIndex$1(ogState, facet, context);
|
|
1521
|
+
stateParams.searchTerm = getSearchTerm$1(ogState);
|
|
1491
1522
|
|
|
1492
|
-
if (context === Context.facets && ssr || // context === Context.minilist ||
|
|
1523
|
+
if (context === Context$1.facets && ssr || // context === Context.minilist ||
|
|
1493
1524
|
preload || !facetIsLoaded || filterParamsChanged(action) || defaultLang) {
|
|
1494
1525
|
willRun = true;
|
|
1495
1526
|
} else {
|
|
@@ -1538,9 +1569,10 @@ const filterParamsChanged = (action, state) => {
|
|
|
1538
1569
|
const debugExecuteSearch = (action, state) => {
|
|
1539
1570
|
const [queryParams, runSearch] = generateQueryParams(action, state);
|
|
1540
1571
|
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
|
-
|
|
1572
|
+
const stateParams = { ...getQueryParams(action.ogState || state, action.facet, action.context),
|
|
1573
|
+
pageIndex: getPageIndex$1(action.ogState || state, action.facet, action.context),
|
|
1574
|
+
searchTerm: getSearchTerm$1(action.ogState || state)
|
|
1575
|
+
};
|
|
1544
1576
|
console.log(stateParams, queryParams);
|
|
1545
1577
|
console.log('getSelectedFilters', getSelectedFilters(action.ogState || state, action.facet, action.context, 'js'), 'params', action.params);
|
|
1546
1578
|
};
|
|
@@ -1570,9 +1602,9 @@ const mapEntriesToFilterItems = entries => {
|
|
|
1570
1602
|
});
|
|
1571
1603
|
};
|
|
1572
1604
|
|
|
1573
|
-
const searchSagas = [takeEvery(CLEAR_FILTERS, clearFilters
|
|
1605
|
+
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
1606
|
|
|
1575
|
-
const toJS
|
|
1607
|
+
const toJS = obj => obj && 'toJS' in obj && typeof obj.toJS === 'function' ? obj.toJS() : obj;
|
|
1576
1608
|
|
|
1577
1609
|
function* setRouteFilters(action) {
|
|
1578
1610
|
const {
|
|
@@ -1582,8 +1614,8 @@ function* setRouteFilters(action) {
|
|
|
1582
1614
|
defaultLang,
|
|
1583
1615
|
debug
|
|
1584
1616
|
} = action;
|
|
1585
|
-
const context = listingType ? Context.listings : Context.facets;
|
|
1586
|
-
const state = toJS
|
|
1617
|
+
const context = listingType ? Context$1.listings : Context$1.facets;
|
|
1618
|
+
const state = toJS(yield select());
|
|
1587
1619
|
const ssr = getIsSsr(state); // Get current facet from params or state
|
|
1588
1620
|
|
|
1589
1621
|
let currentFacet = params && params.facet || listingType; // Pick the default facet from initialState
|
|
@@ -1605,15 +1637,21 @@ function* setRouteFilters(action) {
|
|
|
1605
1637
|
ssr,
|
|
1606
1638
|
debug
|
|
1607
1639
|
};
|
|
1608
|
-
yield put(nextAction); //
|
|
1640
|
+
yield put(nextAction); // keep track of this state ref for comparing changes to params later
|
|
1641
|
+
|
|
1642
|
+
const ogState = {
|
|
1643
|
+
search: state.search
|
|
1644
|
+
}; // Using call instead of triggering from the put
|
|
1609
1645
|
// to allow this exported saga to continue during SSR
|
|
1610
1646
|
|
|
1611
1647
|
yield call(ensureSearch, { ...nextAction,
|
|
1612
|
-
ogState
|
|
1648
|
+
ogState
|
|
1613
1649
|
});
|
|
1614
1650
|
}
|
|
1615
1651
|
function* doSearch(action) {
|
|
1616
|
-
|
|
1652
|
+
var _action$params;
|
|
1653
|
+
|
|
1654
|
+
const state = toJS(yield select());
|
|
1617
1655
|
|
|
1618
1656
|
if (action.config) {
|
|
1619
1657
|
// If the action contains a config object, we can add this to the
|
|
@@ -1625,12 +1663,20 @@ function* doSearch(action) {
|
|
|
1625
1663
|
|
|
1626
1664
|
const nextAction = { ...action,
|
|
1627
1665
|
type: SET_SEARCH_FILTERS,
|
|
1628
|
-
ssr: getIsSsr(state)
|
|
1666
|
+
ssr: getIsSsr(state),
|
|
1667
|
+
facet: action.facet || ((_action$params = action.params) === null || _action$params === void 0 ? void 0 : _action$params.facet)
|
|
1629
1668
|
};
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1669
|
+
|
|
1670
|
+
if (nextAction.facet) {
|
|
1671
|
+
yield put(nextAction); // keep track of this state ref for comparing changes to params later
|
|
1672
|
+
|
|
1673
|
+
const ogState = {
|
|
1674
|
+
search: state.search
|
|
1675
|
+
};
|
|
1676
|
+
yield call(ensureSearch, { ...nextAction,
|
|
1677
|
+
ogState
|
|
1678
|
+
});
|
|
1679
|
+
}
|
|
1634
1680
|
}
|
|
1635
1681
|
|
|
1636
1682
|
function* loadFilters(action) {
|
|
@@ -1728,7 +1774,9 @@ function* ensureSearch(action) {
|
|
|
1728
1774
|
try {
|
|
1729
1775
|
const state = yield select();
|
|
1730
1776
|
const nextAction = { ...action,
|
|
1731
|
-
ogState: action.ogState ||
|
|
1777
|
+
ogState: action.ogState || {
|
|
1778
|
+
search: state.search
|
|
1779
|
+
}
|
|
1732
1780
|
};
|
|
1733
1781
|
const [queryParams, runSearch] = generateQueryParams(nextAction, state);
|
|
1734
1782
|
if (debug && (debug === true || debug.executeSearch)) debugExecuteSearch(nextAction, state);
|
|
@@ -1746,9 +1794,9 @@ function* ensureSearch(action) {
|
|
|
1746
1794
|
debug
|
|
1747
1795
|
});
|
|
1748
1796
|
}
|
|
1749
|
-
} catch (error
|
|
1797
|
+
} catch (error) {
|
|
1750
1798
|
// eslint-disable-next-line import/namespace
|
|
1751
|
-
error(...['Error running search saga:', error
|
|
1799
|
+
log.error(...['Error running search saga:', error, error.stack]);
|
|
1752
1800
|
}
|
|
1753
1801
|
}
|
|
1754
1802
|
|
|
@@ -1791,15 +1839,15 @@ function* executeSearch(action) {
|
|
|
1791
1839
|
action,
|
|
1792
1840
|
featuredResult,
|
|
1793
1841
|
pageIndex: queryParams.internalPaging && queryParams.internalPageIndex || queryParams.pageIndex,
|
|
1794
|
-
prevResults: getResults(state, facet, action.context, 'js'),
|
|
1842
|
+
prevResults: getResults$1(state, facet, action.context, 'js'),
|
|
1795
1843
|
result,
|
|
1796
1844
|
state
|
|
1797
1845
|
};
|
|
1798
1846
|
const nextAction = mapJson(createStateFrom, facetTemplate);
|
|
1799
1847
|
yield put(nextAction);
|
|
1800
|
-
} catch (error
|
|
1848
|
+
} catch (error) {
|
|
1801
1849
|
// eslint-disable-next-line import/namespace
|
|
1802
|
-
error(...['Error running search saga:', error
|
|
1850
|
+
log.error(...['Error running search saga:', error, error.stack]);
|
|
1803
1851
|
}
|
|
1804
1852
|
}
|
|
1805
1853
|
|
|
@@ -1813,7 +1861,7 @@ function* preloadOtherFacets(action) {
|
|
|
1813
1861
|
const state = yield select();
|
|
1814
1862
|
const currentFacet = getCurrentFacet(state);
|
|
1815
1863
|
|
|
1816
|
-
if (!preload && facet === currentFacet && context !== Context.listings) {
|
|
1864
|
+
if (!preload && facet === currentFacet && context !== Context$1.listings) {
|
|
1817
1865
|
const allFacets = getFacets(state, 'js');
|
|
1818
1866
|
const otherFacets = Object.keys(allFacets).filter(f => f !== currentFacet);
|
|
1819
1867
|
yield all(otherFacets.map((preloadFacet = '') => {
|
|
@@ -1833,7 +1881,7 @@ function* preloadOtherFacets(action) {
|
|
|
1833
1881
|
}
|
|
1834
1882
|
}
|
|
1835
1883
|
|
|
1836
|
-
function* updateCurrentTab
|
|
1884
|
+
function* updateCurrentTab(action) {
|
|
1837
1885
|
const {
|
|
1838
1886
|
id,
|
|
1839
1887
|
mappers
|
|
@@ -1852,10 +1900,10 @@ function* updateCurrentTab$1(action) {
|
|
|
1852
1900
|
|
|
1853
1901
|
|
|
1854
1902
|
if (!nextFacet) nextFacet = Object.entries(facets).filter(([, f]) => f.tabId === id)[0][0];
|
|
1855
|
-
yield put(withMappers(updateCurrentFacet(nextFacet), mappers));
|
|
1903
|
+
yield put(withMappers(updateCurrentFacet$1(nextFacet), mappers));
|
|
1856
1904
|
}
|
|
1857
1905
|
|
|
1858
|
-
function* clearFilters
|
|
1906
|
+
function* clearFilters(action) {
|
|
1859
1907
|
const {
|
|
1860
1908
|
mappers
|
|
1861
1909
|
} = action;
|
|
@@ -1863,12 +1911,12 @@ function* clearFilters$1(action) {
|
|
|
1863
1911
|
yield put(navigate(uri));
|
|
1864
1912
|
}
|
|
1865
1913
|
|
|
1866
|
-
function* updateCurrentFacet
|
|
1914
|
+
function* updateCurrentFacet(action) {
|
|
1867
1915
|
const {
|
|
1868
1916
|
facet,
|
|
1869
1917
|
mappers
|
|
1870
1918
|
} = action;
|
|
1871
|
-
const pageIndex = yield select(getPageIndex, facet);
|
|
1919
|
+
const pageIndex = yield select(getPageIndex$1, facet);
|
|
1872
1920
|
const uri = yield buildUri({
|
|
1873
1921
|
facet,
|
|
1874
1922
|
pageIndex
|
|
@@ -1876,7 +1924,7 @@ function* updateCurrentFacet$1(action) {
|
|
|
1876
1924
|
yield put(navigate(uri));
|
|
1877
1925
|
}
|
|
1878
1926
|
|
|
1879
|
-
function* updateSearchTerm
|
|
1927
|
+
function* updateSearchTerm(action) {
|
|
1880
1928
|
const {
|
|
1881
1929
|
term,
|
|
1882
1930
|
mappers
|
|
@@ -1887,7 +1935,7 @@ function* updateSearchTerm$1(action) {
|
|
|
1887
1935
|
yield put(navigate(uri));
|
|
1888
1936
|
}
|
|
1889
1937
|
|
|
1890
|
-
function* updateSortOrder
|
|
1938
|
+
function* updateSortOrder(action) {
|
|
1891
1939
|
const {
|
|
1892
1940
|
orderBy,
|
|
1893
1941
|
facet,
|
|
@@ -1900,7 +1948,7 @@ function* updateSortOrder$1(action) {
|
|
|
1900
1948
|
yield put(navigate(uri));
|
|
1901
1949
|
}
|
|
1902
1950
|
|
|
1903
|
-
function* updatePageIndex
|
|
1951
|
+
function* updatePageIndex(action) {
|
|
1904
1952
|
const {
|
|
1905
1953
|
pageIndex,
|
|
1906
1954
|
mappers
|
|
@@ -1926,7 +1974,7 @@ function* buildUri({
|
|
|
1926
1974
|
term
|
|
1927
1975
|
}, mappers) {
|
|
1928
1976
|
const state = yield select();
|
|
1929
|
-
const mapUri = mappers
|
|
1977
|
+
const mapUri = (mappers === null || mappers === void 0 ? void 0 : mappers.navigate) || mapStateToSearchUri;
|
|
1930
1978
|
const uri = mapUri({
|
|
1931
1979
|
state,
|
|
1932
1980
|
facet,
|
|
@@ -1938,13 +1986,97 @@ function* buildUri({
|
|
|
1938
1986
|
return `${uri.path}${uri.search && `?${uri.search}` || ''}${uri.hash && `#${uri.hash}` || ''}`;
|
|
1939
1987
|
}
|
|
1940
1988
|
|
|
1989
|
+
var defaultMappers = {
|
|
1990
|
+
results: entries => entries,
|
|
1991
|
+
navigate: mapStateToSearchUri
|
|
1992
|
+
};
|
|
1993
|
+
|
|
1994
|
+
const {
|
|
1995
|
+
getCurrent,
|
|
1996
|
+
getFeaturedResults,
|
|
1997
|
+
getIsLoading,
|
|
1998
|
+
getListing,
|
|
1999
|
+
getPageIndex,
|
|
2000
|
+
getPageIsLoading,
|
|
2001
|
+
getPaging,
|
|
2002
|
+
getQueryParameter,
|
|
2003
|
+
getRenderableFilters,
|
|
2004
|
+
getResults,
|
|
2005
|
+
getSearchTerm
|
|
2006
|
+
} = selectListing;
|
|
2007
|
+
|
|
2008
|
+
const makeSelectListingProps = () => createSelector(state => state, (_, mappers) => mappers, (state, mappers) => ({
|
|
2009
|
+
currentListing: getCurrent(state),
|
|
2010
|
+
currentPageIndex: getPageIndex(state),
|
|
2011
|
+
listing: getListing(state),
|
|
2012
|
+
featured: getFeaturedResults(state),
|
|
2013
|
+
filters: getRenderableFilters(state),
|
|
2014
|
+
isLoading: getIsLoading(state),
|
|
2015
|
+
pageIsLoading: getPageIsLoading(state),
|
|
2016
|
+
paging: getPaging(state),
|
|
2017
|
+
results: getResults(state),
|
|
2018
|
+
resultsInfo: mappers && typeof mappers.resultsInfo === 'function' && mappers.resultsInfo(state),
|
|
2019
|
+
searchTerm: getSearchTerm(state),
|
|
2020
|
+
sortOrder: getQueryParameter({
|
|
2021
|
+
state
|
|
2022
|
+
}, 'dynamicOrderBy', [])
|
|
2023
|
+
}));
|
|
2024
|
+
|
|
2025
|
+
const useListing = ({
|
|
2026
|
+
mappers
|
|
2027
|
+
} = {
|
|
2028
|
+
id: ''
|
|
2029
|
+
}) => {
|
|
2030
|
+
const dispatch = useDispatch();
|
|
2031
|
+
const m = mappers || defaultMappers;
|
|
2032
|
+
const selectListingProps = useMemo(makeSelectListingProps, [m]);
|
|
2033
|
+
const dispatchProps = {
|
|
2034
|
+
clearFilters: () => dispatch(withMappers(clearFilters$1(), m)),
|
|
2035
|
+
updateCurrentFacet: facet => dispatch(withMappers(updateCurrentFacet$1(facet), m)),
|
|
2036
|
+
updatePageIndex: pageIndex => dispatch(withMappers(updatePageIndex$1(pageIndex), m)),
|
|
2037
|
+
updateSearchTerm: term => dispatch(withMappers(updateSearchTerm$1(term), m)),
|
|
2038
|
+
updateSelectedFilters: (filter, key, isUnknownItem = false) => dispatch(withMappers(updateSelectedFilters(filter, key, isUnknownItem), m)),
|
|
2039
|
+
updateSortOrder: orderBy => dispatch(withMappers(updateSortOrder$1(orderBy), m))
|
|
2040
|
+
};
|
|
2041
|
+
const {
|
|
2042
|
+
currentListing,
|
|
2043
|
+
currentPageIndex,
|
|
2044
|
+
featured,
|
|
2045
|
+
filters,
|
|
2046
|
+
isLoading,
|
|
2047
|
+
listing,
|
|
2048
|
+
paging,
|
|
2049
|
+
pageIsLoading,
|
|
2050
|
+
results,
|
|
2051
|
+
resultsInfo,
|
|
2052
|
+
searchTerm,
|
|
2053
|
+
sortOrder
|
|
2054
|
+
} = useSelector(state => selectListingProps(state, m));
|
|
2055
|
+
return {
|
|
2056
|
+
currentListing,
|
|
2057
|
+
currentPageIndex,
|
|
2058
|
+
featured,
|
|
2059
|
+
filters,
|
|
2060
|
+
isLoading,
|
|
2061
|
+
listing,
|
|
2062
|
+
pageIsLoading,
|
|
2063
|
+
paging,
|
|
2064
|
+
results,
|
|
2065
|
+
resultsInfo,
|
|
2066
|
+
searchTerm,
|
|
2067
|
+
sortOrder,
|
|
2068
|
+
title: listing.title,
|
|
2069
|
+
...dispatchProps
|
|
2070
|
+
};
|
|
2071
|
+
};
|
|
2072
|
+
|
|
1941
2073
|
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'),
|
|
1947
|
-
searchTerm: getSearchTerm(state)
|
|
2074
|
+
facet: getFacet(state, id, Context$1.minilist, 'js'),
|
|
2075
|
+
filters: getFilters(state, id, Context$1.minilist, 'js'),
|
|
2076
|
+
isLoading: getIsLoading$1(state, Context$1.minilist, id),
|
|
2077
|
+
pagingInfo: getPaging$1(state, id, Context$1.minilist, 'js'),
|
|
2078
|
+
results: getResults$1(state, id, Context$1.minilist, 'js'),
|
|
2079
|
+
searchTerm: getSearchTerm$1(state)
|
|
1948
2080
|
}));
|
|
1949
2081
|
|
|
1950
2082
|
const useMinilist = ({
|
|
@@ -1981,7 +2113,7 @@ const useMinilist = ({
|
|
|
1981
2113
|
if (id && (mapper || mappers && mappers.results)) {
|
|
1982
2114
|
dispatch(triggerSearch({
|
|
1983
2115
|
config,
|
|
1984
|
-
context: Context.minilist,
|
|
2116
|
+
context: Context$1.minilist,
|
|
1985
2117
|
defaultLang,
|
|
1986
2118
|
facet: id,
|
|
1987
2119
|
mapper,
|
|
@@ -1995,7 +2127,7 @@ const useMinilist = ({
|
|
|
1995
2127
|
return {
|
|
1996
2128
|
filters,
|
|
1997
2129
|
isLoading,
|
|
1998
|
-
pagingInfo,
|
|
2130
|
+
paging: pagingInfo,
|
|
1999
2131
|
results,
|
|
2000
2132
|
searchTerm,
|
|
2001
2133
|
title: facet.title
|
|
@@ -2179,7 +2311,10 @@ const generateFiltersState = ({
|
|
|
2179
2311
|
// the search results during SSR without needing to fetch the filters first
|
|
2180
2312
|
|
|
2181
2313
|
|
|
2182
|
-
Object.entries(filterParams).map(([paramName = '', paramValue]) =>
|
|
2314
|
+
Object.entries(filterParams).map(([paramName = '', paramValue]) => {
|
|
2315
|
+
if (typeof paramValue === 'string') return paramValue.split(',').map(pVal => filters = addFilterItem(filters, paramName, pVal));
|
|
2316
|
+
if (typeof paramValue === 'boolean') filters = addFilterItem(filters, paramName, paramValue);
|
|
2317
|
+
});
|
|
2183
2318
|
return Object.fromEntries(filters);
|
|
2184
2319
|
};
|
|
2185
2320
|
|
|
@@ -2196,9 +2331,9 @@ var reducers = (config => {
|
|
|
2196
2331
|
// Add facets from SearchConfig to initialState
|
|
2197
2332
|
const initState = { ...initialState,
|
|
2198
2333
|
tabs: config.tabs,
|
|
2199
|
-
facets: generateSearchFacets(Context.facets, config),
|
|
2200
|
-
listings: generateSearchFacets(Context.listings, config),
|
|
2201
|
-
minilist: generateSearchFacets(Context.minilist, config)
|
|
2334
|
+
facets: generateSearchFacets(Context$1.facets, config),
|
|
2335
|
+
listings: generateSearchFacets(Context$1.listings, config),
|
|
2336
|
+
minilist: generateSearchFacets(Context$1.minilist, config)
|
|
2202
2337
|
};
|
|
2203
2338
|
return produce((state = initState, action) => {
|
|
2204
2339
|
const context = state.context;
|
|
@@ -2208,7 +2343,7 @@ var reducers = (config => {
|
|
|
2208
2343
|
case APPLY_CONFIG:
|
|
2209
2344
|
{
|
|
2210
2345
|
state = addConfigToState(state, action);
|
|
2211
|
-
return;
|
|
2346
|
+
return state;
|
|
2212
2347
|
}
|
|
2213
2348
|
|
|
2214
2349
|
case CLEAR_FILTERS:
|
|
@@ -2325,7 +2460,7 @@ var reducers = (config => {
|
|
|
2325
2460
|
}));
|
|
2326
2461
|
state.context = context;
|
|
2327
2462
|
state[context] = nextFacets;
|
|
2328
|
-
state[action.context === Context.facets ? 'currentFacet' : 'currentListing'] = facet;
|
|
2463
|
+
state[action.context === Context$1.facets ? 'currentFacet' : 'currentListing'] = facet;
|
|
2329
2464
|
state.term = term;
|
|
2330
2465
|
state.tabs[tabId].currentFacet = facet;
|
|
2331
2466
|
state[context][facet].pagingInfo.pageIndex = Number(pageIndex) - 1 || (state[context][facet].queryParams.loadMorePaging ? state[context][facet].pagingInfo.pageIndex || 0 : 0);
|
|
@@ -2358,9 +2493,9 @@ var reducers = (config => {
|
|
|
2358
2493
|
isCurrentFacet: true
|
|
2359
2494
|
}, state);
|
|
2360
2495
|
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;
|
|
2496
|
+
const useSearchTerm = state[action.context || Context$1.minilist][action.facet].queryParams.useSearchTerm || false;
|
|
2497
|
+
state[action.context || Context$1.minilist][action.facet].filters = filters;
|
|
2498
|
+
state[action.context || Context$1.minilist][action.facet].queryParams.excludeIds = action.excludeIds;
|
|
2364
2499
|
state.term = useSearchTerm ? term : state.term;
|
|
2365
2500
|
state.config.ssr = typeof window === 'undefined';
|
|
2366
2501
|
return;
|
|
@@ -2392,13 +2527,22 @@ var reducers = (config => {
|
|
|
2392
2527
|
{
|
|
2393
2528
|
const {
|
|
2394
2529
|
filter,
|
|
2395
|
-
key
|
|
2530
|
+
key,
|
|
2531
|
+
isUnknownItem
|
|
2396
2532
|
} = action;
|
|
2397
2533
|
const isSingleSelect = state[context][current].filters[filter].isSingleSelect || false;
|
|
2398
2534
|
const isGrouped = state[context][current].filters[filter].isGrouped || false;
|
|
2399
2535
|
const currentItems = state[context][current].filters[filter].items;
|
|
2400
2536
|
if (isGrouped) state[context] = resetFacets(state, context);
|
|
2401
2537
|
state[context][current] = resetFacet(state[context][current]);
|
|
2538
|
+
|
|
2539
|
+
if (isUnknownItem && (currentItems === null || currentItems === void 0 ? void 0 : currentItems.findIndex(item => (item === null || item === void 0 ? void 0 : item.key) === key)) === -1) {
|
|
2540
|
+
currentItems === null || currentItems === void 0 ? void 0 : currentItems.push({
|
|
2541
|
+
key,
|
|
2542
|
+
isSelected: false
|
|
2543
|
+
});
|
|
2544
|
+
}
|
|
2545
|
+
|
|
2402
2546
|
state[context][current].filters[filter].items = currentItems === null || currentItems === void 0 ? void 0 : currentItems.map(item => {
|
|
2403
2547
|
if (item.key === key) {
|
|
2404
2548
|
return { ...item,
|
|
@@ -2432,12 +2576,11 @@ var reducers = (config => {
|
|
|
2432
2576
|
}, initState);
|
|
2433
2577
|
});
|
|
2434
2578
|
|
|
2435
|
-
|
|
2436
|
-
const Context$1 = {
|
|
2579
|
+
const Context = {
|
|
2437
2580
|
facets: 'facets',
|
|
2438
2581
|
listings: 'listings',
|
|
2439
2582
|
minilist: 'minilist'
|
|
2440
2583
|
};
|
|
2441
2584
|
|
|
2442
|
-
export { Context
|
|
2585
|
+
export { Context, actions, doSearch, queries, reducers as reducer, searchSagas as sagas, schema, selectors, setRouteFilters, types, useListing, useMinilist, withListing, withSearch };
|
|
2443
2586
|
//# sourceMappingURL=search.js.map
|