@zengenti/contensis-react-base 3.0.0-beta.3 → 3.0.0-beta.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/cjs/{App-581b6653.js → App-b681e8eb.js} +139 -124
- package/cjs/App-b681e8eb.js.map +1 -0
- package/cjs/{RouteLoader-282c03ab.js → RouteLoader-2ed14766.js} +44 -30
- package/cjs/RouteLoader-2ed14766.js.map +1 -0
- package/cjs/ToJs-09204afd.js +129 -0
- package/cjs/ToJs-09204afd.js.map +1 -0
- package/cjs/{actions-12871aca.js → actions-6b9ef168.js} +9 -8
- package/cjs/actions-6b9ef168.js.map +1 -0
- package/cjs/client.js +43 -22
- package/cjs/client.js.map +1 -1
- package/cjs/contensis-react-base.js +42 -46
- package/cjs/contensis-react-base.js.map +1 -1
- package/cjs/forms.js +275 -275
- package/cjs/forms.js.map +1 -1
- package/cjs/fromJSLeaveImmer-65d26804.js +28 -0
- package/cjs/fromJSLeaveImmer-65d26804.js.map +1 -0
- package/cjs/{login-81d7f9ef.js → login-d67b82aa.js} +113 -79
- package/cjs/login-d67b82aa.js.map +1 -0
- package/cjs/{reducers-fde41d6b.js → reducers-3a4f8971.js} +26 -25
- package/cjs/reducers-3a4f8971.js.map +1 -0
- package/cjs/redux.js +13 -14
- package/cjs/redux.js.map +1 -1
- package/cjs/routing.js +9 -8
- package/cjs/routing.js.map +1 -1
- package/cjs/search.js +228 -164
- package/cjs/search.js.map +1 -1
- package/cjs/{selectors-ed26ed97.js → selectors-2c1b1183.js} +8 -4
- package/cjs/selectors-2c1b1183.js.map +1 -0
- package/cjs/user.js +32 -23
- package/cjs/user.js.map +1 -1
- package/cjs/util.js +48 -45
- package/cjs/util.js.map +1 -1
- package/cjs/{version-f061e409.js → version-7c4ce67e.js} +58 -52
- package/cjs/version-7c4ce67e.js.map +1 -0
- package/cjs/{version-0c190929.js → version-dcfdafd9.js} +5 -5
- package/cjs/{version-0c190929.js.map → version-dcfdafd9.js.map} +1 -1
- package/esm/{App-122f28a3.js → App-c9e818ab.js} +120 -124
- package/esm/App-c9e818ab.js.map +1 -0
- package/esm/{RouteLoader-c2faac87.js → RouteLoader-d4b4d320.js} +37 -23
- package/esm/RouteLoader-d4b4d320.js.map +1 -0
- package/esm/ToJs-2627ce21.js +99 -0
- package/esm/ToJs-2627ce21.js.map +1 -0
- package/esm/{actions-3cc39599.js → actions-5437f43d.js} +8 -7
- package/esm/actions-5437f43d.js.map +1 -0
- package/esm/client.js +22 -20
- package/esm/client.js.map +1 -1
- package/esm/contensis-react-base.js +24 -28
- package/esm/contensis-react-base.js.map +1 -1
- package/esm/forms.js +5 -5
- package/esm/forms.js.map +1 -1
- package/esm/fromJSLeaveImmer-e2f0f331.js +26 -0
- package/esm/fromJSLeaveImmer-e2f0f331.js.map +1 -0
- package/esm/{login-92db44d1.js → login-f6dfbe1b.js} +97 -60
- package/esm/login-f6dfbe1b.js.map +1 -0
- package/esm/{reducers-d6c0edb1.js → reducers-8e5d6232.js} +26 -25
- package/esm/reducers-8e5d6232.js.map +1 -0
- package/esm/redux.js +14 -13
- package/esm/redux.js.map +1 -1
- package/esm/routing.js +9 -8
- package/esm/routing.js.map +1 -1
- package/esm/search.js +198 -152
- package/esm/search.js.map +1 -1
- package/esm/{selectors-82e71d8e.js → selectors-65f0f31c.js} +9 -6
- package/esm/selectors-65f0f31c.js.map +1 -0
- package/esm/user.js +31 -22
- package/esm/user.js.map +1 -1
- package/esm/util.js +17 -10
- package/esm/util.js.map +1 -1
- package/esm/version-696796d7.js +15 -0
- package/esm/{version-59c8f9be.js.map → version-696796d7.js.map} +1 -1
- package/esm/{version-cb9cd09d.js → version-e6a545e1.js} +38 -31
- package/esm/version-e6a545e1.js.map +1 -0
- package/models/redux/appstate.d.ts +5 -10
- package/models/redux/reducers/navigation.d.ts +1 -6
- package/models/redux/reducers/version.d.ts +1 -5
- package/models/redux/selectors/navigation.d.ts +2 -1
- package/models/routing/redux/actions.d.ts +1 -1
- package/models/routing/redux/reducers.d.ts +1 -21
- package/models/routing/redux/selectors.d.ts +1 -1
- package/models/routing/routes.d.ts +3 -2
- package/models/routing/util/expressions.d.ts +3 -2
- package/models/routing/util/queries.d.ts +1 -1
- package/models/search/models/Queries.d.ts +8 -5
- package/models/search/models/Search.d.ts +9 -8
- package/models/search/models/SearchActions.d.ts +1 -0
- package/models/search/models/SearchState.d.ts +3 -0
- package/models/search/models/index.d.ts +3 -2
- package/models/search/redux/actions.d.ts +2 -1
- package/models/search/redux/reducers.d.ts +226 -314
- package/models/search/redux/sagas.d.ts +2 -2
- package/models/search/redux/selectors.d.ts +5 -10
- package/models/search/search/expressions.d.ts +2 -6
- package/models/search/transformations/filter-to-filterexpression.mapper.d.ts +6 -0
- package/models/search/transformations/filters-to-filterexpressions.mapper.d.ts +3 -0
- package/models/server/util/headers.d.ts +3 -2
- package/models/testImmer/redux/reducer.d.ts +1 -7
- package/models/user/components/Login.d.ts +1 -2
- package/models/user/components/LoginForm.d.ts +1 -2
- package/models/user/hocs/withLogin.d.ts +2 -2
- package/models/user/hooks/useChangePassword.d.ts +5 -5
- package/models/user/hooks/useForgotPassword.d.ts +6 -6
- package/models/user/hooks/useLogin.d.ts +9 -45
- package/models/user/hooks/useRegistration.d.ts +4 -4
- package/models/user/redux/reducers.d.ts +5 -32
- package/models/user/redux/sagas/login.d.ts +11 -8
- package/models/user/redux/selectors.d.ts +33 -71
- package/models/user/util/LoginHelper.class.d.ts +4 -3
- package/models/util/json-mapper.d.ts +9 -3
- package/models/util/merge.d.ts +1 -0
- package/package-lock.json +2006 -4796
- package/package.json +47 -48
- package/cjs/App-581b6653.js.map +0 -1
- package/cjs/RouteLoader-282c03ab.js.map +0 -1
- package/cjs/ToJs-87edc45d.js +0 -230
- package/cjs/ToJs-87edc45d.js.map +0 -1
- package/cjs/actions-12871aca.js.map +0 -1
- package/cjs/fromJSLeaveImmer-9b550c8e.js +0 -40
- package/cjs/fromJSLeaveImmer-9b550c8e.js.map +0 -1
- package/cjs/login-81d7f9ef.js.map +0 -1
- package/cjs/reducers-fde41d6b.js.map +0 -1
- package/cjs/selectors-ed26ed97.js.map +0 -1
- package/cjs/version-f061e409.js.map +0 -1
- package/esm/App-122f28a3.js.map +0 -1
- package/esm/RouteLoader-c2faac87.js.map +0 -1
- package/esm/ToJs-52fee252.js +0 -199
- package/esm/ToJs-52fee252.js.map +0 -1
- package/esm/actions-3cc39599.js.map +0 -1
- package/esm/fromJSLeaveImmer-e44d1a91.js +0 -38
- package/esm/fromJSLeaveImmer-e44d1a91.js.map +0 -1
- package/esm/login-92db44d1.js.map +0 -1
- package/esm/reducers-d6c0edb1.js.map +0 -1
- package/esm/selectors-82e71d8e.js.map +0 -1
- package/esm/version-59c8f9be.js +0 -15
- package/esm/version-cb9cd09d.js.map +0 -1
- package/models/search/transformations/filters-to-filterexpression.d.ts +0 -1
- package/models/search/transformations/filters-to-filterexpression.mapper.d.ts +0 -2
- package/models/server/features/caching/cacheHashing.d.ts +0 -1
package/esm/search.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import React, { useMemo, useEffect } from 'react';
|
|
2
2
|
import { connect, useDispatch, useSelector } from 'react-redux';
|
|
3
3
|
import mapJson, { jpath } from 'jsonpath-mapper';
|
|
4
|
-
import
|
|
4
|
+
import * as log from 'loglevel';
|
|
5
5
|
import { takeEvery, select, put, call, all } from '@redux-saga/core/effects';
|
|
6
6
|
import { Client } from 'contensis-delivery-api';
|
|
7
|
-
import
|
|
8
|
-
import { error } from 'loglevel';
|
|
9
|
-
import { createSelector } from 'reselect';
|
|
7
|
+
import { stringify, parse } from 'query-string';
|
|
10
8
|
import { Op, OrderBy, Query } from 'contensis-core-api';
|
|
11
9
|
import merge from 'deepmerge';
|
|
10
|
+
import { createSelector } from 'reselect';
|
|
11
|
+
import { produce } from 'immer';
|
|
12
12
|
import equals from 'deep-equal';
|
|
13
13
|
|
|
14
14
|
/* eslint-disable import/default */
|
|
15
|
-
const toJS = WrappedComponent => wrappedComponentProps => {
|
|
15
|
+
const toJS$1 = WrappedComponent => wrappedComponentProps => {
|
|
16
16
|
const KEY = 0;
|
|
17
17
|
const VALUE = 1;
|
|
18
18
|
const propsJS = Object.entries(wrappedComponentProps).reduce((newProps, wrappedComponentProp) => {
|
|
@@ -121,43 +121,44 @@ const navigate = (path, state) => {
|
|
|
121
121
|
state
|
|
122
122
|
};
|
|
123
123
|
};
|
|
124
|
-
const clearFilters = () => {
|
|
124
|
+
const clearFilters$1 = () => {
|
|
125
125
|
return {
|
|
126
126
|
type: CLEAR_FILTERS
|
|
127
127
|
};
|
|
128
128
|
};
|
|
129
|
-
const updatePageIndex = pageIndex => {
|
|
129
|
+
const updatePageIndex$1 = pageIndex => {
|
|
130
130
|
return {
|
|
131
131
|
type: UPDATE_PAGE_INDEX,
|
|
132
132
|
pageIndex
|
|
133
133
|
};
|
|
134
134
|
};
|
|
135
|
-
const updateCurrentFacet = facet => {
|
|
135
|
+
const updateCurrentFacet$1 = facet => {
|
|
136
136
|
return {
|
|
137
137
|
type: UPDATE_CURRENT_FACET,
|
|
138
138
|
facet
|
|
139
139
|
};
|
|
140
140
|
};
|
|
141
|
-
const updateCurrentTab = id => {
|
|
141
|
+
const updateCurrentTab$1 = id => {
|
|
142
142
|
return {
|
|
143
143
|
type: UPDATE_CURRENT_TAB,
|
|
144
144
|
id
|
|
145
145
|
};
|
|
146
146
|
};
|
|
147
|
-
const updateSearchTerm = term => {
|
|
147
|
+
const updateSearchTerm$1 = term => {
|
|
148
148
|
return {
|
|
149
149
|
type: UPDATE_SEARCH_TERM,
|
|
150
150
|
term
|
|
151
151
|
};
|
|
152
152
|
};
|
|
153
|
-
const updateSelectedFilters = (filter, key) => {
|
|
153
|
+
const updateSelectedFilters = (filter, key, isUnknownItem = false) => {
|
|
154
154
|
return {
|
|
155
155
|
type: UPDATE_SELECTED_FILTERS,
|
|
156
156
|
filter,
|
|
157
|
-
key
|
|
157
|
+
key,
|
|
158
|
+
isUnknownItem
|
|
158
159
|
};
|
|
159
160
|
};
|
|
160
|
-
const updateSortOrder = (orderBy, facet) => {
|
|
161
|
+
const updateSortOrder$1 = (orderBy, facet) => {
|
|
161
162
|
return {
|
|
162
163
|
type: UPDATE_SORT_ORDER,
|
|
163
164
|
orderBy,
|
|
@@ -171,22 +172,22 @@ var actions = /*#__PURE__*/Object.freeze({
|
|
|
171
172
|
triggerSearch: triggerSearch,
|
|
172
173
|
initListing: initListing,
|
|
173
174
|
navigate: navigate,
|
|
174
|
-
clearFilters: clearFilters,
|
|
175
|
-
updatePageIndex: updatePageIndex,
|
|
176
|
-
updateCurrentFacet: updateCurrentFacet,
|
|
177
|
-
updateCurrentTab: updateCurrentTab,
|
|
178
|
-
updateSearchTerm: updateSearchTerm,
|
|
175
|
+
clearFilters: clearFilters$1,
|
|
176
|
+
updatePageIndex: updatePageIndex$1,
|
|
177
|
+
updateCurrentFacet: updateCurrentFacet$1,
|
|
178
|
+
updateCurrentTab: updateCurrentTab$1,
|
|
179
|
+
updateSearchTerm: updateSearchTerm$1,
|
|
179
180
|
updateSelectedFilters: updateSelectedFilters,
|
|
180
|
-
updateSortOrder: updateSortOrder
|
|
181
|
+
updateSortOrder: updateSortOrder$1
|
|
181
182
|
});
|
|
182
183
|
|
|
183
|
-
let Context; // export type Context = 'facets' | 'listings' | 'minilist';
|
|
184
|
+
let Context$1; // export type Context = 'facets' | 'listings' | 'minilist';
|
|
184
185
|
|
|
185
186
|
(function (Context) {
|
|
186
187
|
Context["facets"] = "facets";
|
|
187
188
|
Context["listings"] = "listings";
|
|
188
189
|
Context["minilist"] = "minilist";
|
|
189
|
-
})(Context || (Context = {}));
|
|
190
|
+
})(Context$1 || (Context$1 = {}));
|
|
190
191
|
|
|
191
192
|
// or replace with a stub function for non-immutable gets
|
|
192
193
|
|
|
@@ -217,12 +218,12 @@ const getImmutableOrJS = (state, stateKey, fallbackValue, returnType = globalThi
|
|
|
217
218
|
return result;
|
|
218
219
|
};
|
|
219
220
|
|
|
220
|
-
const getSearchContext = state => getImmutableOrJS(state, ['search', 'context'], Context.facets);
|
|
221
|
-
const getCurrent = (state, context = Context.facets) => context === Context.facets ? getCurrentFacet(state) : getCurrentListing(state);
|
|
221
|
+
const getSearchContext = state => getImmutableOrJS(state, ['search', 'context'], Context$1.facets);
|
|
222
|
+
const getCurrent = (state, context = Context$1.facets) => context === Context$1.facets ? getCurrentFacet(state) : getCurrentListing(state);
|
|
222
223
|
const getCurrentFacet = state => getImmutableOrJS(state, ['search', 'currentFacet']);
|
|
223
224
|
const getCurrentListing = state => getImmutableOrJS(state, ['search', 'currentListing']);
|
|
224
|
-
const getCurrentTab = state => getImmutableOrJS(state, ['search', Context.facets, getCurrentFacet(state), 'tabId'], 0);
|
|
225
|
-
const getFacets = (state, returnType) => getImmutableOrJS(state, ['search', Context.facets], {}, returnType);
|
|
225
|
+
const getCurrentTab = state => getImmutableOrJS(state, ['search', Context$1.facets, getCurrentFacet(state), 'tabId'], 0);
|
|
226
|
+
const getFacets = (state, returnType) => getImmutableOrJS(state, ['search', Context$1.facets], {}, returnType);
|
|
226
227
|
const getTabFacets = state => Object.fromEntries(Object.entries(getFacets(state, 'js')).filter(([key]) => getImmutableOrJS(getFacets(state), [key, 'tabId'], 0) === getCurrentTab(state)));
|
|
227
228
|
const getFacetTitles = state => Object.entries(getFacets(state, 'js')).map(([key, facet = {}]) => {
|
|
228
229
|
var _facet$pagingInfo;
|
|
@@ -233,19 +234,19 @@ const getFacetTitles = state => Object.entries(getFacets(state, 'js')).map(([key
|
|
|
233
234
|
totalCount: (_facet$pagingInfo = facet.pagingInfo) === null || _facet$pagingInfo === void 0 ? void 0 : _facet$pagingInfo.totalCount
|
|
234
235
|
};
|
|
235
236
|
});
|
|
236
|
-
const getFacet = (state, facetName = '', context = Context.facets, returnType) => {
|
|
237
|
+
const getFacet = (state, facetName = '', context = Context$1.facets, returnType) => {
|
|
237
238
|
const currentFacet = facetName || getCurrentFacet(state);
|
|
238
239
|
return getImmutableOrJS(state, ['search', context, currentFacet], {}, returnType);
|
|
239
240
|
};
|
|
240
241
|
const getListing = (state, listing = '') => {
|
|
241
242
|
const currentListing = listing || getCurrentListing(state);
|
|
242
|
-
return getImmutableOrJS(state, ['search', Context.listings, currentListing], {});
|
|
243
|
+
return getImmutableOrJS(state, ['search', Context$1.listings, currentListing], {});
|
|
243
244
|
};
|
|
244
|
-
const getFilters = (state, facet, context = Context.facets, returnType) => {
|
|
245
|
+
const getFilters = (state, facet, context = Context$1.facets, returnType) => {
|
|
245
246
|
return getImmutableOrJS(state, ['search', context, facet || getCurrent(state, context), 'filters'], {}, returnType);
|
|
246
247
|
};
|
|
247
|
-
const getRenderableFilters = (state, facet = '', context = Context.facets) => Object.fromEntries(Object.entries(getFilters(state, facet, context, 'js')).filter(([, f = {}]) => typeof f.renderable !== 'boolean' ? true : f.renderable));
|
|
248
|
-
const getFiltersToLoad = (state, facet, context = Context.facets, returnType) => {
|
|
248
|
+
const getRenderableFilters = (state, facet = '', context = Context$1.facets) => Object.fromEntries(Object.entries(getFilters(state, facet, context, 'js')).filter(([, f = {}]) => typeof f.renderable !== 'boolean' ? true : f.renderable));
|
|
249
|
+
const getFiltersToLoad = (state, facet, context = Context$1.facets, returnType) => {
|
|
249
250
|
const filters = getFilters(state, facet, context, returnType);
|
|
250
251
|
const loadedFilters = Object.entries(filters).map(([key, f = {}]) => [key, (f.items || []).filter(i => {
|
|
251
252
|
const title = i === null || i === void 0 ? void 0 : i.title;
|
|
@@ -254,7 +255,7 @@ const getFiltersToLoad = (state, facet, context = Context.facets, returnType) =>
|
|
|
254
255
|
return loadedFilters.map(([filterKey, isLoaded]) => !isLoaded ? filterKey : null).filter(f => !!f);
|
|
255
256
|
}; // We lowercase the filter key unless it's an ISO date string where the T must be uppercase
|
|
256
257
|
|
|
257
|
-
const getSelectedFilters = (state, facet = '', context = Context.facets, returnType) => {
|
|
258
|
+
const getSelectedFilters = (state, facet = '', context = Context$1.facets, returnType) => {
|
|
258
259
|
const filters = getFilters(state, facet, context, 'js');
|
|
259
260
|
const isoDateRegex = RegExp(/\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d/);
|
|
260
261
|
const selectedFilters = Object.fromEntries(Object.entries(filters).map(([key, filter = {}]) => [key, (filter.items || []).filter(item => !!(item.isSelected || false)).map(item => {
|
|
@@ -265,56 +266,56 @@ const getSelectedFilters = (state, facet = '', context = Context.facets, returnT
|
|
|
265
266
|
const fromJS = makeFromJS(returnType);
|
|
266
267
|
return fromJS(selectedFilters);
|
|
267
268
|
};
|
|
268
|
-
const getResults = (state, current = '', context = Context.facets, returnType) => {
|
|
269
|
+
const getResults = (state, current = '', context = Context$1.facets, returnType) => {
|
|
269
270
|
return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'results'], [], returnType);
|
|
270
271
|
};
|
|
271
|
-
const getIsInternalPaging = (state, current, context = Context.facets) => {
|
|
272
|
+
const getIsInternalPaging = (state, current, context = Context$1.facets) => {
|
|
272
273
|
return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'queryParams', 'internalPaging'], false);
|
|
273
274
|
};
|
|
274
|
-
const getIsLoaded = (state, context = Context.facets, facet) => {
|
|
275
|
+
const getIsLoaded = (state, context = Context$1.facets, facet) => {
|
|
275
276
|
return !!getImmutableOrJS(state, ['search', context, facet || getCurrent(state, context), 'queryDuration'], 0);
|
|
276
277
|
};
|
|
277
|
-
const getIsLoading = (state, context = Context.facets, facet) => {
|
|
278
|
+
const getIsLoading = (state, context = Context$1.facets, facet) => {
|
|
278
279
|
return getImmutableOrJS(state, ['search', context, facet || getCurrent(state, context), 'entries', 'isLoading']);
|
|
279
280
|
};
|
|
280
281
|
const getIsSsr = state => getImmutableOrJS(state, ['search', 'config', 'ssr'], false);
|
|
281
|
-
const getFeaturedResults = (state, current = '', context = Context.facets) => {
|
|
282
|
+
const getFeaturedResults = (state, current = '', context = Context$1.facets) => {
|
|
282
283
|
return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'featuredResults'], []);
|
|
283
284
|
};
|
|
284
|
-
const getPaging = (state, current = '', context = Context.facets, returnType) => {
|
|
285
|
+
const getPaging = (state, current = '', context = Context$1.facets, returnType) => {
|
|
285
286
|
return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'pagingInfo'], {}, returnType);
|
|
286
287
|
};
|
|
287
|
-
const getPageIndex = (state, current = '', context = Context.facets) => {
|
|
288
|
+
const getPageIndex = (state, current = '', context = Context$1.facets) => {
|
|
288
289
|
return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'pagingInfo', 'pageIndex']);
|
|
289
290
|
};
|
|
290
|
-
const getPrevPageIndex = (state, current = '', context = Context.facets) => {
|
|
291
|
+
const getPrevPageIndex = (state, current = '', context = Context$1.facets) => {
|
|
291
292
|
return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'pagingInfo', 'prevPageIndex']);
|
|
292
293
|
};
|
|
293
|
-
const getPageIsLoading = (state, current = '', context = Context.facets) => {
|
|
294
|
+
const getPageIsLoading = (state, current = '', context = Context$1.facets) => {
|
|
294
295
|
return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'pagingInfo', 'isLoading']);
|
|
295
296
|
};
|
|
296
|
-
const getPagesLoaded = (state, current = '', context = Context.facets) => {
|
|
297
|
+
const getPagesLoaded = (state, current = '', context = Context$1.facets) => {
|
|
297
298
|
return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'pagingInfo', 'pagesLoaded'], [], 'js');
|
|
298
299
|
};
|
|
299
|
-
const getTotalCount = (state, current = '', context = Context.facets) => {
|
|
300
|
+
const getTotalCount = (state, current = '', context = Context$1.facets) => {
|
|
300
301
|
return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'pagingInfo', 'totalCount']);
|
|
301
302
|
};
|
|
302
303
|
const getSearchTerm = state => getImmutableOrJS(state, ['search', 'term']);
|
|
303
304
|
const getSearchTabs = (state, returnType) => getImmutableOrJS(state, ['search', 'tabs'], [], returnType);
|
|
304
|
-
const getQueryParams = (state, current = '', context = Context.facets) => {
|
|
305
|
+
const getQueryParams = (state, current = '', context = Context$1.facets) => {
|
|
305
306
|
return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'queryParams'], {}, 'js');
|
|
306
307
|
};
|
|
307
308
|
const getQueryParameter = ({
|
|
308
309
|
state,
|
|
309
310
|
facet,
|
|
310
|
-
context = Context.facets
|
|
311
|
+
context = Context$1.facets
|
|
311
312
|
}, key, ifnull = null) => {
|
|
312
313
|
return getImmutableOrJS(getQueryParams(state, facet, context), key, ifnull, 'js');
|
|
313
314
|
};
|
|
314
|
-
const getCustomApi = (state, current, context = Context.facets, returnType) => {
|
|
315
|
+
const getCustomApi = (state, current, context = Context$1.facets, returnType) => {
|
|
315
316
|
return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'customApi'], null, returnType);
|
|
316
317
|
};
|
|
317
|
-
const getCustomEnv = (state, current, context = Context.facets) => {
|
|
318
|
+
const getCustomEnv = (state, current, context = Context$1.facets) => {
|
|
318
319
|
return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'env']);
|
|
319
320
|
};
|
|
320
321
|
const getTabsAndFacets = (state, returnType) => {
|
|
@@ -330,7 +331,7 @@ const getTabsAndFacets = (state, returnType) => {
|
|
|
330
331
|
return 0;
|
|
331
332
|
}).reduce((a, b) => a + b, 0);
|
|
332
333
|
return { ...tab,
|
|
333
|
-
[Context.facets]: Object.fromEntries(thisTabFacets),
|
|
334
|
+
[Context$1.facets]: Object.fromEntries(thisTabFacets),
|
|
334
335
|
totalCount: thisTabTotal
|
|
335
336
|
};
|
|
336
337
|
});
|
|
@@ -370,14 +371,14 @@ const selectFacets = {
|
|
|
370
371
|
getPageIsLoading,
|
|
371
372
|
getPagesLoaded,
|
|
372
373
|
getPaging,
|
|
373
|
-
getQueryParams: (state, facet) => getQueryParams(state, facet, Context.facets),
|
|
374
|
+
getQueryParams: (state, facet) => getQueryParams(state, facet, Context$1.facets),
|
|
374
375
|
getQueryParameter: ({
|
|
375
376
|
state,
|
|
376
377
|
facet
|
|
377
378
|
}, key, ifnull) => getQueryParameter({
|
|
378
379
|
state,
|
|
379
380
|
facet,
|
|
380
|
-
context: Context.facets
|
|
381
|
+
context: Context$1.facets
|
|
381
382
|
}, key, ifnull),
|
|
382
383
|
getRenderableFilters,
|
|
383
384
|
getResults,
|
|
@@ -392,32 +393,33 @@ const selectFacets = {
|
|
|
392
393
|
|
|
393
394
|
const selectListing = {
|
|
394
395
|
getCurrent: getCurrentListing,
|
|
395
|
-
getFeaturedResults: (state, listing = '') => getFeaturedResults(state, listing, Context.listings),
|
|
396
|
-
getFilters: (state, listing = '') => getFilters(state, listing, Context.listings),
|
|
397
|
-
getFiltersToLoad: (state, listing = '') => getFiltersToLoad(state, listing, Context.listings),
|
|
396
|
+
getFeaturedResults: (state, listing = '') => getFeaturedResults(state, listing, Context$1.listings),
|
|
397
|
+
getFilters: (state, listing = '') => getFilters(state, listing, Context$1.listings),
|
|
398
|
+
getFiltersToLoad: (state, listing = '') => getFiltersToLoad(state, listing, Context$1.listings),
|
|
398
399
|
getListing,
|
|
399
|
-
getIsLoaded: state => getIsLoaded(state, Context.listings),
|
|
400
|
-
getIsLoading: state => getIsLoading(state, Context.listings),
|
|
401
|
-
getPageIndex: (state, listing = '') => getPageIndex(state, listing, Context.listings),
|
|
402
|
-
getPaging: (state, listing = '') => getPaging(state, listing, Context.listings),
|
|
403
|
-
getPageIsLoading: (state, listing = '') => getPageIsLoading(state, listing, Context.listings),
|
|
404
|
-
getPagesLoaded: (state, listing = '') => getPagesLoaded(state, listing, Context.listings),
|
|
405
|
-
getQueryParams: (state, listing = '') => getQueryParams(state, listing, Context.listings),
|
|
400
|
+
getIsLoaded: state => getIsLoaded(state, Context$1.listings),
|
|
401
|
+
getIsLoading: state => getIsLoading(state, Context$1.listings),
|
|
402
|
+
getPageIndex: (state, listing = '') => getPageIndex(state, listing, Context$1.listings),
|
|
403
|
+
getPaging: (state, listing = '') => getPaging(state, listing, Context$1.listings),
|
|
404
|
+
getPageIsLoading: (state, listing = '') => getPageIsLoading(state, listing, Context$1.listings),
|
|
405
|
+
getPagesLoaded: (state, listing = '') => getPagesLoaded(state, listing, Context$1.listings),
|
|
406
|
+
getQueryParams: (state, listing = '') => getQueryParams(state, listing, Context$1.listings),
|
|
406
407
|
getQueryParameter: ({
|
|
407
408
|
state,
|
|
408
409
|
facet
|
|
409
410
|
}, key, ifnull) => getQueryParameter({
|
|
410
411
|
state,
|
|
411
412
|
facet,
|
|
412
|
-
context: Context.listings
|
|
413
|
+
context: Context$1.listings
|
|
413
414
|
}, key, ifnull),
|
|
414
|
-
getRenderableFilters: (state, listing = '') => getRenderableFilters(state, listing, Context.listings),
|
|
415
|
-
getResults: (state, listing = '') => getResults(state, listing, Context.listings),
|
|
415
|
+
getRenderableFilters: (state, listing = '') => getRenderableFilters(state, listing, Context$1.listings),
|
|
416
|
+
getResults: (state, listing = '') => getResults(state, listing, Context$1.listings),
|
|
416
417
|
getSearchTerm,
|
|
417
|
-
getTotalCount: (state, listing = '') => getTotalCount(state, listing, Context.listings),
|
|
418
|
-
getSelectedFilters: (state, listing = '') => getSelectedFilters(state, listing, Context.listings)
|
|
418
|
+
getTotalCount: (state, listing = '') => getTotalCount(state, listing, Context$1.listings),
|
|
419
|
+
getSelectedFilters: (state, listing = '') => getSelectedFilters(state, listing, Context$1.listings)
|
|
419
420
|
};
|
|
420
421
|
const selectCurrentPath = state => getImmutableOrJS(state, ['routing', 'currentPath']);
|
|
422
|
+
const selectCurrentProject = state => getImmutableOrJS(state, ['routing', 'currentProject']);
|
|
421
423
|
const selectVersionStatus = state => getImmutableOrJS(state, ['version', 'contensisVersionStatus']);
|
|
422
424
|
|
|
423
425
|
var selectors = /*#__PURE__*/Object.freeze({
|
|
@@ -460,6 +462,7 @@ var selectors = /*#__PURE__*/Object.freeze({
|
|
|
460
462
|
selectFacets: selectFacets,
|
|
461
463
|
selectListing: selectListing,
|
|
462
464
|
selectCurrentPath: selectCurrentPath,
|
|
465
|
+
selectCurrentProject: selectCurrentProject,
|
|
463
466
|
selectVersionStatus: selectVersionStatus
|
|
464
467
|
});
|
|
465
468
|
|
|
@@ -500,16 +503,16 @@ const withSearch = mappers => SearchComponent => {
|
|
|
500
503
|
};
|
|
501
504
|
|
|
502
505
|
const mapDispatchToProps = {
|
|
503
|
-
clearFilters: () => withMappers(clearFilters(), mappers),
|
|
504
|
-
updateCurrentFacet: facet => withMappers(updateCurrentFacet(facet), mappers),
|
|
505
|
-
updateCurrentTab: id => withMappers(updateCurrentTab(id), mappers),
|
|
506
|
-
updatePageIndex: pageIndex => withMappers(updatePageIndex(pageIndex), mappers),
|
|
507
|
-
updateSearchTerm: term => withMappers(updateSearchTerm(term), mappers),
|
|
508
|
-
updateSelectedFilters: (filter, key) => withMappers(updateSelectedFilters(filter, key), mappers),
|
|
509
|
-
updateSortOrder: orderBy => withMappers(updateSortOrder(orderBy), mappers)
|
|
506
|
+
clearFilters: () => withMappers(clearFilters$1(), mappers),
|
|
507
|
+
updateCurrentFacet: facet => withMappers(updateCurrentFacet$1(facet), mappers),
|
|
508
|
+
updateCurrentTab: id => withMappers(updateCurrentTab$1(id), mappers),
|
|
509
|
+
updatePageIndex: pageIndex => withMappers(updatePageIndex$1(pageIndex), mappers),
|
|
510
|
+
updateSearchTerm: term => withMappers(updateSearchTerm$1(term), mappers),
|
|
511
|
+
updateSelectedFilters: (filter, key, isUnknownItem = false) => withMappers(updateSelectedFilters(filter, key, isUnknownItem), mappers),
|
|
512
|
+
updateSortOrder: orderBy => withMappers(updateSortOrder$1(orderBy), mappers)
|
|
510
513
|
};
|
|
511
514
|
const connector = connect(mapStateToProps, mapDispatchToProps);
|
|
512
|
-
return connector(toJS(Wrapper));
|
|
515
|
+
return connector(toJS$1(Wrapper));
|
|
513
516
|
};
|
|
514
517
|
|
|
515
518
|
/* eslint-disable @typescript-eslint/naming-convention */
|
|
@@ -552,14 +555,14 @@ const withListing = mappers => ListingComponent => {
|
|
|
552
555
|
};
|
|
553
556
|
|
|
554
557
|
const mapDispatchToProps = {
|
|
555
|
-
clearFilters: () => withMappers(clearFilters(), mappers),
|
|
556
|
-
updateCurrentFacet: facet => withMappers(updateCurrentFacet(facet), mappers),
|
|
557
|
-
updatePageIndex: pageIndex => withMappers(updatePageIndex(pageIndex), mappers),
|
|
558
|
-
updateSearchTerm: term => withMappers(updateSearchTerm(term), mappers),
|
|
559
|
-
updateSelectedFilters: (filter, key) => withMappers(updateSelectedFilters(filter, key), mappers),
|
|
560
|
-
updateSortOrder: orderBy => withMappers(updateSortOrder(orderBy), mappers)
|
|
558
|
+
clearFilters: () => withMappers(clearFilters$1(), mappers),
|
|
559
|
+
updateCurrentFacet: facet => withMappers(updateCurrentFacet$1(facet), mappers),
|
|
560
|
+
updatePageIndex: pageIndex => withMappers(updatePageIndex$1(pageIndex), mappers),
|
|
561
|
+
updateSearchTerm: term => withMappers(updateSearchTerm$1(term), mappers),
|
|
562
|
+
updateSelectedFilters: (filter, key, isUnknownItem = false) => withMappers(updateSelectedFilters(filter, key, isUnknownItem), mappers),
|
|
563
|
+
updateSortOrder: orderBy => withMappers(updateSortOrder$1(orderBy), mappers)
|
|
561
564
|
};
|
|
562
|
-
return connect(mapStateToProps, mapDispatchToProps)(toJS(Wrapper));
|
|
565
|
+
return connect(mapStateToProps, mapDispatchToProps)(toJS$1(Wrapper));
|
|
563
566
|
};
|
|
564
567
|
|
|
565
568
|
const getClientConfig = (project, env) => {
|
|
@@ -768,7 +771,7 @@ const extractQuotedPhrases = searchTerm => {
|
|
|
768
771
|
return (searchTerm.match(pattern) || []).map(match => match.replace(/"/g, ''));
|
|
769
772
|
};
|
|
770
773
|
const buildUrl = (route, params) => {
|
|
771
|
-
const qs =
|
|
774
|
+
const qs = stringify(params);
|
|
772
775
|
const path = qs ? `${route}?${qs}` : route;
|
|
773
776
|
return path;
|
|
774
777
|
};
|
|
@@ -849,7 +852,7 @@ const fieldExpression = (field, value, operator = 'equalTo', weight) => {
|
|
|
849
852
|
// to generate expressions that are combined with an 'or' operator
|
|
850
853
|
return [Op.or(...field.map(fieldId => fieldExpression(fieldId, value, operator, weight)).flat())];
|
|
851
854
|
if (operator === 'between') return between(field, value);
|
|
852
|
-
if (Array.isArray(value)) return equalToOrIn(field, value, operator);else return !weight ?
|
|
855
|
+
if (Array.isArray(value)) return equalToOrIn(field, value, operator);else return !weight ? equalToOrIn(field, value, operator) : [equalToOrIn(field, value, operator)[0].weight(weight)];
|
|
853
856
|
};
|
|
854
857
|
const contentTypeIdExpression = (contentTypeIds, webpageTemplates, assetTypes) => {
|
|
855
858
|
const expressions = [];
|
|
@@ -873,8 +876,17 @@ const contentTypeIdExpression = (contentTypeIds, webpageTemplates, assetTypes) =
|
|
|
873
876
|
const filterExpressions = filters => {
|
|
874
877
|
if (!filters) return [];
|
|
875
878
|
const expressions = [];
|
|
876
|
-
filters.map(
|
|
877
|
-
|
|
879
|
+
filters.map(selectedFilter => {
|
|
880
|
+
if (selectedFilter.logicOperator === 'and') // using 'and' logic operator we loop through each filter
|
|
881
|
+
// and loop through all values to add an expression for each filter value
|
|
882
|
+
selectedFilter.values.forEach(value => expressions.push(...fieldExpression(selectedFilter.key, value, selectedFilter.fieldOperator || 'equalTo')));else if (selectedFilter.logicOperator === 'not') {
|
|
883
|
+
const fieldExpressions = fieldExpression(selectedFilter.key, selectedFilter.values, selectedFilter.fieldOperator || 'in');
|
|
884
|
+
fieldExpressions.forEach(expr => {
|
|
885
|
+
expressions.push(Op.not(expr));
|
|
886
|
+
});
|
|
887
|
+
} // using 'or' logic operator we loop over each filter
|
|
888
|
+
// and simply add the array of values to an expression with an 'in' operator
|
|
889
|
+
else expressions.push(...fieldExpression(selectedFilter.key, selectedFilter.values, selectedFilter.fieldOperator || 'in'));
|
|
878
890
|
});
|
|
879
891
|
return expressions;
|
|
880
892
|
};
|
|
@@ -891,8 +903,8 @@ const dataFormatExpression = (contentTypeIds, dataFormat = DataFormats.entry) =>
|
|
|
891
903
|
const withExpr = fieldExpression(Fields.sys.contentTypeId, withContentTypeIds)[0];
|
|
892
904
|
const notExpr = Op.not(fieldExpression(Fields.sys.contentTypeId, notContentTypeIds)[0]);
|
|
893
905
|
andExpr.add(dataFormatExpr);
|
|
894
|
-
if (withContentTypeIds.length > 0) andExpr.add(withExpr);
|
|
895
|
-
if (notContentTypeIds.length > 0) andExpr.add(notExpr);
|
|
906
|
+
if (withContentTypeIds.length > 0 && withExpr) andExpr.add(withExpr);
|
|
907
|
+
if (notContentTypeIds.length > 0 && notExpr) andExpr.add(notExpr);
|
|
896
908
|
return [andExpr];
|
|
897
909
|
}
|
|
898
910
|
|
|
@@ -948,19 +960,45 @@ const equalToOrIn = (field, value, operator = 'equalTo') => {
|
|
|
948
960
|
if (value.length === 0) return [];
|
|
949
961
|
|
|
950
962
|
if (Array.isArray(value)) {
|
|
951
|
-
if (
|
|
952
|
-
return [Op.
|
|
963
|
+
if (operator === 'equalTo') return [Op.in(field, ...value)];
|
|
964
|
+
return [Op.or(...value.map(innerValue => {
|
|
965
|
+
switch (operator) {
|
|
966
|
+
case 'between':
|
|
967
|
+
case 'distanceWithin':
|
|
968
|
+
// Not implemented
|
|
969
|
+
return Op.equalTo(field, innerValue);
|
|
970
|
+
|
|
971
|
+
case 'freeText':
|
|
972
|
+
// TODO: Potentially needs further implementation of new options
|
|
973
|
+
return Op[operator](field, innerValue, false, undefined);
|
|
974
|
+
|
|
975
|
+
default:
|
|
976
|
+
return Op[operator](field, innerValue);
|
|
977
|
+
}
|
|
978
|
+
}))];
|
|
953
979
|
}
|
|
954
980
|
|
|
955
|
-
|
|
981
|
+
switch (operator) {
|
|
982
|
+
case 'between':
|
|
983
|
+
case 'distanceWithin':
|
|
984
|
+
// Not implemented
|
|
985
|
+
return [Op.equalTo(field, value)];
|
|
986
|
+
|
|
987
|
+
case 'freeText':
|
|
988
|
+
// TODO: Potentially needs further implementation of new options
|
|
989
|
+
return [Op[operator](field, value, false, undefined)];
|
|
990
|
+
|
|
991
|
+
default:
|
|
992
|
+
return [Op[operator](field, value)];
|
|
993
|
+
}
|
|
956
994
|
};
|
|
957
995
|
|
|
958
996
|
const between = (field, value) => {
|
|
959
997
|
const handle = betweenValue => {
|
|
960
|
-
const valArr = betweenValue.split('
|
|
998
|
+
const valArr = betweenValue.split('--');
|
|
961
999
|
|
|
962
1000
|
if (valArr.length > 1) {
|
|
963
|
-
const [minimum, maximum
|
|
1001
|
+
const [minimum, maximum] = valArr;
|
|
964
1002
|
return Op.between(field, minimum, maximum);
|
|
965
1003
|
} else {
|
|
966
1004
|
// eslint-disable-next-line no-console
|
|
@@ -970,10 +1008,9 @@ const between = (field, value) => {
|
|
|
970
1008
|
};
|
|
971
1009
|
|
|
972
1010
|
if (value.length === 0) return [];
|
|
973
|
-
if (Array.isArray(value)) return [Op.or(...value.map(handle).filter(bc => bc !== false))];
|
|
974
|
-
|
|
1011
|
+
if (Array.isArray(value)) return [Op.or(...value.map(handle).filter(bc => bc !== false))];
|
|
975
1012
|
const op = handle(value);
|
|
976
|
-
return op ? [op] : [];
|
|
1013
|
+
return op ? [op] : [];
|
|
977
1014
|
};
|
|
978
1015
|
/**
|
|
979
1016
|
* Accept HTTP style objects and map them to
|
|
@@ -1016,7 +1053,7 @@ const customWhereExpressions = where => {
|
|
|
1016
1053
|
// the second property inside the clause
|
|
1017
1054
|
|
|
1018
1055
|
if (notIdx === 1) {
|
|
1019
|
-
expression = Op.not(Op[innerOperator](innerField, innerValue));
|
|
1056
|
+
expression = innerOperator === 'between' ? Op.not(Op[innerOperator](innerField, innerValue[0], innerValue[1])) : Op.not(Op[innerOperator](innerField, innerValue));
|
|
1020
1057
|
}
|
|
1021
1058
|
});
|
|
1022
1059
|
}
|
|
@@ -1028,8 +1065,9 @@ const customWhereExpressions = where => {
|
|
|
1028
1065
|
|
|
1029
1066
|
if (idx === 1 && // operator !== 'and' &&
|
|
1030
1067
|
// operator !== 'or' &&
|
|
1031
|
-
operator !== 'between' &&
|
|
1032
|
-
|
|
1068
|
+
// operator !== 'between' &&
|
|
1069
|
+
operator !== 'distanceWithin') {
|
|
1070
|
+
expression = operator === 'freeText' || operator === 'contains' ? Op[operator](field, value) : operator === 'in' ? Op[operator](field, ...value) : operator === 'exists' ? Op[operator](field, value) : operator === 'between' ? Op[operator](field, value[0], value[1]) : Op[operator](field, value);
|
|
1033
1071
|
if (typeof weight === 'number') expression = expression.weight(weight);
|
|
1034
1072
|
}
|
|
1035
1073
|
});
|
|
@@ -1142,7 +1180,7 @@ const searchUriTemplate = {
|
|
|
1142
1180
|
facet,
|
|
1143
1181
|
pageIndex
|
|
1144
1182
|
}) => {
|
|
1145
|
-
const currentFacet = getSearchContext(state) !== Context.listings && (facet || getCurrentFacet(state));
|
|
1183
|
+
const currentFacet = getSearchContext(state) !== Context$1.listings && (facet || getCurrentFacet(state));
|
|
1146
1184
|
const currentPath = selectCurrentPath(state) || '/search';
|
|
1147
1185
|
const newPath = currentFacet ? `${currentPath}/${currentFacet}` : currentPath;
|
|
1148
1186
|
if (pageIndex) return `${newPath}/${pageIndex + 1}`;
|
|
@@ -1159,7 +1197,7 @@ const searchUriTemplate = {
|
|
|
1159
1197
|
|
|
1160
1198
|
const stateFilters = term ? {} : Object.fromEntries(Object.entries(getSelectedFilters(state, facet, searchContext, 'js')).map(([key, f]) => [key, f === null || f === void 0 ? void 0 : f.join(',')]));
|
|
1161
1199
|
const currentSearch = !term && getImmutableOrJS(state, ['routing', 'location', 'search']);
|
|
1162
|
-
const currentQs = removeEmptyAttributes(
|
|
1200
|
+
const currentQs = removeEmptyAttributes(parse(currentSearch));
|
|
1163
1201
|
if (orderBy) currentQs.orderBy = orderBy;
|
|
1164
1202
|
const searchTerm = getSearchTerm(state); // Use Immutable's merge to merge the stateFilters with any current Qs
|
|
1165
1203
|
// to build the new Qs.
|
|
@@ -1167,7 +1205,7 @@ const searchUriTemplate = {
|
|
|
1167
1205
|
const mergedSearch = removeEmptyAttributes({ ...merge(currentQs, stateFilters),
|
|
1168
1206
|
term: searchTerm
|
|
1169
1207
|
});
|
|
1170
|
-
return
|
|
1208
|
+
return stringify(mergedSearch);
|
|
1171
1209
|
},
|
|
1172
1210
|
hash: {
|
|
1173
1211
|
$path: 'state',
|
|
@@ -1317,14 +1355,15 @@ const filterTemplate = {
|
|
|
1317
1355
|
const filterExpressionMapper = {
|
|
1318
1356
|
// Expression type: so we can identify how to build the query
|
|
1319
1357
|
expressionType: ({
|
|
1320
|
-
|
|
1321
|
-
}) =>
|
|
1358
|
+
contentTypeId
|
|
1359
|
+
}) => contentTypeId ? FilterExpressionTypes.contentType : FilterExpressionTypes.field,
|
|
1322
1360
|
// Key: so we can target the query to a specific field
|
|
1323
|
-
key: '
|
|
1361
|
+
key: 'fieldId',
|
|
1324
1362
|
// Value: so we can filter a specific field by an array of values
|
|
1325
1363
|
// e.g. taxonomy key or contentTypeId array
|
|
1326
|
-
|
|
1327
|
-
|
|
1364
|
+
values: 'selectedValues',
|
|
1365
|
+
fieldOperator: 'fieldOperator',
|
|
1366
|
+
logicOperator: 'logicOperator'
|
|
1328
1367
|
};
|
|
1329
1368
|
|
|
1330
1369
|
const mapFilterToFilterExpression = filter => mapJson(filter, filterExpressionMapper);
|
|
@@ -1334,18 +1373,15 @@ const mapFiltersToFilterExpression = (filters, selectedFilters) => {
|
|
|
1334
1373
|
const filterExpressions = []; // Iterate through the keys in selectedFilters and locate
|
|
1335
1374
|
// the items that are selected and queryable
|
|
1336
1375
|
|
|
1337
|
-
Object.entries(selectedFilters).map(([fkey,
|
|
1376
|
+
Object.entries(selectedFilters).map(([fkey, selectedValues]) => {
|
|
1338
1377
|
const filter = filters[fkey];
|
|
1339
1378
|
|
|
1340
|
-
if (
|
|
1341
|
-
|
|
1379
|
+
if (selectedValues && filter) {
|
|
1380
|
+
// Where we have a value for a selectedFilter
|
|
1342
1381
|
// and a filter is found for the current key
|
|
1343
1382
|
// map the filter to a filterExpression object
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
filter,
|
|
1347
|
-
selectedItems,
|
|
1348
|
-
selectedValue
|
|
1383
|
+
const expr = mapFilterToFilterExpression({ ...filter,
|
|
1384
|
+
selectedValues
|
|
1349
1385
|
});
|
|
1350
1386
|
filterExpressions.push(expr);
|
|
1351
1387
|
}
|
|
@@ -1424,9 +1460,9 @@ const queryParamsTemplate = {
|
|
|
1424
1460
|
}) => {
|
|
1425
1461
|
var _getFacet;
|
|
1426
1462
|
|
|
1427
|
-
return (_getFacet = getFacet(state, facet, context)) === null || _getFacet === void 0 ? void 0 : _getFacet.projectId;
|
|
1463
|
+
return ((_getFacet = getFacet(state, facet, context)) === null || _getFacet === void 0 ? void 0 : _getFacet.projectId) || selectCurrentProject(state);
|
|
1428
1464
|
},
|
|
1429
|
-
searchTerm: root => root.context !== Context.minilist || getQueryParameter(root, 'useSearchTerm', false) ? getSearchTerm(root.state) : '',
|
|
1465
|
+
searchTerm: root => root.context !== Context$1.minilist || getQueryParameter(root, 'useSearchTerm', false) ? getSearchTerm(root.state) : '',
|
|
1430
1466
|
selectedFilters: ({
|
|
1431
1467
|
state,
|
|
1432
1468
|
facet,
|
|
@@ -1489,7 +1525,7 @@ const runSearch = (action, state, queryParams) => {
|
|
|
1489
1525
|
stateParams.pageIndex = getPageIndex(ogState, facet, context);
|
|
1490
1526
|
stateParams.searchTerm = getSearchTerm(ogState);
|
|
1491
1527
|
|
|
1492
|
-
if (context === Context.facets && ssr || // context === Context.minilist ||
|
|
1528
|
+
if (context === Context$1.facets && ssr || // context === Context.minilist ||
|
|
1493
1529
|
preload || !facetIsLoaded || filterParamsChanged(action) || defaultLang) {
|
|
1494
1530
|
willRun = true;
|
|
1495
1531
|
} else {
|
|
@@ -1538,9 +1574,10 @@ const filterParamsChanged = (action, state) => {
|
|
|
1538
1574
|
const debugExecuteSearch = (action, state) => {
|
|
1539
1575
|
const [queryParams, runSearch] = generateQueryParams(action, state);
|
|
1540
1576
|
console.log('runSearch', runSearch, 'action', action, 'filterParamsChanged', filterParamsChanged(action, state), 'getIsLoaded(state, context, facet)', getIsLoaded(state, action.context, action.facet));
|
|
1541
|
-
const stateParams = getQueryParams(action.ogState || state, action.facet, action.context)
|
|
1542
|
-
|
|
1543
|
-
|
|
1577
|
+
const stateParams = { ...getQueryParams(action.ogState || state, action.facet, action.context),
|
|
1578
|
+
pageIndex: getPageIndex(action.ogState || state, action.facet, action.context),
|
|
1579
|
+
searchTerm: getSearchTerm(action.ogState || state)
|
|
1580
|
+
};
|
|
1544
1581
|
console.log(stateParams, queryParams);
|
|
1545
1582
|
console.log('getSelectedFilters', getSelectedFilters(action.ogState || state, action.facet, action.context, 'js'), 'params', action.params);
|
|
1546
1583
|
};
|
|
@@ -1570,9 +1607,9 @@ const mapEntriesToFilterItems = entries => {
|
|
|
1570
1607
|
});
|
|
1571
1608
|
};
|
|
1572
1609
|
|
|
1573
|
-
const searchSagas = [takeEvery(CLEAR_FILTERS, clearFilters
|
|
1610
|
+
const searchSagas = [takeEvery(CLEAR_FILTERS, clearFilters), takeEvery(DO_SEARCH, doSearch), takeEvery(SET_ROUTE_FILTERS, loadFilters), takeEvery(SET_SEARCH_ENTRIES, preloadOtherFacets), takeEvery(UPDATE_CURRENT_FACET, updateCurrentFacet), takeEvery(UPDATE_CURRENT_TAB, updateCurrentTab), takeEvery(UPDATE_PAGE_INDEX, updatePageIndex), takeEvery(UPDATE_SEARCH_TERM, updateSearchTerm), takeEvery(UPDATE_SORT_ORDER, updateSortOrder), takeEvery(UPDATE_SELECTED_FILTERS, applySearchFilter)];
|
|
1574
1611
|
|
|
1575
|
-
const toJS
|
|
1612
|
+
const toJS = obj => obj && 'toJS' in obj && typeof obj.toJS === 'function' ? obj.toJS() : obj;
|
|
1576
1613
|
|
|
1577
1614
|
function* setRouteFilters(action) {
|
|
1578
1615
|
const {
|
|
@@ -1582,8 +1619,8 @@ function* setRouteFilters(action) {
|
|
|
1582
1619
|
defaultLang,
|
|
1583
1620
|
debug
|
|
1584
1621
|
} = action;
|
|
1585
|
-
const context = listingType ? Context.listings : Context.facets;
|
|
1586
|
-
const state = toJS
|
|
1622
|
+
const context = listingType ? Context$1.listings : Context$1.facets;
|
|
1623
|
+
const state = toJS(yield select());
|
|
1587
1624
|
const ssr = getIsSsr(state); // Get current facet from params or state
|
|
1588
1625
|
|
|
1589
1626
|
let currentFacet = params && params.facet || listingType; // Pick the default facet from initialState
|
|
@@ -1613,7 +1650,7 @@ function* setRouteFilters(action) {
|
|
|
1613
1650
|
});
|
|
1614
1651
|
}
|
|
1615
1652
|
function* doSearch(action) {
|
|
1616
|
-
const state = toJS
|
|
1653
|
+
const state = toJS(yield select());
|
|
1617
1654
|
|
|
1618
1655
|
if (action.config) {
|
|
1619
1656
|
// If the action contains a config object, we can add this to the
|
|
@@ -1746,9 +1783,9 @@ function* ensureSearch(action) {
|
|
|
1746
1783
|
debug
|
|
1747
1784
|
});
|
|
1748
1785
|
}
|
|
1749
|
-
} catch (error
|
|
1786
|
+
} catch (error) {
|
|
1750
1787
|
// eslint-disable-next-line import/namespace
|
|
1751
|
-
error(...['Error running search saga:', error
|
|
1788
|
+
log.error(...['Error running search saga:', error, error.stack]);
|
|
1752
1789
|
}
|
|
1753
1790
|
}
|
|
1754
1791
|
|
|
@@ -1797,9 +1834,9 @@ function* executeSearch(action) {
|
|
|
1797
1834
|
};
|
|
1798
1835
|
const nextAction = mapJson(createStateFrom, facetTemplate);
|
|
1799
1836
|
yield put(nextAction);
|
|
1800
|
-
} catch (error
|
|
1837
|
+
} catch (error) {
|
|
1801
1838
|
// eslint-disable-next-line import/namespace
|
|
1802
|
-
error(...['Error running search saga:', error
|
|
1839
|
+
log.error(...['Error running search saga:', error, error.stack]);
|
|
1803
1840
|
}
|
|
1804
1841
|
}
|
|
1805
1842
|
|
|
@@ -1813,7 +1850,7 @@ function* preloadOtherFacets(action) {
|
|
|
1813
1850
|
const state = yield select();
|
|
1814
1851
|
const currentFacet = getCurrentFacet(state);
|
|
1815
1852
|
|
|
1816
|
-
if (!preload && facet === currentFacet && context !== Context.listings) {
|
|
1853
|
+
if (!preload && facet === currentFacet && context !== Context$1.listings) {
|
|
1817
1854
|
const allFacets = getFacets(state, 'js');
|
|
1818
1855
|
const otherFacets = Object.keys(allFacets).filter(f => f !== currentFacet);
|
|
1819
1856
|
yield all(otherFacets.map((preloadFacet = '') => {
|
|
@@ -1833,7 +1870,7 @@ function* preloadOtherFacets(action) {
|
|
|
1833
1870
|
}
|
|
1834
1871
|
}
|
|
1835
1872
|
|
|
1836
|
-
function* updateCurrentTab
|
|
1873
|
+
function* updateCurrentTab(action) {
|
|
1837
1874
|
const {
|
|
1838
1875
|
id,
|
|
1839
1876
|
mappers
|
|
@@ -1852,10 +1889,10 @@ function* updateCurrentTab$1(action) {
|
|
|
1852
1889
|
|
|
1853
1890
|
|
|
1854
1891
|
if (!nextFacet) nextFacet = Object.entries(facets).filter(([, f]) => f.tabId === id)[0][0];
|
|
1855
|
-
yield put(withMappers(updateCurrentFacet(nextFacet), mappers));
|
|
1892
|
+
yield put(withMappers(updateCurrentFacet$1(nextFacet), mappers));
|
|
1856
1893
|
}
|
|
1857
1894
|
|
|
1858
|
-
function* clearFilters
|
|
1895
|
+
function* clearFilters(action) {
|
|
1859
1896
|
const {
|
|
1860
1897
|
mappers
|
|
1861
1898
|
} = action;
|
|
@@ -1863,7 +1900,7 @@ function* clearFilters$1(action) {
|
|
|
1863
1900
|
yield put(navigate(uri));
|
|
1864
1901
|
}
|
|
1865
1902
|
|
|
1866
|
-
function* updateCurrentFacet
|
|
1903
|
+
function* updateCurrentFacet(action) {
|
|
1867
1904
|
const {
|
|
1868
1905
|
facet,
|
|
1869
1906
|
mappers
|
|
@@ -1876,7 +1913,7 @@ function* updateCurrentFacet$1(action) {
|
|
|
1876
1913
|
yield put(navigate(uri));
|
|
1877
1914
|
}
|
|
1878
1915
|
|
|
1879
|
-
function* updateSearchTerm
|
|
1916
|
+
function* updateSearchTerm(action) {
|
|
1880
1917
|
const {
|
|
1881
1918
|
term,
|
|
1882
1919
|
mappers
|
|
@@ -1887,7 +1924,7 @@ function* updateSearchTerm$1(action) {
|
|
|
1887
1924
|
yield put(navigate(uri));
|
|
1888
1925
|
}
|
|
1889
1926
|
|
|
1890
|
-
function* updateSortOrder
|
|
1927
|
+
function* updateSortOrder(action) {
|
|
1891
1928
|
const {
|
|
1892
1929
|
orderBy,
|
|
1893
1930
|
facet,
|
|
@@ -1900,7 +1937,7 @@ function* updateSortOrder$1(action) {
|
|
|
1900
1937
|
yield put(navigate(uri));
|
|
1901
1938
|
}
|
|
1902
1939
|
|
|
1903
|
-
function* updatePageIndex
|
|
1940
|
+
function* updatePageIndex(action) {
|
|
1904
1941
|
const {
|
|
1905
1942
|
pageIndex,
|
|
1906
1943
|
mappers
|
|
@@ -1939,11 +1976,11 @@ function* buildUri({
|
|
|
1939
1976
|
}
|
|
1940
1977
|
|
|
1941
1978
|
const makeSelectMinilistProps = () => createSelector(state => state, (_, id) => id, (state, id) => ({
|
|
1942
|
-
facet: getFacet(state, id, Context.minilist, 'js'),
|
|
1943
|
-
filters: getFilters(state, id, Context.minilist, 'js'),
|
|
1944
|
-
isLoading: getIsLoading(state, Context.minilist, id),
|
|
1945
|
-
pagingInfo: getPaging(state, id, Context.minilist, 'js'),
|
|
1946
|
-
results: getResults(state, id, Context.minilist, 'js'),
|
|
1979
|
+
facet: getFacet(state, id, Context$1.minilist, 'js'),
|
|
1980
|
+
filters: getFilters(state, id, Context$1.minilist, 'js'),
|
|
1981
|
+
isLoading: getIsLoading(state, Context$1.minilist, id),
|
|
1982
|
+
pagingInfo: getPaging(state, id, Context$1.minilist, 'js'),
|
|
1983
|
+
results: getResults(state, id, Context$1.minilist, 'js'),
|
|
1947
1984
|
searchTerm: getSearchTerm(state)
|
|
1948
1985
|
}));
|
|
1949
1986
|
|
|
@@ -1981,7 +2018,7 @@ const useMinilist = ({
|
|
|
1981
2018
|
if (id && (mapper || mappers && mappers.results)) {
|
|
1982
2019
|
dispatch(triggerSearch({
|
|
1983
2020
|
config,
|
|
1984
|
-
context: Context.minilist,
|
|
2021
|
+
context: Context$1.minilist,
|
|
1985
2022
|
defaultLang,
|
|
1986
2023
|
facet: id,
|
|
1987
2024
|
mapper,
|
|
@@ -2196,9 +2233,9 @@ var reducers = (config => {
|
|
|
2196
2233
|
// Add facets from SearchConfig to initialState
|
|
2197
2234
|
const initState = { ...initialState,
|
|
2198
2235
|
tabs: config.tabs,
|
|
2199
|
-
facets: generateSearchFacets(Context.facets, config),
|
|
2200
|
-
listings: generateSearchFacets(Context.listings, config),
|
|
2201
|
-
minilist: generateSearchFacets(Context.minilist, config)
|
|
2236
|
+
facets: generateSearchFacets(Context$1.facets, config),
|
|
2237
|
+
listings: generateSearchFacets(Context$1.listings, config),
|
|
2238
|
+
minilist: generateSearchFacets(Context$1.minilist, config)
|
|
2202
2239
|
};
|
|
2203
2240
|
return produce((state = initState, action) => {
|
|
2204
2241
|
const context = state.context;
|
|
@@ -2208,7 +2245,7 @@ var reducers = (config => {
|
|
|
2208
2245
|
case APPLY_CONFIG:
|
|
2209
2246
|
{
|
|
2210
2247
|
state = addConfigToState(state, action);
|
|
2211
|
-
return;
|
|
2248
|
+
return state;
|
|
2212
2249
|
}
|
|
2213
2250
|
|
|
2214
2251
|
case CLEAR_FILTERS:
|
|
@@ -2325,7 +2362,7 @@ var reducers = (config => {
|
|
|
2325
2362
|
}));
|
|
2326
2363
|
state.context = context;
|
|
2327
2364
|
state[context] = nextFacets;
|
|
2328
|
-
state[action.context === Context.facets ? 'currentFacet' : 'currentListing'] = facet;
|
|
2365
|
+
state[action.context === Context$1.facets ? 'currentFacet' : 'currentListing'] = facet;
|
|
2329
2366
|
state.term = term;
|
|
2330
2367
|
state.tabs[tabId].currentFacet = facet;
|
|
2331
2368
|
state[context][facet].pagingInfo.pageIndex = Number(pageIndex) - 1 || (state[context][facet].queryParams.loadMorePaging ? state[context][facet].pagingInfo.pageIndex || 0 : 0);
|
|
@@ -2358,9 +2395,9 @@ var reducers = (config => {
|
|
|
2358
2395
|
isCurrentFacet: true
|
|
2359
2396
|
}, state);
|
|
2360
2397
|
const term = action === null || action === void 0 ? void 0 : (_action$params = action.params) === null || _action$params === void 0 ? void 0 : _action$params.term;
|
|
2361
|
-
const useSearchTerm = state[action.context || Context.minilist][action.facet].queryParams.useSearchTerm || false;
|
|
2362
|
-
state[action.context || Context.minilist][action.facet].filters = filters;
|
|
2363
|
-
state[action.context || Context.minilist][action.facet].queryParams.excludeIds = action.excludeIds;
|
|
2398
|
+
const useSearchTerm = state[action.context || Context$1.minilist][action.facet].queryParams.useSearchTerm || false;
|
|
2399
|
+
state[action.context || Context$1.minilist][action.facet].filters = filters;
|
|
2400
|
+
state[action.context || Context$1.minilist][action.facet].queryParams.excludeIds = action.excludeIds;
|
|
2364
2401
|
state.term = useSearchTerm ? term : state.term;
|
|
2365
2402
|
state.config.ssr = typeof window === 'undefined';
|
|
2366
2403
|
return;
|
|
@@ -2392,13 +2429,22 @@ var reducers = (config => {
|
|
|
2392
2429
|
{
|
|
2393
2430
|
const {
|
|
2394
2431
|
filter,
|
|
2395
|
-
key
|
|
2432
|
+
key,
|
|
2433
|
+
isUnknownItem
|
|
2396
2434
|
} = action;
|
|
2397
2435
|
const isSingleSelect = state[context][current].filters[filter].isSingleSelect || false;
|
|
2398
2436
|
const isGrouped = state[context][current].filters[filter].isGrouped || false;
|
|
2399
2437
|
const currentItems = state[context][current].filters[filter].items;
|
|
2400
2438
|
if (isGrouped) state[context] = resetFacets(state, context);
|
|
2401
2439
|
state[context][current] = resetFacet(state[context][current]);
|
|
2440
|
+
|
|
2441
|
+
if (isUnknownItem && (currentItems === null || currentItems === void 0 ? void 0 : currentItems.findIndex(item => (item === null || item === void 0 ? void 0 : item.key) === key)) === -1) {
|
|
2442
|
+
currentItems === null || currentItems === void 0 ? void 0 : currentItems.push({
|
|
2443
|
+
key,
|
|
2444
|
+
isSelected: false
|
|
2445
|
+
});
|
|
2446
|
+
}
|
|
2447
|
+
|
|
2402
2448
|
state[context][current].filters[filter].items = currentItems === null || currentItems === void 0 ? void 0 : currentItems.map(item => {
|
|
2403
2449
|
if (item.key === key) {
|
|
2404
2450
|
return { ...item,
|
|
@@ -2433,11 +2479,11 @@ var reducers = (config => {
|
|
|
2433
2479
|
});
|
|
2434
2480
|
|
|
2435
2481
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
2436
|
-
const Context
|
|
2482
|
+
const Context = {
|
|
2437
2483
|
facets: 'facets',
|
|
2438
2484
|
listings: 'listings',
|
|
2439
2485
|
minilist: 'minilist'
|
|
2440
2486
|
};
|
|
2441
2487
|
|
|
2442
|
-
export { Context
|
|
2488
|
+
export { Context, actions, doSearch, queries, reducers as reducer, searchSagas as sagas, schema, selectors, setRouteFilters, types, useMinilist, withListing, withSearch };
|
|
2443
2489
|
//# sourceMappingURL=search.js.map
|