@blaze-cms/react-page-builder 0.138.0 → 0.139.0-alpha.1
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/CHANGELOG.md +22 -0
- package/lib/components/Card/Card.js +14 -3
- package/lib/components/Card/Card.js.map +1 -1
- package/lib/components/Card/CardsContainer.js +6 -1
- package/lib/components/Card/CardsContainer.js.map +1 -1
- package/lib/components/Card/CardsRender.js +5 -2
- package/lib/components/Card/CardsRender.js.map +1 -1
- package/lib/components/Card/helpers/filters-setup.js +3 -2
- package/lib/components/Card/helpers/filters-setup.js.map +1 -1
- package/lib/helpers/build-checkbox-filters.js +38 -0
- package/lib/helpers/build-checkbox-filters.js.map +1 -0
- package/lib/helpers/build-query-fields.js +2 -2
- package/lib/helpers/build-query-fields.js.map +1 -1
- package/lib/helpers/build-raw-query-base.js +4 -12
- package/lib/helpers/build-raw-query-base.js.map +1 -1
- package/lib/helpers/build-set-filters.js +3 -9
- package/lib/helpers/build-set-filters.js.map +1 -1
- package/lib/helpers/get-checkbox-filters.js +15 -0
- package/lib/helpers/get-checkbox-filters.js.map +1 -0
- package/lib-es/components/Card/Card.js +14 -3
- package/lib-es/components/Card/Card.js.map +1 -1
- package/lib-es/components/Card/CardsContainer.js +7 -2
- package/lib-es/components/Card/CardsContainer.js.map +1 -1
- package/lib-es/components/Card/CardsRender.js +8 -3
- package/lib-es/components/Card/CardsRender.js.map +1 -1
- package/lib-es/components/Card/helpers/filters-setup.js +3 -2
- package/lib-es/components/Card/helpers/filters-setup.js.map +1 -1
- package/lib-es/helpers/build-checkbox-filters.js +28 -0
- package/lib-es/helpers/build-checkbox-filters.js.map +1 -0
- package/lib-es/helpers/build-query-fields.js +2 -2
- package/lib-es/helpers/build-query-fields.js.map +1 -1
- package/lib-es/helpers/build-raw-query-base.js +1 -8
- package/lib-es/helpers/build-raw-query-base.js.map +1 -1
- package/lib-es/helpers/build-set-filters.js +3 -9
- package/lib-es/helpers/build-set-filters.js.map +1 -1
- package/lib-es/helpers/get-checkbox-filters.js +7 -0
- package/lib-es/helpers/get-checkbox-filters.js.map +1 -0
- package/package.json +2 -2
- package/src/components/Card/Card.js +12 -1
- package/src/components/Card/CardsContainer.js +5 -0
- package/src/components/Card/CardsRender.js +6 -2
- package/src/components/Card/helpers/filters-setup.js +3 -2
- package/src/helpers/build-checkbox-filters.js +23 -0
- package/src/helpers/build-query-fields.js +2 -2
- package/src/helpers/build-raw-query-base.js +1 -6
- package/src/helpers/build-set-filters.js +3 -11
- package/src/helpers/get-checkbox-filters.js +7 -0
- package/tests/unit/src/components/Card/Card.test.js +9 -0
- package/tests/unit/src/components/Card/mockData.js +60 -1
- package/tests/unit/src/helpers/build-checkbox-filters.test.js +27 -0
- package/tests/unit/src/helpers/get-checkbox-filters.test.js +33 -0
|
@@ -3,14 +3,7 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
|
|
|
3
3
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
4
|
import getItemsToDisplayIds from './get-items-to-display-ids';
|
|
5
5
|
import { OR, OR_OPERATOR, KEYWORD } from '../constants';
|
|
6
|
-
|
|
7
|
-
acc.push({
|
|
8
|
-
match: {
|
|
9
|
-
[checkboxFilter]: true
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
return acc;
|
|
13
|
-
}, []);
|
|
6
|
+
import buildCheckboxFilters from './build-checkbox-filters';
|
|
14
7
|
const buildFilterValues = (listFilterValues, relations, stringProps) => {
|
|
15
8
|
const listFilterValuesKeys = Object.keys(listFilterValues);
|
|
16
9
|
return listFilterValuesKeys.map(key => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-raw-query-base.js","names":["getItemsToDisplayIds","OR","OR_OPERATOR","KEYWORD","buildCheckboxFilters","
|
|
1
|
+
{"version":3,"file":"build-raw-query-base.js","names":["getItemsToDisplayIds","OR","OR_OPERATOR","KEYWORD","buildCheckboxFilters","buildFilterValues","listFilterValues","relations","stringProps","listFilterValuesKeys","Object","keys","map","key","values","el","updatedKey","isRelation","includes","relationName","relationProp","split","relation","filter","localField","entityIdentifier","fieldName","match","bool","should","buildItemsToDisplayValues","itemsToDisplay","length","itemToDisplayIds","ids","buildShouldValues","docTypes","Array","isArray","docType","buildRawQueryBase","id","filterValues","checkboxFilters","filterOperator","addListFiltersToQuery","listFilterFinalValues","checkboxFiltersValue","itemsToDisplayValues","isOperatorOr","queryFilters","baseBoolObject","minimum_should_match","must","push","mustNot","undefined","queryFilter","_objectSpread","must_not"],"sources":["../../src/helpers/build-raw-query-base.js"],"sourcesContent":["import getItemsToDisplayIds from './get-items-to-display-ids';\nimport { OR, OR_OPERATOR, KEYWORD } from '../constants';\nimport buildCheckboxFilters from './build-checkbox-filters';\n\nconst buildFilterValues = (listFilterValues, relations, stringProps) => {\n const listFilterValuesKeys = Object.keys(listFilterValues);\n\n return listFilterValuesKeys.map(key => {\n const values = listFilterValues[key].map(el => {\n let updatedKey = key;\n\n const isRelation = key.includes('.');\n\n if (isRelation) {\n const [relationName, relationProp] = key.split('.');\n const [relation] = relations.filter(({ localField }) => localField === relationName);\n const { entityIdentifier = '' } = relation || {};\n if (entityIdentifier && entityIdentifier !== relationName)\n updatedKey = `${entityIdentifier}.${relationProp}`;\n }\n const fieldName = stringProps.includes(updatedKey) ? `${key}.${KEYWORD}` : key;\n return { match: { [fieldName]: el } };\n });\n return { bool: { should: values } };\n });\n};\n\nconst buildItemsToDisplayValues = itemsToDisplay => {\n if (!itemsToDisplay || !itemsToDisplay.length) return [];\n const itemToDisplayIds = getItemsToDisplayIds(itemsToDisplay);\n return [{ ids: { values: itemToDisplayIds } }];\n};\n\nconst buildShouldValues = docTypes => {\n if (Array.isArray(docTypes)) {\n return docTypes.map(docType => ({\n match: {\n docType\n }\n }));\n }\n return [\n {\n match: {\n docType: docTypes\n }\n }\n ];\n};\n\nconst buildRawQueryBase = ({\n docType,\n id,\n filterValues: { checkboxFilters = [], listFilterValues = {} } = {},\n filterOperator,\n relations,\n stringProps,\n itemsToDisplay,\n addListFiltersToQuery = false\n}) => {\n const listFilterFinalValues = buildFilterValues(listFilterValues, relations, stringProps);\n const checkboxFiltersValue = buildCheckboxFilters(checkboxFilters);\n const itemsToDisplayValues = buildItemsToDisplayValues(itemsToDisplay);\n const isOperatorOr = filterOperator === OR;\n\n const queryFilters = [];\n const baseBoolObject = {\n should: buildShouldValues(docType),\n minimum_should_match: 1,\n must: [...itemsToDisplayValues, ...checkboxFiltersValue]\n };\n\n if (isOperatorOr) {\n if (addListFiltersToQuery) {\n queryFilters.push(...listFilterFinalValues);\n } else {\n baseBoolObject.must.push({ bool: { [OR_OPERATOR]: [...listFilterFinalValues] } });\n }\n } else {\n baseBoolObject.must.push(...listFilterFinalValues);\n }\n\n const mustNot = id ? [{ ids: { values: [id] } }] : undefined;\n\n const queryFilter = queryFilters.length\n ? { [OR_OPERATOR]: queryFilters, minimum_should_match: 1 }\n : {};\n return {\n ...queryFilter,\n filter: {\n bool: baseBoolObject\n },\n must_not: mustNot\n };\n};\n\nexport default buildRawQueryBase;\n"],"mappings":";;;AAAA,OAAOA,oBAAoB,MAAM,4BAA4B;AAC7D,SAASC,EAAE,EAAEC,WAAW,EAAEC,OAAO,QAAQ,cAAc;AACvD,OAAOC,oBAAoB,MAAM,0BAA0B;AAE3D,MAAMC,iBAAiB,GAAGA,CAACC,gBAAgB,EAAEC,SAAS,EAAEC,WAAW,KAAK;EACtE,MAAMC,oBAAoB,GAAGC,MAAM,CAACC,IAAI,CAACL,gBAAgB,CAAC;EAE1D,OAAOG,oBAAoB,C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MAAE,CAAC,CAAC;IACnF;EACF,CAAC,MAAM;IACLK,cAAc,CAACE,IAAI,CAACC,IAAI,CAAC,GAAGR,qBAAqB,CAAC;EACpD;EAEA,MAAMS,OAAO,GAAGd,EAAE,GAAG,CAAC;IAAEP,GAAG,EAAE;MAAEpB,MAAM,EAAE,CAAC2B,EAAE;IAAE;EAAE,CAAC,CAAC,GAAGe,SAAS;EAE5D,MAAMC,WAAW,GAAGP,YAAY,CAAClB,MAAM,GACnC;IAAE,CAAC9B,WAAW,GAAGgD,YAAY;IAAEE,oBAAoB,EAAE;EAAE,CAAC,GACxD,CAAC,CAAC;EACN,OAAAM,aAAA,CAAAA,aAAA,KACKD,WAAW;IACdlC,MAAM,EAAE;MACNK,IAAI,EAAEuB;IACR,CAAC;IACDQ,QAAQ,EAAEJ;EAAO;AAErB,CAAC;AAED,eAAef,iBAAiB"}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { FEATURED, SPONSORED } from '../constants';
|
|
2
|
-
|
|
3
|
-
checkboxFilters.push(name);
|
|
4
|
-
};
|
|
2
|
+
import getCheckboxFilters from './get-checkbox-filters';
|
|
5
3
|
const getFilterValues = filterBy => filterBy.reduce((acc, filter) => {
|
|
6
4
|
const [fieldName, ...values] = filter.split('/');
|
|
7
5
|
const value = values.join('/');
|
|
@@ -17,12 +15,8 @@ const buildSetFilters = ({
|
|
|
17
15
|
filterBySponsored
|
|
18
16
|
}) => {
|
|
19
17
|
const checkboxFilters = [];
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
if (filterBySponsored) {
|
|
24
|
-
getCheckboxFilters(checkboxFilters, SPONSORED);
|
|
25
|
-
}
|
|
18
|
+
getCheckboxFilters(checkboxFilters, FEATURED, filterByFeatured);
|
|
19
|
+
getCheckboxFilters(checkboxFilters, SPONSORED, filterBySponsored);
|
|
26
20
|
const shouldApplyFilterValues = filterBy.length && filterByProperty.length;
|
|
27
21
|
if (!shouldApplyFilterValues) return {
|
|
28
22
|
checkboxFilters,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-set-filters.js","names":["FEATURED","SPONSORED","getCheckboxFilters","
|
|
1
|
+
{"version":3,"file":"build-set-filters.js","names":["FEATURED","SPONSORED","getCheckboxFilters","getFilterValues","filterBy","reduce","acc","filter","fieldName","values","split","value","join","previousValue","finalValue","buildSetFilters","filterByProperty","filterByFeatured","filterBySponsored","checkboxFilters","shouldApplyFilterValues","length","listFilterValues"],"sources":["../../src/helpers/build-set-filters.js"],"sourcesContent":["import { FEATURED, SPONSORED } from '../constants';\nimport getCheckboxFilters from './get-checkbox-filters';\n\nconst getFilterValues = filterBy =>\n filterBy.reduce((acc, filter) => {\n const [fieldName, ...values] = filter.split('/');\n const value = values.join('/');\n const previousValue = acc[fieldName];\n const finalValue = previousValue ? [...previousValue, value] : [value];\n\n acc[fieldName] = finalValue;\n return acc;\n }, {});\n\nconst buildSetFilters = ({\n filterBy = [],\n filterByProperty = [],\n filterByFeatured,\n filterBySponsored\n}) => {\n const checkboxFilters = [];\n getCheckboxFilters(checkboxFilters, FEATURED, filterByFeatured);\n getCheckboxFilters(checkboxFilters, SPONSORED, filterBySponsored);\n\n const shouldApplyFilterValues = filterBy.length && filterByProperty.length;\n if (!shouldApplyFilterValues) return { checkboxFilters, listFilterValues: {} };\n\n const listFilterValues = getFilterValues(filterBy);\n return { checkboxFilters, listFilterValues };\n};\n\nexport default buildSetFilters;\n"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,SAAS,QAAQ,cAAc;AAClD,OAAOC,kBAAkB,MAAM,wBAAwB;AAEvD,MAAMC,eAAe,GAAGC,QAAQ,IAC9BA,QAAQ,CAACC,MAAM,CAAC,CAACC,GAAG,EAAEC,MAAM,KAAK;EAC/B,MAAM,CAACC,SAAS,EAAE,GAAGC,MAAM,CAAC,GAAGF,MAAM,CAACG,KAAK,CAAC,GAAG,CAAC;EAChD,MAAMC,KAAK,GAAGF,MAAM,CAACG,IAAI,CAAC,GAAG,CAAC;EAC9B,MAAMC,aAAa,GAAGP,GAAG,CAACE,SAAS,CAAC;EACpC,MAAMM,UAAU,GAAGD,aAAa,GAAG,CAAC,GAAGA,aAAa,EAAEF,KAAK,CAAC,GAAG,CAACA,KAAK,CAAC;EAEtEL,GAAG,CAACE,SAAS,CAAC,GAAGM,UAAU;EAC3B,OAAOR,GAAG;AACZ,CAAC,EAAE,CAAC,CAAC,CAAC;AAER,MAAMS,eAAe,GAAGA,CAAC;EACvBX,QAAQ,GAAG,EAAE;EACbY,gBAAgB,GAAG,EAAE;EACrBC,gBAAgB;EAChBC;AACF,CAAC,KAAK;EACJ,MAAMC,eAAe,GAAG,EAAE;EAC1BjB,kBAAkB,CAACiB,eAAe,EAAEnB,QAAQ,EAAEiB,gBAAgB,CAAC;EAC/Df,kBAAkB,CAACiB,eAAe,EAAElB,SAAS,EAAEiB,iBAAiB,CAAC;EAEjE,MAAME,uBAAuB,GAAGhB,QAAQ,CAACiB,MAAM,IAAIL,gBAAgB,CAACK,MAAM;EAC1E,IAAI,CAACD,uBAAuB,EAAE,OAAO;IAAED,eAAe;IAAEG,gBAAgB,EAAE,CAAC;EAAE,CAAC;EAE9E,MAAMA,gBAAgB,GAAGnB,eAAe,CAACC,QAAQ,CAAC;EAClD,OAAO;IAAEe,eAAe;IAAEG;EAAiB,CAAC;AAC9C,CAAC;AAED,eAAeP,eAAe"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
const getCheckboxFilters = (checkboxFilters, name, value) => {
|
|
2
|
+
if (typeof value === 'string') {
|
|
3
|
+
if (value !== 'off') checkboxFilters.push([name, value]);
|
|
4
|
+
} else if (value) checkboxFilters.push(name);
|
|
5
|
+
};
|
|
6
|
+
export default getCheckboxFilters;
|
|
7
|
+
//# sourceMappingURL=get-checkbox-filters.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-checkbox-filters.js","names":["getCheckboxFilters","checkboxFilters","name","value","push"],"sources":["../../src/helpers/get-checkbox-filters.js"],"sourcesContent":["const getCheckboxFilters = (checkboxFilters, name, value) => {\n if (typeof value === 'string') {\n if (value !== 'off') checkboxFilters.push([name, value]);\n } else if (value) checkboxFilters.push(name);\n};\n\nexport default getCheckboxFilters;\n"],"mappings":"AAAA,MAAMA,kBAAkB,GAAGA,CAACC,eAAe,EAAEC,IAAI,EAAEC,KAAK,KAAK;EAC3D,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IAC7B,IAAIA,KAAK,KAAK,KAAK,EAAEF,eAAe,CAACG,IAAI,CAAC,CAACF,IAAI,EAAEC,KAAK,CAAC,CAAC;EAC1D,CAAC,MAAM,IAAIA,KAAK,EAAEF,eAAe,CAACG,IAAI,CAACF,IAAI,CAAC;AAC9C,CAAC;AAED,eAAeF,kBAAkB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blaze-cms/react-page-builder",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.139.0-alpha.1",
|
|
4
4
|
"description": "Blaze react page builder",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "lib-es/index.js",
|
|
@@ -89,5 +89,5 @@
|
|
|
89
89
|
"lib/*",
|
|
90
90
|
"lib-es/*"
|
|
91
91
|
],
|
|
92
|
-
"gitHead": "
|
|
92
|
+
"gitHead": "1cee8a2d2777b141287f3f59844156f56fa97f80"
|
|
93
93
|
}
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
import LazyImage from '../LazyImage';
|
|
13
13
|
import { getPublishedListingUrl, useDynamicSizeKey } from './helpers';
|
|
14
14
|
import { CARD_STRING, CARD_CHILDREN_WITH_LINKS } from './constants';
|
|
15
|
+
import BuildPBComponents from '../../hooks/helpers/buildPBComponents';
|
|
15
16
|
|
|
16
17
|
const Card = ({
|
|
17
18
|
id,
|
|
@@ -40,6 +41,8 @@ const Card = ({
|
|
|
40
41
|
titleOverlayModifier,
|
|
41
42
|
overlayModifier,
|
|
42
43
|
gridModifier,
|
|
44
|
+
parent,
|
|
45
|
+
pageBuilderComponents,
|
|
43
46
|
__typename: dataEntity,
|
|
44
47
|
...otherProps
|
|
45
48
|
}) => {
|
|
@@ -140,6 +143,11 @@ const Card = ({
|
|
|
140
143
|
</BlazeLink>
|
|
141
144
|
</div>
|
|
142
145
|
)}
|
|
146
|
+
{!!pageBuilderComponents.length && (
|
|
147
|
+
<div className="card__item card__item--full" data-testid="full-card">
|
|
148
|
+
{BuildPBComponents(pageBuilderComponents, { parent })}
|
|
149
|
+
</div>
|
|
150
|
+
)}
|
|
143
151
|
{!!parsedPropsToDisplay.length && (
|
|
144
152
|
<div className={getModifiers('card__details', modifiers)}>
|
|
145
153
|
{parsedPropsToDisplay.map((prop, i) => {
|
|
@@ -173,6 +181,7 @@ const Card = ({
|
|
|
173
181
|
};
|
|
174
182
|
|
|
175
183
|
Card.propTypes = {
|
|
184
|
+
parent: PropTypes.object.isRequired,
|
|
176
185
|
id: PropTypes.string.isRequired,
|
|
177
186
|
image: PropTypes.shape({
|
|
178
187
|
url: PropTypes.string,
|
|
@@ -209,11 +218,13 @@ Card.propTypes = {
|
|
|
209
218
|
cardChildren: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]),
|
|
210
219
|
gtmChildren: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]),
|
|
211
220
|
gridModifier: PropTypes.string,
|
|
212
|
-
priority: PropTypes.bool
|
|
221
|
+
priority: PropTypes.bool,
|
|
222
|
+
pageBuilderComponents: PropTypes.array
|
|
213
223
|
};
|
|
214
224
|
|
|
215
225
|
Card.defaultProps = {
|
|
216
226
|
entityProps: {},
|
|
227
|
+
pageBuilderComponents: [],
|
|
217
228
|
image: {
|
|
218
229
|
url: null,
|
|
219
230
|
data: {}
|
|
@@ -36,6 +36,7 @@ const CardContainer = ({
|
|
|
36
36
|
autoScrollTimer,
|
|
37
37
|
overlayModifier,
|
|
38
38
|
titleOverlayModifier,
|
|
39
|
+
parent,
|
|
39
40
|
...cardProps
|
|
40
41
|
}) => {
|
|
41
42
|
const { itemId } = useContext(MainContext);
|
|
@@ -69,6 +70,7 @@ const CardContainer = ({
|
|
|
69
70
|
if (hasNewBannerSettings && shouldRenderBanner) bannerIndex += 1;
|
|
70
71
|
if (!hasNewBannerSettings && baseAdunit) bannerIndex += 1;
|
|
71
72
|
const parsedCardProps = {
|
|
73
|
+
parent,
|
|
72
74
|
key: id,
|
|
73
75
|
id,
|
|
74
76
|
enableCarousel,
|
|
@@ -130,6 +132,8 @@ const CardContainer = ({
|
|
|
130
132
|
};
|
|
131
133
|
|
|
132
134
|
CardContainer.propTypes = {
|
|
135
|
+
pageBuilderComponents: PropTypes.array,
|
|
136
|
+
parent: PropTypes.object.isRequired,
|
|
133
137
|
cardData: PropTypes.array.isRequired,
|
|
134
138
|
graphqlEntityMap: PropTypes.object.isRequired,
|
|
135
139
|
name: PropTypes.string,
|
|
@@ -159,6 +163,7 @@ CardContainer.propTypes = {
|
|
|
159
163
|
CardContainer.defaultProps = {
|
|
160
164
|
gtmChildren: [],
|
|
161
165
|
cardChildren: [],
|
|
166
|
+
pageBuilderComponents: [],
|
|
162
167
|
name: '',
|
|
163
168
|
gridModifier: '',
|
|
164
169
|
propsToDisplay: [],
|
|
@@ -4,7 +4,7 @@ import dynamic from 'next/dynamic';
|
|
|
4
4
|
import PropTypes from 'prop-types';
|
|
5
5
|
import { MainContext } from '@blaze-cms/nextjs-components';
|
|
6
6
|
import { generateSingleItemQuery } from '../../application/query';
|
|
7
|
-
import { SEARCH_PUBLISHED_CONTENT, AND } from '../../constants';
|
|
7
|
+
import { SEARCH_PUBLISHED_CONTENT, AND, FULL } from '../../constants';
|
|
8
8
|
import { useGetEntitySchemasAsObj, useGetImages } from '../../hooks';
|
|
9
9
|
import {
|
|
10
10
|
getUpdatedFilterBy,
|
|
@@ -78,6 +78,8 @@ const CardsRender = ({
|
|
|
78
78
|
const docTypes = entitiesTypes.map(({ docType: type }) => type);
|
|
79
79
|
const entityTypes = entitiesTypes.map(({ entityType: eType }) => eType);
|
|
80
80
|
|
|
81
|
+
const { style } = otherProps;
|
|
82
|
+
|
|
81
83
|
const {
|
|
82
84
|
getAction,
|
|
83
85
|
queryProps,
|
|
@@ -94,7 +96,8 @@ const CardsRender = ({
|
|
|
94
96
|
currentSchema: parentSchema,
|
|
95
97
|
filterEntitySchema,
|
|
96
98
|
isPreview,
|
|
97
|
-
itemEntityUpdated: unpublishedParentEntityName
|
|
99
|
+
itemEntityUpdated: unpublishedParentEntityName,
|
|
100
|
+
isFull: style === FULL
|
|
98
101
|
});
|
|
99
102
|
|
|
100
103
|
const {
|
|
@@ -200,6 +203,7 @@ const CardsRender = ({
|
|
|
200
203
|
gtmChildren={gtmChildren}
|
|
201
204
|
cardChildren={regularChildren}
|
|
202
205
|
graphqlEntityMap={graphqlEntityMap}
|
|
206
|
+
parent={otherProps.parent}
|
|
203
207
|
{...variableProps}
|
|
204
208
|
/>
|
|
205
209
|
</>
|
|
@@ -10,9 +10,10 @@ const filtersSetup = ({
|
|
|
10
10
|
currentSchema,
|
|
11
11
|
filterEntitySchema,
|
|
12
12
|
isPreview,
|
|
13
|
-
itemEntityUpdated
|
|
13
|
+
itemEntityUpdated,
|
|
14
|
+
isFull
|
|
14
15
|
}) => {
|
|
15
|
-
const fields = buildQueryFields(entityFields, entityTypes);
|
|
16
|
+
const fields = buildQueryFields(entityFields, entityTypes, isFull);
|
|
16
17
|
const action = getSearchPublishedContent(fields);
|
|
17
18
|
const inheritedFilters = getInheritedFilters(filterBy, filterByProperty);
|
|
18
19
|
const entitySameAsCurrentItemEntity = entities.includes(itemEntityUpdated);
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const getFilterValue = value => {
|
|
2
|
+
// To be updated with future filter options
|
|
3
|
+
switch (value) {
|
|
4
|
+
case 'not':
|
|
5
|
+
return false;
|
|
6
|
+
case 'on':
|
|
7
|
+
return true;
|
|
8
|
+
default:
|
|
9
|
+
return true;
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const buildCheckboxFilters = checkboxFilters =>
|
|
14
|
+
checkboxFilters.reduce((acc, checkboxFilter) => {
|
|
15
|
+
if (typeof checkboxFilter === 'string') acc.push({ match: { [checkboxFilter]: true } });
|
|
16
|
+
else {
|
|
17
|
+
const filterValue = getFilterValue(checkboxFilter[1]);
|
|
18
|
+
acc.push({ match: { [checkboxFilter[0]]: filterValue } });
|
|
19
|
+
}
|
|
20
|
+
return acc;
|
|
21
|
+
}, []);
|
|
22
|
+
|
|
23
|
+
export default buildCheckboxFilters;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const buildQueryFields = (sanitizedEntityFields, entityTypes,
|
|
1
|
+
const buildQueryFields = (sanitizedEntityFields, entityTypes, isFull) =>
|
|
2
2
|
`results {
|
|
3
3
|
${entityTypes.map(
|
|
4
4
|
entityType => `
|
|
@@ -6,7 +6,7 @@ const buildQueryFields = (sanitizedEntityFields, entityTypes, isFullList) =>
|
|
|
6
6
|
${sanitizedEntityFields}
|
|
7
7
|
__typename
|
|
8
8
|
id
|
|
9
|
-
${
|
|
9
|
+
${isFull ? 'pageBuilderComponents' : ''}
|
|
10
10
|
}`
|
|
11
11
|
)}
|
|
12
12
|
},
|
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
import getItemsToDisplayIds from './get-items-to-display-ids';
|
|
2
2
|
import { OR, OR_OPERATOR, KEYWORD } from '../constants';
|
|
3
|
-
|
|
4
|
-
const buildCheckboxFilters = checkboxFilters =>
|
|
5
|
-
checkboxFilters.reduce((acc, checkboxFilter) => {
|
|
6
|
-
acc.push({ match: { [checkboxFilter]: true } });
|
|
7
|
-
return acc;
|
|
8
|
-
}, []);
|
|
3
|
+
import buildCheckboxFilters from './build-checkbox-filters';
|
|
9
4
|
|
|
10
5
|
const buildFilterValues = (listFilterValues, relations, stringProps) => {
|
|
11
6
|
const listFilterValuesKeys = Object.keys(listFilterValues);
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import { FEATURED, SPONSORED } from '../constants';
|
|
2
|
-
|
|
3
|
-
const getCheckboxFilters = (checkboxFilters, name) => {
|
|
4
|
-
checkboxFilters.push(name);
|
|
5
|
-
};
|
|
2
|
+
import getCheckboxFilters from './get-checkbox-filters';
|
|
6
3
|
|
|
7
4
|
const getFilterValues = filterBy =>
|
|
8
5
|
filterBy.reduce((acc, filter) => {
|
|
@@ -22,13 +19,8 @@ const buildSetFilters = ({
|
|
|
22
19
|
filterBySponsored
|
|
23
20
|
}) => {
|
|
24
21
|
const checkboxFilters = [];
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
getCheckboxFilters(checkboxFilters, FEATURED);
|
|
28
|
-
}
|
|
29
|
-
if (filterBySponsored) {
|
|
30
|
-
getCheckboxFilters(checkboxFilters, SPONSORED);
|
|
31
|
-
}
|
|
22
|
+
getCheckboxFilters(checkboxFilters, FEATURED, filterByFeatured);
|
|
23
|
+
getCheckboxFilters(checkboxFilters, SPONSORED, filterBySponsored);
|
|
32
24
|
|
|
33
25
|
const shouldApplyFilterValues = filterBy.length && filterByProperty.length;
|
|
34
26
|
if (!shouldApplyFilterValues) return { checkboxFilters, listFilterValues: {} };
|
|
@@ -5,6 +5,7 @@ import React from 'react';
|
|
|
5
5
|
import { render as _render, act, waitFor } from '@testing-library/react';
|
|
6
6
|
import '@testing-library/jest-dom/extend-expect';
|
|
7
7
|
import Card from '../../../../../src/components/Card/Card';
|
|
8
|
+
import { pageBuilderComponentsMocks } from './mockData';
|
|
8
9
|
|
|
9
10
|
const render = async (Component, props) => {
|
|
10
11
|
let renderResults;
|
|
@@ -202,4 +203,12 @@ describe('Card component', () => {
|
|
|
202
203
|
expect(container.firstChild).toHaveClass('card--sponsored');
|
|
203
204
|
expect(container.firstChild).toHaveClass('card--featured');
|
|
204
205
|
});
|
|
206
|
+
|
|
207
|
+
it('should render pageBuilderComponents if exist', async () => {
|
|
208
|
+
const { getByTestId } = await render(Card, {
|
|
209
|
+
...componentProps,
|
|
210
|
+
pageBuilderComponents: pageBuilderComponentsMocks
|
|
211
|
+
});
|
|
212
|
+
expect(getByTestId('full-card')).toBeInTheDocument();
|
|
213
|
+
});
|
|
205
214
|
});
|
|
@@ -134,4 +134,63 @@ const mockWIthMultiEntities = [
|
|
|
134
134
|
}
|
|
135
135
|
];
|
|
136
136
|
|
|
137
|
-
|
|
137
|
+
const pageBuilderComponentsMocks = [
|
|
138
|
+
{
|
|
139
|
+
type: 'button',
|
|
140
|
+
settings: {
|
|
141
|
+
canShowInEditorView: true,
|
|
142
|
+
showInEditorView: true,
|
|
143
|
+
name: 'button-1',
|
|
144
|
+
modifier: null,
|
|
145
|
+
elementTitle: null,
|
|
146
|
+
text: 'button - doc',
|
|
147
|
+
afterClickText: null,
|
|
148
|
+
childSeoVisibility: false,
|
|
149
|
+
buttonType: 'default',
|
|
150
|
+
clickAction: null,
|
|
151
|
+
style: 'button',
|
|
152
|
+
size: 'default',
|
|
153
|
+
icon: null,
|
|
154
|
+
url: null,
|
|
155
|
+
alignment: 'center',
|
|
156
|
+
access: {
|
|
157
|
+
display: 'always'
|
|
158
|
+
},
|
|
159
|
+
gtmClassName: null
|
|
160
|
+
},
|
|
161
|
+
id: '8b1643c0-99d5-11ee-b4dd-039c35219d25',
|
|
162
|
+
items: [],
|
|
163
|
+
name: 'button-1'
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
type: 'image',
|
|
167
|
+
settings: {
|
|
168
|
+
imageId: 'e9b10c10-8221-11ee-b31f-a96882651546',
|
|
169
|
+
showInEditorView: true,
|
|
170
|
+
canShowInEditorView: true,
|
|
171
|
+
name: 'image-1',
|
|
172
|
+
modifier: null,
|
|
173
|
+
elementTitle: null,
|
|
174
|
+
fetchFromRelation: false,
|
|
175
|
+
isHero: false,
|
|
176
|
+
priority: false,
|
|
177
|
+
areImageCreditsDisplayed: false,
|
|
178
|
+
isCaptionDisplayed: true,
|
|
179
|
+
caption: 'doc image',
|
|
180
|
+
alt: null,
|
|
181
|
+
url: null,
|
|
182
|
+
enableLightbox: false,
|
|
183
|
+
displayCount: false,
|
|
184
|
+
parallax: false,
|
|
185
|
+
access: {
|
|
186
|
+
display: 'always'
|
|
187
|
+
},
|
|
188
|
+
gtmClassName: null
|
|
189
|
+
},
|
|
190
|
+
id: '9ac5eb90-99d5-11ee-b4dd-039c35219d25',
|
|
191
|
+
items: [],
|
|
192
|
+
name: 'image-1'
|
|
193
|
+
}
|
|
194
|
+
];
|
|
195
|
+
|
|
196
|
+
export { cardDataMockedOptions, mockWIthMultiEntities, pageBuilderComponentsMocks };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import buildCheckboxFilters from '../../../../src/helpers/build-checkbox-filters';
|
|
2
|
+
|
|
3
|
+
describe('buildCheckboxFilters helper', () => {
|
|
4
|
+
it('should build filter if value is a string', () => {
|
|
5
|
+
const checkboxFilters = ['filterName'];
|
|
6
|
+
const result = buildCheckboxFilters(checkboxFilters);
|
|
7
|
+
expect(result).toEqual([{ match: { filterName: true } }]);
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
it('should handle new array filters', () => {
|
|
11
|
+
const checkboxFilters = [['filterName', 'not'], ['secondFilter', 'on']];
|
|
12
|
+
const result = buildCheckboxFilters(checkboxFilters);
|
|
13
|
+
expect(result).toEqual([{ match: { filterName: false } }, { match: { secondFilter: true } }]);
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it('builds checkbox filters with a mix of string and array elements', () => {
|
|
17
|
+
const checkboxFilters = ['filterName', ['filterType', 'not']];
|
|
18
|
+
const result = buildCheckboxFilters(checkboxFilters);
|
|
19
|
+
expect(result).toEqual([{ match: { filterName: true } }, { match: { filterType: false } }]);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it('handles empty array input', () => {
|
|
23
|
+
const checkboxFilters = [];
|
|
24
|
+
const result = buildCheckboxFilters(checkboxFilters);
|
|
25
|
+
expect(result).toEqual([]);
|
|
26
|
+
});
|
|
27
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import getCheckboxFilters from '../../../../src/helpers/get-checkbox-filters';
|
|
2
|
+
|
|
3
|
+
describe('getCheckboxFilters helper', () => {
|
|
4
|
+
it('adds [name, value] to checkboxFilters when value is a non-"off" string', () => {
|
|
5
|
+
const checkboxFilters = [];
|
|
6
|
+
getCheckboxFilters(checkboxFilters, 'filterName', 'on');
|
|
7
|
+
expect(checkboxFilters).toEqual([['filterName', 'on']]);
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
it('does not add to checkboxFilters when value is "off"', () => {
|
|
11
|
+
const checkboxFilters = [];
|
|
12
|
+
getCheckboxFilters(checkboxFilters, 'filterName', 'off');
|
|
13
|
+
expect(checkboxFilters).toEqual([]);
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it('does not add to checkboxFilters when value is falsy', () => {
|
|
17
|
+
const checkboxFilters = [];
|
|
18
|
+
getCheckboxFilters(checkboxFilters, 'filterName', null);
|
|
19
|
+
expect(checkboxFilters).toEqual([]);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it('adds name to checkboxFilters when value is truthy and not a string', () => {
|
|
23
|
+
const checkboxFilters = [];
|
|
24
|
+
getCheckboxFilters(checkboxFilters, 'filterName', true);
|
|
25
|
+
expect(checkboxFilters).toEqual(['filterName']);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it('adds name to checkboxFilters when value is truthy and not a string', () => {
|
|
29
|
+
const checkboxFilters = [];
|
|
30
|
+
getCheckboxFilters(checkboxFilters, 'filterName', true);
|
|
31
|
+
expect(checkboxFilters).toEqual(['filterName']);
|
|
32
|
+
});
|
|
33
|
+
});
|