@blaze-cms/react-page-builder 0.144.0 → 0.145.0-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.145.0-alpha.0](https://github.com/thebyte9/blaze/compare/v0.144.0...v0.145.0-alpha.0) (2024-07-26)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * list component handle id filters ([#4445](https://github.com/thebyte9/blaze/issues/4445)) ([789ae4d](https://github.com/thebyte9/blaze/commit/789ae4d99000656e7d0fea44d129705b6dba11e2))
12
+
13
+
14
+
15
+
16
+
6
17
  # [0.144.0](https://github.com/thebyte9/blaze/compare/v0.144.0-alpha.2...v0.144.0) (2024-07-11)
7
18
 
8
19
  **Note:** Version bump only for package @blaze-cms/react-page-builder
@@ -58,7 +58,6 @@ var buildInheritedFilters = function buildInheritedFilters(entityData, inherited
58
58
  relationEntityName = _getFilterProps.relationEntityName,
59
59
  relationForeignKeys = _getFilterProps.relationForeignKeys,
60
60
  shouldIgnoreFilter = _getFilterProps.shouldIgnoreFilter;
61
- if (filterName === _constants.ID) return;
62
61
  var relationData = getRelationData(entityData, relationName, relationForeignKeys);
63
62
  if (currentEntityId === entityName && (0, _isFilterEntitysId["default"])(filterName, currentEntityId) || shouldIgnoreFilter) {
64
63
  relationFilters.push("".concat(filterName, "/").concat(itemId));
@@ -67,12 +66,13 @@ var buildInheritedFilters = function buildInheritedFilters(entityData, inherited
67
66
  var isDataArray = Array.isArray(relationData);
68
67
  var arrayHasData = checkIfArrayHasData(isDataArray, relationData);
69
68
  if (!relationEntityName) {
70
- var filtersNoRelation = setFiltersNoRelation(isDataArray, arrayHasData, relationData, relationName);
69
+ var filtersNoRelation = setFiltersNoRelation(isDataArray, arrayHasData, relationData, filterName === _constants.ID ? filterName : relationName);
71
70
  relationFilters.push.apply(relationFilters, (0, _toConsumableArray2["default"])(filtersNoRelation));
72
71
  }
73
72
  if (arrayHasData) {
74
73
  var filterValues = relationData.reduce(function (acc, relationValue) {
75
- if (relationValue[relationProp]) acc.push("".concat(filterName, "/").concat(relationValue[relationProp]));
74
+ var filterNameToUse = filterName === _constants.ID ? 'ids' : filterName;
75
+ if (relationValue[relationProp]) acc.push("".concat(filterNameToUse, "/").concat(relationValue[relationProp]));
76
76
  return acc;
77
77
  }, []);
78
78
  relationFilters.push.apply(relationFilters, (0, _toConsumableArray2["default"])(filterValues));
@@ -1 +1 @@
1
- {"version":3,"file":"build-inherited-filters.js","names":["_lodash","_interopRequireDefault","require","_isFilterEntitysId","_getFilterProps2","_constants","getRelationData","entityData","relationName","currentRelationNames","length","arrayOfRelations","map","name","filter","Boolean","flatten","checkIfArrayHasData","isDataArray","relationData","setFiltersNoRelation","arrayHasData","filters","filterValues","reduce","acc","relationValue","_typeof2","push","concat","apply","_toConsumableArray2","buildInheritedFilters","inheritedFilters","currentSchema","filterEntitySchema","itemId","relationFilters","currentEntityId","identifier","forEach","_getFilterProps","getFilterProps","filterName","entityName","relationProp","relationEntityName","relationForeignKeys","shouldIgnoreFilter","ID","isFilterEntitysId","Array","isArray","filtersNoRelation","_default","exports"],"sources":["../../src/helpers/build-inherited-filters.js"],"sourcesContent":["import flatten from 'lodash.flatten';\nimport isFilterEntitysId from './is-filter-entitys-id';\nimport getFilterProps from './get-filter-props';\nimport { ID } from '../constants';\n\nconst getRelationData = (entityData, relationName, currentRelationNames) => {\n if (!entityData) return null;\n if (currentRelationNames && currentRelationNames.length) {\n const arrayOfRelations = currentRelationNames.map(name => entityData[name]).filter(Boolean);\n return arrayOfRelations.length ? flatten(arrayOfRelations) : null;\n }\n return entityData[relationName];\n};\n\nconst checkIfArrayHasData = (isDataArray, relationData) => isDataArray && !!relationData.length;\n\nconst setFiltersNoRelation = (isDataArray, arrayHasData, relationData, relationName) => {\n const filters = [];\n if (arrayHasData) {\n const filterValues = relationData.reduce((acc, relationValue) => {\n if (relationValue && typeof relationValue !== 'object')\n acc.push(`${relationName}/${relationValue}`);\n return acc;\n }, []);\n filters.push(...filterValues);\n } else if (!isDataArray && typeof relationData !== 'object') {\n filters.push(`${relationName}/${relationData}`);\n }\n\n return filters;\n};\nconst buildInheritedFilters = (\n entityData,\n inheritedFilters,\n currentSchema,\n filterEntitySchema,\n itemId\n) => {\n const relationFilters = [];\n const { identifier: currentEntityId } = currentSchema;\n\n inheritedFilters.forEach(filter => {\n const {\n filterName,\n entityName,\n relationName,\n relationProp,\n relationEntityName,\n relationForeignKeys,\n shouldIgnoreFilter\n } = getFilterProps(filter, currentSchema, filterEntitySchema);\n\n if (filterName === ID) return;\n\n const relationData = getRelationData(entityData, relationName, relationForeignKeys);\n if (\n (currentEntityId === entityName && isFilterEntitysId(filterName, currentEntityId)) ||\n shouldIgnoreFilter\n ) {\n relationFilters.push(`${filterName}/${itemId}`);\n }\n\n if (!relationData) return;\n\n const isDataArray = Array.isArray(relationData);\n const arrayHasData = checkIfArrayHasData(isDataArray, relationData);\n\n if (!relationEntityName) {\n const filtersNoRelation = setFiltersNoRelation(\n isDataArray,\n arrayHasData,\n relationData,\n relationName\n );\n relationFilters.push(...filtersNoRelation);\n }\n\n if (arrayHasData) {\n const filterValues = relationData.reduce((acc, relationValue) => {\n if (relationValue[relationProp]) acc.push(`${filterName}/${relationValue[relationProp]}`);\n return acc;\n }, []);\n relationFilters.push(...filterValues);\n } else if (!isDataArray && relationData[relationProp]) {\n relationFilters.push(`${filterName}/${relationData[relationProp]}`);\n }\n });\n\n return relationFilters;\n};\n\nexport default buildInheritedFilters;\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA,IAAAA,OAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,kBAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,gBAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,UAAA,GA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Y,GAAGJ,mBAAmB,CAACC,WAAW,EAAEC,YAAY,CAAC;IAEnE,IAAI,CAAC2B,kBAAkB,EAAE;MACvB,IAAMO,iBAAiB,GAAGjC,oBAAoB,CAC5CF,WAAW,EACXG,YAAY,EACZF,YAAY,EACZX,YACF,CAAC;MACD6B,eAAe,CAACT,IAAI,CAAAE,KAAA,CAApBO,eAAe,MAAAN,mBAAA,aAASsB,iBAAiB,EAAC;IAC5C;IAEA,IAAIhC,YAAY,EAAE;MAChB,IAAME,YAAY,GAAGJ,YAAY,CAACK,MAAM,CAAC,UAACC,GAAG,EAAEC,aAAa,EAAK;QAC/D,IAAIA,aAAa,CAACmB,YAAY,CAAC,EAAEpB,GAAG,CAACG,IAAI,IAAAC,MAAA,CAAIc,UAAU,OAAAd,MAAA,CAAIH,aAAa,CAACmB,YAAY,CAAC,CAAE,CAAC;QACzF,OAAOpB,GAAG;MACZ,CAAC,EAAE,EAAE,CAAC;MACNY,eAAe,CAACT,IAAI,CAAAE,KAAA,CAApBO,eAAe,MAAAN,mBAAA,aAASR,YAAY,EAAC;IACvC,CAAC,MAAM,IAAI,CAACL,WAAW,IAAIC,YAAY,CAAC0B,YAAY,CAAC,EAAE;MACrDR,eAAe,CAACT,IAAI,IAAAC,MAAA,CAAIc,UAAU,OAAAd,MAAA,CAAIV,YAAY,CAAC0B,YAAY,CAAC,CAAE,CAAC;IACrE;EACF,CAAC,CAAC;EAEF,OAAOR,eAAe;AACxB,CAAC;AAAC,IAAAiB,QAAA,GAAAC,OAAA,cAEavB,qBAAqB"}
1
+ {"version":3,"file":"build-inherited-filters.js","names":["_lodash","_interopRequireDefault","require","_isFilterEntitysId","_getFilterProps2","_constants","getRelationData","entityData","relationName","currentRelationNames","length","arrayOfRelations","map","name","filter","Boolean","flatten","checkIfArrayHasData","isDataArray","relationData","setFiltersNoRelation","arrayHasData","filters","filterValues","reduce","acc","relationValue","_typeof2","push","concat","apply","_toConsumableArray2","buildInheritedFilters","inheritedFilters","currentSchema","filterEntitySchema","itemId","relationFilters","currentEntityId","identifier","forEach","_getFilterProps","getFilterProps","filterName","entityName","relationProp","relationEntityName","relationForeignKeys","shouldIgnoreFilter","isFilterEntitysId","Array","isArray","filtersNoRelation","ID","filterNameToUse","_default","exports"],"sources":["../../src/helpers/build-inherited-filters.js"],"sourcesContent":["import flatten from 'lodash.flatten';\nimport isFilterEntitysId from './is-filter-entitys-id';\nimport getFilterProps from './get-filter-props';\nimport { ID } from '../constants';\n\nconst getRelationData = (entityData, relationName, currentRelationNames) => {\n if (!entityData) return null;\n if (currentRelationNames && currentRelationNames.length) {\n const arrayOfRelations = currentRelationNames.map(name => entityData[name]).filter(Boolean);\n return arrayOfRelations.length ? flatten(arrayOfRelations) : null;\n }\n return entityData[relationName];\n};\n\nconst checkIfArrayHasData = (isDataArray, relationData) => isDataArray && !!relationData.length;\n\nconst setFiltersNoRelation = (isDataArray, arrayHasData, relationData, relationName) => {\n const filters = [];\n if (arrayHasData) {\n const filterValues = relationData.reduce((acc, relationValue) => {\n if (relationValue && typeof relationValue !== 'object')\n acc.push(`${relationName}/${relationValue}`);\n return acc;\n }, []);\n filters.push(...filterValues);\n } else if (!isDataArray && typeof relationData !== 'object') {\n filters.push(`${relationName}/${relationData}`);\n }\n\n return filters;\n};\nconst buildInheritedFilters = (\n entityData,\n inheritedFilters,\n currentSchema,\n filterEntitySchema,\n itemId\n) => {\n const relationFilters = [];\n const { identifier: currentEntityId } = currentSchema;\n\n inheritedFilters.forEach(filter => {\n const {\n filterName,\n entityName,\n relationName,\n relationProp,\n relationEntityName,\n relationForeignKeys,\n shouldIgnoreFilter\n } = getFilterProps(filter, currentSchema, filterEntitySchema);\n\n const relationData = getRelationData(entityData, relationName, relationForeignKeys);\n if (\n (currentEntityId === entityName && isFilterEntitysId(filterName, currentEntityId)) ||\n shouldIgnoreFilter\n ) {\n relationFilters.push(`${filterName}/${itemId}`);\n }\n\n if (!relationData) return;\n\n const isDataArray = Array.isArray(relationData);\n const arrayHasData = checkIfArrayHasData(isDataArray, relationData);\n\n if (!relationEntityName) {\n const filtersNoRelation = setFiltersNoRelation(\n isDataArray,\n arrayHasData,\n relationData,\n filterName === ID ? filterName : relationName\n );\n relationFilters.push(...filtersNoRelation);\n }\n\n if (arrayHasData) {\n const filterValues = relationData.reduce((acc, relationValue) => {\n const filterNameToUse = filterName === ID ? 'ids' : filterName;\n if (relationValue[relationProp])\n acc.push(`${filterNameToUse}/${relationValue[relationProp]}`);\n return acc;\n }, []);\n relationFilters.push(...filterValues);\n } else if (!isDataArray && relationData[relationProp]) {\n relationFilters.push(`${filterName}/${relationData[relationProp]}`);\n }\n });\n\n return relationFilters;\n};\n\nexport default buildInheritedFilters;\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA,IAAAA,OAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,kBAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,gBAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,UAAA,GAAAH,OAAA;AAEA,IAAMI,eAAe,GAAG,SAAlBA,eAAeA,CAAIC,UAAU,EAAEC,YAAY,EAAEC,oBAAoB,EAAK;EAC1E,IAAI,CAACF,UAAU,EAAE,OAAO,IAAI;EAC5B,IAAIE,oBAAoB,IAAIA,oBAAoB,CAACC,MAAM,EAAE;IACvD,IAAMC,gBAAgB,GAAGF,oBAAoB,CAACG,GAAG,CAAC,UAAAC,IAAI;MAAA,OAAIN,UAAU,CAACM,IAAI,CAAC;IAAA,EAAC,CAACC,MAAM,CAACC,OAAO,CAAC;IAC3F,OAAOJ,gBAAgB,CAACD,MAAM,GAAG,IAAAM,kBAAO,EAACL,gBAAgB,CAAC,GAAG,IAAI;EACnE;EACA,OAAOJ,UAAU,CAACC,YAAY,CAAC;AACjC,CAAC;AAED,IAAMS,mBAAmB,GAAG,SAAtBA,mBAAmBA,CAAIC,WAAW,EAAEC,YAAY;EAAA,OAAKD,WAAW,IAAI,CAAC,CAACC,YAAY,CA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,CAAC;QAC/D,OAAOpB,GAAG;MACZ,CAAC,EAAE,EAAE,CAAC;MACNY,eAAe,CAACT,IAAI,CAAAE,KAAA,CAApBO,eAAe,MAAAN,mBAAA,aAASR,YAAY,EAAC;IACvC,CAAC,MAAM,IAAI,CAACL,WAAW,IAAIC,YAAY,CAAC0B,YAAY,CAAC,EAAE;MACrDR,eAAe,CAACT,IAAI,IAAAC,MAAA,CAAIc,UAAU,OAAAd,MAAA,CAAIV,YAAY,CAAC0B,YAAY,CAAC,CAAE,CAAC;IACrE;EACF,CAAC,CAAC;EAEF,OAAOR,eAAe;AACxB,CAAC;AAAC,IAAAkB,QAAA,GAAAC,OAAA,cAEaxB,qBAAqB"}
@@ -10,6 +10,7 @@ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/sli
10
10
  require("core-js/modules/es.array.find.js");
11
11
  require("core-js/modules/es.object.to-string.js");
12
12
  var _getFilterRelationKeys = _interopRequireDefault(require("./get-filter-relation-keys"));
13
+ var _constants = require("../constants");
13
14
  var getFilterLocalKeys = function getFilterLocalKeys(relationName, relations) {
14
15
  var _ref = relations.find(function (_ref2) {
15
16
  var localField = _ref2.localField;
@@ -46,6 +47,15 @@ var getFilterProps = function getFilterProps(filter) {
46
47
  _filterName$split2 = (0, _slicedToArray2["default"])(_filterName$split, 2),
47
48
  relationName = _filterName$split2[0],
48
49
  relationProp = _filterName$split2[1];
50
+ if (filterName === _constants.ID) {
51
+ var idRelation = currentEntityRelations.find(function (_ref7) {
52
+ var entityIdentifier = _ref7.entityIdentifier;
53
+ return entityIdentifier === filteryEntityId;
54
+ });
55
+ if (idRelation) {
56
+ relationName = idRelation.foreignKey;
57
+ }
58
+ }
49
59
  var hasProperty = !!(currentEntityProperties[filterName] || currentEntityDynamicProperties[filterName]);
50
60
  var relationEntityName = relationProp ? getFilterLocalKeys(relationName, currentEntityRelations) : null;
51
61
  var filterNameEntity = getRelationEntity(filterName, filterEntityRelations);
@@ -1 +1 @@
1
- {"version":3,"file":"get-filter-props.js","names":["_getFilterRelationKeys","_interopRequireDefault","require","getFilterLocalKeys","relationName","relations","_ref","find","_ref2","localField","entityIdentifier","getRelationEntity","filterName","filterEntityRelations","_ref3","_ref4","foreignKey","getFilterProps","filter","_ref5","arguments","length","undefined","_ref5$relations","currentEntityRelations","_ref5$properties","properties","currentEntityProperties","_ref5$dynamicProperti","dynamicProperties","currentEntityDynamicProperties","currentEntityId","identifier","_ref6","_ref6$relations","filteryEntityId","_filter$split","split","_filter$split2","_slicedToArray2","_filterName$split","_filterName$split2","relationProp","hasProperty","relationEntityName","filterNameEntity","propertyEntityName","entityName","isEntityItself","shouldCheckRelationNames","relationForeignKeys","getFilterRelationKeys","shouldIgnoreFilter","_default","exports"],"sources":["../../src/helpers/get-filter-props.js"],"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"],"mappings":";;;;;;;;;;;AAAA,IAAAA,sBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAMC,kBAAkB,GAAG,SAArBA,kBAAkBA,CAAIC,YAAY,EAAEC,SAAS,EAAK;EACtD,IAAAC,IAAA,GACED,SAAS,CAACE,IAAI,CAAC,UAAAC,KAAA;MAAA,IAAGC,UAAU,GAAAD,KAAA,CAAVC,UAAU;MAAA,OAAOA,UAAU,KAAKL,YAAY;IAAA,EAAC,IAAI,CAAC,CAAC;IAD/DM,gBAAgB,GAAAJ,IAAA,CAAhBI,gBAAgB;EAExB,OAAOA,gBAAgB;AACzB,CAAC;AAED,IAAMC,iBAAiB,GAAG,SAApBA,iBAAiBA,CAAIC,UAAU,EAAEC,qBAAqB,EAAK;EAC/D,IAAAC,KAAA,GACED,qBAAqB,CAACN,IAAI,CAAC,UAAAQ,KAAA;MAAA,IAAGC,UAAU,GAAAD,KAAA,CAAVC,UAAU;MAAA,OAAOA,UAAU,KAAKJ,UAAU;IAAA,EAAC,IAAI,CAAC,CAAC;IADzEF,gBAAgB,GAAAI,KAAA,CAAhBJ,gBAAgB;EAExB,OAAOA,gBAAgB;AACzB,CAAC;AAED,IAAMO,cAAc,GAAG,SAAjBA,cAAcA,CAClBC,MAAM,EAQH;EAAA,IAAAC,KAAA,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAFC,CAAC,CAAC;IAAAG,eAAA,GAAAJ,KAAA,CAJJd,SAAS;IAAEmB,sBAAsB,GAAAD,eAAA,cAAG,EAAE,GAAA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GjB,eAAe,KAAKe,kBAAkB;EAC7D,IAAMG,wBAAwB,GAAG,CAACN,WAAW,IAAI,CAACC,kBAAkB;EACpE,IAAMM,mBAAmB,GAAGD,wBAAwB,GAChD,IAAAE,iCAAqB,EAACL,kBAAkB,EAAEtB,sBAAsB,EAAEG,uBAAuB,CAAC,GAC1F,EAAE;EACN,IAAMyB,kBAAkB,GAAGH,wBAAwB,IAAI,CAACC,mBAAmB,CAAC7B,MAAM;EAElF,OAAO;IACLT,UAAU,EAAVA,UAAU;IACVmC,UAAU,EAAVA,UAAU;IACV3C,YAAY,EAAZA,YAAY;IACZsC,YAAY,EAAZA,YAAY;IACZC,WAAW,EAAXA,WAAW;IACXC,kBAAkB,EAAlBA,kBAAkB;IAClBI,cAAc,EAAdA,cAAc;IACdE,mBAAmB,EAAnBA,mBAAmB;IACnBE,kBAAkB,EAAlBA;EACF,CAAC;AACH,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,cAEarC,cAAc"}
1
+ {"version":3,"file":"get-filter-props.js","names":["_getFilterRelationKeys","_interopRequireDefault","require","_constants","getFilterLocalKeys","relationName","relations","_ref","find","_ref2","localField","entityIdentifier","getRelationEntity","filterName","filterEntityRelations","_ref3","_ref4","foreignKey","getFilterProps","filter","_ref5","arguments","length","undefined","_ref5$relations","currentEntityRelations","_ref5$properties","properties","currentEntityProperties","_ref5$dynamicProperti","dynamicProperties","currentEntityDynamicProperties","currentEntityId","identifier","_ref6","_ref6$relations","filteryEntityId","_filter$split","split","_filter$split2","_slicedToArray2","_filterName$split","_filterName$split2","relationProp","ID","idRelation","_ref7","hasProperty","relationEntityName","filterNameEntity","propertyEntityName","entityName","isEntityItself","shouldCheckRelationNames","relationForeignKeys","getFilterRelationKeys","shouldIgnoreFilter","_default","exports"],"sources":["../../src/helpers/get-filter-props.js"],"sourcesContent":["import getFilterRelationKeys from './get-filter-relation-keys';\nimport { ID } from '../constants';\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 let [relationName, relationProp] = filterName.split('.');\n\n if (filterName === ID) {\n const idRelation = currentEntityRelations.find(\n ({ entityIdentifier }) => entityIdentifier === filteryEntityId\n );\n if (idRelation) {\n relationName = idRelation.foreignKey;\n }\n }\n\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"],"mappings":";;;;;;;;;;;AAAA,IAAAA,sBAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AAEA,IAAME,kBAAkB,GAAG,SAArBA,kBAAkBA,CAAIC,YAAY,EAAEC,SAAS,EAAK;EACtD,IAAAC,IAAA,GACED,S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BAAwB,GAChD,IAAAE,iCAAqB,EAACL,kBAAkB,EAAEzB,sBAAsB,EAAEG,uBAAuB,CAAC,GAC1F,EAAE;EACN,IAAM4B,kBAAkB,GAAGH,wBAAwB,IAAI,CAACC,mBAAmB,CAAChC,MAAM;EAElF,OAAO;IACLT,UAAU,EAAVA,UAAU;IACVsC,UAAU,EAAVA,UAAU;IACV9C,YAAY,EAAZA,YAAY;IACZsC,YAAY,EAAZA,YAAY;IACZI,WAAW,EAAXA,WAAW;IACXC,kBAAkB,EAAlBA,kBAAkB;IAClBI,cAAc,EAAdA,cAAc;IACdE,mBAAmB,EAAnBA,mBAAmB;IACnBE,kBAAkB,EAAlBA;EACF,CAAC;AACH,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,cAEaxC,cAAc"}
@@ -39,7 +39,6 @@ const buildInheritedFilters = (entityData, inheritedFilters, currentSchema, filt
39
39
  relationForeignKeys,
40
40
  shouldIgnoreFilter
41
41
  } = getFilterProps(filter, currentSchema, filterEntitySchema);
42
- if (filterName === ID) return;
43
42
  const relationData = getRelationData(entityData, relationName, relationForeignKeys);
44
43
  if (currentEntityId === entityName && isFilterEntitysId(filterName, currentEntityId) || shouldIgnoreFilter) {
45
44
  relationFilters.push(`${filterName}/${itemId}`);
@@ -48,12 +47,13 @@ const buildInheritedFilters = (entityData, inheritedFilters, currentSchema, filt
48
47
  const isDataArray = Array.isArray(relationData);
49
48
  const arrayHasData = checkIfArrayHasData(isDataArray, relationData);
50
49
  if (!relationEntityName) {
51
- const filtersNoRelation = setFiltersNoRelation(isDataArray, arrayHasData, relationData, relationName);
50
+ const filtersNoRelation = setFiltersNoRelation(isDataArray, arrayHasData, relationData, filterName === ID ? filterName : relationName);
52
51
  relationFilters.push(...filtersNoRelation);
53
52
  }
54
53
  if (arrayHasData) {
55
54
  const filterValues = relationData.reduce((acc, relationValue) => {
56
- if (relationValue[relationProp]) acc.push(`${filterName}/${relationValue[relationProp]}`);
55
+ const filterNameToUse = filterName === ID ? 'ids' : filterName;
56
+ if (relationValue[relationProp]) acc.push(`${filterNameToUse}/${relationValue[relationProp]}`);
57
57
  return acc;
58
58
  }, []);
59
59
  relationFilters.push(...filterValues);
@@ -1 +1 @@
1
- {"version":3,"file":"build-inherited-filters.js","names":["flatten","isFilterEntitysId","getFilterProps","ID","getRelationData","entityData","relationName","currentRelationNames","length","arrayOfRelations","map","name","filter","Boolean","checkIfArrayHasData","isDataArray","relationData","setFiltersNoRelation","arrayHasData","filters","filterValues","reduce","acc","relationValue","push","buildInheritedFilters","inheritedFilters","currentSchema","filterEntitySchema","itemId","relationFilters","identifier","currentEntityId","forEach","filterName","entityName","relationProp","relationEntityName","relationForeignKeys","shouldIgnoreFilter","Array","isArray","filtersNoRelation"],"sources":["../../src/helpers/build-inherited-filters.js"],"sourcesContent":["import flatten from 'lodash.flatten';\nimport isFilterEntitysId from './is-filter-entitys-id';\nimport getFilterProps from './get-filter-props';\nimport { ID } from '../constants';\n\nconst getRelationData = (entityData, relationName, currentRelationNames) => {\n if (!entityData) return null;\n if (currentRelationNames && currentRelationNames.length) {\n const arrayOfRelations = currentRelationNames.map(name => entityData[name]).filter(Boolean);\n return arrayOfRelations.length ? flatten(arrayOfRelations) : null;\n }\n return entityData[relationName];\n};\n\nconst checkIfArrayHasData = (isDataArray, relationData) => isDataArray && !!relationData.length;\n\nconst setFiltersNoRelation = (isDataArray, arrayHasData, relationData, relationName) => {\n const filters = [];\n if (arrayHasData) {\n const filterValues = relationData.reduce((acc, relationValue) => {\n if (relationValue && typeof relationValue !== 'object')\n acc.push(`${relationName}/${relationValue}`);\n return acc;\n }, []);\n filters.push(...filterValues);\n } else if (!isDataArray && typeof relationData !== 'object') {\n filters.push(`${relationName}/${relationData}`);\n }\n\n return filters;\n};\nconst buildInheritedFilters = (\n entityData,\n inheritedFilters,\n currentSchema,\n filterEntitySchema,\n itemId\n) => {\n const relationFilters = [];\n const { identifier: currentEntityId } = currentSchema;\n\n inheritedFilters.forEach(filter => {\n const {\n filterName,\n entityName,\n relationName,\n relationProp,\n relationEntityName,\n relationForeignKeys,\n shouldIgnoreFilter\n } = getFilterProps(filter, currentSchema, filterEntitySchema);\n\n if (filterName === ID) return;\n\n const relationData = getRelationData(entityData, relationName, relationForeignKeys);\n if (\n (currentEntityId === entityName && isFilterEntitysId(filterName, currentEntityId)) ||\n shouldIgnoreFilter\n ) {\n relationFilters.push(`${filterName}/${itemId}`);\n }\n\n if (!relationData) return;\n\n const isDataArray = Array.isArray(relationData);\n const arrayHasData = checkIfArrayHasData(isDataArray, relationData);\n\n if (!relationEntityName) {\n const filtersNoRelation = setFiltersNoRelation(\n isDataArray,\n arrayHasData,\n relationData,\n relationName\n );\n relationFilters.push(...filtersNoRelation);\n }\n\n if (arrayHasData) {\n const filterValues = relationData.reduce((acc, relationValue) => {\n if (relationValue[relationProp]) acc.push(`${filterName}/${relationValue[relationProp]}`);\n return acc;\n }, []);\n relationFilters.push(...filterValues);\n } else if (!isDataArray && relationData[relationProp]) {\n relationFilters.push(`${filterName}/${relationData[relationProp]}`);\n }\n });\n\n return relationFilters;\n};\n\nexport default buildInheritedFilters;\n"],"mappings":"AAAA,OAAOA,OAAO,MAAM,gBAAgB;AACpC,OAAOC,iBAAiB,MAAM,wBAAwB;AACtD,OAAOC,cAAc,MAAM,oBAAoB;AAC/C,SAASC,EAAE,QAAQ,cAAc;AAEjC,MAAMC,eAAe,GAAGA,CAACC,UAAU,EAAEC,YAAY,EAAEC,oBAAoB,KAAK;EAC1E,IAAI,CAACF,UAAU,EAAE,OAAO,IAAI;EAC5B,IAAIE,oBAAoB,IAAIA,oBAAoB,CAACC,MAAM,EAAE;IACvD,MAAMC,gBAAgB,GAAGF,oBAAoB,CAACG,GAAG,CAACC,IAAI,IAAIN,UAAU,CAACM,IAAI,CAAC,CAAC,CAACC,MAAM,CAACC,OAAO,CAAC;IAC3F,OAAOJ,gBAAgB,CAACD,MAAM,GAAGR,OAAO,CAACS,gBAAgB,CAAC,GAAG,IAAI;EACn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js","names":["flatten","isFilterEntitysId","getFilterProps","ID","getRelationData","entityData","relationName","currentRelationNames","length","arrayOfRelations","map","name","filter","Boolean","checkIfArrayHasData","isDataArray","relationData","setFiltersNoRelation","arrayHasData","filters","filterValues","reduce","acc","relationValue","push","buildInheritedFilters","inheritedFilters","currentSchema","filterEntitySchema","itemId","relationFilters","identifier","currentEntityId","forEach","filterName","entityName","relationProp","relationEntityName","relationForeignKeys","shouldIgnoreFilter","Array","isArray","filtersNoRelation","filterNameToUse"],"sources":["../../src/helpers/build-inherited-filters.js"],"sourcesContent":["import flatten from 'lodash.flatten';\nimport isFilterEntitysId from './is-filter-entitys-id';\nimport getFilterProps from './get-filter-props';\nimport { ID } from '../constants';\n\nconst getRelationData = (entityData, relationName, currentRelationNames) => {\n if (!entityData) return null;\n if (currentRelationNames && currentRelationNames.length) {\n const arrayOfRelations = currentRelationNames.map(name => entityData[name]).filter(Boolean);\n return arrayOfRelations.length ? flatten(arrayOfRelations) : null;\n }\n return entityData[relationName];\n};\n\nconst checkIfArrayHasData = (isDataArray, relationData) => isDataArray && !!relationData.length;\n\nconst setFiltersNoRelation = (isDataArray, arrayHasData, relationData, relationName) => {\n const filters = [];\n if (arrayHasData) {\n const filterValues = relationData.reduce((acc, relationValue) => {\n if (relationValue && typeof relationValue !== 'object')\n acc.push(`${relationName}/${relationValue}`);\n return acc;\n }, []);\n filters.push(...filterValues);\n } else if (!isDataArray && typeof relationData !== 'object') {\n filters.push(`${relationName}/${relationData}`);\n }\n\n return filters;\n};\nconst buildInheritedFilters = (\n entityData,\n inheritedFilters,\n currentSchema,\n filterEntitySchema,\n itemId\n) => {\n const relationFilters = [];\n const { identifier: currentEntityId } = currentSchema;\n\n inheritedFilters.forEach(filter => {\n const {\n filterName,\n entityName,\n relationName,\n relationProp,\n relationEntityName,\n relationForeignKeys,\n shouldIgnoreFilter\n } = getFilterProps(filter, currentSchema, filterEntitySchema);\n\n const relationData = getRelationData(entityData, relationName, relationForeignKeys);\n if (\n (currentEntityId === entityName && isFilterEntitysId(filterName, currentEntityId)) ||\n shouldIgnoreFilter\n ) {\n relationFilters.push(`${filterName}/${itemId}`);\n }\n\n if (!relationData) return;\n\n const isDataArray = Array.isArray(relationData);\n const arrayHasData = checkIfArrayHasData(isDataArray, relationData);\n\n if (!relationEntityName) {\n const filtersNoRelation = setFiltersNoRelation(\n isDataArray,\n arrayHasData,\n relationData,\n filterName === ID ? filterName : relationName\n );\n relationFilters.push(...filtersNoRelation);\n }\n\n if (arrayHasData) {\n const filterValues = relationData.reduce((acc, relationValue) => {\n const filterNameToUse = filterName === ID ? 'ids' : filterName;\n if (relationValue[relationProp])\n acc.push(`${filterNameToUse}/${relationValue[relationProp]}`);\n return acc;\n }, []);\n relationFilters.push(...filterValues);\n } else if (!isDataArray && relationData[relationProp]) {\n relationFilters.push(`${filterName}/${relationData[relationProp]}`);\n }\n });\n\n return relationFilters;\n};\n\nexport default buildInheritedFilters;\n"],"mappings":"AAAA,OAAOA,OAAO,MAAM,gBAAgB;AACpC,OAAOC,iBAAiB,MAAM,wBAAwB;AACtD,OAAOC,cAAc,MAAM,oBAAoB;AAC/C,SAASC,EAAE,QAAQ,cAAc;AAEjC,MAAMC,eAAe,GAAGA,CAACC,UAAU,EAAEC,YAAY,EAAEC,oBAAoB,KAAK;EAC1E,IAAI,CAACF,UAAU,EAAE,OAAO,IAAI;EAC5B,IAAIE,oBAAoB,IAAIA,oBAAoB,CAACC,MAAM,EAAE;IACvD,MAAMC,gBAAgB,GAAGF,oBAAoB,CAACG,GAAG,CAACC,IAAI,IAAIN,UAAU,CAACM,IAAI,CAAC,CAAC,CAACC,MAAM,CAACC,OAAO,CAAC;IAC3F,OAAOJ,gBAAgB,CAACD,MAAM,GAAGR,OAAO,CAACS,gBAAgB,CAAC,GAAG,IAAI;EACnE;EACA,OAAOJ,UAAU,CAACC,YAAY,CAAC;AACjC,CAAC;AAED,MAAMQ,mBAAmB,GAAGA,CAACC,WAAW,EAAEC,YAAY,KAAKD,W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';
2
+ import { ID } from '../constants';
2
3
  const getFilterLocalKeys = (relationName, relations) => {
3
4
  const {
4
5
  entityIdentifier
@@ -25,7 +26,15 @@ const getFilterProps = (filter, {
25
26
  identifier: filteryEntityId
26
27
  } = {}) => {
27
28
  const [filterName] = filter.split('/');
28
- const [relationName, relationProp] = filterName.split('.');
29
+ let [relationName, relationProp] = filterName.split('.');
30
+ if (filterName === ID) {
31
+ const idRelation = currentEntityRelations.find(({
32
+ entityIdentifier
33
+ }) => entityIdentifier === filteryEntityId);
34
+ if (idRelation) {
35
+ relationName = idRelation.foreignKey;
36
+ }
37
+ }
29
38
  const hasProperty = !!(currentEntityProperties[filterName] || currentEntityDynamicProperties[filterName]);
30
39
  const relationEntityName = relationProp ? getFilterLocalKeys(relationName, currentEntityRelations) : null;
31
40
  const filterNameEntity = getRelationEntity(filterName, filterEntityRelations);
@@ -1 +1 @@
1
- {"version":3,"file":"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"],"sources":["../../src/helpers/get-filter-props.js"],"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"],"mappings":"AAAA,OAAOA,qBAAqB,MAAM,4BAA4B;AAE9D,MAAMC,kBAAkB,GAAGA,CAACC,YAAY,EAAEC,SAAS,KAAK;EACtD,MAAM;IAAEC;EAAiB,CAAC,GACxBD,SAAS,CAACE,IAAI,CAAC,CAAC;IAAEC;EAAW,CAAC,KAAKA,UAAU,KAAKJ,YAAY,CAAC,IAAI,CAAC,CAAC;EACvE,OAAOE,gBAAgB;AACzB,CAAC;AAED,MAAMG,iBAAiB,GAAGA,CAACC,UAAU,EAAEC,qBAAqB,KAAK;EAC/D,MAAM;IAAEL;EAAiB,CAAC,GACxBK,qBAAqB,CAACJ,IAAI,CAAC,CAAC;IAAEK;EAAW,CAAC,KAAKA,UAAU,KAAKF,UAAU,CAAC,IAAI,CAAC,CAAC;EACjF,OAAOJ,gBAAgB;AACzB,CAAC;AAED,MAAMO,cAAc,GAAGA,CACrBC,MAAM,EACN;EACET,SAAS,EAAEU,sBAAsB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AmB;IACnBC;EACF,CAAC;AACH,CAAC;AAED,eAAepB,cAAc"}
1
+ {"version":3,"file":"get-filter-props.js","names":["getFilterRelationKeys","ID","getFilterLocalKeys","relationName","relations","entityIdentifier","find","localField","getRelationEntity","filterName","filterEntityRelations","foreignKey","getFilterProps","filter","currentEntityRelations","properties","currentEntityProperties","dynamicProperties","currentEntityDynamicProperties","identifier","currentEntityId","filteryEntityId","split","relationProp","idRelation","hasProperty","relationEntityName","filterNameEntity","propertyEntityName","entityName","isEntityItself","shouldCheckRelationNames","relationForeignKeys","shouldIgnoreFilter","length"],"sources":["../../src/helpers/get-filter-props.js"],"sourcesContent":["import getFilterRelationKeys from './get-filter-relation-keys';\nimport { ID } from '../constants';\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 let [relationName, relationProp] = filterName.split('.');\n\n if (filterName === ID) {\n const idRelation = currentEntityRelations.find(\n ({ entityIdentifier }) => entityIdentifier === filteryEntityId\n );\n if (idRelation) {\n relationName = idRelation.foreignKey;\n }\n }\n\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"],"mappings":"AAAA,OAAOA,qBAAqB,MAAM,4BAA4B;AAC9D,SAASC,EAAE,QAAQ,cAAc;AAEjC,MAAMC,kBAAkB,GAAGA,CAACC,YAAY,EAAEC,SAAS,KAAK;EACtD,MAAM;IAAEC;EAAiB,CAAC,GACxBD,SAAS,CAACE,IAAI,CAAC,CAAC;IAAEC;EAAW,CAAC,KAAKA,UAAU,KAAKJ,YAAY,CAAC,IAAI,CAAC,CAAC;EACvE,OAAOE,gBAAgB;AACzB,CAAC;AAED,MAAMG,iBAAiB,GAAGA,CAACC,UAAU,EAAEC,qBAAqB,KAAK;EAC/D,MAAM;IAAEL;EAAiB,CAAC,GACxBK,qBAAqB,CAACJ,IAAI,CAAC,CAAC;IAAEK;EAAW,CAAC,KAAKA,UAAU,KAAKF,UAAU,CAAC,IAAI,CAAC,CAAC;EACjF,OAAOJ,gBAAgB;AACzB,CAAC;AAED,MAAMO,cAAc,GAAGA,CACrBC,MAAM,EACN;EACET,SAAS,EAAEU,sBAAsB,GAAG,EAAE;EACtCC,UAAU,EAAEC,uBAAuB,GAAG,CAAC,CAAC;EACxCC,iBAAiB,EAAEC,8BAA8B,GAAG,CAAC,CAAC;EACtDC,UAAU,EAAEC;AACd,CAAC,GAAG,CAAC,CAAC,EACN;EAAEhB,SAAS,EAAEM,qBAAqB,GAAG,EAAE;EAAES,UAAU,EAAEE;AAAgB,CAAC,GAAG,CAAC,CAAC,KACxE;EACH,MAAM,CAACZ,UAAU,CAAC,GAAGI,MAAM,CAACS,KAA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@
1
1
  {
2
2
  "name": "@blaze-cms/react-page-builder",
3
- "version": "0.144.0",
3
+ "version": "0.145.0-alpha.0",
4
4
  "description": "Blaze react page builder",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib-es/index.js",
@@ -90,5 +90,5 @@
90
90
  "lib/*",
91
91
  "lib-es/*"
92
92
  ],
93
- "gitHead": "b131477abe0ded343fad13df715df146c60e196b"
93
+ "gitHead": "3a7ae260bafa6417c642d254d5e5a43ee629df3f"
94
94
  }
@@ -50,8 +50,6 @@ const buildInheritedFilters = (
50
50
  shouldIgnoreFilter
51
51
  } = getFilterProps(filter, currentSchema, filterEntitySchema);
52
52
 
53
- if (filterName === ID) return;
54
-
55
53
  const relationData = getRelationData(entityData, relationName, relationForeignKeys);
56
54
  if (
57
55
  (currentEntityId === entityName && isFilterEntitysId(filterName, currentEntityId)) ||
@@ -70,14 +68,16 @@ const buildInheritedFilters = (
70
68
  isDataArray,
71
69
  arrayHasData,
72
70
  relationData,
73
- relationName
71
+ filterName === ID ? filterName : relationName
74
72
  );
75
73
  relationFilters.push(...filtersNoRelation);
76
74
  }
77
75
 
78
76
  if (arrayHasData) {
79
77
  const filterValues = relationData.reduce((acc, relationValue) => {
80
- if (relationValue[relationProp]) acc.push(`${filterName}/${relationValue[relationProp]}`);
78
+ const filterNameToUse = filterName === ID ? 'ids' : filterName;
79
+ if (relationValue[relationProp])
80
+ acc.push(`${filterNameToUse}/${relationValue[relationProp]}`);
81
81
  return acc;
82
82
  }, []);
83
83
  relationFilters.push(...filterValues);
@@ -1,4 +1,5 @@
1
1
  import getFilterRelationKeys from './get-filter-relation-keys';
2
+ import { ID } from '../constants';
2
3
 
3
4
  const getFilterLocalKeys = (relationName, relations) => {
4
5
  const { entityIdentifier } =
@@ -23,7 +24,17 @@ const getFilterProps = (
23
24
  { relations: filterEntityRelations = [], identifier: filteryEntityId } = {}
24
25
  ) => {
25
26
  const [filterName] = filter.split('/');
26
- const [relationName, relationProp] = filterName.split('.');
27
+ let [relationName, relationProp] = filterName.split('.');
28
+
29
+ if (filterName === ID) {
30
+ const idRelation = currentEntityRelations.find(
31
+ ({ entityIdentifier }) => entityIdentifier === filteryEntityId
32
+ );
33
+ if (idRelation) {
34
+ relationName = idRelation.foreignKey;
35
+ }
36
+ }
37
+
27
38
  const hasProperty = !!(
28
39
  currentEntityProperties[filterName] || currentEntityDynamicProperties[filterName]
29
40
  );
@@ -78,6 +78,19 @@ const MOCKED_SCHEMA_FOR_FILTERS = {
78
78
  searchable: true,
79
79
  onDeleteAction: 'unset'
80
80
  },
81
+ {
82
+ relationType: 'hasMany',
83
+ entityIdentifier: 'page',
84
+ foreignKey: 'relatedPageIds',
85
+ localField: 'relatedPages',
86
+ description: 'Related pages',
87
+ label: 'Related Profiles',
88
+ showInForm: true,
89
+ displayFormName: 'Related Profiles',
90
+ formPriority: 3.11,
91
+ formFieldType: 'relationStandard',
92
+ searchable: false
93
+ },
81
94
  {
82
95
  relationType: 'hasMany',
83
96
  entityIdentifier: 'profile',
@@ -13,11 +13,13 @@ const entityData = {
13
13
  yachts: [{ id: 'some' }],
14
14
  image: { name: 'image name' },
15
15
  tags: [{ name: 'tag1' }, { name: 'tag2' }],
16
- brokers: [{ price: 1 }]
16
+ brokers: [{ price: 1 }],
17
+ relatedPageIds: ['related-page-id']
17
18
  };
18
19
 
19
20
  const filterByProperty = ['category.name/category'];
20
21
  const filterByPropertyMoreData = [
22
+ 'id/page',
21
23
  'category.name/category',
22
24
  'image.name/image',
23
25
  'tags.name/tags',
@@ -84,6 +86,8 @@ describe('build inherited filters', () => {
84
86
 
85
87
  it('should return an array with filter set for more relations', () => {
86
88
  expect(relationFiltersMoreData).toEqual([
89
+ 'id/page-id',
90
+ 'id/related-page-id',
87
91
  'category.name/cat',
88
92
  'image.name/page-id',
89
93
  'image.name/image name',
@@ -65,6 +65,15 @@ describe('getFilterProps function', () => {
65
65
  expect(dyanmicPropFilter).toHaveProperty('shouldIgnoreFilter', false);
66
66
  });
67
67
 
68
+ it('should return relation foriegnKey for matching relaiton entity for id propery', () => {
69
+ const dyanmicPropFilter = getFilterProps(
70
+ 'id',
71
+ MOCKED_SCHEMA_FOR_FILTERS,
72
+ MOCKED_SCHEMA_FOR_FILTERS
73
+ );
74
+ expect(dyanmicPropFilter).toHaveProperty('relationName', 'relatedPageIds');
75
+ });
76
+
68
77
  // todo: add test case
69
78
  // it('should return relationForeignKeys array with values if it isnt a schema or relation prop', () => {
70
79
  // expect(withRelationKeys.relationForeignKeys).toBeDefined();