@zengenti/contensis-react-base 3.0.2-beta.1 → 3.0.2-beta.10
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-ee485b92.js → App-81a45001.js} +111 -427
- package/cjs/App-81a45001.js.map +1 -0
- package/cjs/ContensisDeliveryApi-de88df2a.js +231 -0
- package/cjs/ContensisDeliveryApi-de88df2a.js.map +1 -0
- package/cjs/{RouteLoader-3aa6456e.js → RouteLoader-47d70a26.js} +23 -37
- package/{esm/RouteLoader-5171c63f.js.map → cjs/RouteLoader-47d70a26.js.map} +1 -1
- package/cjs/{ToJs-a9a8522b.js → ToJs-61c03582.js} +3 -4
- package/cjs/{ToJs-a9a8522b.js.map → ToJs-61c03582.js.map} +1 -1
- package/cjs/client.js +20 -27
- package/cjs/client.js.map +1 -1
- package/cjs/contensis-react-base.js +124 -188
- package/cjs/contensis-react-base.js.map +1 -1
- package/cjs/forms.js +15 -154
- 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-840860bc.js → login-51b66359.js} +64 -113
- package/cjs/login-51b66359.js.map +1 -0
- package/cjs/{reducers-3a4f8971.js → reducers-9afb5f89.js} +14 -31
- package/cjs/reducers-9afb5f89.js.map +1 -0
- package/cjs/redux.js +17 -17
- package/cjs/redux.js.map +1 -1
- package/cjs/routing.js +6 -7
- package/cjs/routing.js.map +1 -1
- package/cjs/{sagas-e2a34262.js → sagas-6d12e7ca.js} +183 -282
- package/cjs/sagas-6d12e7ca.js.map +1 -0
- package/cjs/search.js +56 -82
- package/cjs/search.js.map +1 -1
- package/cjs/{selectors-656da4b7.js → selectors-c76c2676.js} +84 -7
- package/cjs/selectors-c76c2676.js.map +1 -0
- package/cjs/urls-6fcaf4c6.js.map +1 -1
- package/cjs/user.js +4 -13
- package/cjs/user.js.map +1 -1
- package/cjs/util.js +45 -53
- package/cjs/util.js.map +1 -1
- package/cjs/{version-78dfc3bd.js → version-38afaf2a.js} +45 -158
- package/cjs/version-38afaf2a.js.map +1 -0
- package/cjs/version-886f49d8.js +98 -0
- package/cjs/version-886f49d8.js.map +1 -0
- package/esm/{App-640239d2.js → App-5f914483.js} +93 -407
- package/esm/App-5f914483.js.map +1 -0
- package/esm/ContensisDeliveryApi-ad06857d.js +227 -0
- package/esm/ContensisDeliveryApi-ad06857d.js.map +1 -0
- package/esm/{RouteLoader-5171c63f.js → RouteLoader-f5d5f733.js} +22 -36
- package/{cjs/RouteLoader-3aa6456e.js.map → esm/RouteLoader-f5d5f733.js.map} +1 -1
- package/esm/{ToJs-4e02a04d.js → ToJs-0066e629.js} +3 -4
- package/esm/{ToJs-4e02a04d.js.map → ToJs-0066e629.js.map} +1 -1
- package/esm/client.js +15 -22
- package/esm/client.js.map +1 -1
- package/esm/contensis-react-base.js +119 -183
- package/esm/contensis-react-base.js.map +1 -1
- package/esm/forms.js +15 -154
- 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-57395c9c.js → login-4d07c2de.js} +63 -112
- package/esm/login-4d07c2de.js.map +1 -0
- package/esm/{reducers-8e5d6232.js → reducers-3d5c37d1.js} +14 -31
- package/esm/reducers-3d5c37d1.js.map +1 -0
- package/esm/redux.js +9 -8
- package/esm/redux.js.map +1 -1
- package/esm/routing.js +3 -4
- package/esm/routing.js.map +1 -1
- package/esm/{sagas-bb925ef4.js → sagas-53d2aefb.js} +135 -235
- package/esm/sagas-53d2aefb.js.map +1 -0
- package/esm/search.js +57 -83
- package/esm/search.js.map +1 -1
- package/esm/{selectors-a5e5835b.js → selectors-3f0d804d.js} +70 -7
- package/esm/selectors-3f0d804d.js.map +1 -0
- package/esm/urls-eac9a747.js.map +1 -1
- package/esm/user.js +6 -15
- package/esm/user.js.map +1 -1
- package/esm/util.js +42 -53
- package/esm/util.js.map +1 -1
- package/esm/{version-e3a5ec66.js → version-dd31c7f0.js} +32 -141
- package/esm/version-dd31c7f0.js.map +1 -0
- package/esm/version-f4629693.js +87 -0
- package/esm/version-f4629693.js.map +1 -0
- package/models/util/ContensisDeliveryApi.d.ts +6 -0
- package/models/util/index.d.ts +1 -0
- package/package.json +1 -1
- package/cjs/App-ee485b92.js.map +0 -1
- package/cjs/actions-8dc9e8de.js +0 -87
- package/cjs/actions-8dc9e8de.js.map +0 -1
- package/cjs/login-840860bc.js.map +0 -1
- package/cjs/reducers-3a4f8971.js.map +0 -1
- package/cjs/sagas-e2a34262.js.map +0 -1
- package/cjs/selectors-656da4b7.js.map +0 -1
- package/cjs/version-78dfc3bd.js.map +0 -1
- package/cjs/version-eba6d09b.js +0 -20
- package/cjs/version-eba6d09b.js.map +0 -1
- package/esm/App-640239d2.js.map +0 -1
- package/esm/actions-180948dd.js +0 -72
- package/esm/actions-180948dd.js.map +0 -1
- package/esm/login-57395c9c.js.map +0 -1
- package/esm/reducers-8e5d6232.js.map +0 -1
- package/esm/sagas-bb925ef4.js.map +0 -1
- package/esm/selectors-a5e5835b.js.map +0 -1
- package/esm/version-2485e2fb.js +0 -15
- package/esm/version-2485e2fb.js.map +0 -1
- package/esm/version-e3a5ec66.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,12 +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
|
-
|
|
1559
|
-
if (context ===
|
|
1486
|
+
stateParams.pageSize = getPageSize(ogState, facet, context);
|
|
1487
|
+
if (context === Context.facets && ssr ||
|
|
1488
|
+
// context === Context.minilist ||
|
|
1560
1489
|
preload || !facetIsLoaded || filterParamsChanged(action) || defaultLang) {
|
|
1561
1490
|
willRun = true;
|
|
1562
1491
|
} else {
|
|
@@ -1564,28 +1493,24 @@ const runSearch = (action, state, queryParams) => {
|
|
|
1564
1493
|
// are the same as what we already have in state
|
|
1565
1494
|
Object.entries(stateParams).forEach(([param, value]) => {
|
|
1566
1495
|
const queryParam = queryParams[param];
|
|
1567
|
-
|
|
1568
1496
|
if (JSON.stringify(value) !== JSON.stringify(queryParam)) {
|
|
1569
1497
|
willRun = true;
|
|
1570
1498
|
}
|
|
1571
1499
|
});
|
|
1572
1500
|
}
|
|
1573
|
-
|
|
1574
1501
|
const internalPaging = getIsInternalPaging(ogState, facet, context);
|
|
1575
|
-
|
|
1576
1502
|
if (internalPaging && facetIsLoaded) {
|
|
1577
1503
|
willRun = false;
|
|
1578
1504
|
}
|
|
1579
|
-
|
|
1580
1505
|
return willRun;
|
|
1581
1506
|
};
|
|
1507
|
+
|
|
1582
1508
|
/**
|
|
1583
1509
|
* This will tell us if filter parameters have been
|
|
1584
1510
|
* changed by some external event such as a route change
|
|
1585
1511
|
* @param action
|
|
1586
1512
|
* @returns true or false
|
|
1587
1513
|
*/
|
|
1588
|
-
|
|
1589
1514
|
const filterParamsChanged = (action, state) => {
|
|
1590
1515
|
const {
|
|
1591
1516
|
context,
|
|
@@ -1600,12 +1525,13 @@ const filterParamsChanged = (action, state) => {
|
|
|
1600
1525
|
});
|
|
1601
1526
|
return paramsChanged.filter(f => f === true).length > 0;
|
|
1602
1527
|
};
|
|
1603
|
-
/* eslint-disable no-console */
|
|
1604
1528
|
|
|
1529
|
+
/* eslint-disable no-console */
|
|
1605
1530
|
const debugExecuteSearch = (action, state) => {
|
|
1606
1531
|
const [queryParams, runSearch] = generateQueryParams(action, state);
|
|
1607
1532
|
console.log('runSearch', runSearch, 'action', action, 'filterParamsChanged', filterParamsChanged(action, state), 'getIsLoaded(state, context, facet)', getIsLoaded(state, action.context, action.facet));
|
|
1608
|
-
const stateParams = {
|
|
1533
|
+
const stateParams = {
|
|
1534
|
+
...getQueryParams(action.ogState || state, action.facet, action.context),
|
|
1609
1535
|
pageIndex: getPageIndex(action.ogState || state, action.facet, action.context),
|
|
1610
1536
|
searchTerm: getSearchTerm(action.ogState || state)
|
|
1611
1537
|
};
|
|
@@ -1616,10 +1542,11 @@ const scrollTop = scrollYPos => {
|
|
|
1616
1542
|
if (typeof window !== 'undefined') window.scrollTo(0, scrollYPos);
|
|
1617
1543
|
};
|
|
1618
1544
|
|
|
1545
|
+
// *** FILTER ITEM MAPPING ***
|
|
1546
|
+
|
|
1619
1547
|
// Base mapping, fields that are the same across all mappings
|
|
1620
1548
|
// to save repeating these elements in every mapper, spread this
|
|
1621
1549
|
// into your discrete mappings
|
|
1622
|
-
|
|
1623
1550
|
const base = {
|
|
1624
1551
|
contentTypeId: Fields.sys.contentTypeId,
|
|
1625
1552
|
title: 'entryTitle',
|
|
@@ -1627,16 +1554,13 @@ const base = {
|
|
|
1627
1554
|
path: 'sys.slug',
|
|
1628
1555
|
isSelected: 'isSelected'
|
|
1629
1556
|
};
|
|
1630
|
-
|
|
1631
1557
|
const mapEntriesToFilterItems = entries => {
|
|
1632
1558
|
if (!entries) return [];
|
|
1633
1559
|
return entries.map(entry => {
|
|
1634
1560
|
const template = base;
|
|
1635
|
-
|
|
1636
1561
|
if (template) {
|
|
1637
1562
|
return mapJson__default["default"](entry, template);
|
|
1638
1563
|
}
|
|
1639
|
-
|
|
1640
1564
|
return entry;
|
|
1641
1565
|
});
|
|
1642
1566
|
};
|
|
@@ -1666,9 +1590,7 @@ const mapQueryParamsToCustomApi = queryParams => {
|
|
|
1666
1590
|
};
|
|
1667
1591
|
|
|
1668
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)];
|
|
1669
|
-
|
|
1670
1593
|
const toJS = obj => obj && 'toJS' in obj && typeof obj.toJS === 'function' ? obj.toJS() : obj;
|
|
1671
|
-
|
|
1672
1594
|
function* setRouteFilters(action) {
|
|
1673
1595
|
const {
|
|
1674
1596
|
mappers,
|
|
@@ -1677,19 +1599,19 @@ function* setRouteFilters(action) {
|
|
|
1677
1599
|
defaultLang,
|
|
1678
1600
|
debug
|
|
1679
1601
|
} = action;
|
|
1680
|
-
const context = listingType ?
|
|
1602
|
+
const context = listingType ? Context.listings : Context.facets;
|
|
1681
1603
|
const state = toJS(yield effects.select());
|
|
1682
|
-
const ssr = getIsSsr(state);
|
|
1604
|
+
const ssr = getIsSsr(state);
|
|
1683
1605
|
|
|
1684
|
-
|
|
1606
|
+
// Get current facet from params or state
|
|
1607
|
+
let currentFacet = params && params.facet || listingType;
|
|
1685
1608
|
|
|
1609
|
+
// Pick the default facet from initialState
|
|
1686
1610
|
if (!currentFacet) {
|
|
1687
1611
|
var _Object$keys;
|
|
1688
|
-
|
|
1689
1612
|
const tabs = getSearchTabs(state, 'js');
|
|
1690
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]) || '';
|
|
1691
1614
|
}
|
|
1692
|
-
|
|
1693
1615
|
const nextAction = {
|
|
1694
1616
|
type: SET_ROUTE_FILTERS,
|
|
1695
1617
|
context,
|
|
@@ -1700,48 +1622,50 @@ function* setRouteFilters(action) {
|
|
|
1700
1622
|
ssr,
|
|
1701
1623
|
debug
|
|
1702
1624
|
};
|
|
1703
|
-
yield effects.put(nextAction);
|
|
1625
|
+
yield effects.put(nextAction);
|
|
1704
1626
|
|
|
1627
|
+
// keep track of this state ref for comparing changes to params later
|
|
1705
1628
|
const ogState = {
|
|
1706
1629
|
search: state.search
|
|
1707
|
-
};
|
|
1708
|
-
// to allow this exported saga to continue during SSR
|
|
1630
|
+
};
|
|
1709
1631
|
|
|
1710
|
-
|
|
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,
|
|
1711
1636
|
ogState
|
|
1712
1637
|
});
|
|
1713
1638
|
}
|
|
1714
1639
|
function* doSearch(action) {
|
|
1715
1640
|
var _action$params;
|
|
1716
|
-
|
|
1717
1641
|
const state = toJS(yield effects.select());
|
|
1718
|
-
|
|
1719
1642
|
if (action.config) {
|
|
1720
1643
|
// If the action contains a config object, we can add this to the
|
|
1721
1644
|
// state at runtime
|
|
1722
|
-
yield effects.put({
|
|
1645
|
+
yield effects.put({
|
|
1646
|
+
...action,
|
|
1723
1647
|
type: APPLY_CONFIG
|
|
1724
1648
|
});
|
|
1725
1649
|
}
|
|
1726
|
-
|
|
1727
|
-
|
|
1650
|
+
const nextAction = {
|
|
1651
|
+
...action,
|
|
1728
1652
|
type: SET_SEARCH_FILTERS,
|
|
1729
1653
|
ssr: getIsSsr(state),
|
|
1730
1654
|
facet: action.facet || ((_action$params = action.params) === null || _action$params === void 0 ? void 0 : _action$params.facet)
|
|
1731
1655
|
};
|
|
1732
|
-
|
|
1733
1656
|
if (nextAction.facet && (action.config || Object.keys(getFacet(state, nextAction.facet, action.context, 'js')).length > 0)) {
|
|
1734
|
-
yield effects.put(nextAction);
|
|
1657
|
+
yield effects.put(nextAction);
|
|
1735
1658
|
|
|
1659
|
+
// keep track of this state ref for comparing changes to params later
|
|
1736
1660
|
const ogState = {
|
|
1737
1661
|
search: state.search
|
|
1738
1662
|
};
|
|
1739
|
-
yield effects.call(ensureSearch, {
|
|
1663
|
+
yield effects.call(ensureSearch, {
|
|
1664
|
+
...nextAction,
|
|
1740
1665
|
ogState
|
|
1741
1666
|
});
|
|
1742
1667
|
}
|
|
1743
1668
|
}
|
|
1744
|
-
|
|
1745
1669
|
function* loadFilters(action) {
|
|
1746
1670
|
const {
|
|
1747
1671
|
facet: facetKey,
|
|
@@ -1749,7 +1673,6 @@ function* loadFilters(action) {
|
|
|
1749
1673
|
mappers = {}
|
|
1750
1674
|
} = action;
|
|
1751
1675
|
const filtersToLoad = yield effects.select(getFiltersToLoad, facetKey, context, 'js');
|
|
1752
|
-
|
|
1753
1676
|
if (filtersToLoad.length > 0) {
|
|
1754
1677
|
yield effects.put({
|
|
1755
1678
|
type: LOAD_FILTERS,
|
|
@@ -1775,7 +1698,6 @@ function* loadFilters(action) {
|
|
|
1775
1698
|
if (filtersToLoadSagas) yield effects.all(filtersToLoadSagas);
|
|
1776
1699
|
}
|
|
1777
1700
|
}
|
|
1778
|
-
|
|
1779
1701
|
function* loadFilter(action) {
|
|
1780
1702
|
const {
|
|
1781
1703
|
facetKey,
|
|
@@ -1801,7 +1723,6 @@ function* loadFilter(action) {
|
|
|
1801
1723
|
selectedKeys,
|
|
1802
1724
|
mapper
|
|
1803
1725
|
};
|
|
1804
|
-
|
|
1805
1726
|
try {
|
|
1806
1727
|
if (contentTypeId) {
|
|
1807
1728
|
const versionStatus = yield effects.select(selectVersionStatus);
|
|
@@ -1811,7 +1732,6 @@ function* loadFilter(action) {
|
|
|
1811
1732
|
if (payload.type === 'error') throw payload;
|
|
1812
1733
|
createStateFrom.payload = payload;
|
|
1813
1734
|
}
|
|
1814
|
-
|
|
1815
1735
|
if (path) {
|
|
1816
1736
|
const payload = yield cachedSearch.getTaxonomyNodeByPath(path, projectId);
|
|
1817
1737
|
if (!payload) throw new Error(`No payload returned for taxonomy path: '${path}'`);
|
|
@@ -1822,35 +1742,33 @@ function* loadFilter(action) {
|
|
|
1822
1742
|
createStateFrom.type = LOAD_FILTERS_ERROR;
|
|
1823
1743
|
createStateFrom.error = error;
|
|
1824
1744
|
}
|
|
1825
|
-
|
|
1826
1745
|
const nextAction = mapJson__default["default"](createStateFrom, filterTemplate);
|
|
1827
1746
|
yield effects.put(nextAction);
|
|
1828
1747
|
}
|
|
1829
|
-
|
|
1830
1748
|
function* ensureSearch(action) {
|
|
1831
1749
|
const {
|
|
1832
1750
|
context,
|
|
1833
1751
|
facet,
|
|
1834
1752
|
debug
|
|
1835
1753
|
} = action;
|
|
1836
|
-
|
|
1837
1754
|
try {
|
|
1838
1755
|
const state = yield effects.select();
|
|
1839
|
-
const nextAction = {
|
|
1756
|
+
const nextAction = {
|
|
1757
|
+
...action,
|
|
1840
1758
|
ogState: action.ogState || {
|
|
1841
1759
|
search: state.search
|
|
1842
1760
|
}
|
|
1843
1761
|
};
|
|
1844
1762
|
const [queryParams, runSearch] = generateQueryParams(nextAction, state);
|
|
1845
1763
|
if (debug && (debug === true || debug.executeSearch)) debugExecuteSearch(nextAction, state);
|
|
1846
|
-
|
|
1847
1764
|
if (runSearch) {
|
|
1848
1765
|
yield effects.put({
|
|
1849
1766
|
type: EXECUTE_SEARCH,
|
|
1850
1767
|
facet,
|
|
1851
1768
|
context
|
|
1852
1769
|
});
|
|
1853
|
-
yield effects.call(executeSearch, {
|
|
1770
|
+
yield effects.call(executeSearch, {
|
|
1771
|
+
...nextAction,
|
|
1854
1772
|
context,
|
|
1855
1773
|
facet,
|
|
1856
1774
|
queryParams,
|
|
@@ -1862,7 +1780,6 @@ function* ensureSearch(action) {
|
|
|
1862
1780
|
log__namespace.error(...['Error running search saga:', error, error.stack]);
|
|
1863
1781
|
}
|
|
1864
1782
|
}
|
|
1865
|
-
|
|
1866
1783
|
function* executeSearch(action) {
|
|
1867
1784
|
const {
|
|
1868
1785
|
context,
|
|
@@ -1870,14 +1787,12 @@ function* executeSearch(action) {
|
|
|
1870
1787
|
queryParams,
|
|
1871
1788
|
mappers
|
|
1872
1789
|
} = action;
|
|
1873
|
-
|
|
1874
1790
|
try {
|
|
1875
1791
|
const state = yield effects.select();
|
|
1876
1792
|
let result = {};
|
|
1877
1793
|
let featuredResult;
|
|
1878
1794
|
let featuredQuery;
|
|
1879
1795
|
const customApi = getCustomApi(state, facet, context, 'js');
|
|
1880
|
-
|
|
1881
1796
|
if (customApi) {
|
|
1882
1797
|
const apiParams = typeof mappers === 'object' && typeof mappers.customApi === 'function' && mappers.customApi(queryParams) || mapQueryParamsToCustomApi(queryParams);
|
|
1883
1798
|
result.payload = yield callCustomApi(customApi, apiParams);
|
|
@@ -1885,19 +1800,16 @@ function* executeSearch(action) {
|
|
|
1885
1800
|
} else {
|
|
1886
1801
|
if (queryParams.featuredResults) {
|
|
1887
1802
|
featuredQuery = searchQuery(queryParams, true);
|
|
1888
|
-
featuredResult = yield timedSearch(featuredQuery, queryParams.linkDepth, queryParams.projectId, queryParams.env);
|
|
1889
|
-
|
|
1803
|
+
featuredResult = yield timedSearch(featuredQuery, queryParams.linkDepth, queryParams.projectId, queryParams.env);
|
|
1804
|
+
// eslint-disable-next-line require-atomic-updates
|
|
1890
1805
|
queryParams.excludeIds = getItemsFromResult(featuredResult).map(fi => {
|
|
1891
1806
|
var _fi$sys;
|
|
1892
|
-
|
|
1893
1807
|
return fi === null || fi === void 0 ? void 0 : (_fi$sys = fi.sys) === null || _fi$sys === void 0 ? void 0 : _fi$sys.id;
|
|
1894
1808
|
}).filter(fi => typeof fi === 'string');
|
|
1895
1809
|
}
|
|
1896
|
-
|
|
1897
1810
|
const query = searchQuery(queryParams);
|
|
1898
1811
|
result = yield timedSearch(query, queryParams.linkDepth, queryParams.projectId, queryParams.env);
|
|
1899
1812
|
}
|
|
1900
|
-
|
|
1901
1813
|
const createStateFrom = {
|
|
1902
1814
|
action,
|
|
1903
1815
|
featuredResult,
|
|
@@ -1913,7 +1825,6 @@ function* executeSearch(action) {
|
|
|
1913
1825
|
log__namespace.error(...['Error running search saga:', error, error.stack]);
|
|
1914
1826
|
}
|
|
1915
1827
|
}
|
|
1916
|
-
|
|
1917
1828
|
function* preloadOtherFacets(action) {
|
|
1918
1829
|
const {
|
|
1919
1830
|
preload,
|
|
@@ -1923,18 +1834,19 @@ function* preloadOtherFacets(action) {
|
|
|
1923
1834
|
} = action;
|
|
1924
1835
|
const state = yield effects.select();
|
|
1925
1836
|
const currentFacet = getCurrentFacet(state);
|
|
1926
|
-
|
|
1927
|
-
if (!preload && facet === currentFacet && context !== exports.Context.listings) {
|
|
1837
|
+
if (!preload && facet === currentFacet && context !== Context.listings) {
|
|
1928
1838
|
const allFacets = getFacets(state, 'js');
|
|
1929
1839
|
const otherFacets = Object.keys(allFacets).filter(f => f !== currentFacet);
|
|
1930
1840
|
yield effects.all(otherFacets.map((preloadFacet = '') => {
|
|
1931
|
-
const preloadAction = {
|
|
1841
|
+
const preloadAction = {
|
|
1842
|
+
...action,
|
|
1932
1843
|
facet: preloadFacet,
|
|
1933
1844
|
preload: true
|
|
1934
1845
|
};
|
|
1935
1846
|
const [queryParams, runSearch] = generateQueryParams(preloadAction, state);
|
|
1936
1847
|
if (debug && (debug === true || debug.preloadOtherFacets)) debugExecuteSearch(preloadAction, state);
|
|
1937
|
-
return runSearch && effects.call(executeSearch, {
|
|
1848
|
+
return runSearch && effects.call(executeSearch, {
|
|
1849
|
+
...action,
|
|
1938
1850
|
type: EXECUTE_SEARCH_PRELOAD,
|
|
1939
1851
|
preload: true,
|
|
1940
1852
|
facet: preloadFacet,
|
|
@@ -1943,7 +1855,6 @@ function* preloadOtherFacets(action) {
|
|
|
1943
1855
|
}));
|
|
1944
1856
|
}
|
|
1945
1857
|
}
|
|
1946
|
-
|
|
1947
1858
|
function* updateCurrentTab(action) {
|
|
1948
1859
|
const {
|
|
1949
1860
|
id,
|
|
@@ -1953,19 +1864,16 @@ function* updateCurrentTab(action) {
|
|
|
1953
1864
|
const facets = getFacets(state, 'js');
|
|
1954
1865
|
const tabs = getSearchTabs(state, 'js');
|
|
1955
1866
|
let nextFacet = tabs === null || tabs === void 0 ? void 0 : tabs[id].currentFacet;
|
|
1956
|
-
|
|
1957
1867
|
if (!nextFacet) {
|
|
1958
1868
|
Object.entries(facets).map(([facetName, facet]) => {
|
|
1959
1869
|
if (facet.tabId === id && (tabs === null || tabs === void 0 ? void 0 : tabs[id].defaultFacet) === facetName) nextFacet = facetName;
|
|
1960
1870
|
});
|
|
1961
|
-
}
|
|
1871
|
+
}
|
|
1872
|
+
// If the next Tab does not have a defaultFacet,
|
|
1962
1873
|
// take the first facet for that tab
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
1874
|
if (!nextFacet) nextFacet = Object.entries(facets).filter(([, f]) => f.tabId === id)[0][0];
|
|
1966
1875
|
yield effects.put(withMappers(updateCurrentFacet$1(nextFacet), mappers));
|
|
1967
1876
|
}
|
|
1968
|
-
|
|
1969
1877
|
function* clearFilters(action) {
|
|
1970
1878
|
const {
|
|
1971
1879
|
mappers
|
|
@@ -1973,7 +1881,6 @@ function* clearFilters(action) {
|
|
|
1973
1881
|
const uri = yield buildUri({}, mappers);
|
|
1974
1882
|
yield effects.put(navigate(uri));
|
|
1975
1883
|
}
|
|
1976
|
-
|
|
1977
1884
|
function* updateCurrentFacet(action) {
|
|
1978
1885
|
const {
|
|
1979
1886
|
facet,
|
|
@@ -1986,7 +1893,6 @@ function* updateCurrentFacet(action) {
|
|
|
1986
1893
|
}, mappers);
|
|
1987
1894
|
yield effects.put(navigate(uri));
|
|
1988
1895
|
}
|
|
1989
|
-
|
|
1990
1896
|
function* updateSearchTerm(action) {
|
|
1991
1897
|
const {
|
|
1992
1898
|
term,
|
|
@@ -1997,7 +1903,6 @@ function* updateSearchTerm(action) {
|
|
|
1997
1903
|
}, mappers);
|
|
1998
1904
|
yield effects.put(navigate(uri));
|
|
1999
1905
|
}
|
|
2000
|
-
|
|
2001
1906
|
function* updateSortOrder(action) {
|
|
2002
1907
|
const {
|
|
2003
1908
|
orderBy,
|
|
@@ -2010,7 +1915,6 @@ function* updateSortOrder(action) {
|
|
|
2010
1915
|
}, mappers);
|
|
2011
1916
|
yield effects.put(navigate(uri));
|
|
2012
1917
|
}
|
|
2013
|
-
|
|
2014
1918
|
function* updatePageIndex(action) {
|
|
2015
1919
|
const {
|
|
2016
1920
|
pageIndex,
|
|
@@ -2023,7 +1927,6 @@ function* updatePageIndex(action) {
|
|
|
2023
1927
|
yield effects.put(navigate(uri));
|
|
2024
1928
|
if (typeof scrollYPos !== 'undefined') scrollTop(scrollYPos);
|
|
2025
1929
|
}
|
|
2026
|
-
|
|
2027
1930
|
function* updatePageSize(action) {
|
|
2028
1931
|
const {
|
|
2029
1932
|
pageSize,
|
|
@@ -2036,7 +1939,6 @@ function* updatePageSize(action) {
|
|
|
2036
1939
|
yield effects.put(navigate(uri));
|
|
2037
1940
|
if (typeof scrollYPos !== 'undefined') scrollTop(scrollYPos);
|
|
2038
1941
|
}
|
|
2039
|
-
|
|
2040
1942
|
function* applySearchFilter(action) {
|
|
2041
1943
|
const {
|
|
2042
1944
|
mappers,
|
|
@@ -2046,7 +1948,6 @@ function* applySearchFilter(action) {
|
|
|
2046
1948
|
yield effects.put(navigate(uri));
|
|
2047
1949
|
if (typeof scrollYPos !== 'undefined') scrollTop(scrollYPos);
|
|
2048
1950
|
}
|
|
2049
|
-
|
|
2050
1951
|
function* buildUri({
|
|
2051
1952
|
facet,
|
|
2052
1953
|
orderBy,
|
|
@@ -2063,11 +1964,10 @@ function* buildUri({
|
|
|
2063
1964
|
pageIndex,
|
|
2064
1965
|
pageSize,
|
|
2065
1966
|
term
|
|
2066
|
-
});
|
|
2067
|
-
|
|
1967
|
+
});
|
|
1968
|
+
// return uri;
|
|
2068
1969
|
return `${uri.path}${uri.search && `?${uri.search}` || ''}${uri.hash && `#${uri.hash}` || ''}`;
|
|
2069
1970
|
}
|
|
2070
|
-
|
|
2071
1971
|
function* triggerMinilistSsr(options) {
|
|
2072
1972
|
yield effects.call(doSearch, {
|
|
2073
1973
|
type: DO_SEARCH,
|
|
@@ -2083,6 +1983,7 @@ function* triggerSearchSsr(options) {
|
|
|
2083
1983
|
|
|
2084
1984
|
exports.APPLY_CONFIG = APPLY_CONFIG;
|
|
2085
1985
|
exports.CLEAR_FILTERS = CLEAR_FILTERS;
|
|
1986
|
+
exports.Context = Context;
|
|
2086
1987
|
exports.EXECUTE_SEARCH = EXECUTE_SEARCH;
|
|
2087
1988
|
exports.EXECUTE_SEARCH_ERROR = EXECUTE_SEARCH_ERROR;
|
|
2088
1989
|
exports.LOAD_FILTERS = LOAD_FILTERS;
|
|
@@ -2148,4 +2049,4 @@ exports.updateSearchTerm = updateSearchTerm$1;
|
|
|
2148
2049
|
exports.updateSelectedFilters = updateSelectedFilters;
|
|
2149
2050
|
exports.updateSortOrder = updateSortOrder$1;
|
|
2150
2051
|
exports.withMappers = withMappers;
|
|
2151
|
-
//# sourceMappingURL=sagas-
|
|
2052
|
+
//# sourceMappingURL=sagas-6d12e7ca.js.map
|