@blaze-cms/react-page-builder 0.124.0-alpha.2 → 0.124.0-alpha.6
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 +32 -0
- package/lib/application/query/index.js +1 -1
- package/lib/application/query/index.js.map +1 -1
- package/lib/components/CarouselWrapper.js +2 -2
- package/lib/components/CarouselWrapper.js.map +1 -1
- package/lib/components/SearchContent/index.js +130 -63
- package/lib/components/SearchContent/index.js.map +1 -1
- package/lib/helpers/build-props-query.js +18 -11
- package/lib/helpers/build-props-query.js.map +1 -1
- package/lib-es/application/query/index.js +4 -0
- package/lib-es/application/query/index.js.map +1 -1
- package/lib-es/components/CarouselWrapper.js +2 -2
- package/lib-es/components/CarouselWrapper.js.map +1 -1
- package/lib-es/components/SearchContent/index.js +84 -50
- package/lib-es/components/SearchContent/index.js.map +1 -1
- package/lib-es/helpers/build-props-query.js +11 -2
- package/lib-es/helpers/build-props-query.js.map +1 -1
- package/package.json +2 -2
- package/src/application/query/index.js +4 -0
- package/src/components/CarouselWrapper.js +2 -2
- package/src/components/SearchContent/index.js +77 -38
- package/src/helpers/build-props-query.js +6 -3
- package/tests/unit/src/helpers/build-props-query.test.js +43 -0
|
@@ -22,23 +22,24 @@ const buildPropsQuery = (data, extraProps = [], cardOptions = null) => {
|
|
|
22
22
|
const basicProps = uniqueProps
|
|
23
23
|
.filter(prop => prop && !prop.includes('.'))
|
|
24
24
|
.filter((prop, i, arr) => arr.indexOf(prop) === i);
|
|
25
|
-
const complexProps = buildComplexProps(shouldAddCategoryProps, uniqueProps);
|
|
26
|
-
|
|
25
|
+
const complexProps = buildComplexProps(shouldAddCategoryProps, uniqueProps, data);
|
|
27
26
|
return [...basicProps, ...complexProps].join(',');
|
|
28
27
|
};
|
|
29
28
|
|
|
30
|
-
const buildComplexProps = (shouldAddCategoryProps, props) =>
|
|
29
|
+
const buildComplexProps = (shouldAddCategoryProps, props, { getEntitySchema: { relations } }) =>
|
|
31
30
|
props
|
|
32
31
|
.filter(prop => prop && prop.includes('.'))
|
|
33
32
|
.map(nested => nested.split('.')[0])
|
|
34
33
|
.filter((prop, i, arr) => arr.indexOf(prop) === i)
|
|
35
34
|
.map(base => {
|
|
35
|
+
const matchingRelation = relations.find(({ localField }) => localField === base);
|
|
36
36
|
const nestedProps = props
|
|
37
37
|
.filter(
|
|
38
38
|
(extraProp, i, arr) =>
|
|
39
39
|
extraProp && extraProp.startsWith(`${base}.`) && arr.indexOf(extraProp) === i
|
|
40
40
|
)
|
|
41
41
|
.map(nested => nested.split('.')[1]);
|
|
42
|
+
if (matchingRelation && !nestedProps.includes('id')) nestedProps.push('id');
|
|
42
43
|
|
|
43
44
|
const jointNestedProps = nestedProps.join(',');
|
|
44
45
|
if (base === 'category' && shouldAddCategoryProps)
|
|
@@ -70,6 +71,8 @@ const getTypeBaseProps = (data, cardOptions, extraPropsHaveCategory) => {
|
|
|
70
71
|
typeBasedProps.push(...getCategoyProps(shouldAddCategoryProps, hasCategory, hasPreheader));
|
|
71
72
|
typeBasedProps.push(...getContentProps(isContent));
|
|
72
73
|
|
|
74
|
+
if (properties.url || dynamicProperties.url) typeBasedProps.push('url');
|
|
75
|
+
|
|
73
76
|
if (displayThumbnail && relations.find(({ localField }) => localField === 'image')) {
|
|
74
77
|
typeBasedProps.push('image.id', 'image.url', 'image.data');
|
|
75
78
|
}
|
|
@@ -33,6 +33,7 @@ describe('get card render props', () => {
|
|
|
33
33
|
dynamicProperties: {}
|
|
34
34
|
}
|
|
35
35
|
};
|
|
36
|
+
|
|
36
37
|
const cardProps = {};
|
|
37
38
|
|
|
38
39
|
it('should be a function', () => {
|
|
@@ -159,4 +160,46 @@ describe('get card render props', () => {
|
|
|
159
160
|
'id,name,url,sponsored,featured,category{name,listingPageId,listingPageEntity, id publishedListingPage{id, url}}'
|
|
160
161
|
);
|
|
161
162
|
});
|
|
163
|
+
|
|
164
|
+
it('should include url if property has url', () => {
|
|
165
|
+
testUrlProperty({ extraProperties: { url: 'url' }, cardProps });
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
it('should include url if dynamic property has url', () => {
|
|
169
|
+
testUrlProperty({ dynamicProperties: { url: 'url' }, cardProps });
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
it('should add id prop to nested relations', () => {
|
|
173
|
+
const _data = {
|
|
174
|
+
getEntitySchema: {
|
|
175
|
+
interfaces: [CONTENT_INTERFACE],
|
|
176
|
+
properties: {
|
|
177
|
+
id: 'id',
|
|
178
|
+
categoryId: 'catId'
|
|
179
|
+
},
|
|
180
|
+
relations: [{ localField: 'address' }],
|
|
181
|
+
dynamicProperties: {}
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
const query = buildPropsQuery(_data, ['address.country'], cardProps);
|
|
185
|
+
expect(query).toEqual(
|
|
186
|
+
'id,name,url,sponsored,featured,category{name,listingPageId,listingPageEntity, id publishedListingPage{id, url}},address{country,id}'
|
|
187
|
+
);
|
|
188
|
+
});
|
|
162
189
|
});
|
|
190
|
+
|
|
191
|
+
function testUrlProperty({ extraProperties = {}, dynamicProperties = {}, cardProps }) {
|
|
192
|
+
const dataWithUrlProperty = {
|
|
193
|
+
getEntitySchema: {
|
|
194
|
+
interfaces: [],
|
|
195
|
+
properties: {
|
|
196
|
+
id: 'id',
|
|
197
|
+
...extraProperties
|
|
198
|
+
},
|
|
199
|
+
relations: [],
|
|
200
|
+
dynamicProperties
|
|
201
|
+
}
|
|
202
|
+
};
|
|
203
|
+
const query = buildPropsQuery(dataWithUrlProperty, [], cardProps);
|
|
204
|
+
expect(query).toEqual('id,name,url');
|
|
205
|
+
}
|