@zengenti/contensis-react-base 3.0.2-beta.5 → 3.0.2-beta.7
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/cjs/{App-48706fde.js → App-81a45001.js} +89 -133
- package/{esm/App-e058aa68.js.map → cjs/App-81a45001.js.map} +1 -1
- package/cjs/{ContensisDeliveryApi-cfdefe17.js → ContensisDeliveryApi-de88df2a.js} +13 -66
- package/cjs/ContensisDeliveryApi-de88df2a.js.map +1 -0
- package/cjs/{RouteLoader-fcd1e4f1.js → RouteLoader-47d70a26.js} +22 -35
- package/{esm/RouteLoader-e46234cc.js.map → cjs/RouteLoader-47d70a26.js.map} +1 -1
- package/cjs/{ToJs-d962c80f.js → ToJs-61c03582.js} +3 -4
- package/cjs/{ToJs-d962c80f.js.map → ToJs-61c03582.js.map} +1 -1
- package/cjs/client.js +11 -18
- package/cjs/client.js.map +1 -1
- package/cjs/contensis-react-base.js +113 -177
- package/cjs/contensis-react-base.js.map +1 -1
- package/cjs/forms.js +11 -153
- package/cjs/forms.js.map +1 -1
- package/cjs/{fromJSLeaveImmer-e74c673c.js → fromJSLeaveImmer-7c363211.js} +1 -4
- package/cjs/{fromJSLeaveImmer-e74c673c.js.map → fromJSLeaveImmer-7c363211.js.map} +1 -1
- package/cjs/{login-dfcea036.js → login-51b66359.js} +63 -111
- package/cjs/login-51b66359.js.map +1 -0
- package/cjs/{reducers-73a03ef4.js → reducers-9afb5f89.js} +10 -31
- package/{esm/reducers-aa8cef1e.js.map → cjs/reducers-9afb5f89.js.map} +1 -1
- package/cjs/redux.js +5 -4
- package/cjs/redux.js.map +1 -1
- package/cjs/routing.js +3 -3
- package/cjs/{sagas-8a20e424.js → sagas-6d12e7ca.js} +182 -282
- package/{esm/sagas-e576b6f6.js.map → cjs/sagas-6d12e7ca.js.map} +1 -1
- package/cjs/search.js +56 -82
- package/cjs/search.js.map +1 -1
- package/cjs/{selectors-fa607198.js → selectors-c76c2676.js} +1 -6
- package/cjs/selectors-c76c2676.js.map +1 -0
- package/cjs/urls-6fcaf4c6.js.map +1 -1
- package/cjs/user.js +4 -12
- package/cjs/user.js.map +1 -1
- package/cjs/util.js +35 -55
- package/cjs/util.js.map +1 -1
- package/cjs/{version-7ce96442.js → version-38afaf2a.js} +24 -58
- package/{esm/version-03d555b7.js.map → cjs/version-38afaf2a.js.map} +1 -1
- package/cjs/{version-d6e26cc4.js → version-886f49d8.js} +3 -6
- package/cjs/{version-d6e26cc4.js.map → version-886f49d8.js.map} +1 -1
- package/esm/{App-e058aa68.js → App-5f914483.js} +89 -133
- package/{cjs/App-48706fde.js.map → esm/App-5f914483.js.map} +1 -1
- package/esm/{ContensisDeliveryApi-8abcf222.js → ContensisDeliveryApi-ad06857d.js} +13 -66
- package/esm/ContensisDeliveryApi-ad06857d.js.map +1 -0
- package/esm/{RouteLoader-e46234cc.js → RouteLoader-f5d5f733.js} +22 -35
- package/{cjs/RouteLoader-fcd1e4f1.js.map → esm/RouteLoader-f5d5f733.js.map} +1 -1
- package/esm/{ToJs-502f7a11.js → ToJs-0066e629.js} +3 -4
- package/esm/{ToJs-502f7a11.js.map → ToJs-0066e629.js.map} +1 -1
- package/esm/client.js +12 -19
- package/esm/client.js.map +1 -1
- package/esm/contensis-react-base.js +114 -178
- package/esm/contensis-react-base.js.map +1 -1
- package/esm/forms.js +11 -153
- package/esm/forms.js.map +1 -1
- package/esm/{fromJSLeaveImmer-0114ffcf.js → fromJSLeaveImmer-e2dacd63.js} +1 -4
- package/esm/{fromJSLeaveImmer-0114ffcf.js.map → fromJSLeaveImmer-e2dacd63.js.map} +1 -1
- package/esm/{login-a950263f.js → login-4d07c2de.js} +63 -111
- package/esm/login-4d07c2de.js.map +1 -0
- package/esm/{reducers-aa8cef1e.js → reducers-3d5c37d1.js} +10 -31
- package/{cjs/reducers-73a03ef4.js.map → esm/reducers-3d5c37d1.js.map} +1 -1
- package/esm/redux.js +8 -7
- package/esm/redux.js.map +1 -1
- package/esm/routing.js +3 -3
- package/esm/{sagas-e576b6f6.js → sagas-53d2aefb.js} +134 -235
- package/{cjs/sagas-8a20e424.js.map → esm/sagas-53d2aefb.js.map} +1 -1
- package/esm/search.js +57 -83
- package/esm/search.js.map +1 -1
- package/esm/{selectors-78355a01.js → selectors-3f0d804d.js} +1 -6
- package/esm/selectors-3f0d804d.js.map +1 -0
- package/esm/urls-eac9a747.js.map +1 -1
- package/esm/user.js +6 -14
- package/esm/user.js.map +1 -1
- package/esm/util.js +35 -55
- package/esm/util.js.map +1 -1
- package/esm/{version-03d555b7.js → version-dd31c7f0.js} +24 -58
- package/{cjs/version-7ce96442.js.map → esm/version-dd31c7f0.js.map} +1 -1
- package/esm/{version-5ce7dbce.js → version-f4629693.js} +3 -6
- package/esm/{version-5ce7dbce.js.map → version-f4629693.js.map} +1 -1
- package/models/app/pages/VersionInfo/components/VersionInfo.styled.d.ts +2 -1
- package/models/user/components.styled/Login.styled.d.ts +1 -1
- package/models/user/components.styled/LoginForm.styled.d.ts +1 -1
- package/package.json +2 -2
- package/cjs/ContensisDeliveryApi-cfdefe17.js.map +0 -1
- package/cjs/login-dfcea036.js.map +0 -1
- package/cjs/selectors-fa607198.js.map +0 -1
- package/esm/ContensisDeliveryApi-8abcf222.js.map +0 -1
- package/esm/login-a950263f.js.map +0 -1
- package/esm/selectors-78355a01.js.map +0 -1
|
@@ -81,7 +81,8 @@ var types = /*#__PURE__*/Object.freeze({
|
|
|
81
81
|
});
|
|
82
82
|
|
|
83
83
|
const withMappers = (action, mappers) => {
|
|
84
|
-
return {
|
|
84
|
+
return {
|
|
85
|
+
...action,
|
|
85
86
|
mappers
|
|
86
87
|
};
|
|
87
88
|
};
|
|
@@ -201,53 +202,47 @@ var actions = /*#__PURE__*/Object.freeze({
|
|
|
201
202
|
updateSortOrder: updateSortOrder$1
|
|
202
203
|
});
|
|
203
204
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
(function (Context) {
|
|
205
|
+
let Context = /*#__PURE__*/function (Context) {
|
|
207
206
|
Context["facets"] = "facets";
|
|
208
207
|
Context["listings"] = "listings";
|
|
209
208
|
Context["minilist"] = "minilist";
|
|
210
|
-
|
|
209
|
+
return Context;
|
|
210
|
+
}({});
|
|
211
|
+
// export type Context = 'facets' | 'listings' | 'minilist';
|
|
211
212
|
|
|
213
|
+
// Find a fromJS function from global that is dynamically loaded in createStore
|
|
212
214
|
// or replace with a stub function for non-immutable gets
|
|
213
|
-
|
|
214
215
|
const makeFromJS = (returnType = globalThis.STATE_TYPE || 'immutable') => {
|
|
215
216
|
var _immutable, _immutable2;
|
|
216
|
-
|
|
217
217
|
return returnType === 'immutable' ? ((_immutable = globalThis.immutable) === null || _immutable === void 0 ? void 0 : _immutable.fromJSOrdered) || ((_immutable2 = globalThis.immutable) === null || _immutable2 === void 0 ? void 0 : _immutable2.fromJS) || (v => v) : v => v;
|
|
218
218
|
};
|
|
219
|
-
|
|
220
219
|
const getImmutableOrJS = (state, stateKey, fallbackValue, returnType = globalThis.STATE_TYPE || 'immutable') => {
|
|
221
220
|
// Find a fromJS function from global that is dynamically loaded in createStore
|
|
222
221
|
// or replace with a stub function for non-immutable gets
|
|
223
222
|
const fromJS = makeFromJS(returnType);
|
|
224
|
-
|
|
225
223
|
if (state && 'get' in state && typeof state.get === 'function' && 'getIn' in state && typeof state.getIn === 'function' && 'toJS' in state && typeof state.toJS === 'function') {
|
|
226
224
|
if (Array.isArray(stateKey)) return fromJS(state.getIn(stateKey, fallbackValue));
|
|
227
225
|
return fromJS(state.get(stateKey, fallbackValue));
|
|
228
226
|
}
|
|
229
|
-
|
|
230
227
|
if (Array.isArray(stateKey) && state && typeof state === 'object') {
|
|
231
228
|
const result = mapJson.jpath(stateKey.join('.'), state);
|
|
232
229
|
if (typeof result === 'undefined') return fallbackValue;
|
|
233
230
|
return result;
|
|
234
231
|
}
|
|
235
|
-
|
|
236
232
|
const result = state && typeof state === 'object' ? state[stateKey] : undefined;
|
|
237
233
|
if (typeof result === 'undefined') return fallbackValue;
|
|
238
234
|
return result;
|
|
239
235
|
};
|
|
240
236
|
|
|
241
|
-
const getSearchContext = state => getImmutableOrJS(state, ['search', 'context'],
|
|
242
|
-
const getCurrent = (state, context =
|
|
237
|
+
const getSearchContext = state => getImmutableOrJS(state, ['search', 'context'], Context.facets);
|
|
238
|
+
const getCurrent = (state, context = Context.facets) => context === Context.facets ? getCurrentFacet(state) : getCurrentListing(state);
|
|
243
239
|
const getCurrentFacet = state => getImmutableOrJS(state, ['search', 'currentFacet']);
|
|
244
240
|
const getCurrentListing = state => getImmutableOrJS(state, ['search', 'currentListing']);
|
|
245
|
-
const getCurrentTab = state => getImmutableOrJS(state, ['search',
|
|
246
|
-
const getFacets = (state, returnType) => getImmutableOrJS(state, ['search',
|
|
241
|
+
const getCurrentTab = state => getImmutableOrJS(state, ['search', Context.facets, getCurrentFacet(state), 'tabId'], 0);
|
|
242
|
+
const getFacets = (state, returnType) => getImmutableOrJS(state, ['search', Context.facets], {}, returnType);
|
|
247
243
|
const getTabFacets = state => Object.fromEntries(Object.entries(getFacets(state, 'js')).filter(([key]) => getImmutableOrJS(getFacets(state), [key, 'tabId'], 0) === getCurrentTab(state)));
|
|
248
244
|
const getFacetTitles = state => Object.entries(getFacets(state, 'js')).map(([key, facet = {}]) => {
|
|
249
245
|
var _facet$pagingInfo;
|
|
250
|
-
|
|
251
246
|
return {
|
|
252
247
|
isSelected: getCurrentFacet(state) === key,
|
|
253
248
|
key,
|
|
@@ -255,28 +250,29 @@ const getFacetTitles = state => Object.entries(getFacets(state, 'js')).map(([key
|
|
|
255
250
|
totalCount: (_facet$pagingInfo = facet.pagingInfo) === null || _facet$pagingInfo === void 0 ? void 0 : _facet$pagingInfo.totalCount
|
|
256
251
|
};
|
|
257
252
|
});
|
|
258
|
-
const getFacet = (state, facetName = '', context =
|
|
253
|
+
const getFacet = (state, facetName = '', context = Context.facets, returnType) => {
|
|
259
254
|
const currentFacet = facetName || getCurrentFacet(state);
|
|
260
255
|
return getImmutableOrJS(state, ['search', context, currentFacet], {}, returnType);
|
|
261
256
|
};
|
|
262
257
|
const getListing = (state, listing = '') => {
|
|
263
258
|
const currentListing = listing || getCurrentListing(state);
|
|
264
|
-
return getImmutableOrJS(state, ['search',
|
|
259
|
+
return getImmutableOrJS(state, ['search', Context.listings, currentListing], {});
|
|
265
260
|
};
|
|
266
|
-
const getFilters = (state, facet, context =
|
|
261
|
+
const getFilters = (state, facet, context = Context.facets, returnType) => {
|
|
267
262
|
return getImmutableOrJS(state, ['search', context, facet || getCurrent(state, context), 'filters'], {}, returnType);
|
|
268
263
|
};
|
|
269
|
-
const getRenderableFilters = (state, facet = '', context =
|
|
270
|
-
const getFiltersToLoad = (state, facet, context =
|
|
264
|
+
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));
|
|
265
|
+
const getFiltersToLoad = (state, facet, context = Context.facets, returnType) => {
|
|
271
266
|
const filters = getFilters(state, facet, context, returnType);
|
|
272
267
|
const loadedFilters = Object.entries(filters).map(([key, f = {}]) => [key, (f.items || []).filter(i => {
|
|
273
268
|
const title = i === null || i === void 0 ? void 0 : i.title;
|
|
274
269
|
return typeof title !== 'undefined' && !!title;
|
|
275
270
|
}).length > 0 && (f.isError || false) === false]);
|
|
276
271
|
return loadedFilters.map(([filterKey, isLoaded]) => !isLoaded ? filterKey : null).filter(f => !!f);
|
|
277
|
-
};
|
|
272
|
+
};
|
|
278
273
|
|
|
279
|
-
|
|
274
|
+
// We lowercase the filter key unless it's an ISO date string where the T must be uppercase
|
|
275
|
+
const getSelectedFilters = (state, facet = '', context = Context.facets, returnType) => {
|
|
280
276
|
const filters = getFilters(state, facet, context, 'js');
|
|
281
277
|
const isoDateRegex = RegExp(/\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d/);
|
|
282
278
|
const selectedFilters = Object.fromEntries(Object.entries(filters).map(([key, filter = {}]) => [key, (filter.items || []).filter(item => !!(item.isSelected || false)).map(item => {
|
|
@@ -287,60 +283,61 @@ const getSelectedFilters = (state, facet = '', context = exports.Context.facets,
|
|
|
287
283
|
const fromJS = makeFromJS(returnType);
|
|
288
284
|
return fromJS(selectedFilters);
|
|
289
285
|
};
|
|
290
|
-
const getResults = (state, current = '', context =
|
|
286
|
+
const getResults = (state, current = '', context = Context.facets, returnType) => {
|
|
291
287
|
return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'results'], [], returnType);
|
|
292
288
|
};
|
|
293
|
-
const getIsInternalPaging = (state, current, context =
|
|
289
|
+
const getIsInternalPaging = (state, current, context = Context.facets) => {
|
|
294
290
|
return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'queryParams', 'internalPaging'], false);
|
|
295
291
|
};
|
|
296
|
-
const getIsLoaded = (state, context =
|
|
292
|
+
const getIsLoaded = (state, context = Context.facets, facet) => {
|
|
297
293
|
return !!getImmutableOrJS(state, ['search', context, facet || getCurrent(state, context), 'queryDuration'], 0);
|
|
298
294
|
};
|
|
299
|
-
const getIsLoading = (state, context =
|
|
295
|
+
const getIsLoading = (state, context = Context.facets, facet) => {
|
|
300
296
|
return getImmutableOrJS(state, ['search', context, facet || getCurrent(state, context), 'entries', 'isLoading']);
|
|
301
297
|
};
|
|
302
298
|
const getIsSsr = state => getImmutableOrJS(state, ['search', 'config', 'ssr'], false);
|
|
303
|
-
const getFeaturedResults = (state, current = '', context =
|
|
299
|
+
const getFeaturedResults = (state, current = '', context = Context.facets, returnType) => {
|
|
304
300
|
return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'featuredResults'], [], returnType);
|
|
305
301
|
};
|
|
306
|
-
const getPaging = (state, current = '', context =
|
|
302
|
+
const getPaging = (state, current = '', context = Context.facets, returnType) => {
|
|
307
303
|
return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'pagingInfo'], {}, returnType);
|
|
308
304
|
};
|
|
309
|
-
const getPageIndex = (state, current = '', context =
|
|
305
|
+
const getPageIndex = (state, current = '', context = Context.facets) => {
|
|
310
306
|
return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'pagingInfo', 'pageIndex']);
|
|
311
307
|
};
|
|
312
|
-
const getPageSize = (state, current = '', context =
|
|
308
|
+
const getPageSize = (state, current = '', context = Context.facets) => {
|
|
313
309
|
return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'pagingInfo', 'pageSize'], 0 // Defaults to 0 because we want it to fall back to a query param if not defined
|
|
314
310
|
);
|
|
315
311
|
};
|
|
316
|
-
|
|
312
|
+
|
|
313
|
+
const getPrevPageIndex = (state, current = '', context = Context.facets) => {
|
|
317
314
|
return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'pagingInfo', 'prevPageIndex']);
|
|
318
315
|
};
|
|
319
|
-
const getPageIsLoading = (state, current = '', context =
|
|
316
|
+
const getPageIsLoading = (state, current = '', context = Context.facets) => {
|
|
320
317
|
return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'pagingInfo', 'isLoading']);
|
|
321
318
|
};
|
|
322
|
-
const getPagesLoaded = (state, current = '', context =
|
|
319
|
+
const getPagesLoaded = (state, current = '', context = Context.facets) => {
|
|
323
320
|
return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'pagingInfo', 'pagesLoaded'], [], 'js');
|
|
324
321
|
};
|
|
325
|
-
const getTotalCount = (state, current = '', context =
|
|
322
|
+
const getTotalCount = (state, current = '', context = Context.facets) => {
|
|
326
323
|
return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'pagingInfo', 'totalCount']);
|
|
327
324
|
};
|
|
328
325
|
const getSearchTerm = state => getImmutableOrJS(state, ['search', 'term']);
|
|
329
326
|
const getSearchTabs = (state, returnType) => getImmutableOrJS(state, ['search', 'tabs'], [], returnType);
|
|
330
|
-
const getQueryParams = (state, current = '', context =
|
|
327
|
+
const getQueryParams = (state, current = '', context = Context.facets) => {
|
|
331
328
|
return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'queryParams'], {}, 'js');
|
|
332
329
|
};
|
|
333
330
|
const getQueryParameter = ({
|
|
334
331
|
state,
|
|
335
332
|
facet,
|
|
336
|
-
context =
|
|
333
|
+
context = Context.facets
|
|
337
334
|
}, key, ifnull = null) => {
|
|
338
335
|
return getImmutableOrJS(getQueryParams(state, facet, context), key, ifnull, 'js');
|
|
339
336
|
};
|
|
340
|
-
const getCustomApi = (state, current, context =
|
|
337
|
+
const getCustomApi = (state, current, context = Context.facets, returnType) => {
|
|
341
338
|
return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'customApi'], null, returnType);
|
|
342
339
|
};
|
|
343
|
-
const getCustomEnv = (state, current, context =
|
|
340
|
+
const getCustomEnv = (state, current, context = Context.facets) => {
|
|
344
341
|
return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'env']);
|
|
345
342
|
};
|
|
346
343
|
const getTabsAndFacets = (state, returnType) => {
|
|
@@ -355,8 +352,9 @@ const getTabsAndFacets = (state, returnType) => {
|
|
|
355
352
|
if (!countFields || countFields.find((f = []) => (f === null || f === void 0 ? void 0 : f[0]) === facetName)) return getImmutableOrJS(facet, ['pagingInfo', 'totalCount']);
|
|
356
353
|
return 0;
|
|
357
354
|
}).reduce((a, b) => a + b, 0);
|
|
358
|
-
return {
|
|
359
|
-
|
|
355
|
+
return {
|
|
356
|
+
...tab,
|
|
357
|
+
[Context.facets]: Object.fromEntries(thisTabFacets),
|
|
360
358
|
totalCount: thisTabTotal
|
|
361
359
|
};
|
|
362
360
|
});
|
|
@@ -372,12 +370,12 @@ const getFacetsTotalCount = state => {
|
|
|
372
370
|
const facets = getFacets(state);
|
|
373
371
|
const wholeSearchTotal = Object.entries(facets).map(([, t = {}]) => {
|
|
374
372
|
var _t$pagingInfo;
|
|
375
|
-
|
|
376
373
|
return ((_t$pagingInfo = t.pagingInfo) === null || _t$pagingInfo === void 0 ? void 0 : _t$pagingInfo.totalCount) || 0;
|
|
377
374
|
}).reduce((a, b) => a + b, 0);
|
|
378
375
|
return wholeSearchTotal;
|
|
379
|
-
};
|
|
376
|
+
};
|
|
380
377
|
|
|
378
|
+
// An exported copy of the relevant selectors scoped by default to a facets context
|
|
381
379
|
const selectFacets = {
|
|
382
380
|
getCurrent: getCurrentFacet,
|
|
383
381
|
getCurrentTab,
|
|
@@ -396,14 +394,14 @@ const selectFacets = {
|
|
|
396
394
|
getPageIsLoading,
|
|
397
395
|
getPagesLoaded,
|
|
398
396
|
getPaging,
|
|
399
|
-
getQueryParams: (state, facet) => getQueryParams(state, facet,
|
|
397
|
+
getQueryParams: (state, facet) => getQueryParams(state, facet, Context.facets),
|
|
400
398
|
getQueryParameter: ({
|
|
401
399
|
state,
|
|
402
400
|
facet
|
|
403
401
|
}, key, ifnull) => getQueryParameter({
|
|
404
402
|
state,
|
|
405
403
|
facet,
|
|
406
|
-
context:
|
|
404
|
+
context: Context.facets
|
|
407
405
|
}, key, ifnull),
|
|
408
406
|
getRenderableFilters,
|
|
409
407
|
getResults,
|
|
@@ -414,34 +412,35 @@ const selectFacets = {
|
|
|
414
412
|
getSearchTerm,
|
|
415
413
|
getSearchTotalCount,
|
|
416
414
|
getSelectedFilters
|
|
417
|
-
};
|
|
415
|
+
};
|
|
418
416
|
|
|
417
|
+
// An exported copy of the relevant selectors pre-scoped to a listing context
|
|
419
418
|
const selectListing = {
|
|
420
419
|
getCurrent: getCurrentListing,
|
|
421
|
-
getFeaturedResults: (state, listing = '') => getFeaturedResults(state, listing,
|
|
422
|
-
getFilters: (state, listing = '') => getFilters(state, listing,
|
|
423
|
-
getFiltersToLoad: (state, listing = '') => getFiltersToLoad(state, listing,
|
|
420
|
+
getFeaturedResults: (state, listing = '') => getFeaturedResults(state, listing, Context.listings, 'js'),
|
|
421
|
+
getFilters: (state, listing = '') => getFilters(state, listing, Context.listings, 'js'),
|
|
422
|
+
getFiltersToLoad: (state, listing = '') => getFiltersToLoad(state, listing, Context.listings),
|
|
424
423
|
getListing,
|
|
425
|
-
getIsLoaded: state => getIsLoaded(state,
|
|
426
|
-
getIsLoading: state => getIsLoading(state,
|
|
427
|
-
getPageIndex: (state, listing = '') => getPageIndex(state, listing,
|
|
428
|
-
getPaging: (state, listing = '') => getPaging(state, listing,
|
|
429
|
-
getPageIsLoading: (state, listing = '') => getPageIsLoading(state, listing,
|
|
430
|
-
getPagesLoaded: (state, listing = '') => getPagesLoaded(state, listing,
|
|
431
|
-
getQueryParams: (state, listing = '') => getQueryParams(state, listing,
|
|
424
|
+
getIsLoaded: state => getIsLoaded(state, Context.listings),
|
|
425
|
+
getIsLoading: state => getIsLoading(state, Context.listings),
|
|
426
|
+
getPageIndex: (state, listing = '') => getPageIndex(state, listing, Context.listings),
|
|
427
|
+
getPaging: (state, listing = '') => getPaging(state, listing, Context.listings, 'js'),
|
|
428
|
+
getPageIsLoading: (state, listing = '') => getPageIsLoading(state, listing, Context.listings),
|
|
429
|
+
getPagesLoaded: (state, listing = '') => getPagesLoaded(state, listing, Context.listings),
|
|
430
|
+
getQueryParams: (state, listing = '') => getQueryParams(state, listing, Context.listings),
|
|
432
431
|
getQueryParameter: ({
|
|
433
432
|
state,
|
|
434
433
|
facet
|
|
435
434
|
}, key, ifnull) => getQueryParameter({
|
|
436
435
|
state,
|
|
437
436
|
facet,
|
|
438
|
-
context:
|
|
437
|
+
context: Context.listings
|
|
439
438
|
}, key, ifnull),
|
|
440
|
-
getRenderableFilters: (state, listing = '') => getRenderableFilters(state, listing,
|
|
441
|
-
getResults: (state, listing = '') => getResults(state, listing,
|
|
439
|
+
getRenderableFilters: (state, listing = '') => getRenderableFilters(state, listing, Context.listings),
|
|
440
|
+
getResults: (state, listing = '') => getResults(state, listing, Context.listings, 'js'),
|
|
442
441
|
getSearchTerm,
|
|
443
|
-
getTotalCount: (state, listing = '') => getTotalCount(state, listing,
|
|
444
|
-
getSelectedFilters: (state, listing = '') => getSelectedFilters(state, listing,
|
|
442
|
+
getTotalCount: (state, listing = '') => getTotalCount(state, listing, Context.listings),
|
|
443
|
+
getSelectedFilters: (state, listing = '') => getSelectedFilters(state, listing, Context.listings, 'js')
|
|
445
444
|
};
|
|
446
445
|
const selectCurrentPath = state => getImmutableOrJS(state, ['routing', 'currentPath']);
|
|
447
446
|
const selectCurrentProject = state => getImmutableOrJS(state, ['routing', 'currentProject']);
|
|
@@ -496,31 +495,23 @@ const now = () => {
|
|
|
496
495
|
if (typeof window == 'undefined') {
|
|
497
496
|
return Date.now();
|
|
498
497
|
}
|
|
499
|
-
|
|
500
498
|
return window.performance.now();
|
|
501
499
|
};
|
|
502
500
|
|
|
503
501
|
const getClientConfig = (project, env) => {
|
|
504
|
-
let config = DELIVERY_API_CONFIG;
|
|
505
|
-
/* global DELIVERY_API_CONFIG */
|
|
506
|
-
|
|
502
|
+
let config = DELIVERY_API_CONFIG; /* global DELIVERY_API_CONFIG */
|
|
507
503
|
if (project) {
|
|
508
504
|
config.projectId = project;
|
|
509
505
|
}
|
|
510
|
-
|
|
511
|
-
if (typeof window != 'undefined' && PROXY_DELIVERY_API
|
|
512
|
-
/* global PROXY_DELIVERY_API */
|
|
513
|
-
) {
|
|
506
|
+
if (typeof window != 'undefined' && PROXY_DELIVERY_API /* global PROXY_DELIVERY_API */) {
|
|
514
507
|
// ensure a relative url is used to bypass the need for CORS (separate OPTIONS calls)
|
|
515
508
|
config.rootUrl = env || '';
|
|
516
509
|
config.responseHandler = {
|
|
517
510
|
404: () => null
|
|
518
511
|
};
|
|
519
512
|
}
|
|
520
|
-
|
|
521
513
|
return config;
|
|
522
514
|
};
|
|
523
|
-
|
|
524
515
|
class CacheNode {
|
|
525
516
|
constructor(key, value) {
|
|
526
517
|
this.key = key;
|
|
@@ -528,9 +519,7 @@ class CacheNode {
|
|
|
528
519
|
this.next = null;
|
|
529
520
|
this.prev = null;
|
|
530
521
|
}
|
|
531
|
-
|
|
532
522
|
}
|
|
533
|
-
|
|
534
523
|
class LruCache {
|
|
535
524
|
constructor(limit = 100) {
|
|
536
525
|
this.map = {};
|
|
@@ -539,7 +528,6 @@ class LruCache {
|
|
|
539
528
|
this.limit = limit || 100;
|
|
540
529
|
this.size = 0;
|
|
541
530
|
}
|
|
542
|
-
|
|
543
531
|
get(key) {
|
|
544
532
|
if (this.map[key]) {
|
|
545
533
|
let value = this.map[key].value;
|
|
@@ -549,10 +537,8 @@ class LruCache {
|
|
|
549
537
|
return value;
|
|
550
538
|
}
|
|
551
539
|
}
|
|
552
|
-
|
|
553
540
|
set(key, value) {
|
|
554
541
|
let node = new CacheNode(key, value);
|
|
555
|
-
|
|
556
542
|
if (this.map[key]) {
|
|
557
543
|
this.remove(key);
|
|
558
544
|
} else {
|
|
@@ -563,60 +549,46 @@ class LruCache {
|
|
|
563
549
|
this.tail.next = null;
|
|
564
550
|
}
|
|
565
551
|
}
|
|
566
|
-
|
|
567
552
|
this.setHead(node);
|
|
568
553
|
}
|
|
569
|
-
|
|
570
554
|
setHead(node) {
|
|
571
555
|
node.next = this.head;
|
|
572
556
|
node.prev = null;
|
|
573
|
-
|
|
574
557
|
if (this.head) {
|
|
575
558
|
this.head.prev = node;
|
|
576
559
|
}
|
|
577
|
-
|
|
578
560
|
this.head = node;
|
|
579
|
-
|
|
580
561
|
if (!this.tail) {
|
|
581
562
|
this.tail = node;
|
|
582
563
|
}
|
|
583
|
-
|
|
584
564
|
this.size++;
|
|
585
565
|
this.map[node.key] = node;
|
|
586
566
|
}
|
|
587
|
-
|
|
588
567
|
remove(key) {
|
|
589
568
|
let node = this.map[key];
|
|
590
|
-
|
|
591
569
|
if (node.prev) {
|
|
592
570
|
node.prev.next = node.next;
|
|
593
571
|
} else {
|
|
594
572
|
this.head = node.next;
|
|
595
573
|
}
|
|
596
|
-
|
|
597
574
|
if (node.next) {
|
|
598
575
|
node.next.prev = node.prev;
|
|
599
576
|
} else {
|
|
600
577
|
this.tail = node.prev;
|
|
601
578
|
}
|
|
602
|
-
|
|
603
579
|
delete this.map[key];
|
|
604
580
|
this.size--;
|
|
605
581
|
}
|
|
606
|
-
|
|
607
582
|
}
|
|
608
|
-
|
|
609
583
|
class CachedSearch {
|
|
610
584
|
constructor() {
|
|
611
585
|
this.cache = new LruCache();
|
|
612
586
|
this.taxonomyLookup = {};
|
|
613
587
|
}
|
|
614
|
-
|
|
615
588
|
search(query, linkDepth, project, env) {
|
|
616
589
|
const client = contensisDeliveryApi.Client.create(getClientConfig(project, env));
|
|
617
590
|
return this.request(project + JSON.stringify(query) + linkDepth.toString(), () => client.entries.search(query, linkDepth));
|
|
618
591
|
}
|
|
619
|
-
|
|
620
592
|
getTaxonomyNodeByPath(path, project, env) {
|
|
621
593
|
const client = contensisDeliveryApi.Client.create(getClientConfig(project, env));
|
|
622
594
|
return this.request(`[TAXONOMY NODE] ${path}`, () => client.taxonomy.getNodeByPath({
|
|
@@ -625,7 +597,6 @@ class CachedSearch {
|
|
|
625
597
|
childDepth: 2
|
|
626
598
|
}).then(node => this.extendTaxonomyNode(node)));
|
|
627
599
|
}
|
|
628
|
-
|
|
629
600
|
request(key, execute) {
|
|
630
601
|
if (!this.cache.get(key) || typeof window == 'undefined') {
|
|
631
602
|
let promise = execute();
|
|
@@ -634,41 +605,36 @@ class CachedSearch {
|
|
|
634
605
|
this.cache.remove(key);
|
|
635
606
|
});
|
|
636
607
|
}
|
|
637
|
-
|
|
638
608
|
return this.cache.get(key);
|
|
639
609
|
}
|
|
640
|
-
|
|
641
610
|
extendTaxonomyNode(node) {
|
|
642
611
|
let id = this.getTaxonomyId(node);
|
|
643
612
|
this.taxonomyLookup[id] = node.key;
|
|
644
|
-
return {
|
|
613
|
+
return {
|
|
614
|
+
...node,
|
|
645
615
|
id,
|
|
646
616
|
children: node.children ? node.children.map(n => this.extendTaxonomyNode(n)) : null
|
|
647
617
|
};
|
|
648
618
|
}
|
|
649
|
-
|
|
650
619
|
getTaxonomyId(node) {
|
|
651
620
|
if (node.key) {
|
|
652
621
|
let parts = node.key.split('/');
|
|
653
622
|
return parts[parts.length - 1];
|
|
654
623
|
}
|
|
655
|
-
|
|
656
624
|
return '';
|
|
657
625
|
}
|
|
658
|
-
|
|
659
626
|
fetch(uri, opts = {}) {
|
|
660
627
|
return this.request(`[FETCH] ${uri} ${JSON.stringify(opts)}`, () => fetch(uri, opts));
|
|
661
628
|
}
|
|
662
|
-
|
|
663
629
|
}
|
|
664
|
-
|
|
665
630
|
const cachedSearch = new CachedSearch();
|
|
666
631
|
|
|
667
632
|
// eslint-disable-next-line import/default
|
|
668
633
|
function fixFreeTextForElastic(s) {
|
|
669
634
|
const illegalChars = ['>', '<', '=', '|', '!', '{', '}', '[', ']', '^', '~', '*', '?', ':', '\\', '/'];
|
|
670
635
|
const illegalRegEx = new RegExp(illegalChars.map(c => '\\' + c).join('|'), 'g');
|
|
671
|
-
s = s.replace(illegalRegEx, '');
|
|
636
|
+
s = s.replace(illegalRegEx, '');
|
|
637
|
+
// s = s.replace(encodedRegEx, ''); // (m) => '\\\\' + m);
|
|
672
638
|
|
|
673
639
|
return s;
|
|
674
640
|
}
|
|
@@ -688,13 +654,11 @@ const getItemsFromResult = result => {
|
|
|
688
654
|
const {
|
|
689
655
|
payload
|
|
690
656
|
} = result || {};
|
|
691
|
-
|
|
692
657
|
if (payload) {
|
|
693
658
|
if (Array.isArray(payload)) return payload;
|
|
694
659
|
if (Array.isArray(payload.items)) return payload.items;
|
|
695
660
|
return payload;
|
|
696
661
|
}
|
|
697
|
-
|
|
698
662
|
return [];
|
|
699
663
|
};
|
|
700
664
|
const extractQuotedPhrases = searchTerm => {
|
|
@@ -706,6 +670,7 @@ const buildUrl = (route, params) => {
|
|
|
706
670
|
const path = qs ? `${route}${route.includes('?') ? '&' : '?'}${qs}` : route;
|
|
707
671
|
return path;
|
|
708
672
|
};
|
|
673
|
+
|
|
709
674
|
/**
|
|
710
675
|
* Returns all params from the current route query string or static route
|
|
711
676
|
* Supply static route argument if reading parameters from the route path
|
|
@@ -714,15 +679,14 @@ const buildUrl = (route, params) => {
|
|
|
714
679
|
* @param location location object containing at least pathname and search
|
|
715
680
|
* @returns Keyed params object
|
|
716
681
|
*/
|
|
717
|
-
|
|
718
682
|
const routeParams = (staticRoute, location) => {
|
|
719
683
|
var _staticRoute$match;
|
|
720
|
-
|
|
721
684
|
// match.params is react-router-config/react-router@5 style
|
|
722
685
|
// params is supplied with RouteObject in react-router@6
|
|
723
686
|
const pathParams = (staticRoute === null || staticRoute === void 0 ? void 0 : (_staticRoute$match = staticRoute.match) === null || _staticRoute$match === void 0 ? void 0 : _staticRoute$match.params) || (staticRoute === null || staticRoute === void 0 ? void 0 : staticRoute.params) || {};
|
|
724
687
|
const queryParams = queryString.parse(typeof window !== 'undefined' ? window.location.search : (location === null || location === void 0 ? void 0 : location.search) || '');
|
|
725
|
-
return {
|
|
688
|
+
return {
|
|
689
|
+
...pathParams,
|
|
726
690
|
...queryParams
|
|
727
691
|
};
|
|
728
692
|
};
|
|
@@ -730,13 +694,11 @@ const callCustomApi = async (customApi, filters) => {
|
|
|
730
694
|
const apiUri = customApi.uri || '';
|
|
731
695
|
let uri = buildUrl(apiUri, filters);
|
|
732
696
|
if (!uri) throw new Error('uri is required to use customApi');
|
|
733
|
-
|
|
734
697
|
if (typeof window == 'undefined') {
|
|
735
698
|
if (!uri.startsWith('http')) uri = `http://localhost:3001${uri}`;
|
|
736
699
|
const response = await fetch(uri);
|
|
737
700
|
return await response.json();
|
|
738
701
|
}
|
|
739
|
-
|
|
740
702
|
const response = await cachedSearch.fetch(uri);
|
|
741
703
|
return await response.clone().json();
|
|
742
704
|
};
|
|
@@ -744,32 +706,27 @@ const removeEmptyAttributes = obj => {
|
|
|
744
706
|
Object.entries(obj).forEach(([key, val]) => val && typeof val === 'object' && removeEmptyAttributes(val) || (typeof val === 'undefined' || val === null || val === '') && delete obj[key]);
|
|
745
707
|
return obj;
|
|
746
708
|
};
|
|
747
|
-
const toArray = (obj, seperator = ',') => typeof obj === 'undefined' || obj === null ? obj : Array.isArray(obj) ? obj : obj.split(seperator);
|
|
709
|
+
const toArray = (obj, seperator = ',') => typeof obj === 'undefined' || obj === null ? obj : Array.isArray(obj) ? obj : obj.split(seperator);
|
|
748
710
|
|
|
711
|
+
// assumes array elements are primitive types
|
|
749
712
|
const areArraysEqualSets = (a1, a2) => {
|
|
750
713
|
const superSet = {};
|
|
751
|
-
|
|
752
714
|
for (const ai of a1) {
|
|
753
715
|
const e = ai + typeof ai;
|
|
754
716
|
superSet[e] = 1;
|
|
755
717
|
}
|
|
756
|
-
|
|
757
718
|
for (const ai of a2) {
|
|
758
719
|
const e = ai + typeof ai;
|
|
759
|
-
|
|
760
720
|
if (!superSet[e]) {
|
|
761
721
|
return false;
|
|
762
722
|
}
|
|
763
|
-
|
|
764
723
|
superSet[e] = 2;
|
|
765
724
|
}
|
|
766
|
-
|
|
767
725
|
for (const e in superSet) {
|
|
768
726
|
if (superSet[e] === 1) {
|
|
769
727
|
return false;
|
|
770
728
|
}
|
|
771
729
|
}
|
|
772
|
-
|
|
773
730
|
return true;
|
|
774
731
|
};
|
|
775
732
|
|
|
@@ -780,12 +737,12 @@ const searchUriTemplate = {
|
|
|
780
737
|
}) => {
|
|
781
738
|
const context = getSearchContext(state);
|
|
782
739
|
const currentPath = selectCurrentPath(state) || '/search';
|
|
783
|
-
|
|
784
740
|
if (context !== 'listings') {
|
|
785
741
|
const currentFacet = facet || getCurrentFacet(state);
|
|
786
742
|
const filters = getSelectedFilters(state, facet, context);
|
|
787
|
-
const currentFilter = filters.contentTypeId;
|
|
743
|
+
const currentFilter = filters.contentTypeId;
|
|
788
744
|
|
|
745
|
+
// Check if we have a filter first
|
|
789
746
|
const newPath = (currentFilter === null || currentFilter === void 0 ? void 0 : currentFilter.length) > 0 && currentFacet ? `${currentPath}/${currentFacet}/${currentFilter}` : currentFacet ? `${currentPath}/${currentFacet}` : currentPath;
|
|
790
747
|
return newPath;
|
|
791
748
|
} else {
|
|
@@ -800,29 +757,29 @@ const searchUriTemplate = {
|
|
|
800
757
|
pageIndex,
|
|
801
758
|
pageSize
|
|
802
759
|
}) => {
|
|
803
|
-
const searchContext = getSearchContext(state);
|
|
760
|
+
const searchContext = getSearchContext(state);
|
|
761
|
+
// Lose stateFilters and currentSearch if a new
|
|
804
762
|
// term is passed via an argument
|
|
805
|
-
|
|
806
763
|
const stateFilters = term ? {} : Object.fromEntries(Object.entries(getSelectedFilters(state, facet, searchContext, 'js')).map(([k, f]) => [k, f === null || f === void 0 ? void 0 : f.join(',')]));
|
|
807
764
|
const currentSearch = !term && getImmutableOrJS(state, ['routing', 'location', 'search']);
|
|
808
765
|
const currentQs = removeEmptyAttributes(queryString.parse(currentSearch));
|
|
809
766
|
if (orderBy) currentQs.orderBy = orderBy;
|
|
810
|
-
const searchTerm = getSearchTerm(state);
|
|
767
|
+
const searchTerm = getSearchTerm(state);
|
|
768
|
+
// Use Immutable's merge to merge the stateFilters with any current Qs
|
|
811
769
|
// to build the new Qs.
|
|
812
|
-
|
|
813
770
|
const mergedSearch = removeEmptyAttributes(merge__default["default"](currentQs, stateFilters));
|
|
814
771
|
if (searchTerm) mergedSearch.term = searchTerm;
|
|
815
772
|
if (pageIndex) mergedSearch.pageIndex = pageIndex + 1;
|
|
816
773
|
if (pageIndex === 0) mergedSearch.pageIndex = undefined;
|
|
817
|
-
if (pageSize) mergedSearch.pageSize = pageSize;
|
|
774
|
+
if (pageSize) mergedSearch.pageSize = pageSize;
|
|
818
775
|
|
|
776
|
+
// We don't want these as search params in the url, we just need the search package to see them
|
|
819
777
|
return queryString.stringify(mergedSearch);
|
|
820
778
|
},
|
|
821
779
|
hash: ({
|
|
822
780
|
state
|
|
823
781
|
}) => getImmutableOrJS(state, ['routing', 'location', 'hash'], '').replace('#', '')
|
|
824
782
|
};
|
|
825
|
-
|
|
826
783
|
const mapStateToSearchUri = state => mapJson__default["default"](state, searchUriTemplate);
|
|
827
784
|
|
|
828
785
|
const DataFormats = {
|
|
@@ -857,7 +814,8 @@ const Fields = {
|
|
|
857
814
|
|
|
858
815
|
const fieldExpression = (field, value, operator = 'equalTo', weight, fuzzySearch = false) => {
|
|
859
816
|
if (!field || !value || Array.isArray(value) && value.length === 0) return [];
|
|
860
|
-
if (Array.isArray(field))
|
|
817
|
+
if (Array.isArray(field))
|
|
818
|
+
// If an array of fieldIds have been provided, call self for each fieldId
|
|
861
819
|
// to generate expressions that are combined with an 'or' operator
|
|
862
820
|
return [contensisCoreApi.Op.or(...field.map(fieldId => fieldExpression(fieldId, value, operator, weight, fuzzySearch)).flat())];
|
|
863
821
|
if (operator === 'between') return between(field, value);
|
|
@@ -866,19 +824,15 @@ const fieldExpression = (field, value, operator = 'equalTo', weight, fuzzySearch
|
|
|
866
824
|
const contentTypeIdExpression = (contentTypeIds, webpageTemplates, assetTypes) => {
|
|
867
825
|
const expressions = [];
|
|
868
826
|
if (!contentTypeIds && !webpageTemplates && !assetTypes) return expressions;
|
|
869
|
-
|
|
870
827
|
if (contentTypeIds && contentTypeIds.length > 0) {
|
|
871
828
|
expressions.push(...dataFormatExpression(contentTypeIds, DataFormats.entry));
|
|
872
829
|
}
|
|
873
|
-
|
|
874
830
|
if (webpageTemplates && webpageTemplates.length > 0) {
|
|
875
831
|
expressions.push(...dataFormatExpression(webpageTemplates, DataFormats.webpage));
|
|
876
832
|
}
|
|
877
|
-
|
|
878
833
|
if (assetTypes && assetTypes.length > 0) {
|
|
879
834
|
expressions.push(...dataFormatExpression(assetTypes, DataFormats.asset));
|
|
880
835
|
}
|
|
881
|
-
|
|
882
836
|
if (expressions.length > 1) return [contensisCoreApi.Op.or(...expressions)];
|
|
883
837
|
return expressions;
|
|
884
838
|
};
|
|
@@ -886,14 +840,16 @@ const filterExpressions = (filters, isOptional = false) => {
|
|
|
886
840
|
if (!filters) return [];
|
|
887
841
|
const expressions = [];
|
|
888
842
|
filters.map(selectedFilter => {
|
|
889
|
-
if (selectedFilter.logicOperator === 'and')
|
|
843
|
+
if (selectedFilter.logicOperator === 'and')
|
|
844
|
+
// using 'and' logic operator we loop through each filter
|
|
890
845
|
// and loop through all values to add an expression for each filter value
|
|
891
846
|
selectedFilter.values.forEach(value => expressions.push(...fieldExpression(selectedFilter.key, value, selectedFilter.fieldOperator || 'equalTo')));else if (selectedFilter.logicOperator === 'not') {
|
|
892
847
|
const fieldExpressions = fieldExpression(selectedFilter.key, selectedFilter.values, selectedFilter.fieldOperator || 'in');
|
|
893
848
|
fieldExpressions.forEach(expr => {
|
|
894
849
|
expressions.push(contensisCoreApi.Op.not(expr));
|
|
895
850
|
});
|
|
896
|
-
}
|
|
851
|
+
}
|
|
852
|
+
// using 'or' logic operator we loop over each filter
|
|
897
853
|
// and simply add the array of values to an expression with an 'in' operator
|
|
898
854
|
else expressions.push(...fieldExpression(selectedFilter.key, selectedFilter.values, selectedFilter.fieldOperator || 'in'));
|
|
899
855
|
if (isOptional) expressions.push(contensisCoreApi.Op.not(fieldExpression(selectedFilter.key, true, 'exists')[0]));
|
|
@@ -917,7 +873,6 @@ const dataFormatExpression = (contentTypeIds, dataFormat = DataFormats.entry) =>
|
|
|
917
873
|
if (notContentTypeIds.length > 0 && notExpr) andExpr.add(notExpr);
|
|
918
874
|
return [andExpr];
|
|
919
875
|
}
|
|
920
|
-
|
|
921
876
|
return [];
|
|
922
877
|
};
|
|
923
878
|
const featuredResultsExpression = ({
|
|
@@ -926,24 +881,22 @@ const featuredResultsExpression = ({
|
|
|
926
881
|
fieldValue = true
|
|
927
882
|
} = {}) => {
|
|
928
883
|
const expressions = [];
|
|
929
|
-
|
|
930
884
|
if (contentTypeId) {
|
|
931
885
|
expressions.push(...contentTypeIdExpression(Array.isArray(contentTypeId) ? contentTypeId : [contentTypeId]));
|
|
932
886
|
}
|
|
933
|
-
|
|
934
887
|
if (fieldId && fieldValue) {
|
|
935
888
|
expressions.push(...fieldExpression(fieldId, fieldValue));
|
|
936
889
|
}
|
|
937
|
-
|
|
938
890
|
return expressions;
|
|
939
891
|
};
|
|
940
892
|
const languagesExpression = languages => fieldExpression(Fields.sys.language, languages);
|
|
941
893
|
const includeInSearchExpressions = (webpageTemplates, includeInSearchFields) => {
|
|
942
|
-
const expressions = [];
|
|
894
|
+
const expressions = [];
|
|
895
|
+
// Or include this expression if we have explicity specified non-default includeInSearch fields
|
|
896
|
+
if (Array.isArray(includeInSearchFields)) expressions.push(...includeInSearchFields.map(includeInSearchField => contensisCoreApi.Op.or(contensisCoreApi.Op.and(contensisCoreApi.Op.exists(includeInSearchField, true), contensisCoreApi.Op.equalTo(includeInSearchField, true)), contensisCoreApi.Op.exists(includeInSearchField, false))));
|
|
943
897
|
|
|
944
|
-
|
|
898
|
+
// If webpageTemplates have been specified, include this expression
|
|
945
899
|
// with the default includeInSearch field from classic Contensis.
|
|
946
|
-
|
|
947
900
|
if (Array.isArray(webpageTemplates) && webpageTemplates.length > 0) expressions.push(contensisCoreApi.Op.or(contensisCoreApi.Op.and(contensisCoreApi.Op.exists(Fields.sys.includeInSearch, true), contensisCoreApi.Op.equalTo(Fields.sys.includeInSearch, true)), contensisCoreApi.Op.exists(Fields.sys.includeInSearch, false)));
|
|
948
901
|
return expressions;
|
|
949
902
|
};
|
|
@@ -963,69 +916,52 @@ const excludeIdsExpression = excludeIds => {
|
|
|
963
916
|
};
|
|
964
917
|
const orderByExpression = orderBy => {
|
|
965
918
|
let expression;
|
|
966
|
-
|
|
967
919
|
if (orderBy && orderBy.length > 0) {
|
|
968
920
|
expression = contensisCoreApi.OrderBy;
|
|
969
|
-
|
|
970
921
|
for (const ob of orderBy) {
|
|
971
922
|
var _expression, _expression2;
|
|
972
|
-
|
|
973
923
|
expression = ob.startsWith('-') ? (_expression = expression) === null || _expression === void 0 ? void 0 : _expression.desc(ob.substring(1)) : (_expression2 = expression) === null || _expression2 === void 0 ? void 0 : _expression2.asc(ob);
|
|
974
924
|
}
|
|
975
925
|
}
|
|
976
|
-
|
|
977
926
|
return expression;
|
|
978
927
|
};
|
|
979
|
-
|
|
980
928
|
const equalToOrIn = (field, value, operator = 'equalTo', fuzzySearch = false) => {
|
|
981
929
|
if (value.length === 0) return [];
|
|
982
|
-
|
|
983
930
|
if (Array.isArray(value)) {
|
|
984
931
|
if (operator === 'equalTo' || operator === 'in') return [contensisCoreApi.Op.in(field, ...value)];
|
|
985
932
|
const expressions = value.map(innerValue => {
|
|
986
933
|
var _between, _distanceWithin;
|
|
987
|
-
|
|
988
934
|
switch (operator) {
|
|
989
935
|
case 'between':
|
|
990
936
|
return (_between = between(field, innerValue)) === null || _between === void 0 ? void 0 : _between[0];
|
|
991
|
-
|
|
992
937
|
case 'distanceWithin':
|
|
993
938
|
return (_distanceWithin = distanceWithin(field, innerValue)) === null || _distanceWithin === void 0 ? void 0 : _distanceWithin[0];
|
|
994
|
-
|
|
995
939
|
case 'exists':
|
|
996
940
|
return contensisCoreApi.Op.exists(field, innerValue);
|
|
997
|
-
|
|
998
941
|
case 'freeText':
|
|
999
942
|
// TODO: Potentially needs further implementation of new options
|
|
1000
943
|
return contensisCoreApi.Op[operator](field, innerValue, fuzzySearch, undefined);
|
|
1001
|
-
|
|
1002
944
|
default:
|
|
1003
945
|
return contensisCoreApi.Op[operator](field, innerValue);
|
|
1004
946
|
}
|
|
1005
947
|
});
|
|
1006
948
|
return (expressions === null || expressions === void 0 ? void 0 : expressions.length) > 1 ? [contensisCoreApi.Op.or(...expressions)] : expressions || [];
|
|
1007
949
|
}
|
|
1008
|
-
|
|
1009
950
|
switch (operator) {
|
|
1010
951
|
case 'between':
|
|
1011
952
|
return between(field, value);
|
|
1012
|
-
|
|
1013
953
|
case 'distanceWithin':
|
|
1014
954
|
return distanceWithin(field, value);
|
|
1015
|
-
|
|
1016
955
|
case 'freeText':
|
|
1017
956
|
// TODO: Potentially needs further implementation of new options
|
|
1018
957
|
return [contensisCoreApi.Op.freeText(field, value, fuzzySearch, undefined)];
|
|
1019
|
-
|
|
1020
958
|
default:
|
|
1021
959
|
return [contensisCoreApi.Op[operator](field, value)];
|
|
1022
960
|
}
|
|
1023
961
|
};
|
|
1024
|
-
|
|
1025
962
|
const between = (field, value) => {
|
|
1026
963
|
const handle = betweenValue => {
|
|
1027
964
|
const valArr = betweenValue.split('--');
|
|
1028
|
-
|
|
1029
965
|
if (valArr.length > 1) {
|
|
1030
966
|
const [minimum, maximum] = valArr;
|
|
1031
967
|
return contensisCoreApi.Op.between(field, minimum, maximum);
|
|
@@ -1035,17 +971,14 @@ const between = (field, value) => {
|
|
|
1035
971
|
return false;
|
|
1036
972
|
}
|
|
1037
973
|
};
|
|
1038
|
-
|
|
1039
974
|
if (value.length === 0) return [];
|
|
1040
975
|
if (Array.isArray(value)) return [contensisCoreApi.Op.or(...value.map(handle).filter(bc => bc !== false))];
|
|
1041
976
|
const op = handle(value);
|
|
1042
977
|
return op ? [op] : [];
|
|
1043
978
|
};
|
|
1044
|
-
|
|
1045
979
|
const distanceWithin = (field, value) => {
|
|
1046
980
|
const handle = distanceValue => {
|
|
1047
981
|
const valArr = distanceValue.split(' ');
|
|
1048
|
-
|
|
1049
982
|
if (valArr.length > 1) {
|
|
1050
983
|
const [lat, lon] = valArr;
|
|
1051
984
|
return contensisCoreApi.Op.distanceWithin(field, Number(lat), Number(lon), (valArr === null || valArr === void 0 ? void 0 : valArr[2]) || '10mi');
|
|
@@ -1055,28 +988,27 @@ const distanceWithin = (field, value) => {
|
|
|
1055
988
|
return false;
|
|
1056
989
|
}
|
|
1057
990
|
};
|
|
1058
|
-
|
|
1059
991
|
if (value.length === 0) return [];
|
|
1060
992
|
if (Array.isArray(value)) return [contensisCoreApi.Op.or(...value.map(handle).filter(bc => bc !== false))];
|
|
1061
993
|
const op = handle(value);
|
|
1062
994
|
return op ? [op] : [];
|
|
1063
995
|
};
|
|
996
|
+
|
|
1064
997
|
/**
|
|
1065
998
|
* Accept HTTP style objects and map them to
|
|
1066
999
|
* their equivalent JS client "Op" expressions
|
|
1067
1000
|
* @param {array} where the where array as you'd provide it to the HTTP API
|
|
1068
1001
|
* @returns {array} array of constructed Delivery API Operators
|
|
1069
1002
|
*/
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
1003
|
const customWhereExpressions = where => {
|
|
1073
|
-
if (!where || !Array.isArray(where)) return [];
|
|
1004
|
+
if (!where || !Array.isArray(where)) return [];
|
|
1074
1005
|
|
|
1006
|
+
// Map each clause inside the where array
|
|
1075
1007
|
return where.map(clause => {
|
|
1076
|
-
let expression;
|
|
1008
|
+
let expression;
|
|
1009
|
+
// Map through each property in the clause so we can
|
|
1077
1010
|
// capture the values required and reconstruct them as
|
|
1078
1011
|
// a Delivery API expression
|
|
1079
|
-
|
|
1080
1012
|
let operator;
|
|
1081
1013
|
Object.keys(clause).map((key, idx) => {
|
|
1082
1014
|
// The clause may contain only one key
|
|
@@ -1084,7 +1016,6 @@ const customWhereExpressions = where => {
|
|
|
1084
1016
|
const field = clause.field;
|
|
1085
1017
|
const value = clause[Object.keys(clause).find(k => !['field', 'weight'].includes(k)) || ''];
|
|
1086
1018
|
const weight = clause.weight;
|
|
1087
|
-
|
|
1088
1019
|
if (idx === 0) {
|
|
1089
1020
|
if (operator === 'and' || operator === 'or') {
|
|
1090
1021
|
// These are array expressions so we can call ourself recursively
|
|
@@ -1092,24 +1023,21 @@ const customWhereExpressions = where => {
|
|
|
1092
1023
|
const recurseExpr = customWhereExpressions(clause[operator]);
|
|
1093
1024
|
expression = contensisCoreApi.Op[operator](...recurseExpr);
|
|
1094
1025
|
}
|
|
1095
|
-
|
|
1096
1026
|
if (['not'].includes(operator)) {
|
|
1097
1027
|
// A 'not' expression is an object with only one inner field and inner operator
|
|
1098
1028
|
Object.keys(value).map((notKey, notIdx) => {
|
|
1099
1029
|
const innerOperator = notKey;
|
|
1100
1030
|
const innerValue = value[notKey];
|
|
1101
|
-
const innerField = value.field;
|
|
1031
|
+
const innerField = value.field;
|
|
1032
|
+
// Map the expression when we've looped and scoped to
|
|
1102
1033
|
// the second property inside the clause
|
|
1103
|
-
|
|
1104
1034
|
if (notIdx === 1) expression = contensisCoreApi.Op.not(makeJsExpression(innerOperator, innerField, innerValue));
|
|
1105
1035
|
});
|
|
1106
1036
|
}
|
|
1107
|
-
}
|
|
1037
|
+
}
|
|
1038
|
+
// Map the expression when we've looped and scoped to
|
|
1108
1039
|
// the second property inside the clause
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
1040
|
operator = Object.keys(clause).find(clauseKey => !['field', 'weight'].includes(clauseKey));
|
|
1112
|
-
|
|
1113
1041
|
if (idx === 1) {
|
|
1114
1042
|
expression = makeJsExpression(operator, field, value);
|
|
1115
1043
|
if (typeof weight === 'number') expression = expression.weight(weight);
|
|
@@ -1118,28 +1046,29 @@ const customWhereExpressions = where => {
|
|
|
1118
1046
|
return expression;
|
|
1119
1047
|
});
|
|
1120
1048
|
};
|
|
1121
|
-
|
|
1122
1049
|
const makeJsExpression = (operator, field, value) => operator === 'freeText' || operator === 'contains' ? contensisCoreApi.Op[operator](field, value) : operator === 'in' ? contensisCoreApi.Op[operator](field, ...value) : operator === 'exists' ? contensisCoreApi.Op[operator](field, value) : operator === 'between' ? contensisCoreApi.Op[operator](field, value[0], value[1]) : operator === 'distanceWithin' ? contensisCoreApi.Op[operator](field, value === null || value === void 0 ? void 0 : value.lat, value === null || value === void 0 ? void 0 : value.lon, value === null || value === void 0 ? void 0 : value.distance) : contensisCoreApi.Op[operator](field, value);
|
|
1123
|
-
|
|
1124
1050
|
const termExpressions = (searchTerm, weightedSearchFields, fuzzySearch) => {
|
|
1125
1051
|
if (searchTerm && weightedSearchFields && weightedSearchFields.length > 0) {
|
|
1126
1052
|
// Extract any phrases in quotes to array
|
|
1127
|
-
const quotedPhrases = extractQuotedPhrases(searchTerm);
|
|
1053
|
+
const quotedPhrases = extractQuotedPhrases(searchTerm);
|
|
1128
1054
|
|
|
1055
|
+
// Modify the search term to remove any quoted phrases to leave any remaining terms
|
|
1129
1056
|
let modifiedSearchTerm = searchTerm;
|
|
1130
|
-
quotedPhrases.forEach(qp => modifiedSearchTerm = modifiedSearchTerm.replace(qp, '').replace('""', '').trim());
|
|
1057
|
+
quotedPhrases.forEach(qp => modifiedSearchTerm = modifiedSearchTerm.replace(qp, '').replace('""', '').trim());
|
|
1131
1058
|
|
|
1132
|
-
|
|
1059
|
+
// Push to the operators array to include in the query
|
|
1060
|
+
const operators = [];
|
|
1133
1061
|
|
|
1062
|
+
// Helper functions to generate Op expressions
|
|
1134
1063
|
const containsOp = (f, term) => fieldExpression(f.fieldId, fixFreeTextForElastic(term), 'contains', f.weight);
|
|
1064
|
+
const freeTextOp = (f, term) => fieldExpression(f.fieldId, fixFreeTextForElastic(term), 'freeText', f.weight, fuzzySearch);
|
|
1135
1065
|
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1066
|
+
// For each weighted search field
|
|
1139
1067
|
weightedSearchFields.forEach(wsf => {
|
|
1140
1068
|
// Push to field operators
|
|
1141
|
-
const fieldOperators = [];
|
|
1069
|
+
const fieldOperators = [];
|
|
1142
1070
|
|
|
1071
|
+
// Add operator expressions for modified search term
|
|
1143
1072
|
if (modifiedSearchTerm) {
|
|
1144
1073
|
if ([Fields.keywords, Fields.sys.filename, Fields.sys.uri].includes(wsf.fieldId)) {
|
|
1145
1074
|
fieldOperators.push(...containsOp(wsf, modifiedSearchTerm));
|
|
@@ -1150,20 +1079,22 @@ const termExpressions = (searchTerm, weightedSearchFields, fuzzySearch) => {
|
|
|
1150
1079
|
fieldOperators.push(...freeTextOp(wsf, modifiedSearchTerm));
|
|
1151
1080
|
}
|
|
1152
1081
|
}
|
|
1153
|
-
}
|
|
1082
|
+
}
|
|
1154
1083
|
|
|
1084
|
+
// Add operator expressions for any quoted phrases
|
|
1085
|
+
quotedPhrases.forEach(qp => fieldOperators.push(...containsOp(wsf, qp)));
|
|
1155
1086
|
|
|
1156
|
-
|
|
1087
|
+
// If we are using multiple operators for a field we will
|
|
1157
1088
|
// wrap each field inside an And operator so we will match
|
|
1158
1089
|
// all terms/phrases rather than any terms/phrases
|
|
1159
|
-
|
|
1160
1090
|
if (fieldOperators.length > 1) {
|
|
1161
1091
|
operators.push(contensisCoreApi.Op.and(...fieldOperators));
|
|
1162
1092
|
} else {
|
|
1163
1093
|
operators.push(...fieldOperators);
|
|
1164
1094
|
}
|
|
1165
|
-
});
|
|
1095
|
+
});
|
|
1166
1096
|
|
|
1097
|
+
// Wrap operators in an Or operator
|
|
1167
1098
|
return [contensisCoreApi.Op.or().addRange(operators).add(contensisCoreApi.Op.freeText(Fields.searchContent, searchTerm, fuzzySearch))];
|
|
1168
1099
|
} else if (searchTerm) {
|
|
1169
1100
|
// Searching without weightedSearchFields defined will fall back
|
|
@@ -1223,11 +1154,9 @@ const searchQuery = ({
|
|
|
1223
1154
|
const query = new contensisCoreApi.Query(...expressions);
|
|
1224
1155
|
if (!searchTerm) query.orderBy = orderByExpression(orderBy);
|
|
1225
1156
|
if (dynamicOrderBy && dynamicOrderBy.length) query.orderBy = orderByExpression(dynamicOrderBy);
|
|
1226
|
-
|
|
1227
1157
|
if (fields && fields.length > 0 && !isFeatured) {
|
|
1228
1158
|
query.fields = fields;
|
|
1229
1159
|
}
|
|
1230
|
-
|
|
1231
1160
|
query.pageIndex = isFeatured ? 0 : pageIndex;
|
|
1232
1161
|
query.pageSize = isFeatured && typeof featuredResults.count === 'number' ? featuredResults.count : pageSize;
|
|
1233
1162
|
return query;
|
|
@@ -1248,7 +1177,6 @@ const mapEntriesToSearchResults = ({
|
|
|
1248
1177
|
const mapperFunc = mapper || mappers && mappers.results;
|
|
1249
1178
|
return items && typeof mapperFunc === 'function' ? mapperFunc(items, facet, context, state) : [];
|
|
1250
1179
|
};
|
|
1251
|
-
|
|
1252
1180
|
const facetTemplate = {
|
|
1253
1181
|
type: () => SET_SEARCH_ENTRIES,
|
|
1254
1182
|
context: 'action.context',
|
|
@@ -1291,11 +1219,9 @@ const facetTemplate = {
|
|
|
1291
1219
|
pagesLoaded
|
|
1292
1220
|
}) => {
|
|
1293
1221
|
const loaded = [...(pagesLoaded || [])];
|
|
1294
|
-
|
|
1295
1222
|
if (isNaN(loaded.find(l => l === pageIndex))) {
|
|
1296
1223
|
loaded.push(pageIndex);
|
|
1297
1224
|
}
|
|
1298
|
-
|
|
1299
1225
|
return loaded.sort((a, b) => a - b);
|
|
1300
1226
|
}
|
|
1301
1227
|
},
|
|
@@ -1318,18 +1244,21 @@ const facetTemplate = {
|
|
|
1318
1244
|
prevPageIndex
|
|
1319
1245
|
} = action.queryParams;
|
|
1320
1246
|
const results = mapEntriesToSearchResults(action, getItemsFromResult(result), state);
|
|
1321
|
-
if (!loadMorePaging) return results;
|
|
1247
|
+
if (!loadMorePaging) return results;
|
|
1322
1248
|
|
|
1249
|
+
// add a _pageIndex property to the returned results to help us later
|
|
1323
1250
|
const nextResults = results.map((r, idx) => ({
|
|
1324
1251
|
_pageIndex: pageIndex,
|
|
1325
1252
|
_pagePosition: idx,
|
|
1326
1253
|
...r
|
|
1327
1254
|
}));
|
|
1328
|
-
const loadedPages = pagesLoaded || [];
|
|
1255
|
+
const loadedPages = pagesLoaded || [];
|
|
1329
1256
|
|
|
1330
|
-
if
|
|
1331
|
-
|
|
1257
|
+
// if pageIndex is found in loadedPages, we have already loaded this page
|
|
1258
|
+
if (!isNaN(loadedPages.find(l => l === pageIndex))) return prevResults;
|
|
1332
1259
|
|
|
1260
|
+
// Determine where we put the results depending on if we
|
|
1261
|
+
// are paging forwards, backwards, or doing a new search
|
|
1333
1262
|
const firstResultSet = pageIndex > prevPageIndex ? prevResults || [] : nextResults;
|
|
1334
1263
|
const secondResultSet = pageIndex > prevPageIndex ? nextResults : prevResults || [];
|
|
1335
1264
|
const onlyResultSet = loadedPages.length === 0 ? nextResults : false;
|
|
@@ -1360,13 +1289,11 @@ const filterTemplate = {
|
|
|
1360
1289
|
if (payload && (payload.items || payload.children)) {
|
|
1361
1290
|
const items = (payload.items || payload.children).map(item => {
|
|
1362
1291
|
var _item$sys;
|
|
1363
|
-
|
|
1364
1292
|
item.isSelected = selectedKeys === null || selectedKeys === void 0 ? void 0 : selectedKeys.includes((item === null || item === void 0 ? void 0 : (_item$sys = item.sys) === null || _item$sys === void 0 ? void 0 : _item$sys.id) || item.key);
|
|
1365
1293
|
return item;
|
|
1366
1294
|
});
|
|
1367
1295
|
return mapper(items);
|
|
1368
1296
|
}
|
|
1369
|
-
|
|
1370
1297
|
return [];
|
|
1371
1298
|
}
|
|
1372
1299
|
},
|
|
@@ -1389,22 +1316,22 @@ const filterExpressionMapper = {
|
|
|
1389
1316
|
fieldOperator: 'fieldOperator',
|
|
1390
1317
|
logicOperator: 'logicOperator'
|
|
1391
1318
|
};
|
|
1392
|
-
|
|
1393
1319
|
const mapFilterToFilterExpression = filter => mapJson__default["default"](filter, filterExpressionMapper);
|
|
1394
1320
|
|
|
1395
1321
|
const mapFiltersToFilterExpression = (filters, selectedFilters) => {
|
|
1396
1322
|
if (!selectedFilters || Object.keys(selectedFilters).length === 0) return [];
|
|
1397
|
-
const filterExpressions = [];
|
|
1398
|
-
// the items that are selected and queryable
|
|
1323
|
+
const filterExpressions = [];
|
|
1399
1324
|
|
|
1325
|
+
// Iterate through the keys in selectedFilters and locate
|
|
1326
|
+
// the items that are selected and queryable
|
|
1400
1327
|
Object.entries(selectedFilters).map(([fkey, selectedValues]) => {
|
|
1401
1328
|
const filter = filters[fkey];
|
|
1402
|
-
|
|
1403
1329
|
if (selectedValues && filter) {
|
|
1404
1330
|
// Where we have a value for a selectedFilter
|
|
1405
1331
|
// and a filter is found for the current key
|
|
1406
1332
|
// map the filter to a filterExpression object
|
|
1407
|
-
const expr = mapFilterToFilterExpression({
|
|
1333
|
+
const expr = mapFilterToFilterExpression({
|
|
1334
|
+
...filter,
|
|
1408
1335
|
selectedValues
|
|
1409
1336
|
});
|
|
1410
1337
|
filterExpressions.push(expr);
|
|
@@ -1440,8 +1367,8 @@ const queryParamsTemplate = {
|
|
|
1440
1367
|
context
|
|
1441
1368
|
}) => {
|
|
1442
1369
|
const stateFilters = getFilters(state, facet, context, 'js');
|
|
1443
|
-
const selectedFilters = getSelectedFilters(state, facet, context, 'js');
|
|
1444
|
-
|
|
1370
|
+
const selectedFilters = getSelectedFilters(state, facet, context, 'js');
|
|
1371
|
+
// Use another mapping function to map the filter parameters for the query
|
|
1445
1372
|
const filterParams = mapFiltersToFilterExpression(stateFilters, selectedFilters);
|
|
1446
1373
|
return filterParams;
|
|
1447
1374
|
},
|
|
@@ -1490,10 +1417,9 @@ const queryParamsTemplate = {
|
|
|
1490
1417
|
context
|
|
1491
1418
|
}) => {
|
|
1492
1419
|
var _getFacet;
|
|
1493
|
-
|
|
1494
1420
|
return ((_getFacet = getFacet(state, facet, context)) === null || _getFacet === void 0 ? void 0 : _getFacet.projectId) || selectCurrentProject(state);
|
|
1495
1421
|
},
|
|
1496
|
-
searchTerm: root => root.context !==
|
|
1422
|
+
searchTerm: root => root.context !== Context.minilist || getQueryParameter(root, 'useSearchTerm', false) ? getSearchTerm(root.state) : '',
|
|
1497
1423
|
selectedFilters: ({
|
|
1498
1424
|
state,
|
|
1499
1425
|
facet,
|
|
@@ -1505,11 +1431,12 @@ const queryParamsTemplate = {
|
|
|
1505
1431
|
weightedSearchFields: root => {
|
|
1506
1432
|
const wsf = getQueryParameter(root, 'weightedSearchFields', []);
|
|
1507
1433
|
const deduped = wsf.filter((v, i, a) => a.findIndex(t => t.fieldId === v.fieldId) === i);
|
|
1508
|
-
return deduped;
|
|
1434
|
+
return deduped;
|
|
1435
|
+
// return wsf;
|
|
1509
1436
|
},
|
|
1437
|
+
|
|
1510
1438
|
webpageTemplates: root => getQueryParameter(root, 'webpageTemplates', [])
|
|
1511
1439
|
};
|
|
1512
|
-
|
|
1513
1440
|
const mapStateToQueryParams = sourceJson => mapJson__default["default"](sourceJson, queryParamsTemplate);
|
|
1514
1441
|
|
|
1515
1442
|
/**
|
|
@@ -1523,9 +1450,9 @@ const generateQueryParams = (action, state) => {
|
|
|
1523
1450
|
const {
|
|
1524
1451
|
context,
|
|
1525
1452
|
facet
|
|
1526
|
-
} = action;
|
|
1453
|
+
} = action;
|
|
1454
|
+
// Map parameters using state and some additional
|
|
1527
1455
|
// inputs from the action
|
|
1528
|
-
|
|
1529
1456
|
const queryParams = mapStateToQueryParams({
|
|
1530
1457
|
context,
|
|
1531
1458
|
facet,
|
|
@@ -1534,12 +1461,12 @@ const generateQueryParams = (action, state) => {
|
|
|
1534
1461
|
});
|
|
1535
1462
|
return [queryParams, runSearch(action, state, queryParams)];
|
|
1536
1463
|
};
|
|
1464
|
+
|
|
1537
1465
|
/**
|
|
1538
1466
|
* Checks if we have already loaded everything we're asking for and tells us to run the search or not
|
|
1539
1467
|
* @param action
|
|
1540
1468
|
* @param state
|
|
1541
1469
|
*/
|
|
1542
|
-
|
|
1543
1470
|
const runSearch = (action, state, queryParams) => {
|
|
1544
1471
|
const {
|
|
1545
1472
|
context,
|
|
@@ -1551,13 +1478,14 @@ const runSearch = (action, state, queryParams) => {
|
|
|
1551
1478
|
} = action;
|
|
1552
1479
|
let willRun = false;
|
|
1553
1480
|
const facetIsLoaded = defaultLang ? false : getIsLoaded(state, context, facet);
|
|
1554
|
-
const stateParams = {
|
|
1481
|
+
const stateParams = {
|
|
1482
|
+
...getQueryParams(ogState, facet, context)
|
|
1555
1483
|
};
|
|
1556
1484
|
stateParams.pageIndex = getPageIndex(ogState, facet, context);
|
|
1557
1485
|
stateParams.searchTerm = getSearchTerm(ogState);
|
|
1558
1486
|
stateParams.pageSize = getPageSize(ogState, facet, context);
|
|
1559
|
-
|
|
1560
|
-
|
|
1487
|
+
if (context === Context.facets && ssr ||
|
|
1488
|
+
// context === Context.minilist ||
|
|
1561
1489
|
preload || !facetIsLoaded || filterParamsChanged(action) || defaultLang) {
|
|
1562
1490
|
willRun = true;
|
|
1563
1491
|
} else {
|
|
@@ -1565,28 +1493,24 @@ const runSearch = (action, state, queryParams) => {
|
|
|
1565
1493
|
// are the same as what we already have in state
|
|
1566
1494
|
Object.entries(stateParams).forEach(([param, value]) => {
|
|
1567
1495
|
const queryParam = queryParams[param];
|
|
1568
|
-
|
|
1569
1496
|
if (JSON.stringify(value) !== JSON.stringify(queryParam)) {
|
|
1570
1497
|
willRun = true;
|
|
1571
1498
|
}
|
|
1572
1499
|
});
|
|
1573
1500
|
}
|
|
1574
|
-
|
|
1575
1501
|
const internalPaging = getIsInternalPaging(ogState, facet, context);
|
|
1576
|
-
|
|
1577
1502
|
if (internalPaging && facetIsLoaded) {
|
|
1578
1503
|
willRun = false;
|
|
1579
1504
|
}
|
|
1580
|
-
|
|
1581
1505
|
return willRun;
|
|
1582
1506
|
};
|
|
1507
|
+
|
|
1583
1508
|
/**
|
|
1584
1509
|
* This will tell us if filter parameters have been
|
|
1585
1510
|
* changed by some external event such as a route change
|
|
1586
1511
|
* @param action
|
|
1587
1512
|
* @returns true or false
|
|
1588
1513
|
*/
|
|
1589
|
-
|
|
1590
1514
|
const filterParamsChanged = (action, state) => {
|
|
1591
1515
|
const {
|
|
1592
1516
|
context,
|
|
@@ -1601,12 +1525,13 @@ const filterParamsChanged = (action, state) => {
|
|
|
1601
1525
|
});
|
|
1602
1526
|
return paramsChanged.filter(f => f === true).length > 0;
|
|
1603
1527
|
};
|
|
1604
|
-
/* eslint-disable no-console */
|
|
1605
1528
|
|
|
1529
|
+
/* eslint-disable no-console */
|
|
1606
1530
|
const debugExecuteSearch = (action, state) => {
|
|
1607
1531
|
const [queryParams, runSearch] = generateQueryParams(action, state);
|
|
1608
1532
|
console.log('runSearch', runSearch, 'action', action, 'filterParamsChanged', filterParamsChanged(action, state), 'getIsLoaded(state, context, facet)', getIsLoaded(state, action.context, action.facet));
|
|
1609
|
-
const stateParams = {
|
|
1533
|
+
const stateParams = {
|
|
1534
|
+
...getQueryParams(action.ogState || state, action.facet, action.context),
|
|
1610
1535
|
pageIndex: getPageIndex(action.ogState || state, action.facet, action.context),
|
|
1611
1536
|
searchTerm: getSearchTerm(action.ogState || state)
|
|
1612
1537
|
};
|
|
@@ -1617,10 +1542,11 @@ const scrollTop = scrollYPos => {
|
|
|
1617
1542
|
if (typeof window !== 'undefined') window.scrollTo(0, scrollYPos);
|
|
1618
1543
|
};
|
|
1619
1544
|
|
|
1545
|
+
// *** FILTER ITEM MAPPING ***
|
|
1546
|
+
|
|
1620
1547
|
// Base mapping, fields that are the same across all mappings
|
|
1621
1548
|
// to save repeating these elements in every mapper, spread this
|
|
1622
1549
|
// into your discrete mappings
|
|
1623
|
-
|
|
1624
1550
|
const base = {
|
|
1625
1551
|
contentTypeId: Fields.sys.contentTypeId,
|
|
1626
1552
|
title: 'entryTitle',
|
|
@@ -1628,16 +1554,13 @@ const base = {
|
|
|
1628
1554
|
path: 'sys.slug',
|
|
1629
1555
|
isSelected: 'isSelected'
|
|
1630
1556
|
};
|
|
1631
|
-
|
|
1632
1557
|
const mapEntriesToFilterItems = entries => {
|
|
1633
1558
|
if (!entries) return [];
|
|
1634
1559
|
return entries.map(entry => {
|
|
1635
1560
|
const template = base;
|
|
1636
|
-
|
|
1637
1561
|
if (template) {
|
|
1638
1562
|
return mapJson__default["default"](entry, template);
|
|
1639
1563
|
}
|
|
1640
|
-
|
|
1641
1564
|
return entry;
|
|
1642
1565
|
});
|
|
1643
1566
|
};
|
|
@@ -1667,9 +1590,7 @@ const mapQueryParamsToCustomApi = queryParams => {
|
|
|
1667
1590
|
};
|
|
1668
1591
|
|
|
1669
1592
|
const searchSagas = [effects.takeEvery(CLEAR_FILTERS, clearFilters), effects.takeEvery(DO_SEARCH, doSearch), effects.takeEvery(SET_ROUTE_FILTERS, loadFilters), effects.takeEvery(SET_SEARCH_ENTRIES, preloadOtherFacets), effects.takeEvery(UPDATE_CURRENT_FACET, updateCurrentFacet), effects.takeEvery(UPDATE_CURRENT_TAB, updateCurrentTab), effects.takeEvery(UPDATE_PAGE_INDEX, updatePageIndex), effects.takeEvery(UPDATE_PAGE_SIZE, updatePageSize), effects.takeEvery(UPDATE_SEARCH_TERM, updateSearchTerm), effects.takeEvery(UPDATE_SORT_ORDER, updateSortOrder), effects.takeEvery(UPDATE_SELECTED_FILTERS, applySearchFilter)];
|
|
1670
|
-
|
|
1671
1593
|
const toJS = obj => obj && 'toJS' in obj && typeof obj.toJS === 'function' ? obj.toJS() : obj;
|
|
1672
|
-
|
|
1673
1594
|
function* setRouteFilters(action) {
|
|
1674
1595
|
const {
|
|
1675
1596
|
mappers,
|
|
@@ -1678,19 +1599,19 @@ function* setRouteFilters(action) {
|
|
|
1678
1599
|
defaultLang,
|
|
1679
1600
|
debug
|
|
1680
1601
|
} = action;
|
|
1681
|
-
const context = listingType ?
|
|
1602
|
+
const context = listingType ? Context.listings : Context.facets;
|
|
1682
1603
|
const state = toJS(yield effects.select());
|
|
1683
|
-
const ssr = getIsSsr(state);
|
|
1604
|
+
const ssr = getIsSsr(state);
|
|
1684
1605
|
|
|
1685
|
-
|
|
1606
|
+
// Get current facet from params or state
|
|
1607
|
+
let currentFacet = params && params.facet || listingType;
|
|
1686
1608
|
|
|
1609
|
+
// Pick the default facet from initialState
|
|
1687
1610
|
if (!currentFacet) {
|
|
1688
1611
|
var _Object$keys;
|
|
1689
|
-
|
|
1690
1612
|
const tabs = getSearchTabs(state, 'js');
|
|
1691
1613
|
currentFacet = (tabs === null || tabs === void 0 ? void 0 : tabs[0].defaultFacet) || ((_Object$keys = Object.keys(getFacets(state, 'js'))) === null || _Object$keys === void 0 ? void 0 : _Object$keys[0]) || '';
|
|
1692
1614
|
}
|
|
1693
|
-
|
|
1694
1615
|
const nextAction = {
|
|
1695
1616
|
type: SET_ROUTE_FILTERS,
|
|
1696
1617
|
context,
|
|
@@ -1701,48 +1622,50 @@ function* setRouteFilters(action) {
|
|
|
1701
1622
|
ssr,
|
|
1702
1623
|
debug
|
|
1703
1624
|
};
|
|
1704
|
-
yield effects.put(nextAction);
|
|
1625
|
+
yield effects.put(nextAction);
|
|
1705
1626
|
|
|
1627
|
+
// keep track of this state ref for comparing changes to params later
|
|
1706
1628
|
const ogState = {
|
|
1707
1629
|
search: state.search
|
|
1708
|
-
};
|
|
1709
|
-
// to allow this exported saga to continue during SSR
|
|
1630
|
+
};
|
|
1710
1631
|
|
|
1711
|
-
|
|
1632
|
+
// Using call instead of triggering from the put
|
|
1633
|
+
// to allow this exported saga to continue during SSR
|
|
1634
|
+
yield effects.call(ensureSearch, {
|
|
1635
|
+
...nextAction,
|
|
1712
1636
|
ogState
|
|
1713
1637
|
});
|
|
1714
1638
|
}
|
|
1715
1639
|
function* doSearch(action) {
|
|
1716
1640
|
var _action$params;
|
|
1717
|
-
|
|
1718
1641
|
const state = toJS(yield effects.select());
|
|
1719
|
-
|
|
1720
1642
|
if (action.config) {
|
|
1721
1643
|
// If the action contains a config object, we can add this to the
|
|
1722
1644
|
// state at runtime
|
|
1723
|
-
yield effects.put({
|
|
1645
|
+
yield effects.put({
|
|
1646
|
+
...action,
|
|
1724
1647
|
type: APPLY_CONFIG
|
|
1725
1648
|
});
|
|
1726
1649
|
}
|
|
1727
|
-
|
|
1728
|
-
|
|
1650
|
+
const nextAction = {
|
|
1651
|
+
...action,
|
|
1729
1652
|
type: SET_SEARCH_FILTERS,
|
|
1730
1653
|
ssr: getIsSsr(state),
|
|
1731
1654
|
facet: action.facet || ((_action$params = action.params) === null || _action$params === void 0 ? void 0 : _action$params.facet)
|
|
1732
1655
|
};
|
|
1733
|
-
|
|
1734
1656
|
if (nextAction.facet && (action.config || Object.keys(getFacet(state, nextAction.facet, action.context, 'js')).length > 0)) {
|
|
1735
|
-
yield effects.put(nextAction);
|
|
1657
|
+
yield effects.put(nextAction);
|
|
1736
1658
|
|
|
1659
|
+
// keep track of this state ref for comparing changes to params later
|
|
1737
1660
|
const ogState = {
|
|
1738
1661
|
search: state.search
|
|
1739
1662
|
};
|
|
1740
|
-
yield effects.call(ensureSearch, {
|
|
1663
|
+
yield effects.call(ensureSearch, {
|
|
1664
|
+
...nextAction,
|
|
1741
1665
|
ogState
|
|
1742
1666
|
});
|
|
1743
1667
|
}
|
|
1744
1668
|
}
|
|
1745
|
-
|
|
1746
1669
|
function* loadFilters(action) {
|
|
1747
1670
|
const {
|
|
1748
1671
|
facet: facetKey,
|
|
@@ -1750,7 +1673,6 @@ function* loadFilters(action) {
|
|
|
1750
1673
|
mappers = {}
|
|
1751
1674
|
} = action;
|
|
1752
1675
|
const filtersToLoad = yield effects.select(getFiltersToLoad, facetKey, context, 'js');
|
|
1753
|
-
|
|
1754
1676
|
if (filtersToLoad.length > 0) {
|
|
1755
1677
|
yield effects.put({
|
|
1756
1678
|
type: LOAD_FILTERS,
|
|
@@ -1776,7 +1698,6 @@ function* loadFilters(action) {
|
|
|
1776
1698
|
if (filtersToLoadSagas) yield effects.all(filtersToLoadSagas);
|
|
1777
1699
|
}
|
|
1778
1700
|
}
|
|
1779
|
-
|
|
1780
1701
|
function* loadFilter(action) {
|
|
1781
1702
|
const {
|
|
1782
1703
|
facetKey,
|
|
@@ -1802,7 +1723,6 @@ function* loadFilter(action) {
|
|
|
1802
1723
|
selectedKeys,
|
|
1803
1724
|
mapper
|
|
1804
1725
|
};
|
|
1805
|
-
|
|
1806
1726
|
try {
|
|
1807
1727
|
if (contentTypeId) {
|
|
1808
1728
|
const versionStatus = yield effects.select(selectVersionStatus);
|
|
@@ -1812,7 +1732,6 @@ function* loadFilter(action) {
|
|
|
1812
1732
|
if (payload.type === 'error') throw payload;
|
|
1813
1733
|
createStateFrom.payload = payload;
|
|
1814
1734
|
}
|
|
1815
|
-
|
|
1816
1735
|
if (path) {
|
|
1817
1736
|
const payload = yield cachedSearch.getTaxonomyNodeByPath(path, projectId);
|
|
1818
1737
|
if (!payload) throw new Error(`No payload returned for taxonomy path: '${path}'`);
|
|
@@ -1823,35 +1742,33 @@ function* loadFilter(action) {
|
|
|
1823
1742
|
createStateFrom.type = LOAD_FILTERS_ERROR;
|
|
1824
1743
|
createStateFrom.error = error;
|
|
1825
1744
|
}
|
|
1826
|
-
|
|
1827
1745
|
const nextAction = mapJson__default["default"](createStateFrom, filterTemplate);
|
|
1828
1746
|
yield effects.put(nextAction);
|
|
1829
1747
|
}
|
|
1830
|
-
|
|
1831
1748
|
function* ensureSearch(action) {
|
|
1832
1749
|
const {
|
|
1833
1750
|
context,
|
|
1834
1751
|
facet,
|
|
1835
1752
|
debug
|
|
1836
1753
|
} = action;
|
|
1837
|
-
|
|
1838
1754
|
try {
|
|
1839
1755
|
const state = yield effects.select();
|
|
1840
|
-
const nextAction = {
|
|
1756
|
+
const nextAction = {
|
|
1757
|
+
...action,
|
|
1841
1758
|
ogState: action.ogState || {
|
|
1842
1759
|
search: state.search
|
|
1843
1760
|
}
|
|
1844
1761
|
};
|
|
1845
1762
|
const [queryParams, runSearch] = generateQueryParams(nextAction, state);
|
|
1846
1763
|
if (debug && (debug === true || debug.executeSearch)) debugExecuteSearch(nextAction, state);
|
|
1847
|
-
|
|
1848
1764
|
if (runSearch) {
|
|
1849
1765
|
yield effects.put({
|
|
1850
1766
|
type: EXECUTE_SEARCH,
|
|
1851
1767
|
facet,
|
|
1852
1768
|
context
|
|
1853
1769
|
});
|
|
1854
|
-
yield effects.call(executeSearch, {
|
|
1770
|
+
yield effects.call(executeSearch, {
|
|
1771
|
+
...nextAction,
|
|
1855
1772
|
context,
|
|
1856
1773
|
facet,
|
|
1857
1774
|
queryParams,
|
|
@@ -1863,7 +1780,6 @@ function* ensureSearch(action) {
|
|
|
1863
1780
|
log__namespace.error(...['Error running search saga:', error, error.stack]);
|
|
1864
1781
|
}
|
|
1865
1782
|
}
|
|
1866
|
-
|
|
1867
1783
|
function* executeSearch(action) {
|
|
1868
1784
|
const {
|
|
1869
1785
|
context,
|
|
@@ -1871,14 +1787,12 @@ function* executeSearch(action) {
|
|
|
1871
1787
|
queryParams,
|
|
1872
1788
|
mappers
|
|
1873
1789
|
} = action;
|
|
1874
|
-
|
|
1875
1790
|
try {
|
|
1876
1791
|
const state = yield effects.select();
|
|
1877
1792
|
let result = {};
|
|
1878
1793
|
let featuredResult;
|
|
1879
1794
|
let featuredQuery;
|
|
1880
1795
|
const customApi = getCustomApi(state, facet, context, 'js');
|
|
1881
|
-
|
|
1882
1796
|
if (customApi) {
|
|
1883
1797
|
const apiParams = typeof mappers === 'object' && typeof mappers.customApi === 'function' && mappers.customApi(queryParams) || mapQueryParamsToCustomApi(queryParams);
|
|
1884
1798
|
result.payload = yield callCustomApi(customApi, apiParams);
|
|
@@ -1886,19 +1800,16 @@ function* executeSearch(action) {
|
|
|
1886
1800
|
} else {
|
|
1887
1801
|
if (queryParams.featuredResults) {
|
|
1888
1802
|
featuredQuery = searchQuery(queryParams, true);
|
|
1889
|
-
featuredResult = yield timedSearch(featuredQuery, queryParams.linkDepth, queryParams.projectId, queryParams.env);
|
|
1890
|
-
|
|
1803
|
+
featuredResult = yield timedSearch(featuredQuery, queryParams.linkDepth, queryParams.projectId, queryParams.env);
|
|
1804
|
+
// eslint-disable-next-line require-atomic-updates
|
|
1891
1805
|
queryParams.excludeIds = getItemsFromResult(featuredResult).map(fi => {
|
|
1892
1806
|
var _fi$sys;
|
|
1893
|
-
|
|
1894
1807
|
return fi === null || fi === void 0 ? void 0 : (_fi$sys = fi.sys) === null || _fi$sys === void 0 ? void 0 : _fi$sys.id;
|
|
1895
1808
|
}).filter(fi => typeof fi === 'string');
|
|
1896
1809
|
}
|
|
1897
|
-
|
|
1898
1810
|
const query = searchQuery(queryParams);
|
|
1899
1811
|
result = yield timedSearch(query, queryParams.linkDepth, queryParams.projectId, queryParams.env);
|
|
1900
1812
|
}
|
|
1901
|
-
|
|
1902
1813
|
const createStateFrom = {
|
|
1903
1814
|
action,
|
|
1904
1815
|
featuredResult,
|
|
@@ -1914,7 +1825,6 @@ function* executeSearch(action) {
|
|
|
1914
1825
|
log__namespace.error(...['Error running search saga:', error, error.stack]);
|
|
1915
1826
|
}
|
|
1916
1827
|
}
|
|
1917
|
-
|
|
1918
1828
|
function* preloadOtherFacets(action) {
|
|
1919
1829
|
const {
|
|
1920
1830
|
preload,
|
|
@@ -1924,18 +1834,19 @@ function* preloadOtherFacets(action) {
|
|
|
1924
1834
|
} = action;
|
|
1925
1835
|
const state = yield effects.select();
|
|
1926
1836
|
const currentFacet = getCurrentFacet(state);
|
|
1927
|
-
|
|
1928
|
-
if (!preload && facet === currentFacet && context !== exports.Context.listings) {
|
|
1837
|
+
if (!preload && facet === currentFacet && context !== Context.listings) {
|
|
1929
1838
|
const allFacets = getFacets(state, 'js');
|
|
1930
1839
|
const otherFacets = Object.keys(allFacets).filter(f => f !== currentFacet);
|
|
1931
1840
|
yield effects.all(otherFacets.map((preloadFacet = '') => {
|
|
1932
|
-
const preloadAction = {
|
|
1841
|
+
const preloadAction = {
|
|
1842
|
+
...action,
|
|
1933
1843
|
facet: preloadFacet,
|
|
1934
1844
|
preload: true
|
|
1935
1845
|
};
|
|
1936
1846
|
const [queryParams, runSearch] = generateQueryParams(preloadAction, state);
|
|
1937
1847
|
if (debug && (debug === true || debug.preloadOtherFacets)) debugExecuteSearch(preloadAction, state);
|
|
1938
|
-
return runSearch && effects.call(executeSearch, {
|
|
1848
|
+
return runSearch && effects.call(executeSearch, {
|
|
1849
|
+
...action,
|
|
1939
1850
|
type: EXECUTE_SEARCH_PRELOAD,
|
|
1940
1851
|
preload: true,
|
|
1941
1852
|
facet: preloadFacet,
|
|
@@ -1944,7 +1855,6 @@ function* preloadOtherFacets(action) {
|
|
|
1944
1855
|
}));
|
|
1945
1856
|
}
|
|
1946
1857
|
}
|
|
1947
|
-
|
|
1948
1858
|
function* updateCurrentTab(action) {
|
|
1949
1859
|
const {
|
|
1950
1860
|
id,
|
|
@@ -1954,19 +1864,16 @@ function* updateCurrentTab(action) {
|
|
|
1954
1864
|
const facets = getFacets(state, 'js');
|
|
1955
1865
|
const tabs = getSearchTabs(state, 'js');
|
|
1956
1866
|
let nextFacet = tabs === null || tabs === void 0 ? void 0 : tabs[id].currentFacet;
|
|
1957
|
-
|
|
1958
1867
|
if (!nextFacet) {
|
|
1959
1868
|
Object.entries(facets).map(([facetName, facet]) => {
|
|
1960
1869
|
if (facet.tabId === id && (tabs === null || tabs === void 0 ? void 0 : tabs[id].defaultFacet) === facetName) nextFacet = facetName;
|
|
1961
1870
|
});
|
|
1962
|
-
}
|
|
1871
|
+
}
|
|
1872
|
+
// If the next Tab does not have a defaultFacet,
|
|
1963
1873
|
// take the first facet for that tab
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
1874
|
if (!nextFacet) nextFacet = Object.entries(facets).filter(([, f]) => f.tabId === id)[0][0];
|
|
1967
1875
|
yield effects.put(withMappers(updateCurrentFacet$1(nextFacet), mappers));
|
|
1968
1876
|
}
|
|
1969
|
-
|
|
1970
1877
|
function* clearFilters(action) {
|
|
1971
1878
|
const {
|
|
1972
1879
|
mappers
|
|
@@ -1974,7 +1881,6 @@ function* clearFilters(action) {
|
|
|
1974
1881
|
const uri = yield buildUri({}, mappers);
|
|
1975
1882
|
yield effects.put(navigate(uri));
|
|
1976
1883
|
}
|
|
1977
|
-
|
|
1978
1884
|
function* updateCurrentFacet(action) {
|
|
1979
1885
|
const {
|
|
1980
1886
|
facet,
|
|
@@ -1987,7 +1893,6 @@ function* updateCurrentFacet(action) {
|
|
|
1987
1893
|
}, mappers);
|
|
1988
1894
|
yield effects.put(navigate(uri));
|
|
1989
1895
|
}
|
|
1990
|
-
|
|
1991
1896
|
function* updateSearchTerm(action) {
|
|
1992
1897
|
const {
|
|
1993
1898
|
term,
|
|
@@ -1998,7 +1903,6 @@ function* updateSearchTerm(action) {
|
|
|
1998
1903
|
}, mappers);
|
|
1999
1904
|
yield effects.put(navigate(uri));
|
|
2000
1905
|
}
|
|
2001
|
-
|
|
2002
1906
|
function* updateSortOrder(action) {
|
|
2003
1907
|
const {
|
|
2004
1908
|
orderBy,
|
|
@@ -2011,7 +1915,6 @@ function* updateSortOrder(action) {
|
|
|
2011
1915
|
}, mappers);
|
|
2012
1916
|
yield effects.put(navigate(uri));
|
|
2013
1917
|
}
|
|
2014
|
-
|
|
2015
1918
|
function* updatePageIndex(action) {
|
|
2016
1919
|
const {
|
|
2017
1920
|
pageIndex,
|
|
@@ -2024,7 +1927,6 @@ function* updatePageIndex(action) {
|
|
|
2024
1927
|
yield effects.put(navigate(uri));
|
|
2025
1928
|
if (typeof scrollYPos !== 'undefined') scrollTop(scrollYPos);
|
|
2026
1929
|
}
|
|
2027
|
-
|
|
2028
1930
|
function* updatePageSize(action) {
|
|
2029
1931
|
const {
|
|
2030
1932
|
pageSize,
|
|
@@ -2037,7 +1939,6 @@ function* updatePageSize(action) {
|
|
|
2037
1939
|
yield effects.put(navigate(uri));
|
|
2038
1940
|
if (typeof scrollYPos !== 'undefined') scrollTop(scrollYPos);
|
|
2039
1941
|
}
|
|
2040
|
-
|
|
2041
1942
|
function* applySearchFilter(action) {
|
|
2042
1943
|
const {
|
|
2043
1944
|
mappers,
|
|
@@ -2047,7 +1948,6 @@ function* applySearchFilter(action) {
|
|
|
2047
1948
|
yield effects.put(navigate(uri));
|
|
2048
1949
|
if (typeof scrollYPos !== 'undefined') scrollTop(scrollYPos);
|
|
2049
1950
|
}
|
|
2050
|
-
|
|
2051
1951
|
function* buildUri({
|
|
2052
1952
|
facet,
|
|
2053
1953
|
orderBy,
|
|
@@ -2064,11 +1964,10 @@ function* buildUri({
|
|
|
2064
1964
|
pageIndex,
|
|
2065
1965
|
pageSize,
|
|
2066
1966
|
term
|
|
2067
|
-
});
|
|
2068
|
-
|
|
1967
|
+
});
|
|
1968
|
+
// return uri;
|
|
2069
1969
|
return `${uri.path}${uri.search && `?${uri.search}` || ''}${uri.hash && `#${uri.hash}` || ''}`;
|
|
2070
1970
|
}
|
|
2071
|
-
|
|
2072
1971
|
function* triggerMinilistSsr(options) {
|
|
2073
1972
|
yield effects.call(doSearch, {
|
|
2074
1973
|
type: DO_SEARCH,
|
|
@@ -2084,6 +1983,7 @@ function* triggerSearchSsr(options) {
|
|
|
2084
1983
|
|
|
2085
1984
|
exports.APPLY_CONFIG = APPLY_CONFIG;
|
|
2086
1985
|
exports.CLEAR_FILTERS = CLEAR_FILTERS;
|
|
1986
|
+
exports.Context = Context;
|
|
2087
1987
|
exports.EXECUTE_SEARCH = EXECUTE_SEARCH;
|
|
2088
1988
|
exports.EXECUTE_SEARCH_ERROR = EXECUTE_SEARCH_ERROR;
|
|
2089
1989
|
exports.LOAD_FILTERS = LOAD_FILTERS;
|
|
@@ -2149,4 +2049,4 @@ exports.updateSearchTerm = updateSearchTerm$1;
|
|
|
2149
2049
|
exports.updateSelectedFilters = updateSelectedFilters;
|
|
2150
2050
|
exports.updateSortOrder = updateSortOrder$1;
|
|
2151
2051
|
exports.withMappers = withMappers;
|
|
2152
|
-
//# sourceMappingURL=sagas-
|
|
2052
|
+
//# sourceMappingURL=sagas-6d12e7ca.js.map
|