@blaze-cms/react-page-builder 0.120.0-alpha.0 → 0.120.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 +11 -0
- package/lib/helpers/build-props-query.js +15 -7
- package/lib/helpers/build-props-query.js.map +1 -1
- package/lib-es/helpers/build-props-query.js +11 -8
- package/lib-es/helpers/build-props-query.js.map +1 -1
- package/package.json +2 -2
- package/src/helpers/build-props-query.js +7 -10
- package/tests/unit/src/helpers/build-props-query.test.js +28 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [0.120.0-alpha.1](https://github.com/thebyte9/blaze/compare/v0.120.0-alpha.0...v0.120.0-alpha.1) (2022-02-10)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* allow card images for non content entities ([#3335](https://github.com/thebyte9/blaze/issues/3335)) ([ebbcdaf](https://github.com/thebyte9/blaze/commit/ebbcdaf3310c3ddc4f39f4bb70ed5f9939099559))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
# [0.120.0-alpha.0](https://github.com/thebyte9/blaze/compare/v0.119.1...v0.120.0-alpha.0) (2022-02-09)
|
|
7
18
|
|
|
8
19
|
|
|
@@ -43,6 +43,8 @@ require("core-js/modules/es.string.split.js");
|
|
|
43
43
|
|
|
44
44
|
require("core-js/modules/es.string.starts-with.js");
|
|
45
45
|
|
|
46
|
+
require("core-js/modules/es.array.find.js");
|
|
47
|
+
|
|
46
48
|
var _constants = require("../constants");
|
|
47
49
|
|
|
48
50
|
var defaultProps = [_constants.ID, 'name'];
|
|
@@ -117,24 +119,30 @@ var getTypeBaseProps = function getTypeBaseProps(data, cardOptions, extraPropsHa
|
|
|
117
119
|
var getEntitySchema = data.getEntitySchema;
|
|
118
120
|
var interfaces = getEntitySchema.interfaces,
|
|
119
121
|
properties = getEntitySchema.properties,
|
|
120
|
-
dynamicProperties = getEntitySchema.dynamicProperties
|
|
122
|
+
dynamicProperties = getEntitySchema.dynamicProperties,
|
|
123
|
+
relations = getEntitySchema.relations;
|
|
121
124
|
var isContent = !!interfaces.includes('content/content');
|
|
122
125
|
var hasCategory = checkProps(properties) || checkProps(dynamicProperties);
|
|
123
126
|
var hasPreheader = properties[_constants.PREHEADER_PROP];
|
|
124
127
|
var typeBasedProps = [].concat(defaultProps);
|
|
125
128
|
typeBasedProps.push.apply(typeBasedProps, (0, _toConsumableArray2["default"])(getCategoyProps(shouldAddCategoryProps, hasCategory, hasPreheader)));
|
|
126
|
-
typeBasedProps.push.apply(typeBasedProps, (0, _toConsumableArray2["default"])(getContentProps(isContent
|
|
129
|
+
typeBasedProps.push.apply(typeBasedProps, (0, _toConsumableArray2["default"])(getContentProps(isContent)));
|
|
130
|
+
|
|
131
|
+
if (displayThumbnail && relations.find(function (_ref2) {
|
|
132
|
+
var localField = _ref2.localField;
|
|
133
|
+
return localField === 'image';
|
|
134
|
+
})) {
|
|
135
|
+
typeBasedProps.push('image.id', 'image.url', 'image.data');
|
|
136
|
+
}
|
|
137
|
+
|
|
127
138
|
return {
|
|
128
139
|
typeBasedProps: typeBasedProps,
|
|
129
140
|
shouldAddCategoryProps: shouldAddCategoryProps
|
|
130
141
|
};
|
|
131
142
|
};
|
|
132
143
|
|
|
133
|
-
var getContentProps = function getContentProps(isContent
|
|
134
|
-
|
|
135
|
-
var props = ['url', 'sponsored', 'featured'];
|
|
136
|
-
if (displayThumbnail) props.push('image.id', 'image.url', 'image.data');
|
|
137
|
-
return props;
|
|
144
|
+
var getContentProps = function getContentProps(isContent) {
|
|
145
|
+
return isContent ? ['url', 'sponsored', 'featured'] : [];
|
|
138
146
|
};
|
|
139
147
|
|
|
140
148
|
var getCategoyProps = function getCategoyProps(shouldAddCategoryProps, hasCategory, hasPreheader) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/helpers/build-props-query.js"],"names":["defaultProps","ID","categoryProps","checkProps","props","Object","keys","filter","prop","CATEGORY_ID","length","buildPropsQuery","data","extraProps","cardOptions","extraPropsHaveCategory","includes","getTypeBaseProps","typeBasedProps","shouldAddCategoryProps","allProps","uniqueProps","Set","basicProps","i","arr","indexOf","complexProps","buildComplexProps","join","map","nested","split","base","nestedProps","extraProp","startsWith","jointNestedProps","isCard","displayCategory","displayThumbnail","getEntitySchema","interfaces","properties","dynamicProperties","isContent","hasCategory","hasPreheader","PREHEADER_PROP","push","getCategoyProps","getContentProps","HEADLINE_PROP"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/helpers/build-props-query.js"],"names":["defaultProps","ID","categoryProps","checkProps","props","Object","keys","filter","prop","CATEGORY_ID","length","buildPropsQuery","data","extraProps","cardOptions","extraPropsHaveCategory","includes","getTypeBaseProps","typeBasedProps","shouldAddCategoryProps","allProps","uniqueProps","Set","basicProps","i","arr","indexOf","complexProps","buildComplexProps","join","map","nested","split","base","nestedProps","extraProp","startsWith","jointNestedProps","isCard","displayCategory","displayThumbnail","getEntitySchema","interfaces","properties","dynamicProperties","relations","isContent","hasCategory","hasPreheader","PREHEADER_PROP","push","getCategoyProps","getContentProps","find","localField","HEADLINE_PROP"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAEA,IAAMA,YAAY,GAAG,CAACC,aAAD,EAAK,MAAL,CAArB;AACA,IAAMC,aAAa,GAAG,kCAAtB;;AAEA,IAAMC,UAAU,GAAG,SAAbA,UAAa,CAAAC,KAAK;AAAA,SACtB,CAAC,EAAEA,KAAK,IAAIC,MAAM,CAACC,IAAP,CAAYF,KAAZ,EAAmBG,MAAnB,CAA0B,UAAAC,IAAI;AAAA,WAAIA,IAAI,KAAKC,sBAAb;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UAApB,EAAgC,WAAhC,EAA6C,YAA7C;AACD;;AAED,SAAO;AAAEhC,IAAAA,cAAc,EAAdA,cAAF;AAAkBC,IAAAA,sBAAsB,EAAtBA;AAAlB,GAAP;AACD,CA1BD;;AA4BA,IAAMiC,eAAe,GAAG,SAAlBA,eAAkB,CAAAN,SAAS;AAAA,SAAKA,SAAS,GAAG,CAAC,KAAD,EAAQ,WAAR,EAAqB,UAArB,CAAH,GAAsC,EAApD;AAAA,CAAjC;;AAEA,IAAMK,eAAe,GAAG,SAAlBA,eAAkB,CAAChC,sBAAD,EAAyB4B,WAAzB,EAAsCC,YAAtC,EAAuD;AAC7E,MAAI,CAAC7B,sBAAL,EAA6B,OAAO,EAAP;AAE7B,MAAMf,KAAK,GAAG,EAAd;;AAEA,MAAI2C,WAAJ,EAAiB;AACf3C,IAAAA,KAAK,CAAC8C,IAAN,CAAW,eAAX,EAA4B,wBAA5B,EAAsD,4BAAtD;AACD;;AAED,MAAIF,YAAJ,EAAkB;AAChB5C,IAAAA,KAAK,CAAC8C,IAAN,WAAcD,yBAAd;AACA7C,IAAAA,KAAK,CAAC8C,IAAN,CAAWK,wBAAX;AACD;;AAED,SAAOnD,KAAP;AACD,CAfD;;eAiBeO,e","sourcesContent":["import { CATEGORY_ID, ID, PREHEADER_PROP, HEADLINE_PROP } from '../constants';\n\nconst defaultProps = [ID, 'name'];\nconst categoryProps = 'id publishedListingPage{id, url}';\n\nconst checkProps = props =>\n !!(props && Object.keys(props).filter(prop => prop === CATEGORY_ID).length);\n\nconst buildPropsQuery = (data, extraProps = [], cardOptions = null) => {\n const extraPropsHaveCategory = !!extraProps.filter(prop => prop.includes('category.')).length;\n\n const { typeBasedProps, shouldAddCategoryProps } = getTypeBaseProps(\n data,\n cardOptions,\n extraPropsHaveCategory\n );\n\n const allProps = [...typeBasedProps, ...extraProps];\n\n const uniqueProps = [...new Set([...allProps])];\n\n const basicProps = uniqueProps\n .filter(prop => prop && !prop.includes('.'))\n .filter((prop, i, arr) => arr.indexOf(prop) === i);\n const complexProps = buildComplexProps(shouldAddCategoryProps, uniqueProps);\n\n return [...basicProps, ...complexProps].join(',');\n};\n\nconst buildComplexProps = (shouldAddCategoryProps, props) =>\n props\n .filter(prop => prop && prop.includes('.'))\n .map(nested => nested.split('.')[0])\n .filter((prop, i, arr) => arr.indexOf(prop) === i)\n .map(base => {\n const nestedProps = props\n .filter(\n (extraProp, i, arr) =>\n extraProp && extraProp.startsWith(`${base}.`) && arr.indexOf(extraProp) === i\n )\n .map(nested => nested.split('.')[1]);\n\n const jointNestedProps = nestedProps.join(',');\n if (base === 'category' && shouldAddCategoryProps)\n return `${base}{${jointNestedProps}, ${categoryProps}}`;\n if (base.includes('published')) {\n return `${base}{${jointNestedProps},url}`;\n }\n return `${base}{${jointNestedProps}}`;\n });\n\nconst getTypeBaseProps = (data, cardOptions, extraPropsHaveCategory) => {\n const isCard = !!cardOptions;\n const { displayCategory = true, displayThumbnail = true } = cardOptions || {};\n\n const shouldAddCategoryProps =\n (isCard && displayCategory) || (!isCard && !extraPropsHaveCategory);\n\n if (!isCard) return { typeBasedProps: [ID], shouldAddCategoryProps };\n\n const { getEntitySchema } = data;\n const { interfaces, properties, dynamicProperties, relations } = getEntitySchema;\n\n const isContent = !!interfaces.includes('content/content');\n const hasCategory = checkProps(properties) || checkProps(dynamicProperties);\n const hasPreheader = properties[PREHEADER_PROP];\n\n const typeBasedProps = [...defaultProps];\n\n typeBasedProps.push(...getCategoyProps(shouldAddCategoryProps, hasCategory, hasPreheader));\n typeBasedProps.push(...getContentProps(isContent));\n\n if (displayThumbnail && relations.find(({ localField }) => localField === 'image')) {\n typeBasedProps.push('image.id', 'image.url', 'image.data');\n }\n\n return { typeBasedProps, shouldAddCategoryProps };\n};\n\nconst getContentProps = isContent => (isContent ? ['url', 'sponsored', 'featured'] : []);\n\nconst getCategoyProps = (shouldAddCategoryProps, hasCategory, hasPreheader) => {\n if (!shouldAddCategoryProps) return [];\n\n const props = [];\n\n if (hasCategory) {\n props.push('category.name', 'category.listingPageId', 'category.listingPageEntity');\n }\n\n if (hasPreheader) {\n props.push(`${PREHEADER_PROP}{name}`);\n props.push(HEADLINE_PROP);\n }\n\n return props;\n};\n\nexport default buildPropsQuery;\n"],"file":"build-props-query.js"}
|
|
@@ -46,26 +46,29 @@ const getTypeBaseProps = (data, cardOptions, extraPropsHaveCategory) => {
|
|
|
46
46
|
const {
|
|
47
47
|
interfaces,
|
|
48
48
|
properties,
|
|
49
|
-
dynamicProperties
|
|
49
|
+
dynamicProperties,
|
|
50
|
+
relations
|
|
50
51
|
} = getEntitySchema;
|
|
51
52
|
const isContent = !!interfaces.includes('content/content');
|
|
52
53
|
const hasCategory = checkProps(properties) || checkProps(dynamicProperties);
|
|
53
54
|
const hasPreheader = properties[PREHEADER_PROP];
|
|
54
55
|
const typeBasedProps = [...defaultProps];
|
|
55
56
|
typeBasedProps.push(...getCategoyProps(shouldAddCategoryProps, hasCategory, hasPreheader));
|
|
56
|
-
typeBasedProps.push(...getContentProps(isContent
|
|
57
|
+
typeBasedProps.push(...getContentProps(isContent));
|
|
58
|
+
|
|
59
|
+
if (displayThumbnail && relations.find(({
|
|
60
|
+
localField
|
|
61
|
+
}) => localField === 'image')) {
|
|
62
|
+
typeBasedProps.push('image.id', 'image.url', 'image.data');
|
|
63
|
+
}
|
|
64
|
+
|
|
57
65
|
return {
|
|
58
66
|
typeBasedProps,
|
|
59
67
|
shouldAddCategoryProps
|
|
60
68
|
};
|
|
61
69
|
};
|
|
62
70
|
|
|
63
|
-
const getContentProps =
|
|
64
|
-
if (!isContent) return [];
|
|
65
|
-
const props = ['url', 'sponsored', 'featured'];
|
|
66
|
-
if (displayThumbnail) props.push('image.id', 'image.url', 'image.data');
|
|
67
|
-
return props;
|
|
68
|
-
};
|
|
71
|
+
const getContentProps = isContent => isContent ? ['url', 'sponsored', 'featured'] : [];
|
|
69
72
|
|
|
70
73
|
const getCategoyProps = (shouldAddCategoryProps, hasCategory, hasPreheader) => {
|
|
71
74
|
if (!shouldAddCategoryProps) return [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/helpers/build-props-query.js"],"names":["CATEGORY_ID","ID","PREHEADER_PROP","HEADLINE_PROP","defaultProps","categoryProps","checkProps","props","Object","keys","filter","prop","length","buildPropsQuery","data","extraProps","cardOptions","extraPropsHaveCategory","includes","typeBasedProps","shouldAddCategoryProps","getTypeBaseProps","allProps","uniqueProps","Set","basicProps","i","arr","indexOf","complexProps","buildComplexProps","join","map","nested","split","base","nestedProps","extraProp","startsWith","jointNestedProps","isCard","displayCategory","displayThumbnail","getEntitySchema","interfaces","properties","dynamicProperties","isContent","hasCategory","hasPreheader","push","getCategoyProps","getContentProps"],"mappings":"AAAA,SAASA,WAAT,EAAsBC,EAAtB,EAA0BC,cAA1B,EAA0CC,aAA1C,QAA+D,cAA/D;AAEA,MAAMC,YAAY,GAAG,CAACH,EAAD,EAAK,MAAL,CAArB;AACA,MAAMI,aAAa,GAAG,kCAAtB;;AAEA,MAAMC,UAAU,GAAGC,KAAK,IACtB,CAAC,EAAEA,KAAK,IAAIC,MAAM,CAACC,IAAP,CAAYF,KAAZ,EAAmBG,MAAnB,CAA0BC,IAAI,IAAIA,IAAI,KAAKX,WAA3C,EAAwDY,MAAnE,CADH;;AAGA,MAAMC,eAAe,GAAG,CAACC,IAAD,EAAOC,UAAU,GAAG,EAApB,EAAwBC,WAAW,GAAG,IAAtC,KAA+C;AACrE,QAAMC,sBAAsB,GAAG,CAAC,CAACF,UAAU,CAACL,MAAX,CAAkBC,IAAI,IAAIA,IAAI,CAACO,QAAL,CAAc,WAAd,CAA1B,EAAsDN,MAAvF;AAEA,QAAM;AAAEO,IAAAA,cAAF;AAAkBC,IAAAA;AAAlB,MAA6CC,gBAAgB,CACjEP,IADiE,EAEjEE,WAFiE,EAGjEC,sBAHiE,CAAnE;AAMA,QAAMK,QAAQ,GAAG,CAAC,GAAGH,cAAJ,EAAoB,GAAGJ,UAAvB,CAA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AAMK,gBAAgB,GAAGH,WAAW,CAACL,IAAZ,CAAiB,GAAjB,CAAzB;AACA,MAAII,IAAI,KAAK,UAAT,IAAuBf,sBAA3B,EACE,OAAQ,GAAEe,IAAK,IAAGI,gBAAiB,KAAIlC,aAAc,GAArD;;AACF,MAAI8B,IAAI,CAACjB,QAAL,CAAc,WAAd,CAAJ,EAAgC;AAC9B,WAAQ,GAAEiB,IAAK,IAAGI,gBAAiB,OAAnC;AACD;;AACD,SAAQ,GAAEJ,IAAK,IAAGI,gBAAiB,GAAnC;AACD,CAnBH,CADF;;AAsBA,MAAMlB,gBAAgB,GAAG,CAACP,IAAD,EAAOE,WAAP,EAAoBC,sBAApB,KAA+C;AACtE,QAAMuB,MAAM,GAAG,CAAC,CAACxB,WAAjB;AACA,QAAM;AAAEyB,IAAAA,eAAe,GAAG,IAApB;AAA0BC,IAAAA,gBAAgB,GAAG;AAA7C,MAAsD1B,WAAW,IAAI,EAA3E;AAEA,QAAMI,sBAAsB,GACzBoB,MAAM,IAAIC,eAAX,IAAgC,CAACD,MAAD,IAAW,CAACvB,sBAD9C;AAGA,MAAI,CAACuB,MAAL,EAAa,OAAO;AAAErB,IAAAA,cAAc,EAAE,CAAClB,EAAD,CAAlB;AAAwBmB,IAAAA;AAAxB,GAAP;AAEb,QAAM;AAAEuB,IAAAA;AAAF,MAAsB7B,IAA5B;AACA,QAAM;AAAE8B,IAAAA,UAAF;AAAcC,IAAAA,UAAd;AAA0BC,IAAAA;
|
|
1
|
+
{"version":3,"sources":["../../src/helpers/build-props-query.js"],"names":["CATEGORY_ID","ID","PREHEADER_PROP","HEADLINE_PROP","defaultProps","categoryProps","checkProps","props","Object","keys","filter","prop","length","buildPropsQuery","data","extraProps","cardOptions","extraPropsHaveCategory","includes","typeBasedProps","shouldAddCategoryProps","getTypeBaseProps","allProps","uniqueProps","Set","basicProps","i","arr","indexOf","complexProps","buildComplexProps","join","map","nested","split","base","nestedProps","extraProp","startsWith","jointNestedProps","isCard","displayCategory","displayThumbnail","getEntitySchema","interfaces","properties","dynamicProperties","relations","isContent","hasCategory","hasPreheader","push","getCategoyProps","getContentProps","find","localField"],"mappings":"AAAA,SAASA,WAAT,EAAsBC,EAAtB,EAA0BC,cAA1B,EAA0CC,aAA1C,QAA+D,cAA/D;AAEA,MAAMC,YAAY,GAAG,CAACH,EAAD,EAAK,MAAL,CAArB;AACA,MAAMI,aAAa,GAAG,kCAAtB;;AAEA,MAAMC,UAAU,GAAGC,KAAK,IACtB,CAAC,EAAEA,KAAK,IAAIC,MAAM,CAACC,IAAP,CAAYF,KAAZ,EAAmBG,MAAnB,CAA0BC,IAAI,IAAIA,IAAI,KAAKX,WAA3C,EAAwDY,MAAnE,CADH;;AAGA,MAAMC,eAAe,GAAG,CAACC,IAAD,EAAOC,UAAU,GAAG,EAApB,EAAwBC,WAAW,GAAG,IAAtC,KAA+C;AACrE,QAAMC,sBAAsB,GAAG,CAAC,CAACF,UAAU,CAACL,MAAX,CAAkBC,IAAI,IAAIA,IAAI,CAACO,QAAL,CAAc,WAAd,CAA1B,EAAsDN,MAAvF;AAEA,QAAM;AAAEO,IAAAA,cAAF;AAAkBC,IAAAA;AAAlB,MAA6CC,gBAAgB,CACjEP,IADiE,EAEjEE,WAFiE,EAGjEC,sBAHiE,CAAnE;AAMA,QAAMK,QAAQ,GAAG,CAAC,GAAGH,cAAJ,EAAoB,GAAGJ,UAAvB,CAAjB;AAEA,QAAMQ,WAAW,GAAG,CAAC,GAAG,IAAIC,GAAJ,CAAQ,CAAC,GAAGF,QAAJ,CAAR,CAAJ,CAApB;AAEA,QAAMG,UAAU,GAAGF,WAAW,CAC3Bb,MADgB,CACTC,IAAI,IAAIA,IAAI,IAAI,CAACA,IAAI,CAACO,QAAL,CAAc,GAAd,CADR,EAEhBR,MAFgB,CAET,CAACC,IAAD,EAAOe,CAAP,EAAUC,GAAV,KAAkBA,GAAG,CAACC,OAAJ,CAAYjB,IAAZ,MAAsBe,CAF/B,CAAnB;AAGA,QAAMG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AApB,EAAgC,WAAhC,EAA6C,YAA7C;AACD;;AAED,SAAO;AAAEhC,IAAAA,cAAF;AAAkBC,IAAAA;AAAlB,GAAP;AACD,CA1BD;;AA4BA,MAAMiC,eAAe,GAAGL,SAAS,IAAKA,SAAS,GAAG,CAAC,KAAD,EAAQ,WAAR,EAAqB,UAArB,CAAH,GAAsC,EAArF;;AAEA,MAAMI,eAAe,GAAG,CAAChC,sBAAD,EAAyB6B,WAAzB,EAAsCC,YAAtC,KAAuD;AAC7E,MAAI,CAAC9B,sBAAL,EAA6B,OAAO,EAAP;AAE7B,QAAMb,KAAK,GAAG,EAAd;;AAEA,MAAI0C,WAAJ,EAAiB;AACf1C,IAAAA,KAAK,CAAC4C,IAAN,CAAW,eAAX,EAA4B,wBAA5B,EAAsD,4BAAtD;AACD;;AAED,MAAID,YAAJ,EAAkB;AAChB3C,IAAAA,KAAK,CAAC4C,IAAN,CAAY,GAAEjD,cAAe,QAA7B;AACAK,IAAAA,KAAK,CAAC4C,IAAN,CAAWhD,aAAX;AACD;;AAED,SAAOI,KAAP;AACD,CAfD;;AAiBA,eAAeM,eAAf","sourcesContent":["import { CATEGORY_ID, ID, PREHEADER_PROP, HEADLINE_PROP } from '../constants';\n\nconst defaultProps = [ID, 'name'];\nconst categoryProps = 'id publishedListingPage{id, url}';\n\nconst checkProps = props =>\n !!(props && Object.keys(props).filter(prop => prop === CATEGORY_ID).length);\n\nconst buildPropsQuery = (data, extraProps = [], cardOptions = null) => {\n const extraPropsHaveCategory = !!extraProps.filter(prop => prop.includes('category.')).length;\n\n const { typeBasedProps, shouldAddCategoryProps } = getTypeBaseProps(\n data,\n cardOptions,\n extraPropsHaveCategory\n );\n\n const allProps = [...typeBasedProps, ...extraProps];\n\n const uniqueProps = [...new Set([...allProps])];\n\n const basicProps = uniqueProps\n .filter(prop => prop && !prop.includes('.'))\n .filter((prop, i, arr) => arr.indexOf(prop) === i);\n const complexProps = buildComplexProps(shouldAddCategoryProps, uniqueProps);\n\n return [...basicProps, ...complexProps].join(',');\n};\n\nconst buildComplexProps = (shouldAddCategoryProps, props) =>\n props\n .filter(prop => prop && prop.includes('.'))\n .map(nested => nested.split('.')[0])\n .filter((prop, i, arr) => arr.indexOf(prop) === i)\n .map(base => {\n const nestedProps = props\n .filter(\n (extraProp, i, arr) =>\n extraProp && extraProp.startsWith(`${base}.`) && arr.indexOf(extraProp) === i\n )\n .map(nested => nested.split('.')[1]);\n\n const jointNestedProps = nestedProps.join(',');\n if (base === 'category' && shouldAddCategoryProps)\n return `${base}{${jointNestedProps}, ${categoryProps}}`;\n if (base.includes('published')) {\n return `${base}{${jointNestedProps},url}`;\n }\n return `${base}{${jointNestedProps}}`;\n });\n\nconst getTypeBaseProps = (data, cardOptions, extraPropsHaveCategory) => {\n const isCard = !!cardOptions;\n const { displayCategory = true, displayThumbnail = true } = cardOptions || {};\n\n const shouldAddCategoryProps =\n (isCard && displayCategory) || (!isCard && !extraPropsHaveCategory);\n\n if (!isCard) return { typeBasedProps: [ID], shouldAddCategoryProps };\n\n const { getEntitySchema } = data;\n const { interfaces, properties, dynamicProperties, relations } = getEntitySchema;\n\n const isContent = !!interfaces.includes('content/content');\n const hasCategory = checkProps(properties) || checkProps(dynamicProperties);\n const hasPreheader = properties[PREHEADER_PROP];\n\n const typeBasedProps = [...defaultProps];\n\n typeBasedProps.push(...getCategoyProps(shouldAddCategoryProps, hasCategory, hasPreheader));\n typeBasedProps.push(...getContentProps(isContent));\n\n if (displayThumbnail && relations.find(({ localField }) => localField === 'image')) {\n typeBasedProps.push('image.id', 'image.url', 'image.data');\n }\n\n return { typeBasedProps, shouldAddCategoryProps };\n};\n\nconst getContentProps = isContent => (isContent ? ['url', 'sponsored', 'featured'] : []);\n\nconst getCategoyProps = (shouldAddCategoryProps, hasCategory, hasPreheader) => {\n if (!shouldAddCategoryProps) return [];\n\n const props = [];\n\n if (hasCategory) {\n props.push('category.name', 'category.listingPageId', 'category.listingPageEntity');\n }\n\n if (hasPreheader) {\n props.push(`${PREHEADER_PROP}{name}`);\n props.push(HEADLINE_PROP);\n }\n\n return props;\n};\n\nexport default buildPropsQuery;\n"],"file":"build-props-query.js"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blaze-cms/react-page-builder",
|
|
3
|
-
"version": "0.120.0-alpha.
|
|
3
|
+
"version": "0.120.0-alpha.1",
|
|
4
4
|
"description": "Blaze react page builder",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "lib-es/index.js",
|
|
@@ -83,5 +83,5 @@
|
|
|
83
83
|
"lib/*",
|
|
84
84
|
"lib-es/*"
|
|
85
85
|
],
|
|
86
|
-
"gitHead": "
|
|
86
|
+
"gitHead": "141778c58187ccf5dcce736bd5829ba3d805a755"
|
|
87
87
|
}
|
|
@@ -59,7 +59,7 @@ const getTypeBaseProps = (data, cardOptions, extraPropsHaveCategory) => {
|
|
|
59
59
|
if (!isCard) return { typeBasedProps: [ID], shouldAddCategoryProps };
|
|
60
60
|
|
|
61
61
|
const { getEntitySchema } = data;
|
|
62
|
-
const { interfaces, properties, dynamicProperties } = getEntitySchema;
|
|
62
|
+
const { interfaces, properties, dynamicProperties, relations } = getEntitySchema;
|
|
63
63
|
|
|
64
64
|
const isContent = !!interfaces.includes('content/content');
|
|
65
65
|
const hasCategory = checkProps(properties) || checkProps(dynamicProperties);
|
|
@@ -68,19 +68,16 @@ const getTypeBaseProps = (data, cardOptions, extraPropsHaveCategory) => {
|
|
|
68
68
|
const typeBasedProps = [...defaultProps];
|
|
69
69
|
|
|
70
70
|
typeBasedProps.push(...getCategoyProps(shouldAddCategoryProps, hasCategory, hasPreheader));
|
|
71
|
-
typeBasedProps.push(...getContentProps(isContent
|
|
71
|
+
typeBasedProps.push(...getContentProps(isContent));
|
|
72
|
+
|
|
73
|
+
if (displayThumbnail && relations.find(({ localField }) => localField === 'image')) {
|
|
74
|
+
typeBasedProps.push('image.id', 'image.url', 'image.data');
|
|
75
|
+
}
|
|
72
76
|
|
|
73
77
|
return { typeBasedProps, shouldAddCategoryProps };
|
|
74
78
|
};
|
|
75
79
|
|
|
76
|
-
const getContentProps = (isContent,
|
|
77
|
-
if (!isContent) return [];
|
|
78
|
-
|
|
79
|
-
const props = ['url', 'sponsored', 'featured'];
|
|
80
|
-
if (displayThumbnail) props.push('image.id', 'image.url', 'image.data');
|
|
81
|
-
|
|
82
|
-
return props;
|
|
83
|
-
};
|
|
80
|
+
const getContentProps = isContent => (isContent ? ['url', 'sponsored', 'featured'] : []);
|
|
84
81
|
|
|
85
82
|
const getCategoyProps = (shouldAddCategoryProps, hasCategory, hasPreheader) => {
|
|
86
83
|
if (!shouldAddCategoryProps) return [];
|
|
@@ -6,6 +6,11 @@ import buildPropsQuery from '../../../../src/helpers/build-props-query';
|
|
|
6
6
|
const CONTENT_INTERFACE = 'content/content';
|
|
7
7
|
|
|
8
8
|
describe('get card render props', () => {
|
|
9
|
+
const relations = [
|
|
10
|
+
{
|
|
11
|
+
localField: 'image'
|
|
12
|
+
}
|
|
13
|
+
];
|
|
9
14
|
const data = {
|
|
10
15
|
getEntitySchema: {
|
|
11
16
|
interfaces: [CONTENT_INTERFACE],
|
|
@@ -13,6 +18,7 @@ describe('get card render props', () => {
|
|
|
13
18
|
id: 'id',
|
|
14
19
|
name: 'someName'
|
|
15
20
|
},
|
|
21
|
+
relations,
|
|
16
22
|
dynamicProperties: {}
|
|
17
23
|
}
|
|
18
24
|
};
|
|
@@ -23,6 +29,7 @@ describe('get card render props', () => {
|
|
|
23
29
|
id: 'id',
|
|
24
30
|
alternativePreHeader: { type: 'object ' }
|
|
25
31
|
},
|
|
32
|
+
relations,
|
|
26
33
|
dynamicProperties: {}
|
|
27
34
|
}
|
|
28
35
|
};
|
|
@@ -50,6 +57,7 @@ describe('get card render props', () => {
|
|
|
50
57
|
id: 'id',
|
|
51
58
|
categoryId: 'catId'
|
|
52
59
|
},
|
|
60
|
+
relations,
|
|
53
61
|
dynamicProperties: {}
|
|
54
62
|
}
|
|
55
63
|
};
|
|
@@ -78,6 +86,7 @@ describe('get card render props', () => {
|
|
|
78
86
|
alternativePreHeader: { type: 'object ' },
|
|
79
87
|
categoryId: { type: 'object ' }
|
|
80
88
|
},
|
|
89
|
+
relations,
|
|
81
90
|
dynamicProperties: {}
|
|
82
91
|
}
|
|
83
92
|
};
|
|
@@ -118,6 +127,7 @@ describe('get card render props', () => {
|
|
|
118
127
|
id: 'id',
|
|
119
128
|
categoryId: 'someName'
|
|
120
129
|
},
|
|
130
|
+
relations: [],
|
|
121
131
|
dynamicProperties: {}
|
|
122
132
|
}
|
|
123
133
|
};
|
|
@@ -131,4 +141,22 @@ describe('get card render props', () => {
|
|
|
131
141
|
const query = buildPropsQuery(data, [], { displayCategory: false, displayThumbnail: false });
|
|
132
142
|
expect(query).toEqual('id,name,url,sponsored,featured');
|
|
133
143
|
});
|
|
144
|
+
|
|
145
|
+
it('should not fetch image if the schema does not have imageId property', () => {
|
|
146
|
+
const _data = {
|
|
147
|
+
getEntitySchema: {
|
|
148
|
+
interfaces: [CONTENT_INTERFACE],
|
|
149
|
+
properties: {
|
|
150
|
+
id: 'id',
|
|
151
|
+
categoryId: 'catId'
|
|
152
|
+
},
|
|
153
|
+
relations: [{ localField: 'noImage' }],
|
|
154
|
+
dynamicProperties: {}
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
const query = buildPropsQuery(_data, [], cardProps);
|
|
158
|
+
expect(query).toEqual(
|
|
159
|
+
'id,name,url,sponsored,featured,category{name,listingPageId,listingPageEntity, id publishedListingPage{id, url}}'
|
|
160
|
+
);
|
|
161
|
+
});
|
|
134
162
|
});
|