@blaze-cms/react-page-builder 0.122.0 → 0.122.1-alpha.0

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 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.122.1-alpha.0](https://github.com/thebyte9/blaze/compare/v0.122.0...v0.122.1-alpha.0) (2022-03-16)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * handle non array data types when adding link to data summary ([#3382](https://github.com/thebyte9/blaze/issues/3382)) ([dd3ae87](https://github.com/thebyte9/blaze/commit/dd3ae8738d2ccc53909954b46b3f06d2cda93484))
12
+
13
+
14
+
15
+
16
+
6
17
  # [0.122.0](https://github.com/thebyte9/blaze/compare/v0.122.0-alpha.2...v0.122.0) (2022-03-15)
7
18
 
8
19
  **Note:** Version bump only for package @blaze-cms/react-page-builder
@@ -19,6 +19,8 @@ require("core-js/modules/es.regexp.exec.js");
19
19
 
20
20
  require("core-js/modules/es.string.split.js");
21
21
 
22
+ require("core-js/modules/es.array.is-array.js");
23
+
22
24
  var getLinkToPublishedContent = function getLinkToPublishedContent() {
23
25
  var key = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
24
26
  var props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
@@ -28,8 +30,9 @@ var getLinkToPublishedContent = function getLinkToPublishedContent() {
28
30
  _key$split2 = (0, _slicedToArray2["default"])(_key$split, 1),
29
31
  baseKey = _key$split2[0];
30
32
 
31
- var content = props[baseKey] && props[baseKey][0];
32
- return content ? content.url : '';
33
+ if (!props[baseKey]) return '';
34
+ var content = Array.isArray(props[baseKey]) ? props[baseKey][0] : props[baseKey];
35
+ return content && content.url ? content.url : '';
33
36
  }
34
37
 
35
38
  return '';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/components/DataSummary/helpers/get-link-to-published-content.js"],"names":["getLinkToPublishedContent","key","props","includes","split","baseKey","content","url"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,IAAMA,yBAAyB,GAAG,SAA5BA,yBAA4B,GAA0B;AAAA,MAAzBC,GAAyB,uEAAnB,EAAmB;AAAA,MAAfC,KAAe,uEAAP,EAAO;;AAC1D,MAAID,GAAG,CAACE,QAAJ,CAAa,WAAb,CAAJ,EAA+B;AAC7B,qBAAkBF,GAAG,CAACG,KAAJ,CAAU,GAAV,CAAlB;AAAA;AAAA,QAAOC,OAAP;;AACA,QAAMC,OAAO,GAAGJ,KAAK,CAACG,OAAD,CAAL,IAAkBH,KAAK,CAACG,OAAD,CAAL,CAAe,CAAf,CAAlC;AACA,WAAOC,OAAO,GAAGA,OAAO,CAACC,GAAX,GAAiB,EAA/B;AACD;;AACD,SAAO,EAAP;AACD,CAPD;;eASeP,yB","sourcesContent":["const getLinkToPublishedContent = (key = '', props = {}) => {\n if (key.includes('published')) {\n const [baseKey] = key.split('.');\n const content = props[baseKey] && props[baseKey][0];\n return content ? content.url : '';\n }\n return '';\n};\n\nexport default getLinkToPublishedContent;\n"],"file":"get-link-to-published-content.js"}
1
+ {"version":3,"sources":["../../../../src/components/DataSummary/helpers/get-link-to-published-content.js"],"names":["getLinkToPublishedContent","key","props","includes","split","baseKey","content","Array","isArray","url"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAMA,yBAAyB,GAAG,SAA5BA,yBAA4B,GAA0B;AAAA,MAAzBC,GAAyB,uEAAnB,EAAmB;AAAA,MAAfC,KAAe,uEAAP,EAAO;;AAC1D,MAAID,GAAG,CAACE,QAAJ,CAAa,WAAb,CAAJ,EAA+B;AAC7B,qBAAkBF,GAAG,CAACG,KAAJ,CAAU,GAAV,CAAlB;AAAA;AAAA,QAAOC,OAAP;;AACA,QAAI,CAACH,KAAK,CAACG,OAAD,CAAV,EAAqB,OAAO,EAAP;AAErB,QAAMC,OAAO,GAAGC,KAAK,CAACC,OAAN,CAAcN,KAAK,CAACG,OAAD,CAAnB,IAAgCH,KAAK,CAACG,OAAD,CAAL,CAAe,CAAf,CAAhC,GAAoDH,KAAK,CAACG,OAAD,CAAzE;AACA,WAAOC,OAAO,IAAIA,OAAO,CAACG,GAAnB,GAAyBH,OAAO,CAACG,GAAjC,GAAuC,EAA9C;AACD;;AACD,SAAO,EAAP;AACD,CATD;;eAWeT,yB","sourcesContent":["const getLinkToPublishedContent = (key = '', props = {}) => {\n if (key.includes('published')) {\n const [baseKey] = key.split('.');\n if (!props[baseKey]) return '';\n\n const content = Array.isArray(props[baseKey]) ? props[baseKey][0] : props[baseKey];\n return content && content.url ? content.url : '';\n }\n return '';\n};\n\nexport default getLinkToPublishedContent;\n"],"file":"get-link-to-published-content.js"}
@@ -47,6 +47,8 @@ var getFilterProps = function getFilterProps(filter) {
47
47
  currentEntityRelations = _ref5$relations === void 0 ? [] : _ref5$relations,
48
48
  _ref5$properties = _ref5.properties,
49
49
  currentEntityProperties = _ref5$properties === void 0 ? {} : _ref5$properties,
50
+ _ref5$dynamicProperti = _ref5.dynamicProperties,
51
+ currentEntityDynamicProperties = _ref5$dynamicProperti === void 0 ? {} : _ref5$dynamicProperti,
50
52
  currentEntityId = _ref5.identifier;
51
53
 
52
54
  var _ref6 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
@@ -63,7 +65,7 @@ var getFilterProps = function getFilterProps(filter) {
63
65
  relationName = _filterName$split2[0],
64
66
  relationProp = _filterName$split2[1];
65
67
 
66
- var hasProperty = !!currentEntityProperties[filterName];
68
+ var hasProperty = !!(currentEntityProperties[filterName] || currentEntityDynamicProperties[filterName]);
67
69
  var relationEntityName = relationProp ? getFilterLocalKeys(relationName, currentEntityRelations) : null;
68
70
  var filterNameEntity = getRelationEntity(filterName, filterEntityRelations);
69
71
  var propertyEntityName = relationEntityName || filterNameEntity;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/helpers/get-filter-props.js"],"names":["getFilterLocalKeys","relationName","relations","find","localField","entityIdentifier","getRelationEntity","filterName","filterEntityRelations","foreignKey","getFilterProps","filter","currentEntityRelations","properties","currentEntityProperties","currentEntityId","identifier","filteryEntityId","split","relationProp","hasProperty","relationEntityName","filterNameEntity","propertyEntityName","entityName","isEntityItself","shouldCheckRelationNames","relationForeignKeys","shouldIgnoreFilter","length"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;AAEA,IAAMA,kBAAkB,GAAG,SAArBA,kBAAqB,CAACC,YAAD,EAAeC,SAAf,EAA6B;AACtD,aACEA,SAAS,CAACC,IAAV,CAAe;AAAA,QAAGC,UAAH,SAAGA,UAAH;AAAA,WAAoBA,UAAU,KAAKH,YAAnC;AAAA,GAAf,KAAmE,EADrE;AAAA,MAAQI,gBAAR,QAAQA,gBAAR;;AAEA,SAAOA,gBAAP;AACD,CAJD;;AAMA,IAAMC,iBAAiB,GAAG,SAApBA,iBAAoB,CAACC,UAAD,EAAaC,qBAAb,EAAuC;AAC/D,cACEA,qBAAqB,CAACL,IAAtB,CAA2B;AAAA,QAAGM,UAAH,SAAGA,UAAH;AAAA,WAAoBA,UAAU,KAAKF,UAAnC;AAAA,GAA3B,KAA6E,EAD/E;AAAA,MAAQF,gBAAR,SAAQA,gBAAR;;AAEA,SAAOA,gBAAP;AACD,CAJD;;AAMA,IAAMK,cAAc,GAAG,SAAjBA,cAAiB,CACrBC,MADqB,EAQlB;AAAA,kFAFC,EAED;AAAA,8BALDT,SAKC;AAAA,MALUU,sBAKV,gCALmC,EAKnC;AAAA,+BAJDC,UAIC;AAAA,MAJWC,uBAIX,iCAJqC,EAIrC;AAAA,MAHWC,eAGX,SAHDC,UAGC;;AAAA,kFADsE,EACtE;AAAA,8BADDd,SACC;AAAA,MADUM,qBACV,gCADkC,EAClC;AAAA,MADkDS,eAClD,SADsCD,UACtC;;AACH,sBAAqBL,MAAM,CAACO,KAAP,CAAa,GAAb,CAArB;AAAA;AAAA,MAAOX,UAAP;;AACA,0BAAqCA,UAAU,CAACW,KAAX,CAAiB,GAAjB,CAArC;AAAA;AAAA,MAAOjB,YAAP;AAAA,MAAqBkB,YAArB;;AACA,MAAMC,WAAW,GAAG,CAAC,CAACN,uBAAuB,CAACP,UAAD,CAA7C;AACA,MAAMc,kBAAkB,GAAGF,YAAY,GACnCnB,kBAAkB,CAACC,YAAD,EAAeW,sBAAf,CADiB,GAEnC,IAFJ;AAGA,MAAMU,gBAAgB,GAAGhB,iBAAiB,CAACC,UAAD,EAAaC,qBAAb,CAA1C;AAEA,MAAMe,kBAAkB,GAAGF,kBAAkB,IAAIC,gBAAjD;AACA,MAAME,UAAU,GAAGF,gBAAgB,GAAGL,eAAH,GAAqBI,kBAAxD;AACA,MAAMI,cAAc,GAAGV,eAAe,KAAKQ,kBAA3C;AACA,MAAMG,wBAAwB,GAAG,CAACN,WAAD,IAAgB,CAACC,kBAAlD;AACA,MAAMM,mBAAmB,GAAGD,wBAAwB,GAChD,uCAAsBH,kBAAtB,EAA0CX,sBAA1C,EAAkEE,uBAAlE,CADgD,GAEhD,EAFJ;AAGA,MAAMc,kBAAkB,GAAGF,wBAAwB,IAAI,CAACC,mBAAmB,CAACE,MAA5E;AAEA,SAAO;AACLtB,IAAAA,UAAU,EAAVA,UADK;AAELiB,IAAAA,UAAU,EAAVA,UAFK;AAGLvB,IAAAA,YAAY,EAAZA,YAHK;AAILkB,IAAAA,YAAY,EAAZA,YAJK;AAKLC,IAAAA,WAAW,EAAXA,WALK;AAMLC,IAAAA,kBAAkB,EAAlBA,kBANK;AAOLI,IAAAA,cAAc,EAAdA,cAPK;AAQLE,IAAAA,mBAAmB,EAAnBA,mBARK;AASLC,IAAAA,kBAAkB,EAAlBA;AATK,GAAP;AAWD,CArCD;;eAuCelB,c","sourcesContent":["import getFilterRelationKeys from './get-filter-relation-keys';\n\nconst getFilterLocalKeys = (relationName, relations) => {\n const { entityIdentifier } =\n relations.find(({ localField }) => localField === relationName) || {};\n return entityIdentifier;\n};\n\nconst getRelationEntity = (filterName, filterEntityRelations) => {\n const { entityIdentifier } =\n filterEntityRelations.find(({ foreignKey }) => foreignKey === filterName) || {};\n return entityIdentifier;\n};\n\nconst getFilterProps = (\n filter,\n {\n relations: currentEntityRelations = [],\n properties: currentEntityProperties = {},\n identifier: currentEntityId\n } = {},\n { relations: filterEntityRelations = [], identifier: filteryEntityId } = {}\n) => {\n const [filterName] = filter.split('/');\n const [relationName, relationProp] = filterName.split('.');\n const hasProperty = !!currentEntityProperties[filterName];\n const relationEntityName = relationProp\n ? getFilterLocalKeys(relationName, currentEntityRelations)\n : null;\n const filterNameEntity = getRelationEntity(filterName, filterEntityRelations);\n\n const propertyEntityName = relationEntityName || filterNameEntity;\n const entityName = filterNameEntity ? filteryEntityId : relationEntityName;\n const isEntityItself = currentEntityId === propertyEntityName;\n const shouldCheckRelationNames = !hasProperty && !relationEntityName;\n const relationForeignKeys = shouldCheckRelationNames\n ? getFilterRelationKeys(propertyEntityName, currentEntityRelations, currentEntityProperties)\n : [];\n const shouldIgnoreFilter = shouldCheckRelationNames && !relationForeignKeys.length;\n\n return {\n filterName,\n entityName,\n relationName,\n relationProp,\n hasProperty,\n relationEntityName,\n isEntityItself,\n relationForeignKeys,\n shouldIgnoreFilter\n };\n};\n\nexport default getFilterProps;\n"],"file":"get-filter-props.js"}
1
+ {"version":3,"sources":["../../src/helpers/get-filter-props.js"],"names":["getFilterLocalKeys","relationName","relations","find","localField","entityIdentifier","getRelationEntity","filterName","filterEntityRelations","foreignKey","getFilterProps","filter","currentEntityRelations","properties","currentEntityProperties","dynamicProperties","currentEntityDynamicProperties","currentEntityId","identifier","filteryEntityId","split","relationProp","hasProperty","relationEntityName","filterNameEntity","propertyEntityName","entityName","isEntityItself","shouldCheckRelationNames","relationForeignKeys","shouldIgnoreFilter","length"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;AAEA,IAAMA,kBAAkB,GAAG,SAArBA,kBAAqB,CAACC,YAAD,EAAeC,SAAf,EAA6B;AACtD,aACEA,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;AAGA,MAAMY,gBAAgB,GAAGlB,iBAAiB,CAACC,UAAD,EAAaC,qBAAb,CAA1C;AAEA,MAAMiB,kBAAkB,GAAGF,kBAAkB,IAAIC,gBAAjD;AACA,MAAME,UAAU,GAAGF,gBAAgB,GAAGL,eAAH,GAAqBI,kBAAxD;AACA,MAAMI,cAAc,GAAGV,eAAe,KAAKQ,kBAA3C;AACA,MAAMG,wBAAwB,GAAG,CAACN,WAAD,IAAgB,CAACC,kBAAlD;AACA,MAAMM,mBAAmB,GAAGD,wBAAwB,GAChD,uCAAsBH,kBAAtB,EAA0Cb,sBAA1C,EAAkEE,uBAAlE,CADgD,GAEhD,EAFJ;AAGA,MAAMgB,kBAAkB,GAAGF,wBAAwB,IAAI,CAACC,mBAAmB,CAACE,MAA5E;AAEA,SAAO;AACLxB,IAAAA,UAAU,EAAVA,UADK;AAELmB,IAAAA,UAAU,EAAVA,UAFK;AAGLzB,IAAAA,YAAY,EAAZA,YAHK;AAILoB,IAAAA,YAAY,EAAZA,YAJK;AAKLC,IAAAA,WAAW,EAAXA,WALK;AAMLC,IAAAA,kBAAkB,EAAlBA,kBANK;AAOLI,IAAAA,cAAc,EAAdA,cAPK;AAQLE,IAAAA,mBAAmB,EAAnBA,mBARK;AASLC,IAAAA,kBAAkB,EAAlBA;AATK,GAAP;AAWD,CAxCD;;eA0CepB,c","sourcesContent":["import getFilterRelationKeys from './get-filter-relation-keys';\n\nconst getFilterLocalKeys = (relationName, relations) => {\n const { entityIdentifier } =\n relations.find(({ localField }) => localField === relationName) || {};\n return entityIdentifier;\n};\n\nconst getRelationEntity = (filterName, filterEntityRelations) => {\n const { entityIdentifier } =\n filterEntityRelations.find(({ foreignKey }) => foreignKey === filterName) || {};\n return entityIdentifier;\n};\n\nconst getFilterProps = (\n filter,\n {\n relations: currentEntityRelations = [],\n properties: currentEntityProperties = {},\n dynamicProperties: currentEntityDynamicProperties = {},\n identifier: currentEntityId\n } = {},\n { relations: filterEntityRelations = [], identifier: filteryEntityId } = {}\n) => {\n const [filterName] = filter.split('/');\n const [relationName, relationProp] = filterName.split('.');\n const hasProperty = !!(\n currentEntityProperties[filterName] || currentEntityDynamicProperties[filterName]\n );\n const relationEntityName = relationProp\n ? getFilterLocalKeys(relationName, currentEntityRelations)\n : null;\n const filterNameEntity = getRelationEntity(filterName, filterEntityRelations);\n\n const propertyEntityName = relationEntityName || filterNameEntity;\n const entityName = filterNameEntity ? filteryEntityId : relationEntityName;\n const isEntityItself = currentEntityId === propertyEntityName;\n const shouldCheckRelationNames = !hasProperty && !relationEntityName;\n const relationForeignKeys = shouldCheckRelationNames\n ? getFilterRelationKeys(propertyEntityName, currentEntityRelations, currentEntityProperties)\n : [];\n const shouldIgnoreFilter = shouldCheckRelationNames && !relationForeignKeys.length;\n\n return {\n filterName,\n entityName,\n relationName,\n relationProp,\n hasProperty,\n relationEntityName,\n isEntityItself,\n relationForeignKeys,\n shouldIgnoreFilter\n };\n};\n\nexport default getFilterProps;\n"],"file":"get-filter-props.js"}
@@ -1,8 +1,9 @@
1
1
  const getLinkToPublishedContent = (key = '', props = {}) => {
2
2
  if (key.includes('published')) {
3
3
  const [baseKey] = key.split('.');
4
- const content = props[baseKey] && props[baseKey][0];
5
- return content ? content.url : '';
4
+ if (!props[baseKey]) return '';
5
+ const content = Array.isArray(props[baseKey]) ? props[baseKey][0] : props[baseKey];
6
+ return content && content.url ? content.url : '';
6
7
  }
7
8
 
8
9
  return '';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/components/DataSummary/helpers/get-link-to-published-content.js"],"names":["getLinkToPublishedContent","key","props","includes","baseKey","split","content","url"],"mappings":"AAAA,MAAMA,yBAAyB,GAAG,CAACC,GAAG,GAAG,EAAP,EAAWC,KAAK,GAAG,EAAnB,KAA0B;AAC1D,MAAID,GAAG,CAACE,QAAJ,CAAa,WAAb,CAAJ,EAA+B;AAC7B,UAAM,CAACC,OAAD,IAAYH,GAAG,CAACI,KAAJ,CAAU,GAAV,CAAlB;AACA,UAAMC,OAAO,GAAGJ,KAAK,CAACE,OAAD,CAAL,IAAkBF,KAAK,CAACE,OAAD,CAAL,CAAe,CAAf,CAAlC;AACA,WAAOE,OAAO,GAAGA,OAAO,CAACC,GAAX,GAAiB,EAA/B;AACD;;AACD,SAAO,EAAP;AACD,CAPD;;AASA,eAAeP,yBAAf","sourcesContent":["const getLinkToPublishedContent = (key = '', props = {}) => {\n if (key.includes('published')) {\n const [baseKey] = key.split('.');\n const content = props[baseKey] && props[baseKey][0];\n return content ? content.url : '';\n }\n return '';\n};\n\nexport default getLinkToPublishedContent;\n"],"file":"get-link-to-published-content.js"}
1
+ {"version":3,"sources":["../../../../src/components/DataSummary/helpers/get-link-to-published-content.js"],"names":["getLinkToPublishedContent","key","props","includes","baseKey","split","content","Array","isArray","url"],"mappings":"AAAA,MAAMA,yBAAyB,GAAG,CAACC,GAAG,GAAG,EAAP,EAAWC,KAAK,GAAG,EAAnB,KAA0B;AAC1D,MAAID,GAAG,CAACE,QAAJ,CAAa,WAAb,CAAJ,EAA+B;AAC7B,UAAM,CAACC,OAAD,IAAYH,GAAG,CAACI,KAAJ,CAAU,GAAV,CAAlB;AACA,QAAI,CAACH,KAAK,CAACE,OAAD,CAAV,EAAqB,OAAO,EAAP;AAErB,UAAME,OAAO,GAAGC,KAAK,CAACC,OAAN,CAAcN,KAAK,CAACE,OAAD,CAAnB,IAAgCF,KAAK,CAACE,OAAD,CAAL,CAAe,CAAf,CAAhC,GAAoDF,KAAK,CAACE,OAAD,CAAzE;AACA,WAAOE,OAAO,IAAIA,OAAO,CAACG,GAAnB,GAAyBH,OAAO,CAACG,GAAjC,GAAuC,EAA9C;AACD;;AACD,SAAO,EAAP;AACD,CATD;;AAWA,eAAeT,yBAAf","sourcesContent":["const getLinkToPublishedContent = (key = '', props = {}) => {\n if (key.includes('published')) {\n const [baseKey] = key.split('.');\n if (!props[baseKey]) return '';\n\n const content = Array.isArray(props[baseKey]) ? props[baseKey][0] : props[baseKey];\n return content && content.url ? content.url : '';\n }\n return '';\n};\n\nexport default getLinkToPublishedContent;\n"],"file":"get-link-to-published-content.js"}
@@ -21,6 +21,7 @@ const getRelationEntity = (filterName, filterEntityRelations) => {
21
21
  const getFilterProps = (filter, {
22
22
  relations: currentEntityRelations = [],
23
23
  properties: currentEntityProperties = {},
24
+ dynamicProperties: currentEntityDynamicProperties = {},
24
25
  identifier: currentEntityId
25
26
  } = {}, {
26
27
  relations: filterEntityRelations = [],
@@ -28,7 +29,7 @@ const getFilterProps = (filter, {
28
29
  } = {}) => {
29
30
  const [filterName] = filter.split('/');
30
31
  const [relationName, relationProp] = filterName.split('.');
31
- const hasProperty = !!currentEntityProperties[filterName];
32
+ const hasProperty = !!(currentEntityProperties[filterName] || currentEntityDynamicProperties[filterName]);
32
33
  const relationEntityName = relationProp ? getFilterLocalKeys(relationName, currentEntityRelations) : null;
33
34
  const filterNameEntity = getRelationEntity(filterName, filterEntityRelations);
34
35
  const propertyEntityName = relationEntityName || filterNameEntity;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/helpers/get-filter-props.js"],"names":["getFilterRelationKeys","getFilterLocalKeys","relationName","relations","entityIdentifier","find","localField","getRelationEntity","filterName","filterEntityRelations","foreignKey","getFilterProps","filter","currentEntityRelations","properties","currentEntityProperties","identifier","currentEntityId","filteryEntityId","split","relationProp","hasProperty","relationEntityName","filterNameEntity","propertyEntityName","entityName","isEntityItself","shouldCheckRelationNames","relationForeignKeys","shouldIgnoreFilter","length"],"mappings":"AAAA,OAAOA,qBAAP,MAAkC,4BAAlC;;AAEA,MAAMC,kBAAkB,GAAG,CAACC,YAAD,EAAeC,SAAf,KAA6B;AACtD,QAAM;AAAEC,IAAAA;AAAF,MACJD,SAAS,CAACE,IAAV,CAAe,CAAC;AAAEC,IAAAA;AAAF,GAAD,KAAoBA,UAAU,KAAKJ,YAAlD,KAAmE,EADrE;AAEA,SAAOE,gBAAP;AACD,CAJD;;AAMA,MAAMG,iBAAiB,GAAG,CAACC,UAAD,EA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Mc,kBAAkB,GAAGF,wBAAwB,IAAI,CAACC,mBAAmB,CAACE,MAA5E;AAEA,SAAO;AACLtB,IAAAA,UADK;AAELiB,IAAAA,UAFK;AAGLvB,IAAAA,YAHK;AAILkB,IAAAA,YAJK;AAKLC,IAAAA,WALK;AAMLC,IAAAA,kBANK;AAOLI,IAAAA,cAPK;AAQLE,IAAAA,mBARK;AASLC,IAAAA;AATK,GAAP;AAWD,CArCD;;AAuCA,eAAelB,cAAf","sourcesContent":["import getFilterRelationKeys from './get-filter-relation-keys';\n\nconst getFilterLocalKeys = (relationName, relations) => {\n const { entityIdentifier } =\n relations.find(({ localField }) => localField === relationName) || {};\n return entityIdentifier;\n};\n\nconst getRelationEntity = (filterName, filterEntityRelations) => {\n const { entityIdentifier } =\n filterEntityRelations.find(({ foreignKey }) => foreignKey === filterName) || {};\n return entityIdentifier;\n};\n\nconst getFilterProps = (\n filter,\n {\n relations: currentEntityRelations = [],\n properties: currentEntityProperties = {},\n identifier: currentEntityId\n } = {},\n { relations: filterEntityRelations = [], identifier: filteryEntityId } = {}\n) => {\n const [filterName] = filter.split('/');\n const [relationName, relationProp] = filterName.split('.');\n const hasProperty = !!currentEntityProperties[filterName];\n const relationEntityName = relationProp\n ? getFilterLocalKeys(relationName, currentEntityRelations)\n : null;\n const filterNameEntity = getRelationEntity(filterName, filterEntityRelations);\n\n const propertyEntityName = relationEntityName || filterNameEntity;\n const entityName = filterNameEntity ? filteryEntityId : relationEntityName;\n const isEntityItself = currentEntityId === propertyEntityName;\n const shouldCheckRelationNames = !hasProperty && !relationEntityName;\n const relationForeignKeys = shouldCheckRelationNames\n ? getFilterRelationKeys(propertyEntityName, currentEntityRelations, currentEntityProperties)\n : [];\n const shouldIgnoreFilter = shouldCheckRelationNames && !relationForeignKeys.length;\n\n return {\n filterName,\n entityName,\n relationName,\n relationProp,\n hasProperty,\n relationEntityName,\n isEntityItself,\n relationForeignKeys,\n shouldIgnoreFilter\n };\n};\n\nexport default getFilterProps;\n"],"file":"get-filter-props.js"}
1
+ {"version":3,"sources":["../../src/helpers/get-filter-props.js"],"names":["getFilterRelationKeys","getFilterLocalKeys","relationName","relations","entityIdentifier","find","localField","getRelationEntity","filterName","filterEntityRelations","foreignKey","getFilterProps","filter","currentEntityRelations","properties","currentEntityProperties","dynamicProperties","currentEntityDynamicProperties","identifier","currentEntityId","filteryEntityId","split","relationProp","hasProperty","relationEntityName","filterNameEntity","propertyEntityName","entityName","isEntityItself","shouldCheckRelationNames","relationForeignKeys","shouldIgnoreFilter","length"],"mappings":"AAAA,OAAOA,qBAAP,MAAkC,4BAAlC;;AAEA,MAAMC,kBAAkB,GAAG,CAACC,YAAD,EAAeC,SAAf,KAA6B;AACtD,QAAM;AAAEC,IAAAA;AAAF,MACJD,SAAS,CAACE,IAAV,CAAe,CAAC;AAAEC,IAAAA;AAAF,GAAD,KAAoBA,UAAU,KAAKJ,YAAlD,KAAmE,EADrE;AAEA,SAAOE,gBAAP;AACD,CAJD;;AAMA,MAAMG,iBAAiB,GAAG,CAACC,UAAD,EAAaC,qBAAb,KAAuC;AAC/D,QAAM;AAAEL,IAAAA;AAAF,MACJK,qBAAqB,CAACJ,IAAtB,CAA2B,CAAC;AAAEK,IAAAA;AAAF,GAAD,KAAoBA,UAAU,KAAKF,UAA9D,KAA6E,EAD/E;AAEA,SAAOJ,gBAAP;AACD,CAJD;;AAMA,MAAMO,cAAc,GAAG,CACrBC,MADqB,EAErB;AACET,EAAAA,SAAS,EAAEU,sBAAsB,GAAG,EADtC;AAEEC,EAAAA,UAAU,EAAEC,uBAAuB,GAAG,EAFxC;AAGEC,EAAAA,iBAAiB,EAAEC,8BAA8B,GAAG,EAHtD;AAIEC,EAAAA,UAAU,EAAEC;AAJd,IAKI,EAPiB,EAQrB;AAAEhB,EAAAA,SAAS,EAAEM,qBAAqB,GAAG,EAArC;AAAyCS,EAAAA,UAAU,EAAEE;AAArD,IAAyE,EARpD,KASlB;AACH,QAAM,CAACZ,UAAD,IAAeI,MAAM,CAACS,KAAP,CAAa,GAAb,CAArB;AACA,QAAM,CAACnB,YAAD,EAAeoB,YAAf,IAA+Bd,UAAU,CAACa,KAAX,CAAiB,GAAjB,CAArC;AACA,QAAME,WAAW,GAAG,CAAC,EACnBR,uBAAuB,CAACP,UAAD,CAAvB,IAAuCS,8BAA8B,CAACT,UAAD,CADlD,CAArB;AAGA,QAAMgB,kBAAkB,GAAGF,YAAY,GACnCrB,kBAAkB,CAACC,YAAD,EAAeW,sBAAf,CADiB,GAEnC,IAFJ;AAGA,QAAMY,gBAAgB,GAAGlB,iBAAiB,CAACC,UAAD,EAAaC,qBAAb,CAA1C;AAEA,QAAMiB,kBAAkB,GAAGF,kBAAkB,IAAIC,gBAAjD;AACA,QAAME,UAAU,GAAGF,gBAAgB,GAAGL,eAAH,GAAqBI,kBAAxD;AACA,QAAMI,cAAc,GAAGT,eAAe,KAAKO,kBAA3C;AACA,QAAMG,wBAAwB,GAAG,CAACN,WAAD,IAAgB,CAACC,kBAAlD;AACA,QAAMM,mBAAmB,GAAGD,wBAAwB,GAChD7B,qBAAqB,CAAC0B,kBAAD,EAAqBb,sBAArB,EAA6CE,uBAA7C,CAD2B,GAEhD,EAFJ;AAGA,QAAMgB,kBAAkB,GAAGF,wBAAwB,IAAI,CAACC,mBAAmB,CAACE,MAA5E;AAEA,SAAO;AACLxB,IAAAA,UADK;AAELmB,IAAAA,UAFK;AAGLzB,IAAAA,YAHK;AAILoB,IAAAA,YAJK;AAKLC,IAAAA,WALK;AAMLC,IAAAA,kBANK;AAOLI,IAAAA,cAPK;AAQLE,IAAAA,mBARK;AASLC,IAAAA;AATK,GAAP;AAWD,CAxCD;;AA0CA,eAAepB,cAAf","sourcesContent":["import getFilterRelationKeys from './get-filter-relation-keys';\n\nconst getFilterLocalKeys = (relationName, relations) => {\n const { entityIdentifier } =\n relations.find(({ localField }) => localField === relationName) || {};\n return entityIdentifier;\n};\n\nconst getRelationEntity = (filterName, filterEntityRelations) => {\n const { entityIdentifier } =\n filterEntityRelations.find(({ foreignKey }) => foreignKey === filterName) || {};\n return entityIdentifier;\n};\n\nconst getFilterProps = (\n filter,\n {\n relations: currentEntityRelations = [],\n properties: currentEntityProperties = {},\n dynamicProperties: currentEntityDynamicProperties = {},\n identifier: currentEntityId\n } = {},\n { relations: filterEntityRelations = [], identifier: filteryEntityId } = {}\n) => {\n const [filterName] = filter.split('/');\n const [relationName, relationProp] = filterName.split('.');\n const hasProperty = !!(\n currentEntityProperties[filterName] || currentEntityDynamicProperties[filterName]\n );\n const relationEntityName = relationProp\n ? getFilterLocalKeys(relationName, currentEntityRelations)\n : null;\n const filterNameEntity = getRelationEntity(filterName, filterEntityRelations);\n\n const propertyEntityName = relationEntityName || filterNameEntity;\n const entityName = filterNameEntity ? filteryEntityId : relationEntityName;\n const isEntityItself = currentEntityId === propertyEntityName;\n const shouldCheckRelationNames = !hasProperty && !relationEntityName;\n const relationForeignKeys = shouldCheckRelationNames\n ? getFilterRelationKeys(propertyEntityName, currentEntityRelations, currentEntityProperties)\n : [];\n const shouldIgnoreFilter = shouldCheckRelationNames && !relationForeignKeys.length;\n\n return {\n filterName,\n entityName,\n relationName,\n relationProp,\n hasProperty,\n relationEntityName,\n isEntityItself,\n relationForeignKeys,\n shouldIgnoreFilter\n };\n};\n\nexport default getFilterProps;\n"],"file":"get-filter-props.js"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blaze-cms/react-page-builder",
3
- "version": "0.122.0",
3
+ "version": "0.122.1-alpha.0",
4
4
  "description": "Blaze react page builder",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib-es/index.js",
@@ -84,5 +84,5 @@
84
84
  "lib/*",
85
85
  "lib-es/*"
86
86
  ],
87
- "gitHead": "6b11475b1ebacbfc1435fe85b2c82fdf342568fd"
87
+ "gitHead": "4b3ac649b1bf68ec62963ef5c45a66159a199863"
88
88
  }
@@ -1,8 +1,10 @@
1
1
  const getLinkToPublishedContent = (key = '', props = {}) => {
2
2
  if (key.includes('published')) {
3
3
  const [baseKey] = key.split('.');
4
- const content = props[baseKey] && props[baseKey][0];
5
- return content ? content.url : '';
4
+ if (!props[baseKey]) return '';
5
+
6
+ const content = Array.isArray(props[baseKey]) ? props[baseKey][0] : props[baseKey];
7
+ return content && content.url ? content.url : '';
6
8
  }
7
9
  return '';
8
10
  };
@@ -17,13 +17,16 @@ const getFilterProps = (
17
17
  {
18
18
  relations: currentEntityRelations = [],
19
19
  properties: currentEntityProperties = {},
20
+ dynamicProperties: currentEntityDynamicProperties = {},
20
21
  identifier: currentEntityId
21
22
  } = {},
22
23
  { relations: filterEntityRelations = [], identifier: filteryEntityId } = {}
23
24
  ) => {
24
25
  const [filterName] = filter.split('/');
25
26
  const [relationName, relationProp] = filterName.split('.');
26
- const hasProperty = !!currentEntityProperties[filterName];
27
+ const hasProperty = !!(
28
+ currentEntityProperties[filterName] || currentEntityDynamicProperties[filterName]
29
+ );
27
30
  const relationEntityName = relationProp
28
31
  ? getFilterLocalKeys(relationName, currentEntityRelations)
29
32
  : null;
@@ -20,6 +20,12 @@ const GTM_CLASSNAME = 'gtm-classname';
20
20
 
21
21
  const MOCKED_SCHEMA_FOR_FILTERS = {
22
22
  identifier: 'page',
23
+ dynamicProperties: {
24
+ dynamicProp: {
25
+ type: 'string',
26
+ searchable: true
27
+ }
28
+ },
23
29
  relations: [
24
30
  {
25
31
  relationType: 'hasOne',
@@ -2,6 +2,8 @@ import '@testing-library/jest-dom/extend-expect';
2
2
  import { getLinkToPublishedContent } from '../../../../../../src/components/DataSummary/helpers';
3
3
 
4
4
  describe('get link to published content', () => {
5
+ const publishedKey = 'content.published';
6
+ const content = { url: 'url' };
5
7
  it('should be a function', () => {
6
8
  expect(typeof getLinkToPublishedContent).toEqual('function');
7
9
  });
@@ -17,14 +19,26 @@ describe('get link to published content', () => {
17
19
  });
18
20
 
19
21
  it('should return url if key does include "published" and there is related content published', () => {
20
- const props = { content: [{ url: 'url' }] };
21
- const result = getLinkToPublishedContent('content.published', props);
22
- expect(result).toEqual('url');
22
+ const props = { content: [content] };
23
+ const result = getLinkToPublishedContent(publishedKey, props);
24
+ expect(result).toEqual(content.url);
23
25
  });
24
26
 
25
27
  it('should return blank string if key does include "published" but there is no related content published', () => {
28
+ const props = { content: [] };
29
+ const result = getLinkToPublishedContent(publishedKey, props);
30
+ expect(result).toEqual('');
31
+ });
32
+
33
+ it('should return url if key does include "published" and content is not an array', () => {
34
+ const props = { content };
35
+ const result = getLinkToPublishedContent(publishedKey, props);
36
+ expect(result).toEqual(content.url);
37
+ });
38
+
39
+ it('should return blank string if key does include "published" but there is no url', () => {
26
40
  const props = { content: {} };
27
- const result = getLinkToPublishedContent('content.published', props);
41
+ const result = getLinkToPublishedContent(publishedKey, props);
28
42
  expect(result).toEqual('');
29
43
  });
30
44
  });
@@ -55,6 +55,16 @@ describe('getFilterProps function', () => {
55
55
  expect(!!relationProp.relationEntityName).toBe(true);
56
56
  });
57
57
 
58
+ it('should return relationEntityName key as true if relationName exists and matches in schema', () => {
59
+ const dyanmicPropFilter = getFilterProps(
60
+ 'dynamicProp',
61
+ MOCKED_SCHEMA_FOR_FILTERS,
62
+ MOCKED_SCHEMA_FOR_FILTERS
63
+ );
64
+ expect(dyanmicPropFilter).toHaveProperty('hasProperty', true);
65
+ expect(dyanmicPropFilter).toHaveProperty('shouldIgnoreFilter', false);
66
+ });
67
+
58
68
  // todo: add test case
59
69
  // it('should return relationForeignKeys array with values if it isnt a schema or relation prop', () => {
60
70
  // expect(withRelationKeys.relationForeignKeys).toBeDefined();