@blaze-cms/react-page-builder 0.130.0-admin-updates.6 → 0.130.0-admin-updates.9

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.
Files changed (43) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/lib/components/Card/CardsRender.js +13 -6
  3. package/lib/components/Card/CardsRender.js.map +1 -1
  4. package/lib/components/Card/helpers/get-updated-items-to-display.js +55 -0
  5. package/lib/components/Card/helpers/get-updated-items-to-display.js.map +1 -0
  6. package/lib/components/Card/helpers/index.js +7 -0
  7. package/lib/components/Card/helpers/index.js.map +1 -1
  8. package/lib/components/SearchContent/SearchContentItems.js +1 -1
  9. package/lib/components/SearchContent/SearchContentItems.js.map +1 -1
  10. package/lib/helpers/build-inherited-filters.js +2 -0
  11. package/lib/helpers/build-inherited-filters.js.map +1 -1
  12. package/lib/helpers/build-props-query.js +5 -2
  13. package/lib/helpers/build-props-query.js.map +1 -1
  14. package/lib/helpers/build-set-filters.js +5 -1
  15. package/lib/helpers/build-set-filters.js.map +1 -1
  16. package/lib/helpers/get-query-props.js +13 -2
  17. package/lib/helpers/get-query-props.js.map +1 -1
  18. package/lib-es/components/Card/CardsRender.js +14 -7
  19. package/lib-es/components/Card/CardsRender.js.map +1 -1
  20. package/lib-es/components/Card/helpers/get-updated-items-to-display.js +32 -0
  21. package/lib-es/components/Card/helpers/get-updated-items-to-display.js.map +1 -0
  22. package/lib-es/components/Card/helpers/index.js +1 -0
  23. package/lib-es/components/Card/helpers/index.js.map +1 -1
  24. package/lib-es/components/SearchContent/SearchContentItems.js +1 -1
  25. package/lib-es/components/SearchContent/SearchContentItems.js.map +1 -1
  26. package/lib-es/helpers/build-inherited-filters.js +2 -0
  27. package/lib-es/helpers/build-inherited-filters.js.map +1 -1
  28. package/lib-es/helpers/build-props-query.js +4 -2
  29. package/lib-es/helpers/build-props-query.js.map +1 -1
  30. package/lib-es/helpers/build-set-filters.js +5 -1
  31. package/lib-es/helpers/build-set-filters.js.map +1 -1
  32. package/lib-es/helpers/get-query-props.js +10 -2
  33. package/lib-es/helpers/get-query-props.js.map +1 -1
  34. package/package.json +3 -3
  35. package/src/components/Card/CardsRender.js +27 -7
  36. package/src/components/Card/helpers/get-updated-items-to-display.js +32 -0
  37. package/src/components/Card/helpers/index.js +1 -0
  38. package/src/helpers/build-inherited-filters.js +3 -1
  39. package/src/helpers/build-props-query.js +4 -2
  40. package/src/helpers/build-set-filters.js +2 -1
  41. package/src/helpers/get-query-props.js +12 -4
  42. package/tests/unit/src/components/Card/helpers/get-updated-items-to-display.test.js +72 -0
  43. package/tests/unit/src/helpers/build-props-query.test.js +25 -0
@@ -13,7 +13,7 @@ import { generateSingleItemQuery } from '../../application/query';
13
13
  import { SEARCH_PUBLISHED_CONTENT, AND } from '../../constants';
14
14
  import { useGetEntitySchemasAsObj, useGetImages } from '../../hooks';
15
15
  import { getUpdatedFilterBy, getEntityData, getRequiredSchemas, sortResponseData, getUnpublishedEntityName, renderChildren, splitChildren, removeExtraItems, appendImages } from '../../helpers';
16
- import { filtersSetup, filterQuerySetup, shouldSkipSingleQuery, shouldReturn, getUpdatedSortProperties } from './helpers';
16
+ import { filtersSetup, filterQuerySetup, shouldSkipSingleQuery, shouldReturn, getUpdatedSortProperties, getUpdatedItemsToDisplay } from './helpers';
17
17
  const CardsContainer = dynamic(() => import('./CardsContainer'));
18
18
  const CardsRender = _ref => {
19
19
  let {
@@ -104,6 +104,12 @@ const CardsRender = _ref => {
104
104
  error: schemaError
105
105
  } = useGetEntitySchemasAsObj(getRequiredSchemas([...filterByProperty, ...sortbyFilters], filterEntitySchema), _loading);
106
106
  const updatedFilterBy = getUpdatedFilterBy(inheritedFilters, parentEntityData, parentSchema, filterEntitySchema, parentId, variableProps);
107
+ const updatedItemsToDisplay = getUpdatedItemsToDisplay({
108
+ itemsToDisplay,
109
+ inheritedFilters,
110
+ parentSchema,
111
+ parentEntityData
112
+ });
107
113
  const {
108
114
  limit,
109
115
  variables
@@ -115,10 +121,11 @@ const CardsRender = _ref => {
115
121
  docType: docTypes,
116
122
  filterOperator,
117
123
  filterEntityRelations,
118
- itemsToDisplay,
124
+ itemsToDisplay: updatedItemsToDisplay,
119
125
  entitySameAsCurrentItemEntity,
120
126
  useRandomSort
121
127
  });
128
+ const hasNoFiltersOrItemsToDisplay = !updatedItemsToDisplay.length && !updatedFilterBy;
122
129
  const {
123
130
  data: cardData,
124
131
  error: cardsError,
@@ -126,9 +133,9 @@ const CardsRender = _ref => {
126
133
  } = useQuery(action, {
127
134
  variables,
128
135
  fetchPolicy: useRandomSort ? 'cache-and-network' : 'cache-first',
129
- skip: shouldReturn(!updatedFilterBy, _loading, _load, schemaLoading, _error, _err, schemaError)
136
+ skip: shouldReturn(hasNoFiltersOrItemsToDisplay, _loading, _load, schemaLoading, _error, _err, schemaError)
130
137
  });
131
- const imageIds = itemsToDisplay.map(({
138
+ const imageIds = updatedItemsToDisplay.map(({
132
139
  imageId
133
140
  }) => imageId).filter(Boolean);
134
141
  const {
@@ -137,7 +144,7 @@ const CardsRender = _ref => {
137
144
  } = useGetImages(imageIds, true);
138
145
  const isLoading = shouldReturn(_loading, _load, schemaLoading, cardsLoading, imagesLoading);
139
146
  const hasError = shouldReturn(_error, _err, schemaError);
140
- if (!updatedFilterBy) return null;
147
+ if (hasNoFiltersOrItemsToDisplay) return null;
141
148
  if (isLoading) return null;
142
149
  if (hasError) return null;
143
150
  if (cardsError) return cardsError.message;
@@ -147,14 +154,14 @@ const CardsRender = _ref => {
147
154
  if (!cardDataResults || !cardDataResults.length) return null;
148
155
  cardDataResults = entitySameAsCurrentItemEntity ? removeExtraItems(cardDataResults, limit, parentId) : cardDataResults;
149
156
  if (!cardDataResults.length) return null;
150
- const orderedData = useRandomSort ? cardDataResults : sortResponseData(cardDataResults, itemsToDisplay);
157
+ const orderedData = useRandomSort ? cardDataResults : sortResponseData(cardDataResults, updatedItemsToDisplay);
151
158
  const {
152
159
  regularChildren,
153
160
  gtmChildren
154
161
  } = splitChildren(children, cardDataResults, graphqlEntityMap, {
155
162
  name: variableProps.name
156
163
  });
157
- const updatedCards = appendImages(imagesData, orderedData, itemsToDisplay);
164
+ const updatedCards = appendImages(imagesData, orderedData, updatedItemsToDisplay);
158
165
  return /*#__PURE__*/React.createElement(React.Fragment, null, gtmChildren && renderChildren(gtmChildren), /*#__PURE__*/React.createElement(CardsContainer, _extends({
159
166
  cardData: updatedCards,
160
167
  entity: primaryEntityToUse,
@@ -1 +1 @@
1
- {"version":3,"file":"CardsRender.js","names":["React","useContext","useQuery","dynamic","PropTypes","MainContext","generateSingleItemQuery","SEARCH_PUBLISHED_CONTENT","AND","useGetEntitySchemasAsObj","useGetImages","getUpdatedFilterBy","getEntityData","getRequiredSchemas","sortResponseData","getUnpublishedEntityName","renderChildren","splitChildren","removeExtraItems","appendImages","filtersSetup","filterQuerySetup","shouldSkipSingleQuery","shouldReturn","getUpdatedSortProperties","CardsContainer","CardsRender","_ref","entity","legacyEntity","entities","entityFields","itemsToDisplay","children","otherProps","_objectWithoutProperties","_excluded","isPreview","parent","itemId","parentId","itemEntity","parentEntity","filterBy","filterByProperty","sortby","sort","sortProperties","operator","filterOperator","useRandomSort","updatedSortProperties","sortbyFilters","variableProps","_objectSpread","entitiesToUse","primaryEntityToUse","unpublishedParentEntityName","allEntityNames","uniqueEntityNames","Set","data","mainSchemas","loading","_loading","error","_error","parentSchema","filterEntitySchema","entitiesTypes","map","ent","graphqlEntityMap","reduce","acc","entityType","docTypes","docType","type","entityTypes","eType","getAction","queryProps","inheritedFilters","entitySameAsCurrentItemEntity","action","filterEntityRelations","currentSchema","itemEntityUpdated","entityData","parentEntityData","_err","_load","variables","id","skip","requiredSchema","schemaLoading","schemaError","updatedFilterBy","limit","getEntitySchemas","Object","values","cardData","cardsError","cardsLoading","fetchPolicy","imageIds","imageId","filter","Boolean","imagesData","imagesLoading","isLoading","hasError","message","results","cardDataResults","length","orderedData","regularChildren","gtmChildren","name","updatedCards","createElement","Fragment","_extends","cardChildren","propTypes","oneOfType","arrayOf","node","string","isRequired","array","defaultProps"],"sources":["../../../src/components/Card/CardsRender.js"],"sourcesContent":["import React, { useContext } from 'react';\nimport { useQuery } from '@apollo/client';\nimport dynamic from 'next/dynamic';\nimport PropTypes from 'prop-types';\nimport { MainContext } from '@blaze-cms/nextjs-components';\nimport { generateSingleItemQuery } from '../../application/query';\nimport { SEARCH_PUBLISHED_CONTENT, AND } from '../../constants';\nimport { useGetEntitySchemasAsObj, useGetImages } from '../../hooks';\nimport {\n getUpdatedFilterBy,\n getEntityData,\n getRequiredSchemas,\n sortResponseData,\n getUnpublishedEntityName,\n renderChildren,\n splitChildren,\n removeExtraItems,\n appendImages\n} from '../../helpers';\nimport {\n filtersSetup,\n filterQuerySetup,\n shouldSkipSingleQuery,\n shouldReturn,\n getUpdatedSortProperties\n} from './helpers';\n\nconst CardsContainer = dynamic(() => import('./CardsContainer'));\n\nconst CardsRender = ({\n entity: legacyEntity,\n entities,\n entityFields,\n itemsToDisplay,\n children,\n ...otherProps\n}) => {\n const { isPreview } = useContext(MainContext);\n const {\n parent: { itemId: parentId, itemEntity: parentEntity },\n filterBy = [],\n filterByProperty = [],\n sortby,\n sort,\n sortProperties = [],\n operator: filterOperator = AND,\n useRandomSort\n } = otherProps;\n const [updatedSortProperties, sortbyFilters] = getUpdatedSortProperties(\n sort,\n sortby,\n sortProperties\n );\n\n const variableProps = {\n ...otherProps,\n sortProperties: updatedSortProperties,\n sort: null,\n sortby: null\n };\n\n const entitiesToUse = entities || [legacyEntity];\n const primaryEntityToUse = entitiesToUse[0];\n const unpublishedParentEntityName = getUnpublishedEntityName(parentEntity);\n const allEntityNames = [...entitiesToUse, unpublishedParentEntityName];\n const uniqueEntityNames = [...new Set(allEntityNames)];\n const { data: mainSchemas = {}, loading: _loading, error: _error } = useGetEntitySchemasAsObj(\n uniqueEntityNames\n );\n const parentSchema = mainSchemas[unpublishedParentEntityName] || {};\n const filterEntitySchema = mainSchemas[primaryEntityToUse] || {};\n const entitiesTypes = entitiesToUse.map(ent => getEntityData(ent, mainSchemas[ent]));\n const graphqlEntityMap = entitiesTypes.reduce(\n (acc, entityType) => ({ ...acc, [entityType.entityType]: entityType.entity }),\n {}\n );\n const docTypes = entitiesTypes.map(({ docType: type }) => type);\n const entityTypes = entitiesTypes.map(({ entityType: eType }) => eType);\n\n const {\n getAction,\n queryProps,\n inheritedFilters,\n entitySameAsCurrentItemEntity,\n action,\n filterEntityRelations\n } = filtersSetup({\n entityFields,\n entityTypes,\n filterBy,\n filterByProperty,\n entities: entitiesToUse,\n currentSchema: parentSchema,\n filterEntitySchema,\n isPreview,\n itemEntityUpdated: unpublishedParentEntityName\n });\n const {\n data: { entityData: parentEntityData = {} } = {},\n error: _err,\n loading: _load\n } = useQuery(generateSingleItemQuery(getAction, queryProps), {\n variables: { id: parentId },\n skip: shouldSkipSingleQuery(_loading, getAction, queryProps)\n });\n\n const {\n data: requiredSchema = {},\n loading: schemaLoading,\n error: schemaError\n } = useGetEntitySchemasAsObj(\n getRequiredSchemas([...filterByProperty, ...sortbyFilters], filterEntitySchema),\n _loading\n );\n\n const updatedFilterBy = getUpdatedFilterBy(\n inheritedFilters,\n parentEntityData,\n parentSchema,\n filterEntitySchema,\n parentId,\n variableProps\n );\n\n const { limit, variables } = filterQuerySetup({\n getEntitySchemas: Object.values(requiredSchema),\n entity: primaryEntityToUse,\n updatedFilterBy,\n variableProps,\n docType: docTypes,\n filterOperator,\n filterEntityRelations,\n itemsToDisplay,\n entitySameAsCurrentItemEntity,\n useRandomSort\n });\n const { data: cardData, error: cardsError, loading: cardsLoading } = useQuery(action, {\n variables,\n fetchPolicy: useRandomSort ? 'cache-and-network' : 'cache-first',\n skip: shouldReturn(!updatedFilterBy, _loading, _load, schemaLoading, _error, _err, schemaError)\n });\n\n const imageIds = itemsToDisplay.map(({ imageId }) => imageId).filter(Boolean);\n const { data: imagesData, loading: imagesLoading } = useGetImages(imageIds, true);\n const isLoading = shouldReturn(_loading, _load, schemaLoading, cardsLoading, imagesLoading);\n const hasError = shouldReturn(_error, _err, schemaError);\n\n if (!updatedFilterBy) return null;\n if (isLoading) return null;\n if (hasError) return null;\n if (cardsError) return cardsError.message;\n let { results: cardDataResults } = cardData[SEARCH_PUBLISHED_CONTENT];\n\n if (!cardDataResults || !cardDataResults.length) return null;\n\n cardDataResults = entitySameAsCurrentItemEntity\n ? removeExtraItems(cardDataResults, limit, parentId)\n : cardDataResults;\n if (!cardDataResults.length) return null;\n\n const orderedData = useRandomSort\n ? cardDataResults\n : sortResponseData(cardDataResults, itemsToDisplay);\n const { regularChildren, gtmChildren } = splitChildren(\n children,\n cardDataResults,\n graphqlEntityMap,\n {\n name: variableProps.name\n }\n );\n const updatedCards = appendImages(imagesData, orderedData, itemsToDisplay);\n\n return (\n <>\n {gtmChildren && renderChildren(gtmChildren)}\n <CardsContainer\n cardData={updatedCards}\n entity={primaryEntityToUse}\n gtmChildren={gtmChildren}\n cardChildren={regularChildren}\n graphqlEntityMap={graphqlEntityMap}\n {...variableProps}\n />\n </>\n );\n};\n\nCardsRender.propTypes = {\n children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]),\n entity: PropTypes.string.isRequired,\n entityFields: PropTypes.string.isRequired,\n itemsToDisplay: PropTypes.array,\n entities: PropTypes.array\n};\n\nCardsRender.defaultProps = {\n children: [],\n itemsToDisplay: [],\n entities: []\n};\n\nexport default CardsRender;\n"],"mappings":";;;;;;AAAA,OAAOA,KAAK,IAAIC,UAAU,QAAQ,OAAO;AACzC,SAASC,QAAQ,QAAQ,gBAAgB;AACzC,OAAOC,OAAO,MAAM,cAAc;AAClC,OAAOC,SAAS,MAAM,YAAY;AAClC,SAASC,WAAW,QAAQ,8BAA8B;AAC1D,SAASC,uBAAuB,QAAQ,yBAAyB;AACjE,SAASC,wBAAwB,EAAEC,GAAG,QAAQ,iBAAiB;AAC/D,SAASC,wBAAwB,EAAEC,YAAY,QAAQ,aAAa;AACpE,SACEC,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"CardsRender.js","names":["React","useContext","useQuery","dynamic","PropTypes","MainContext","generateSingleItemQuery","SEARCH_PUBLISHED_CONTENT","AND","useGetEntitySchemasAsObj","useGetImages","getUpdatedFilterBy","getEntityData","getRequiredSchemas","sortResponseData","getUnpublishedEntityName","renderChildren","splitChildren","removeExtraItems","appendImages","filtersSetup","filterQuerySetup","shouldSkipSingleQuery","shouldReturn","getUpdatedSortProperties","getUpdatedItemsToDisplay","CardsContainer","CardsRender","_ref","entity","legacyEntity","entities","entityFields","itemsToDisplay","children","otherProps","_objectWithoutProperties","_excluded","isPreview","parent","itemId","parentId","itemEntity","parentEntity","filterBy","filterByProperty","sortby","sort","sortProperties","operator","filterOperator","useRandomSort","updatedSortProperties","sortbyFilters","variableProps","_objectSpread","entitiesToUse","primaryEntityToUse","unpublishedParentEntityName","allEntityNames","uniqueEntityNames","Set","data","mainSchemas","loading","_loading","error","_error","parentSchema","filterEntitySchema","entitiesTypes","map","ent","graphqlEntityMap","reduce","acc","entityType","docTypes","docType","type","entityTypes","eType","getAction","queryProps","inheritedFilters","entitySameAsCurrentItemEntity","action","filterEntityRelations","currentSchema","itemEntityUpdated","entityData","parentEntityData","_err","_load","variables","id","skip","requiredSchema","schemaLoading","schemaError","updatedFilterBy","updatedItemsToDisplay","limit","getEntitySchemas","Object","values","hasNoFiltersOrItemsToDisplay","length","cardData","cardsError","cardsLoading","fetchPolicy","imageIds","imageId","filter","Boolean","imagesData","imagesLoading","isLoading","hasError","message","results","cardDataResults","orderedData","regularChildren","gtmChildren","name","updatedCards","createElement","Fragment","_extends","cardChildren","propTypes","oneOfType","arrayOf","node","string","isRequired","array","defaultProps"],"sources":["../../../src/components/Card/CardsRender.js"],"sourcesContent":["import React, { useContext } from 'react';\nimport { useQuery } from '@apollo/client';\nimport dynamic from 'next/dynamic';\nimport PropTypes from 'prop-types';\nimport { MainContext } from '@blaze-cms/nextjs-components';\nimport { generateSingleItemQuery } from '../../application/query';\nimport { SEARCH_PUBLISHED_CONTENT, AND } from '../../constants';\nimport { useGetEntitySchemasAsObj, useGetImages } from '../../hooks';\nimport {\n getUpdatedFilterBy,\n getEntityData,\n getRequiredSchemas,\n sortResponseData,\n getUnpublishedEntityName,\n renderChildren,\n splitChildren,\n removeExtraItems,\n appendImages\n} from '../../helpers';\nimport {\n filtersSetup,\n filterQuerySetup,\n shouldSkipSingleQuery,\n shouldReturn,\n getUpdatedSortProperties,\n getUpdatedItemsToDisplay\n} from './helpers';\n\nconst CardsContainer = dynamic(() => import('./CardsContainer'));\n\nconst CardsRender = ({\n entity: legacyEntity,\n entities,\n entityFields,\n itemsToDisplay,\n children,\n ...otherProps\n}) => {\n const { isPreview } = useContext(MainContext);\n const {\n parent: { itemId: parentId, itemEntity: parentEntity },\n filterBy = [],\n filterByProperty = [],\n sortby,\n sort,\n sortProperties = [],\n operator: filterOperator = AND,\n useRandomSort\n } = otherProps;\n const [updatedSortProperties, sortbyFilters] = getUpdatedSortProperties(\n sort,\n sortby,\n sortProperties\n );\n\n const variableProps = {\n ...otherProps,\n sortProperties: updatedSortProperties,\n sort: null,\n sortby: null\n };\n\n const entitiesToUse = entities || [legacyEntity];\n const primaryEntityToUse = entitiesToUse[0];\n const unpublishedParentEntityName = getUnpublishedEntityName(parentEntity);\n const allEntityNames = [...entitiesToUse, unpublishedParentEntityName];\n const uniqueEntityNames = [...new Set(allEntityNames)];\n const { data: mainSchemas = {}, loading: _loading, error: _error } = useGetEntitySchemasAsObj(\n uniqueEntityNames\n );\n const parentSchema = mainSchemas[unpublishedParentEntityName] || {};\n const filterEntitySchema = mainSchemas[primaryEntityToUse] || {};\n const entitiesTypes = entitiesToUse.map(ent => getEntityData(ent, mainSchemas[ent]));\n const graphqlEntityMap = entitiesTypes.reduce(\n (acc, entityType) => ({ ...acc, [entityType.entityType]: entityType.entity }),\n {}\n );\n const docTypes = entitiesTypes.map(({ docType: type }) => type);\n const entityTypes = entitiesTypes.map(({ entityType: eType }) => eType);\n\n const {\n getAction,\n queryProps,\n inheritedFilters,\n entitySameAsCurrentItemEntity,\n action,\n filterEntityRelations\n } = filtersSetup({\n entityFields,\n entityTypes,\n filterBy,\n filterByProperty,\n entities: entitiesToUse,\n currentSchema: parentSchema,\n filterEntitySchema,\n isPreview,\n itemEntityUpdated: unpublishedParentEntityName\n });\n\n const {\n data: { entityData: parentEntityData = {} } = {},\n error: _err,\n loading: _load\n } = useQuery(generateSingleItemQuery(getAction, queryProps), {\n variables: { id: parentId },\n skip: shouldSkipSingleQuery(_loading, getAction, queryProps)\n });\n\n const {\n data: requiredSchema = {},\n loading: schemaLoading,\n error: schemaError\n } = useGetEntitySchemasAsObj(\n getRequiredSchemas([...filterByProperty, ...sortbyFilters], filterEntitySchema),\n _loading\n );\n\n const updatedFilterBy = getUpdatedFilterBy(\n inheritedFilters,\n parentEntityData,\n parentSchema,\n filterEntitySchema,\n parentId,\n variableProps\n );\n\n const updatedItemsToDisplay = getUpdatedItemsToDisplay({\n itemsToDisplay,\n inheritedFilters,\n parentSchema,\n parentEntityData\n });\n\n const { limit, variables } = filterQuerySetup({\n getEntitySchemas: Object.values(requiredSchema),\n entity: primaryEntityToUse,\n updatedFilterBy,\n variableProps,\n docType: docTypes,\n filterOperator,\n filterEntityRelations,\n itemsToDisplay: updatedItemsToDisplay,\n entitySameAsCurrentItemEntity,\n useRandomSort\n });\n\n const hasNoFiltersOrItemsToDisplay = !updatedItemsToDisplay.length && !updatedFilterBy;\n\n const { data: cardData, error: cardsError, loading: cardsLoading } = useQuery(action, {\n variables,\n fetchPolicy: useRandomSort ? 'cache-and-network' : 'cache-first',\n skip: shouldReturn(\n hasNoFiltersOrItemsToDisplay,\n _loading,\n _load,\n schemaLoading,\n _error,\n _err,\n schemaError\n )\n });\n\n const imageIds = updatedItemsToDisplay.map(({ imageId }) => imageId).filter(Boolean);\n const { data: imagesData, loading: imagesLoading } = useGetImages(imageIds, true);\n const isLoading = shouldReturn(_loading, _load, schemaLoading, cardsLoading, imagesLoading);\n const hasError = shouldReturn(_error, _err, schemaError);\n\n if (hasNoFiltersOrItemsToDisplay) return null;\n if (isLoading) return null;\n if (hasError) return null;\n if (cardsError) return cardsError.message;\n let { results: cardDataResults } = cardData[SEARCH_PUBLISHED_CONTENT];\n\n if (!cardDataResults || !cardDataResults.length) return null;\n\n cardDataResults = entitySameAsCurrentItemEntity\n ? removeExtraItems(cardDataResults, limit, parentId)\n : cardDataResults;\n if (!cardDataResults.length) return null;\n\n const orderedData = useRandomSort\n ? cardDataResults\n : sortResponseData(cardDataResults, updatedItemsToDisplay);\n const { regularChildren, gtmChildren } = splitChildren(\n children,\n cardDataResults,\n graphqlEntityMap,\n {\n name: variableProps.name\n }\n );\n const updatedCards = appendImages(imagesData, orderedData, updatedItemsToDisplay);\n\n return (\n <>\n {gtmChildren && renderChildren(gtmChildren)}\n <CardsContainer\n cardData={updatedCards}\n entity={primaryEntityToUse}\n gtmChildren={gtmChildren}\n cardChildren={regularChildren}\n graphqlEntityMap={graphqlEntityMap}\n {...variableProps}\n />\n </>\n );\n};\n\nCardsRender.propTypes = {\n children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]),\n entity: PropTypes.string.isRequired,\n entityFields: PropTypes.string.isRequired,\n itemsToDisplay: PropTypes.array,\n entities: PropTypes.array\n};\n\nCardsRender.defaultProps = {\n children: [],\n itemsToDisplay: [],\n entities: []\n};\n\nexport default CardsRender;\n"],"mappings":";;;;;;AAAA,OAAOA,KAAK,IAAIC,UAAU,QAAQ,OAAO;AACzC,SAASC,QAAQ,QAAQ,gBAAgB;AACzC,OAAOC,OAAO,MAAM,cAAc;AAClC,OAAOC,SAAS,MAAM,YAAY;AAClC,SAASC,WAAW,QAAQ,8BAA8B;AAC1D,SAASC,uBAAuB,QAAQ,yBAAyB;AACjE,SAASC,wBAAwB,EAAEC,GAAG,QAAQ,iBAAiB;AAC/D,SAASC,wBAAwB,EAAEC,YAAY,QAAQ,aAAa;AACpE,SACEC,kBAAkB,EAClBC,aAAa,EACbC,kB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E3B,SAAS,CAACsI;AACtB,CAAC;AAED/G,WAAW,CAACgH,YAAY,GAAG;EACzBzG,QAAQ,EAAE,EAAE;EACZD,cAAc,EAAE,EAAE;EAClBF,QAAQ,EAAE;AACZ,CAAC;AAED,eAAeJ,WAAW"}
@@ -0,0 +1,32 @@
1
+ const getUpdatedItemsToDisplay = ({
2
+ parentSchema,
3
+ parentEntityData,
4
+ itemsToDisplay = [],
5
+ inheritedFilters = []
6
+ }) => {
7
+ const idProp = inheritedFilters.find(filter => filter.indexOf('id/') === 0);
8
+ if (!idProp || !parentSchema || !parentEntityData) return itemsToDisplay;
9
+ const {
10
+ properties
11
+ } = parentSchema;
12
+ const [, entityKey] = idProp.split('/');
13
+ if (!properties || !entityKey) return itemsToDisplay;
14
+ const queryValue = Object.keys(properties).find(propKey => properties[propKey] && properties[propKey].relation && properties[propKey].relation.entityIdentifier === entityKey);
15
+ const parentValues = parentEntityData[queryValue];
16
+ if (!parentValues) return itemsToDisplay;
17
+ const updatedItemsToDisplay = [...itemsToDisplay];
18
+ if (Array.isArray(parentValues)) {
19
+ parentValues.forEach(value => {
20
+ updatedItemsToDisplay.push({
21
+ displayItems: [value]
22
+ });
23
+ });
24
+ } else {
25
+ updatedItemsToDisplay.push({
26
+ displayItems: [parentValues]
27
+ });
28
+ }
29
+ return updatedItemsToDisplay;
30
+ };
31
+ export default getUpdatedItemsToDisplay;
32
+ //# sourceMappingURL=get-updated-items-to-display.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-updated-items-to-display.js","names":["getUpdatedItemsToDisplay","parentSchema","parentEntityData","itemsToDisplay","inheritedFilters","idProp","find","filter","indexOf","properties","entityKey","split","queryValue","Object","keys","propKey","relation","entityIdentifier","parentValues","updatedItemsToDisplay","Array","isArray","forEach","value","push","displayItems"],"sources":["../../../../src/components/Card/helpers/get-updated-items-to-display.js"],"sourcesContent":["const getUpdatedItemsToDisplay = ({\n parentSchema,\n parentEntityData,\n itemsToDisplay = [],\n inheritedFilters = []\n}) => {\n const idProp = inheritedFilters.find(filter => filter.indexOf('id/') === 0);\n\n if (!idProp || !parentSchema || !parentEntityData) return itemsToDisplay;\n const { properties } = parentSchema;\n const [, entityKey] = idProp.split('/');\n if (!properties || !entityKey) return itemsToDisplay;\n const queryValue = Object.keys(properties).find(\n propKey =>\n properties[propKey] &&\n properties[propKey].relation &&\n properties[propKey].relation.entityIdentifier === entityKey\n );\n const parentValues = parentEntityData[queryValue];\n if (!parentValues) return itemsToDisplay;\n const updatedItemsToDisplay = [...itemsToDisplay];\n if (Array.isArray(parentValues)) {\n parentValues.forEach(value => {\n updatedItemsToDisplay.push({ displayItems: [value] });\n });\n } else {\n updatedItemsToDisplay.push({ displayItems: [parentValues] });\n }\n return updatedItemsToDisplay;\n};\n\nexport default getUpdatedItemsToDisplay;\n"],"mappings":"AAAA,MAAMA,wBAAwB,GAAGA,CAAC;EAChCC,YAAY;EACZC,gBAAgB;EAChBC,cAAc,GAAG,EAAE;EACnBC,gBAAgB,GAAG;AACrB,CAAC,KAAK;EACJ,MAAMC,MAAM,GAAGD,gBAAgB,CAACE,IAAI,CAACC,MAAM,IAAIA,MAAM,CAACC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;EAE3E,IAAI,CAACH,MAAM,IAAI,CAACJ,YAAY,IAAI,CAACC,gBAAgB,EAAE,OAAOC,cAAc;EACxE,MAAM;IAAEM;EAAW,CAAC,GAAGR,YAAY;EACnC,MAAM,GAAGS,SAAS,CAAC,GAAGL,MAAM,CAACM,KAAK,CAAC,GAAG,CAAC;EACvC,IAAI,CAACF,UAAU,IAAI,CAACC,SAAS,EAAE,OAAOP,cAAc;EACpD,MAAMS,UAAU,GAAGC,MAAM,CAACC,IAAI,CAACL,UAAU,CAAC,CAACH,IAAI,CAC7CS,OAAO,IACLN,UAAU,CAACM,OAAO,CAAC,IACnBN,UAAU,CAACM,OAAO,CAAC,CAACC,QAAQ,IAC5BP,UAAU,CAACM,OAAO,CAAC,CAACC,QAAQ,CAACC,gBAAgB,KAAKP,SACtD,CAAC;EACD,MAAMQ,YAAY,GAAGhB,gBAAgB,CAACU,UAAU,CAAC;EACjD,IAAI,CAACM,YAAY,EAAE,OAAOf,cAAc;EACxC,MAAMgB,qBAAqB,GAAG,CAAC,GAAGhB,cAAc,CAAC;EACjD,IAAIiB,KAAK,CAACC,OAAO,CAACH,YAAY,CAAC,EAAE;IAC/BA,YAAY,CAACI,OAAO,CAACC,KAAK,IAAI;MAC5BJ,qBAAqB,CAACK,IAAI,CAAC;QAAEC,YAAY,EAAE,CAACF,KAAK;MAAE,CAAC,CAAC;IACvD,CAAC,CAAC;EACJ,CAAC,MAAM;IACLJ,qBAAqB,CAACK,IAAI,CAAC;MAAEC,YAAY,EAAE,CAACP,YAAY;IAAE,CAAC,CAAC;EAC9D;EACA,OAAOC,qBAAqB;AAC9B,CAAC;AAED,eAAenB,wBAAwB"}
@@ -6,4 +6,5 @@ export { default as filterQuerySetup } from './filter-query-setup';
6
6
  export { default as shouldReturn } from './should-return';
7
7
  export { default as shouldSkipSingleQuery } from './should-skip-single-query';
8
8
  export { default as getUpdatedSortProperties } from './get-updated-sort-properties';
9
+ export { default as getUpdatedItemsToDisplay } from './get-updated-items-to-display';
9
10
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["default","getPublishedListingUrl","useDynamicSizeKey","getDynamicGridClasses","filtersSetup","filterQuerySetup","shouldReturn","shouldSkipSingleQuery","getUpdatedSortProperties"],"sources":["../../../../src/components/Card/helpers/index.js"],"sourcesContent":["export { default as getPublishedListingUrl } from './get-published-listing-url';\nexport { default as useDynamicSizeKey } from './use-dynamic-size-key';\nexport { default as getDynamicGridClasses } from './get-dynamic-grid-classes';\nexport { default as filtersSetup } from './filters-setup';\nexport { default as filterQuerySetup } from './filter-query-setup';\nexport { default as shouldReturn } from './should-return';\nexport { default as shouldSkipSingleQuery } from './should-skip-single-query';\nexport { default as getUpdatedSortProperties } from './get-updated-sort-properties';\n"],"mappings":"AAAA,SAASA,OAAO,IAAIC,sBAAsB,QAAQ,6BAA6B;AAC/E,SAASD,OAAO,IAAIE,iBAAiB,QAAQ,wBAAwB;AACrE,SAASF,OAAO,IAAIG,qBAAqB,QAAQ,4BAA4B;AAC7E,SAASH,OAAO,IAAII,YAAY,QAAQ,iBAAiB;AACzD,SAASJ,OAAO,IAAIK,gBAAgB,QAAQ,sBAAsB;AAClE,SAASL,OAAO,IAAIM,YAAY,QAAQ,iBAAiB;AACzD,SAASN,OAAO,IAAIO,qBAAqB,QAAQ,4BAA4B;AAC7E,SAASP,OAAO,IAAIQ,wBAAwB,QAAQ,+BAA+B"}
1
+ {"version":3,"file":"index.js","names":["default","getPublishedListingUrl","useDynamicSizeKey","getDynamicGridClasses","filtersSetup","filterQuerySetup","shouldReturn","shouldSkipSingleQuery","getUpdatedSortProperties","getUpdatedItemsToDisplay"],"sources":["../../../../src/components/Card/helpers/index.js"],"sourcesContent":["export { default as getPublishedListingUrl } from './get-published-listing-url';\nexport { default as useDynamicSizeKey } from './use-dynamic-size-key';\nexport { default as getDynamicGridClasses } from './get-dynamic-grid-classes';\nexport { default as filtersSetup } from './filters-setup';\nexport { default as filterQuerySetup } from './filter-query-setup';\nexport { default as shouldReturn } from './should-return';\nexport { default as shouldSkipSingleQuery } from './should-skip-single-query';\nexport { default as getUpdatedSortProperties } from './get-updated-sort-properties';\nexport { default as getUpdatedItemsToDisplay } from './get-updated-items-to-display';\n"],"mappings":"AAAA,SAASA,OAAO,IAAIC,sBAAsB,QAAQ,6BAA6B;AAC/E,SAASD,OAAO,IAAIE,iBAAiB,QAAQ,wBAAwB;AACrE,SAASF,OAAO,IAAIG,qBAAqB,QAAQ,4BAA4B;AAC7E,SAASH,OAAO,IAAII,YAAY,QAAQ,iBAAiB;AACzD,SAASJ,OAAO,IAAIK,gBAAgB,QAAQ,sBAAsB;AAClE,SAASL,OAAO,IAAIM,YAAY,QAAQ,iBAAiB;AACzD,SAASN,OAAO,IAAIO,qBAAqB,QAAQ,4BAA4B;AAC7E,SAASP,OAAO,IAAIQ,wBAAwB,QAAQ,+BAA+B;AACnF,SAASR,OAAO,IAAIS,wBAAwB,QAAQ,gCAAgC"}
@@ -18,7 +18,7 @@ const SearchContentItems = ({
18
18
  key: id
19
19
  }, /*#__PURE__*/React.createElement("div", {
20
20
  className: "search-content--results__wrapper"
21
- }, (image === null || image === void 0 ? void 0 : image.url) ? /*#__PURE__*/React.createElement(LazyImage, {
21
+ }, image !== null && image !== void 0 && image.url ? /*#__PURE__*/React.createElement(LazyImage, {
22
22
  src: image.url,
23
23
  alt: name,
24
24
  className: "search-content--results__image",
@@ -1 +1 @@
1
- {"version":3,"file":"SearchContentItems.js","names":["React","BlazeLink","LazyImage","SearchContentItems","results","onClick","map","item","url","id","name","image","createElement","href","key","className","src","alt","sizeKey"],"sources":["../../../src/components/SearchContent/SearchContentItems.js"],"sourcesContent":["import React from 'react';\nimport BlazeLink from '../BlazeLink';\nimport LazyImage from '../LazyImage';\n\nconst SearchContentItems = ({ results = [], onClick }) =>\n results.map(item => {\n if (!item.url) return null;\n\n const { id, name, image, url } = item;\n\n return (\n <BlazeLink href={url} onClick={onClick} key={id}>\n <div className=\"search-content--results__wrapper\">\n {image?.url ? (\n <LazyImage\n src={image.url}\n alt={name}\n className=\"search-content--results__image\"\n sizeKey=\"search-result\"\n />\n ) : null}\n <span className=\"search-content--results__title\">{name}</span>\n </div>\n </BlazeLink>\n );\n });\n\nexport default SearchContentItems;\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,SAAS,MAAM,cAAc;AACpC,OAAOC,SAAS,MAAM,cAAc;AAEpC,MAAMC,kBAAkB,GAAGA,CAAC;EAAEC,OAAO,GAAG,EAAE;EAAEC;AAAQ,CAAC,KACnDD,OAAO,CAACE,GAAG,CAACC,IAAI,IAAI;EAClB,IAAI,CAACA,IAAI,CAACC,GAAG,EAAE,OAAO,IAAI;EAE1B,MAAM;IAAEC,EAAE;IAAEC,IAAI;IAAEC,KAAK;IAAEH;EAAI,CAAC,GAAGD,IAAI;EAErC,oBACEP,KAAA,CAAAY,aAAA,CAACX,SAAS;IAACY,IAAI,EAAEL,GAAI;IAACH,OAAO,EAAEA,OAAQ;IAACS,GAAG,EAAEL;EAAG,gBAC9CT,KAAA,CAAAY,aAAA;IAAKG,SAAS,EAAC;EAAkC,GAC9C,CAAAJ,KAAK,aAALA,KAAK,uBAALA,KAAK,CAAEH,GAAG,iBACTR,KAAA,CAAAY,aAAA,CAACV,SAAS;IACRc,GAAG,EAAEL,KAAK,CAACH,GAAI;IACfS,GAAG,EAAEP,IAAK;IACVK,SAAS,EAAC,gCAAgC;IAC1CG,OAAO,EAAC;EAAe,CACxB,CAAC,GACA,IAAI,eACRlB,KAAA,CAAAY,aAAA;IAAMG,SAAS,EAAC;EAAgC,GAAEL,IAAW,CAC1D,CACI,CAAC;AAEhB,CAAC,CAAC;AAEJ,eAAeP,kBAAkB"}
1
+ {"version":3,"file":"SearchContentItems.js","names":["React","BlazeLink","LazyImage","SearchContentItems","results","onClick","map","item","url","id","name","image","createElement","href","key","className","src","alt","sizeKey"],"sources":["../../../src/components/SearchContent/SearchContentItems.js"],"sourcesContent":["import React from 'react';\nimport BlazeLink from '../BlazeLink';\nimport LazyImage from '../LazyImage';\n\nconst SearchContentItems = ({ results = [], onClick }) =>\n results.map(item => {\n if (!item.url) return null;\n\n const { id, name, image, url } = item;\n\n return (\n <BlazeLink href={url} onClick={onClick} key={id}>\n <div className=\"search-content--results__wrapper\">\n {image?.url ? (\n <LazyImage\n src={image.url}\n alt={name}\n className=\"search-content--results__image\"\n sizeKey=\"search-result\"\n />\n ) : null}\n <span className=\"search-content--results__title\">{name}</span>\n </div>\n </BlazeLink>\n );\n });\n\nexport default SearchContentItems;\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,SAAS,MAAM,cAAc;AACpC,OAAOC,SAAS,MAAM,cAAc;AAEpC,MAAMC,kBAAkB,GAAGA,CAAC;EAAEC,OAAO,GAAG,EAAE;EAAEC;AAAQ,CAAC,KACnDD,OAAO,CAACE,GAAG,CAACC,IAAI,IAAI;EAClB,IAAI,CAACA,IAAI,CAACC,GAAG,EAAE,OAAO,IAAI;EAE1B,MAAM;IAAEC,EAAE;IAAEC,IAAI;IAAEC,KAAK;IAAEH;EAAI,CAAC,GAAGD,IAAI;EAErC,oBACEP,KAAA,CAAAY,aAAA,CAACX,SAAS;IAACY,IAAI,EAAEL,GAAI;IAACH,OAAO,EAAEA,OAAQ;IAACS,GAAG,EAAEL;EAAG,gBAC9CT,KAAA,CAAAY,aAAA;IAAKG,SAAS,EAAC;EAAkC,GAC9CJ,KAAK,aAALA,KAAK,eAALA,KAAK,CAAEH,GAAG,gBACTR,KAAA,CAAAY,aAAA,CAACV,SAAS;IACRc,GAAG,EAAEL,KAAK,CAACH,GAAI;IACfS,GAAG,EAAEP,IAAK;IACVK,SAAS,EAAC,gCAAgC;IAC1CG,OAAO,EAAC;EAAe,CACxB,CAAC,GACA,IAAI,eACRlB,KAAA,CAAAY,aAAA;IAAMG,SAAS,EAAC;EAAgC,GAAEL,IAAW,CAC1D,CACI,CAAC;AAEhB,CAAC,CAAC;AAEJ,eAAeP,kBAAkB"}
@@ -1,6 +1,7 @@
1
1
  import flatten from 'lodash.flatten';
2
2
  import isFilterEntitysId from './is-filter-entitys-id';
3
3
  import getFilterProps from './get-filter-props';
4
+ import { ID } from '../constants';
4
5
  const getRelationData = (entityData, relationName, currentRelationNames) => {
5
6
  if (!entityData) return null;
6
7
  if (currentRelationNames && currentRelationNames.length) {
@@ -38,6 +39,7 @@ const buildInheritedFilters = (entityData, inheritedFilters, currentSchema, filt
38
39
  relationForeignKeys,
39
40
  shouldIgnoreFilter
40
41
  } = getFilterProps(filter, currentSchema, filterEntitySchema);
42
+ if (filterName === ID) return;
41
43
  const relationData = getRelationData(entityData, relationName, relationForeignKeys);
42
44
  if (currentEntityId === entityName && isFilterEntitysId(filterName, currentEntityId) || shouldIgnoreFilter) {
43
45
  relationFilters.push(`${filterName}/${itemId}`);
@@ -1 +1 @@
1
- {"version":3,"file":"build-inherited-filters.js","names":["flatten","isFilterEntitysId","getFilterProps","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';\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\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;AAE/C,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,GAAGP,OAAO,CAACQ,gBAAgB,CAAC,GAAG,IAAI;EACnE;EACA,OAAOJ,UAAU,CAACC,YAAY,CAAC;AACjC,CAAC;AAED,MAAMQ,mBAAmB,GAAGA,CAACC,WAAW,EAAEC,YAAY,KAAKD,WAAW,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,EAAEF,eAAe,CAAC,IACjFO,kBAAkB,EAClB;MACAT,eAAe,CAACN,IAAI,CAAE,GAAEU,UAAW,IAAGL,MAAO,EAAC,CAAC;IACjD;IAEA,IAAI,CAACb,YAAY,EAAE;IAEnB,MAAMD,WAAW,GAAGyB,KAAK,CAACC,OAAO,CAACzB,YAAY,CAAC;IAC/C,MAAME,YAAY,GAAGJ,mBAAmB,CAACC,WAAW,EAAEC,YAAY,CAAC;IAEnE,IAAI,CAACqB,kBAAkB,EAAE;MACvB,MAAMK,iBAAiB,GAAGzB,oBAAoB,CAC5CF,WAAW,EACXG,YAAY,EACZF,YAAY,EACZV,YACF,CAAC;MACDwB,eAAe,CAACN,IAAI,CAAC,GAAGkB,iBAAiB,CAAC;IAC5C;IAEA,IAAIxB,YAAY,EAAE;MAChB,MAAME,YAAY,GAAGJ,YAAY,CAACK,MAAM,CAAC,CAACC,GAAG,EAAEC,aAAa,KAAK;QAC/D,IAAIA,aAAa,CAACa,YAAY,CAAC,EAAEd,GAAG,CAACE,IAAI,CAAE,GAAEU,UAAW,IAAGX,aAAa,CAACa,YAAY,CAAE,EAAC,CAAC;QACzF,OAAOd,GAAG;MACZ,CAAC,EAAE,EAAE,CAAC;MACNQ,eAAe,CAACN,IAAI,CAAC,GAAGJ,YAAY,CAAC;IACvC,CAAC,MAAM,IAAI,CAACL,WAAW,IAAIC,YAAY,CAACoB,YAAY,CAAC,EAAE;MACrDN,eAAe,CAACN,IAAI,CAAE,GAAEU,UAAW,IAAGlB,YAAY,CAACoB,YAAY,CAAE,EAAC,CAAC;IACrE;EACF,CAAC,CAAC;EAEF,OAAON,eAAe;AACxB,CAAC;AAED,eAAeL,qBAAqB"}
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;EACnE;EACA,OAAOJ,UAAU,CAACC,YAAY,CAAC;AACjC,CAAC;AAED,MAAMQ,mBAAmB,GAAGA,CAACC,WAAW,EAAEC,YAAY,KAAKD,WAAW,IAAI,CAAC,CAACC,YAAY,CAACR,MAAM;AAE/F,MAAMS,oBAAoB,GAAGA,CAACF,WAAW,EAAEG,YAAY,EAAEF,YAAY,EAAEV,YAAY,KAAK;EACtF,MAAMa,OAAO,GAAG,EAAE;EAClB,IAAID,YAAY,EAAE;IAChB,MAAME,YAAY,GA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WAAW,GAAGyB,KAAK,CAACC,OAAO,CAACzB,YAAY,CAAC;IAC/C,MAAME,YAAY,GAAGJ,mBAAmB,CAACC,WAAW,EAAEC,YAAY,CAAC;IAEnE,IAAI,CAACqB,kBAAkB,EAAE;MACvB,MAAMK,iBAAiB,GAAGzB,oBAAoB,CAC5CF,WAAW,EACXG,YAAY,EACZF,YAAY,EACZV,YACF,CAAC;MACDwB,eAAe,CAACN,IAAI,CAAC,GAAGkB,iBAAiB,CAAC;IAC5C;IAEA,IAAIxB,YAAY,EAAE;MAChB,MAAME,YAAY,GAAGJ,YAAY,CAACK,MAAM,CAAC,CAACC,GAAG,EAAEC,aAAa,KAAK;QAC/D,IAAIA,aAAa,CAACa,YAAY,CAAC,EAAEd,GAAG,CAACE,IAAI,CAAE,GAAEU,UAAW,IAAGX,aAAa,CAACa,YAAY,CAAE,EAAC,CAAC;QACzF,OAAOd,GAAG;MACZ,CAAC,EAAE,EAAE,CAAC;MACNQ,eAAe,CAACN,IAAI,CAAC,GAAGJ,YAAY,CAAC;IACvC,CAAC,MAAM,IAAI,CAACL,WAAW,IAAIC,YAAY,CAACoB,YAAY,CAAC,EAAE;MACrDN,eAAe,CAACN,IAAI,CAAE,GAAEU,UAAW,IAAGlB,YAAY,CAACoB,YAAY,CAAE,EAAC,CAAC;IACrE;EACF,CAAC,CAAC;EAEF,OAAON,eAAe;AACxB,CAAC;AAED,eAAeL,qBAAqB"}
@@ -28,16 +28,18 @@ const buildPropsQuery = (entitySchema, extraProps = [], cardOptions = null, link
28
28
  };
29
29
  const buildComplexProps = (shouldAddCategoryProps, props, {
30
30
  relations = [],
31
- dynamicProperties = {}
31
+ dynamicProperties = {},
32
+ properties = {}
32
33
  }, linkProps) => Object.keys(props).map(base => {
33
34
  const nestedProps = props[base];
34
35
  const hasLink = !!linkProps.find(linkProp => linkProp.includes(base));
36
+ const matchingProperty = !!properties[base];
35
37
  const matchingRelation = relations.find(({
36
38
  localField
37
39
  }) => localField === base);
38
40
  const matchingDynamicProp = Object.keys(dynamicProperties).find(dynamicKey => dynamicKey === base);
39
41
  if (matchingRelation && !nestedProps.includes('id')) nestedProps.push('id');
40
- if (hasLink && (!!matchingRelation || !!matchingDynamicProp)) nestedProps.push('url');
42
+ if (hasLink && (!!matchingProperty || !!matchingRelation || !!matchingDynamicProp)) nestedProps.push('url');
41
43
  const jointNestedProps = nestedProps.join(',');
42
44
  if (base === 'category' && shouldAddCategoryProps) return `${base}{${jointNestedProps}, ${categoryProps}}`;
43
45
  if (base.includes('published')) {
@@ -1 +1 @@
1
- {"version":3,"file":"build-props-query.js","names":["CATEGORY_ID","ID","PREHEADER_PROP","HEADLINE_PROP","defaultProps","categoryProps","checkProps","props","Object","keys","filter","prop","length","buildPropsQuery","entitySchema","extraProps","cardOptions","linkProps","parsedSchema","getEntitySchema","extraPropsHaveCategory","includes","typeBasedProps","shouldAddCategoryProps","getTypeBaseProps","allProps","uniqueProps","Set","basicProps","nestedProps","forEach","push","base","nested","split","complexProps","buildComplexProps","join","relations","dynamicProperties","map","hasLink","find","linkProp","matchingRelation","localField","matchingDynamicProp","dynamicKey","jointNestedProps","isCard","displayCategory","displayThumbnail","interfaces","properties","isContent","hasCategory","hasPreheader","getCategoyProps","getContentProps","url"],"sources":["../../src/helpers/build-props-query.js"],"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 = (entitySchema, extraProps = [], cardOptions = null, linkProps = []) => {\n const parsedSchema = entitySchema.getEntitySchema ? entitySchema.getEntitySchema : entitySchema;\n const extraPropsHaveCategory = !!extraProps.filter(prop => prop.includes('category.')).length;\n const { typeBasedProps, shouldAddCategoryProps } = getTypeBaseProps(\n parsedSchema,\n cardOptions,\n extraPropsHaveCategory\n );\n\n const allProps = [...typeBasedProps, ...extraProps];\n const uniqueProps = [...new Set([...allProps])];\n const basicProps = [];\n const nestedProps = {};\n uniqueProps.forEach(prop => {\n if (prop) {\n if (!prop.includes('.')) {\n basicProps.push(prop);\n return;\n }\n const [base, nested] = prop.split('.');\n if (!nestedProps[base]) nestedProps[base] = [nested];\n else nestedProps[base].push(nested);\n }\n });\n\n const complexProps = buildComplexProps(\n shouldAddCategoryProps,\n nestedProps,\n parsedSchema,\n linkProps\n );\n\n return [...basicProps, ...complexProps].join(',');\n};\n\nconst buildComplexProps = (\n shouldAddCategoryProps,\n props,\n { relations = [], dynamicProperties = {} },\n linkProps\n) =>\n Object.keys(props).map(base => {\n const nestedProps = props[base];\n const hasLink = !!linkProps.find(linkProp => linkProp.includes(base));\n const matchingRelation = relations.find(({ localField }) => localField === base);\n const matchingDynamicProp = Object.keys(dynamicProperties).find(\n dynamicKey => dynamicKey === base\n );\n\n if (matchingRelation && !nestedProps.includes('id')) nestedProps.push('id');\n if (hasLink && (!!matchingRelation || !!matchingDynamicProp)) nestedProps.push('url');\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 = (entitySchema, 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 { interfaces, properties, dynamicProperties, relations } = entitySchema;\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 (properties.url || dynamicProperties.url) typeBasedProps.push('url');\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 const props = [];\n if (hasCategory)\n props.push('category.name', 'category.listingPageId', 'category.listingPageEntity');\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"],"mappings":"AAAA,SAASA,WAAW,EAAEC,EAAE,EAAEC,cAAc,EAAEC,aAAa,QAAQ,cAAc;AAE7E,MAAMC,YAAY,GAAG,CAACH,EAAE,EAAE,MAAM,CAAC;AACjC,MAAMI,aAAa,GAAG,kCAAkC;AAExD,MAAMC,UAAU,GAAGC,KAAK,IACtB,CAAC,EAAEA,KAAK,IAAIC,MAAM,CAACC,IAAI,CAACF,KAAK,CAAC,CAACG,MAAM,CAACC,IAAI,IAAIA,IAAI,KAAKX,WAAW,CAAC,CAACY,MAAM,CAAC;AAE7E,MAAMC,eAAe,GAAGA,CAACC,YAAY,EAAEC,UAAU,GAAG,EAAE,EAAEC,WAAW,GAAG,IAAI,EAAEC,SAAS,GAAG,EAAE,KAAK;EAC7F,MAAMC,YAAY,GAAGJ,YAAY,CAACK,eAAe,GAAGL,YAAY,CAACK,eAAe,GAAGL,YAAY;EAC/F,MAAMM,sBAAsB,GAAG,CAAC,CAACL,UAAU,CAACL,MAAM,CAACC,IAAI,IAAIA,IAAI,CAACU,QAAQ,CAAC,WAAW,CAAC,CAAC,CAACT,MAAM;EAC7F,MAAM;IAAEU,cAAc;IAAEC;EAAuB,CAAC,GAAGC,gBAAgB,CACjEN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AsB,EAAE,OAAO,EAAE;EACtC,MAAMhB,KAAK,GAAG,EAAE;EAChB,IAAIgD,WAAW,EACbhD,KAAK,CAACwB,IAAI,CAAC,eAAe,EAAE,wBAAwB,EAAE,4BAA4B,CAAC;EAErF,IAAIyB,YAAY,EAAE;IAChBjD,KAAK,CAACwB,IAAI,CAAE,GAAE7B,cAAe,QAAO,CAAC;IACrCK,KAAK,CAACwB,IAAI,CAAC5B,aAAa,CAAC;EAC3B;EAEA,OAAOI,KAAK;AACd,CAAC;AAED,eAAeM,eAAe"}
1
+ {"version":3,"file":"build-props-query.js","names":["CATEGORY_ID","ID","PREHEADER_PROP","HEADLINE_PROP","defaultProps","categoryProps","checkProps","props","Object","keys","filter","prop","length","buildPropsQuery","entitySchema","extraProps","cardOptions","linkProps","parsedSchema","getEntitySchema","extraPropsHaveCategory","includes","typeBasedProps","shouldAddCategoryProps","getTypeBaseProps","allProps","uniqueProps","Set","basicProps","nestedProps","forEach","push","base","nested","split","complexProps","buildComplexProps","join","relations","dynamicProperties","properties","map","hasLink","find","linkProp","matchingProperty","matchingRelation","localField","matchingDynamicProp","dynamicKey","jointNestedProps","isCard","displayCategory","displayThumbnail","interfaces","isContent","hasCategory","hasPreheader","getCategoyProps","getContentProps","url"],"sources":["../../src/helpers/build-props-query.js"],"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 = (entitySchema, extraProps = [], cardOptions = null, linkProps = []) => {\n const parsedSchema = entitySchema.getEntitySchema ? entitySchema.getEntitySchema : entitySchema;\n const extraPropsHaveCategory = !!extraProps.filter(prop => prop.includes('category.')).length;\n const { typeBasedProps, shouldAddCategoryProps } = getTypeBaseProps(\n parsedSchema,\n cardOptions,\n extraPropsHaveCategory\n );\n\n const allProps = [...typeBasedProps, ...extraProps];\n const uniqueProps = [...new Set([...allProps])];\n const basicProps = [];\n const nestedProps = {};\n uniqueProps.forEach(prop => {\n if (prop) {\n if (!prop.includes('.')) {\n basicProps.push(prop);\n return;\n }\n const [base, nested] = prop.split('.');\n if (!nestedProps[base]) nestedProps[base] = [nested];\n else nestedProps[base].push(nested);\n }\n });\n\n const complexProps = buildComplexProps(\n shouldAddCategoryProps,\n nestedProps,\n parsedSchema,\n linkProps\n );\n\n return [...basicProps, ...complexProps].join(',');\n};\n\nconst buildComplexProps = (\n shouldAddCategoryProps,\n props,\n { relations = [], dynamicProperties = {}, properties = {} },\n linkProps\n) =>\n Object.keys(props).map(base => {\n const nestedProps = props[base];\n const hasLink = !!linkProps.find(linkProp => linkProp.includes(base));\n const matchingProperty = !!properties[base];\n const matchingRelation = relations.find(({ localField }) => localField === base);\n const matchingDynamicProp = Object.keys(dynamicProperties).find(\n dynamicKey => dynamicKey === base\n );\n\n if (matchingRelation && !nestedProps.includes('id')) nestedProps.push('id');\n if (hasLink && (!!matchingProperty || !!matchingRelation || !!matchingDynamicProp))\n nestedProps.push('url');\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 = (entitySchema, 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 { interfaces, properties, dynamicProperties, relations } = entitySchema;\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 (properties.url || dynamicProperties.url) typeBasedProps.push('url');\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 const props = [];\n if (hasCategory)\n props.push('category.name', 'category.listingPageId', 'category.listingPageEntity');\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"],"mappings":"AAAA,SAASA,WAAW,EAAEC,EAAE,EAAEC,cAAc,EAAEC,aAAa,QAAQ,cAAc;AAE7E,MAAMC,YAAY,GAAG,CAACH,EAAE,EAAE,MAAM,CAAC;AACjC,MAAMI,aAAa,GAAG,kCAAkC;AAExD,MAAMC,UAAU,GAAGC,KAAK,IACtB,CAAC,EAAEA,KAAK,IAAIC,MAAM,CAACC,IAAI,CAACF,KAAK,CAAC,CAACG,MAAM,CAACC,IAAI,IAAIA,IAAI,KAAKX,WAAW,CAAC,CAACY,MAAM,CAAC;AAE7E,MAAMC,eAAe,GAAGA,CAACC,YAAY,EAAEC,UAAU,GAAG,EAAE,EAAEC,WAAW,GAAG,IAAI,EAAEC,SAAS,GAAG,EAAE,KAAK;EAC7F,MAAMC,YAAY,GAAGJ,YAAY,CAACK,eAAe,GAAGL,YAAY,CAACK,eAAe,GAAGL,YAAY;EAC/F,MAAMM,sBAAsB,GAAG,CAAC,CAACL,UAAU,CAACL,MAAM,CAACC,IAAI,IAAIA,IAAI,CAACU,QAAQ,CAAC,WAAW,CAAC,CAAC,CAACT,MAAM;EAC7F,MAAM;IAAEU,c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,IAAKA,SAAS,GAAG,CAAC,KAAK,EAAE,WAAW,EAAE,UAAU,CAAC,GAAG,EAAG;AAExF,MAAMG,eAAe,GAAGA,CAACnC,sBAAsB,EAAEiC,WAAW,EAAEC,YAAY,KAAK;EAC7E,IAAI,CAAClC,sBAAsB,EAAE,OAAO,EAAE;EACtC,MAAMhB,KAAK,GAAG,EAAE;EAChB,IAAIiD,WAAW,EACbjD,KAAK,CAACwB,IAAI,CAAC,eAAe,EAAE,wBAAwB,EAAE,4BAA4B,CAAC;EAErF,IAAI0B,YAAY,EAAE;IAChBlD,KAAK,CAACwB,IAAI,CAAE,GAAE7B,cAAe,QAAO,CAAC;IACrCK,KAAK,CAACwB,IAAI,CAAC5B,aAAa,CAAC;EAC3B;EAEA,OAAOI,KAAK;AACd,CAAC;AAED,eAAeM,eAAe"}
@@ -24,7 +24,11 @@ const buildSetFilters = ({
24
24
  getCheckboxFilters(checkboxFilters, SPONSORED);
25
25
  }
26
26
  const shouldApplyFilterValues = filterBy.length && filterByProperty.length;
27
- const listFilterValues = shouldApplyFilterValues ? getFilterValues(filterBy) : {};
27
+ if (!shouldApplyFilterValues) return {
28
+ checkboxFilters,
29
+ listFilterValues: {}
30
+ };
31
+ const listFilterValues = getFilterValues(filterBy);
28
32
  return {
29
33
  checkboxFilters,
30
34
  listFilterValues
@@ -1 +1 @@
1
- {"version":3,"file":"build-set-filters.js","names":["FEATURED","SPONSORED","getCheckboxFilters","checkboxFilters","name","push","getFilterValues","filterBy","reduce","acc","filter","fieldName","values","split","value","join","previousValue","finalValue","buildSetFilters","filterByProperty","filterByFeatured","filterBySponsored","shouldApplyFilterValues","length","listFilterValues"],"sources":["../../src/helpers/build-set-filters.js"],"sourcesContent":["import { FEATURED, SPONSORED } from '../constants';\n\nconst getCheckboxFilters = (checkboxFilters, name) => {\n checkboxFilters.push(name);\n};\n\nconst getFilterValues = filterBy =>\n filterBy.reduce((acc, filter) => {\n const [fieldName, ...values] = filter.split('/');\n const value = values.join('/');\n const previousValue = acc[fieldName];\n const finalValue = previousValue ? [...previousValue, value] : [value];\n\n acc[fieldName] = finalValue;\n return acc;\n }, {});\n\nconst buildSetFilters = ({\n filterBy = [],\n filterByProperty = [],\n filterByFeatured,\n filterBySponsored\n}) => {\n const checkboxFilters = [];\n\n if (filterByFeatured) {\n getCheckboxFilters(checkboxFilters, FEATURED);\n }\n if (filterBySponsored) {\n getCheckboxFilters(checkboxFilters, SPONSORED);\n }\n\n const shouldApplyFilterValues = filterBy.length && filterByProperty.length;\n const listFilterValues = shouldApplyFilterValues ? getFilterValues(filterBy) : {};\n\n return { checkboxFilters, listFilterValues };\n};\n\nexport default buildSetFilters;\n"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,SAAS,QAAQ,cAAc;AAElD,MAAMC,kBAAkB,GAAGA,CAACC,eAAe,EAAEC,IAAI,KAAK;EACpDD,eAAe,CAACE,IAAI,CAACD,IAAI,CAAC;AAC5B,CAAC;AAED,MAAME,eAAe,GAAGC,QAAQ,IAC9BA,QAAQ,CAACC,MAAM,CAAC,CAACC,GAAG,EAAEC,MAAM,KAAK;EAC/B,MAAM,CAACC,SAAS,EAAE,GAAGC,MAAM,CAAC,GAAGF,MAAM,CAACG,KAAK,CAAC,GAAG,CAAC;EAChD,MAAMC,KAAK,GAAGF,MAAM,CAACG,IAAI,CAAC,GAAG,CAAC;EAC9B,MAAMC,aAAa,GAAGP,GAAG,CAACE,SAAS,CAAC;EACpC,MAAMM,UAAU,GAAGD,aAAa,GAAG,CAAC,GAAGA,aAAa,EAAEF,KAAK,CAAC,GAAG,CAACA,KAAK,CAAC;EAEtEL,GAAG,CAACE,SAAS,CAAC,GAAGM,UAAU;EAC3B,OAAOR,GAAG;AACZ,CAAC,EAAE,CAAC,CAAC,CAAC;AAER,MAAMS,eAAe,GAAGA,CAAC;EACvBX,QAAQ,GAAG,EAAE;EACbY,gBAAgB,GAAG,EAAE;EACrBC,gBAAgB;EAChBC;AACF,CAAC,KAAK;EACJ,MAAMlB,eAAe,GAAG,EAAE;EAE1B,IAAIiB,gBAAgB,EAAE;IACpBlB,kBAAkB,CAACC,eAAe,EAAEH,QAAQ,CAAC;EAC/C;EACA,IAAIqB,iBAAiB,EAAE;IACrBnB,kBAAkB,CAACC,eAAe,EAAEF,SAAS,CAAC;EAChD;EAEA,MAAMqB,uBAAuB,GAAGf,QAAQ,CAACgB,MAAM,IAAIJ,gBAAgB,CAACI,MAAM;EAC1E,MAAMC,gBAAgB,GAAGF,uBAAuB,GAAGhB,eAAe,CAACC,QAAQ,CAAC,GAAG,CAAC,CAAC;EAEjF,OAAO;IAAEJ,eAAe;IAAEqB;EAAiB,CAAC;AAC9C,CAAC;AAED,eAAeN,eAAe"}
1
+ {"version":3,"file":"build-set-filters.js","names":["FEATURED","SPONSORED","getCheckboxFilters","checkboxFilters","name","push","getFilterValues","filterBy","reduce","acc","filter","fieldName","values","split","value","join","previousValue","finalValue","buildSetFilters","filterByProperty","filterByFeatured","filterBySponsored","shouldApplyFilterValues","length","listFilterValues"],"sources":["../../src/helpers/build-set-filters.js"],"sourcesContent":["import { FEATURED, SPONSORED } from '../constants';\n\nconst getCheckboxFilters = (checkboxFilters, name) => {\n checkboxFilters.push(name);\n};\n\nconst getFilterValues = filterBy =>\n filterBy.reduce((acc, filter) => {\n const [fieldName, ...values] = filter.split('/');\n const value = values.join('/');\n const previousValue = acc[fieldName];\n const finalValue = previousValue ? [...previousValue, value] : [value];\n\n acc[fieldName] = finalValue;\n return acc;\n }, {});\n\nconst buildSetFilters = ({\n filterBy = [],\n filterByProperty = [],\n filterByFeatured,\n filterBySponsored\n}) => {\n const checkboxFilters = [];\n\n if (filterByFeatured) {\n getCheckboxFilters(checkboxFilters, FEATURED);\n }\n if (filterBySponsored) {\n getCheckboxFilters(checkboxFilters, SPONSORED);\n }\n\n const shouldApplyFilterValues = filterBy.length && filterByProperty.length;\n if (!shouldApplyFilterValues) return { checkboxFilters, listFilterValues: {} };\n\n const listFilterValues = getFilterValues(filterBy);\n return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AMA,gBAAgB,GAAGlB,eAAe,CAACC,QAAQ,CAAC;EAClD,OAAO;IAAEJ,eAAe;IAAEqB;EAAiB,CAAC;AAC9C,CAAC;AAED,eAAeN,eAAe"}
@@ -1,11 +1,15 @@
1
1
  import isFilterEntitysId from './is-filter-entitys-id';
2
2
  import getFilterProps from './get-filter-props';
3
3
  import { ID } from '../constants';
4
- const getQueryProps = (inheritedFilters, currentSchema, filterEntitySchema) => {
4
+ const getQueryProps = (inheritedFilters, currentSchema, filterEntitySchema = {}) => {
5
5
  if (!currentSchema || !inheritedFilters.length) return ID;
6
6
  const {
7
- identifier: currentEntityId
7
+ identifier: currentEntityId,
8
+ properties
8
9
  } = currentSchema;
10
+ const {
11
+ identifier: filterEntityId
12
+ } = filterEntitySchema;
9
13
  return inheritedFilters.reduce((acc, filter) => {
10
14
  const {
11
15
  filterName,
@@ -20,6 +24,10 @@ const getQueryProps = (inheritedFilters, currentSchema, filterEntitySchema) => {
20
24
  if (relationForeignKeys && relationForeignKeys.length) {
21
25
  return `${acc} ${relationForeignKeys.join(' ')}`;
22
26
  }
27
+ if (filterName === ID) {
28
+ const queryValue = Object.keys(properties).find(propKey => properties[propKey] && properties[propKey].relation && properties[propKey].relation.entityIdentifier === filterEntityId);
29
+ if (queryValue) return `${acc} ${queryValue} `;
30
+ }
23
31
  const queryProp = relationEntityName ? `${relationName} { ${relationProp} }` : filterName;
24
32
  const queryPropFinalValue = isEntityItself && isFilterEntitysId(filterName, currentEntityId) ? ID : queryProp;
25
33
  return `${acc} ${queryPropFinalValue} `;
@@ -1 +1 @@
1
- {"version":3,"file":"get-query-props.js","names":["isFilterEntitysId","getFilterProps","ID","getQueryProps","inheritedFilters","currentSchema","filterEntitySchema","length","identifier","currentEntityId","reduce","acc","filter","filterName","relationName","relationProp","relationEntityName","isEntityItself","relationForeignKeys","shouldIgnoreFilter","join","queryProp","queryPropFinalValue"],"sources":["../../src/helpers/get-query-props.js"],"sourcesContent":["import isFilterEntitysId from './is-filter-entitys-id';\nimport getFilterProps from './get-filter-props';\nimport { ID } from '../constants';\n\nconst getQueryProps = (inheritedFilters, currentSchema, filterEntitySchema) => {\n if (!currentSchema || !inheritedFilters.length) return ID;\n\n const { identifier: currentEntityId } = currentSchema;\n\n return inheritedFilters.reduce((acc, filter) => {\n const {\n filterName,\n relationName,\n relationProp,\n relationEntityName,\n isEntityItself,\n relationForeignKeys,\n shouldIgnoreFilter\n } = getFilterProps(filter, currentSchema, filterEntitySchema);\n\n if (shouldIgnoreFilter) return acc;\n if (relationForeignKeys && relationForeignKeys.length) {\n return `${acc} ${relationForeignKeys.join(' ')}`;\n }\n\n const queryProp = relationEntityName ? `${relationName} { ${relationProp} }` : filterName;\n const queryPropFinalValue =\n isEntityItself && isFilterEntitysId(filterName, currentEntityId) ? ID : queryProp;\n\n return `${acc} ${queryPropFinalValue} `;\n }, ID);\n};\n\nexport default getQueryProps;\n"],"mappings":"AAAA,OAAOA,iBAAiB,MAAM,wBAAwB;AACtD,OAAOC,cAAc,MAAM,oBAAoB;AAC/C,SAASC,EAAE,QAAQ,cAAc;AAEjC,MAAMC,aAAa,GAAGA,CAACC,gBAAgB,EAAEC,aAAa,EAAEC,kBAAkB,KAAK;EAC7E,IAAI,CAACD,aAAa,IAAI,CAACD,gBAAgB,CAACG,MAAM,EAAE,OAAOL,EAAE;EAEzD,MAAM;IAAEM,UAAU,EAAEC;EAAgB,CAAC,GAAGJ,aAAa;EAErD,OAAOD,gBAAgB,CAACM,MAAM,CAAC,CAACC,GAAG,EAAEC,MAAM,KAAK;IAC9C,MAAM;MACJC,UAAU;MACVC,YAAY;MACZC,YAAY;MACZC,kBAAkB;MAClBC,cAAc;MACdC,mBAAmB;MACnBC;IACF,CAAC,GAAGlB,cAAc,CAACW,MAAM,EAAEP,aAAa,EAAEC,kBAAkB,CAAC;IAE7D,IAAIa,kBAAkB,EAAE,OAAOR,GAAG;IAClC,IAAIO,mBAAmB,IAAIA,mBAAmB,CAACX,MAAM,EAAE;MACrD,OAAQ,GAAEI,GAAI,IAAGO,mBAAmB,CAACE,IAAI,CAAC,GAAG,CAAE,EAAC;IAClD;IAEA,MAAMC,SAAS,GAAGL,kBAAkB,GAAI,GAAEF,YAAa,MAAKC,YAAa,IAAG,GAAGF,UAAU;IACzF,MAAMS,mBAAmB,GACvBL,cAAc,IAAIjB,iBAAiB,CAACa,UAAU,EAAEJ,eAAe,CAAC,GAAGP,EAAE,GAAGmB,SAAS;IAEnF,OAAQ,GAAEV,GAAI,IAAGW,mBAAoB,GAAE;EACzC,CAAC,EAAEpB,EAAE,CAAC;AACR,CAAC;AAED,eAAeC,aAAa"}
1
+ {"version":3,"file":"get-query-props.js","names":["isFilterEntitysId","getFilterProps","ID","getQueryProps","inheritedFilters","currentSchema","filterEntitySchema","length","identifier","currentEntityId","properties","filterEntityId","reduce","acc","filter","filterName","relationName","relationProp","relationEntityName","isEntityItself","relationForeignKeys","shouldIgnoreFilter","join","queryValue","Object","keys","find","propKey","relation","entityIdentifier","queryProp","queryPropFinalValue"],"sources":["../../src/helpers/get-query-props.js"],"sourcesContent":["import isFilterEntitysId from './is-filter-entitys-id';\nimport getFilterProps from './get-filter-props';\nimport { ID } from '../constants';\n\nconst getQueryProps = (inheritedFilters, currentSchema, filterEntitySchema = {}) => {\n if (!currentSchema || !inheritedFilters.length) return ID;\n\n const { identifier: currentEntityId, properties } = currentSchema;\n const { identifier: filterEntityId } = filterEntitySchema;\n\n return inheritedFilters.reduce((acc, filter) => {\n const {\n filterName,\n relationName,\n relationProp,\n relationEntityName,\n isEntityItself,\n relationForeignKeys,\n shouldIgnoreFilter\n } = getFilterProps(filter, currentSchema, filterEntitySchema);\n if (shouldIgnoreFilter) return acc;\n if (relationForeignKeys && relationForeignKeys.length) {\n return `${acc} ${relationForeignKeys.join(' ')}`;\n }\n if (filterName === ID) {\n const queryValue = Object.keys(properties).find(\n propKey =>\n properties[propKey] &&\n properties[propKey].relation &&\n properties[propKey].relation.entityIdentifier === filterEntityId\n );\n if (queryValue) return `${acc} ${queryValue} `;\n }\n const queryProp = relationEntityName ? `${relationName} { ${relationProp} }` : filterName;\n const queryPropFinalValue =\n isEntityItself && isFilterEntitysId(filterName, currentEntityId) ? ID : queryProp;\n\n return `${acc} ${queryPropFinalValue} `;\n }, ID);\n};\n\nexport default getQueryProps;\n"],"mappings":"AAAA,OAAOA,iBAAiB,MAAM,wBAAwB;AACtD,OAAOC,cAAc,MAAM,oBAAoB;AAC/C,SAASC,EAAE,QAAQ,cAAc;AAEjC,MAAMC,aAAa,GAAGA,CAACC,gBAAgB,EAAEC,aAAa,EAAEC,kBAAkB,GAAG,CAAC,CAAC,KAAK;EAClF,IAAI,CAACD,aAAa,IAAI,CAACD,gBAAgB,CAACG,MAAM,EAAE,OAAOL,EAAE;EAEzD,MAAM;IAAEM,UAAU,EAAEC,eAAe;IAAEC;EAAW,CAAC,GAAGL,aAAa;EACjE,MAAM;IAAEG,UAAU,EAAEG;EAAe,CAAC,GAAGL,kBAAkB;EAEzD,OAAOF,gBAAgB,CAACQ,MAAM,CAAC,CAACC,GAAG,EAAEC,MAAM,KAAK;IAC9C,MAAM;MACJC,UAAU;MACVC,YAAY;MACZC,YAAY;MACZC,kBAAkB;MAClBC,cAAc;MACdC,mBAAmB;MACnBC;IACF,CAAC,GAAGpB,cAAc,CAACa,MAAM,EAAET,aAAa,EAAEC,kBAAkB,CAAC;IAC7D,IAAIe,kBAAkB,EAAE,OAAOR,GAAG;IAClC,IAAIO,mBAAmB,IAAIA,mBAAmB,CAACb,MAAM,EAAE;MACrD,OAAQ,GAAEM,GAAI,IAAGO,mBAAmB,CAACE,IAAI,CAAC,GAAG,CAAE,EAAC;IAClD;IACA,IAAIP,UAAU,KAAKb,EAAE,EAAE;MACrB,MAAMqB,UAAU,GAAGC,MAAM,CAACC,IAAI,CAACf,UAAU,CAAC,CAACgB,IAAI,CAC7CC,OAAO,IACLjB,UAAU,CAACiB,OAAO,CAAC,IACnBjB,UAAU,CAACiB,OAAO,CAAC,CAACC,QAAQ,IAC5BlB,UAAU,CAACiB,OAAO,CAAC,CAACC,QAAQ,CAACC,gBAAgB,KAAKlB,cACtD,CAAC;MACD,IAAIY,UAAU,EAAE,OAAQ,GAAEV,GAAI,IAAGU,UAAW,GAAE;IAChD;IACA,MAAMO,SAAS,GAAGZ,kBAAkB,GAAI,GAAEF,YAAa,MAAKC,YAAa,IAAG,GAAGF,UAAU;IACzF,MAAMgB,mBAAmB,GACvBZ,cAAc,IAAInB,iBAAiB,CAACe,UAAU,EAAEN,eAAe,CAAC,GAAGP,EAAE,GAAG4B,SAAS;IAEnF,OAAQ,GAAEjB,GAAI,IAAGkB,mBAAoB,GAAE;EACzC,CAAC,EAAE7B,EAAE,CAAC;AACR,CAAC;AAED,eAAeC,aAAa"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blaze-cms/react-page-builder",
3
- "version": "0.130.0-admin-updates.6",
3
+ "version": "0.130.0-admin-updates.9",
4
4
  "description": "Blaze react page builder",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib-es/index.js",
@@ -32,7 +32,7 @@
32
32
  "@blaze-cms/core-errors-ui": "0.130.0-admin-updates.0",
33
33
  "@blaze-cms/image-cdn-react": "0.3.0-alpha.5",
34
34
  "@blaze-cms/nextjs-components": "0.130.0-admin-updates.0",
35
- "@blaze-cms/plugin-search-ui": "0.130.0-admin-updates.4",
35
+ "@blaze-cms/plugin-search-ui": "0.130.0-admin-updates.9",
36
36
  "@blaze-cms/setup-ui": "0.130.0-admin-updates.0",
37
37
  "@blaze-cms/utils": "0.130.0-admin-updates.0",
38
38
  "@blaze-cms/utils-handlebars": "0.130.0-admin-updates.0",
@@ -89,5 +89,5 @@
89
89
  "lib/*",
90
90
  "lib-es/*"
91
91
  ],
92
- "gitHead": "b9d0211de22635574875beede5105697dbb24377"
92
+ "gitHead": "462e28db91657c82f0e901a77dd82d9901d2a160"
93
93
  }
@@ -22,7 +22,8 @@ import {
22
22
  filterQuerySetup,
23
23
  shouldSkipSingleQuery,
24
24
  shouldReturn,
25
- getUpdatedSortProperties
25
+ getUpdatedSortProperties,
26
+ getUpdatedItemsToDisplay
26
27
  } from './helpers';
27
28
 
28
29
  const CardsContainer = dynamic(() => import('./CardsContainer'));
@@ -95,6 +96,7 @@ const CardsRender = ({
95
96
  isPreview,
96
97
  itemEntityUpdated: unpublishedParentEntityName
97
98
  });
99
+
98
100
  const {
99
101
  data: { entityData: parentEntityData = {} } = {},
100
102
  error: _err,
@@ -122,6 +124,13 @@ const CardsRender = ({
122
124
  variableProps
123
125
  );
124
126
 
127
+ const updatedItemsToDisplay = getUpdatedItemsToDisplay({
128
+ itemsToDisplay,
129
+ inheritedFilters,
130
+ parentSchema,
131
+ parentEntityData
132
+ });
133
+
125
134
  const { limit, variables } = filterQuerySetup({
126
135
  getEntitySchemas: Object.values(requiredSchema),
127
136
  entity: primaryEntityToUse,
@@ -130,22 +139,33 @@ const CardsRender = ({
130
139
  docType: docTypes,
131
140
  filterOperator,
132
141
  filterEntityRelations,
133
- itemsToDisplay,
142
+ itemsToDisplay: updatedItemsToDisplay,
134
143
  entitySameAsCurrentItemEntity,
135
144
  useRandomSort
136
145
  });
146
+
147
+ const hasNoFiltersOrItemsToDisplay = !updatedItemsToDisplay.length && !updatedFilterBy;
148
+
137
149
  const { data: cardData, error: cardsError, loading: cardsLoading } = useQuery(action, {
138
150
  variables,
139
151
  fetchPolicy: useRandomSort ? 'cache-and-network' : 'cache-first',
140
- skip: shouldReturn(!updatedFilterBy, _loading, _load, schemaLoading, _error, _err, schemaError)
152
+ skip: shouldReturn(
153
+ hasNoFiltersOrItemsToDisplay,
154
+ _loading,
155
+ _load,
156
+ schemaLoading,
157
+ _error,
158
+ _err,
159
+ schemaError
160
+ )
141
161
  });
142
162
 
143
- const imageIds = itemsToDisplay.map(({ imageId }) => imageId).filter(Boolean);
163
+ const imageIds = updatedItemsToDisplay.map(({ imageId }) => imageId).filter(Boolean);
144
164
  const { data: imagesData, loading: imagesLoading } = useGetImages(imageIds, true);
145
165
  const isLoading = shouldReturn(_loading, _load, schemaLoading, cardsLoading, imagesLoading);
146
166
  const hasError = shouldReturn(_error, _err, schemaError);
147
167
 
148
- if (!updatedFilterBy) return null;
168
+ if (hasNoFiltersOrItemsToDisplay) return null;
149
169
  if (isLoading) return null;
150
170
  if (hasError) return null;
151
171
  if (cardsError) return cardsError.message;
@@ -160,7 +180,7 @@ const CardsRender = ({
160
180
 
161
181
  const orderedData = useRandomSort
162
182
  ? cardDataResults
163
- : sortResponseData(cardDataResults, itemsToDisplay);
183
+ : sortResponseData(cardDataResults, updatedItemsToDisplay);
164
184
  const { regularChildren, gtmChildren } = splitChildren(
165
185
  children,
166
186
  cardDataResults,
@@ -169,7 +189,7 @@ const CardsRender = ({
169
189
  name: variableProps.name
170
190
  }
171
191
  );
172
- const updatedCards = appendImages(imagesData, orderedData, itemsToDisplay);
192
+ const updatedCards = appendImages(imagesData, orderedData, updatedItemsToDisplay);
173
193
 
174
194
  return (
175
195
  <>
@@ -0,0 +1,32 @@
1
+ const getUpdatedItemsToDisplay = ({
2
+ parentSchema,
3
+ parentEntityData,
4
+ itemsToDisplay = [],
5
+ inheritedFilters = []
6
+ }) => {
7
+ const idProp = inheritedFilters.find(filter => filter.indexOf('id/') === 0);
8
+
9
+ if (!idProp || !parentSchema || !parentEntityData) return itemsToDisplay;
10
+ const { properties } = parentSchema;
11
+ const [, entityKey] = idProp.split('/');
12
+ if (!properties || !entityKey) return itemsToDisplay;
13
+ const queryValue = Object.keys(properties).find(
14
+ propKey =>
15
+ properties[propKey] &&
16
+ properties[propKey].relation &&
17
+ properties[propKey].relation.entityIdentifier === entityKey
18
+ );
19
+ const parentValues = parentEntityData[queryValue];
20
+ if (!parentValues) return itemsToDisplay;
21
+ const updatedItemsToDisplay = [...itemsToDisplay];
22
+ if (Array.isArray(parentValues)) {
23
+ parentValues.forEach(value => {
24
+ updatedItemsToDisplay.push({ displayItems: [value] });
25
+ });
26
+ } else {
27
+ updatedItemsToDisplay.push({ displayItems: [parentValues] });
28
+ }
29
+ return updatedItemsToDisplay;
30
+ };
31
+
32
+ export default getUpdatedItemsToDisplay;
@@ -6,3 +6,4 @@ export { default as filterQuerySetup } from './filter-query-setup';
6
6
  export { default as shouldReturn } from './should-return';
7
7
  export { default as shouldSkipSingleQuery } from './should-skip-single-query';
8
8
  export { default as getUpdatedSortProperties } from './get-updated-sort-properties';
9
+ export { default as getUpdatedItemsToDisplay } from './get-updated-items-to-display';
@@ -1,6 +1,7 @@
1
1
  import flatten from 'lodash.flatten';
2
2
  import isFilterEntitysId from './is-filter-entitys-id';
3
3
  import getFilterProps from './get-filter-props';
4
+ import { ID } from '../constants';
4
5
 
5
6
  const getRelationData = (entityData, relationName, currentRelationNames) => {
6
7
  if (!entityData) return null;
@@ -49,8 +50,9 @@ const buildInheritedFilters = (
49
50
  shouldIgnoreFilter
50
51
  } = getFilterProps(filter, currentSchema, filterEntitySchema);
51
52
 
52
- const relationData = getRelationData(entityData, relationName, relationForeignKeys);
53
+ if (filterName === ID) return;
53
54
 
55
+ const relationData = getRelationData(entityData, relationName, relationForeignKeys);
54
56
  if (
55
57
  (currentEntityId === entityName && isFilterEntitysId(filterName, currentEntityId)) ||
56
58
  shouldIgnoreFilter