@blaze-cms/react-page-builder 0.130.0-admin-updates.8 → 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 (37) hide show
  1. package/CHANGELOG.md +11 -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-set-filters.js +5 -1
  13. package/lib/helpers/build-set-filters.js.map +1 -1
  14. package/lib/helpers/get-query-props.js +13 -2
  15. package/lib/helpers/get-query-props.js.map +1 -1
  16. package/lib-es/components/Card/CardsRender.js +14 -7
  17. package/lib-es/components/Card/CardsRender.js.map +1 -1
  18. package/lib-es/components/Card/helpers/get-updated-items-to-display.js +32 -0
  19. package/lib-es/components/Card/helpers/get-updated-items-to-display.js.map +1 -0
  20. package/lib-es/components/Card/helpers/index.js +1 -0
  21. package/lib-es/components/Card/helpers/index.js.map +1 -1
  22. package/lib-es/components/SearchContent/SearchContentItems.js +1 -1
  23. package/lib-es/components/SearchContent/SearchContentItems.js.map +1 -1
  24. package/lib-es/helpers/build-inherited-filters.js +2 -0
  25. package/lib-es/helpers/build-inherited-filters.js.map +1 -1
  26. package/lib-es/helpers/build-set-filters.js +5 -1
  27. package/lib-es/helpers/build-set-filters.js.map +1 -1
  28. package/lib-es/helpers/get-query-props.js +10 -2
  29. package/lib-es/helpers/get-query-props.js.map +1 -1
  30. package/package.json +3 -3
  31. package/src/components/Card/CardsRender.js +27 -7
  32. package/src/components/Card/helpers/get-updated-items-to-display.js +32 -0
  33. package/src/components/Card/helpers/index.js +1 -0
  34. package/src/helpers/build-inherited-filters.js +3 -1
  35. package/src/helpers/build-set-filters.js +2 -1
  36. package/src/helpers/get-query-props.js +12 -4
  37. package/tests/unit/src/components/Card/helpers/get-updated-items-to-display.test.js +72 -0
package/CHANGELOG.md CHANGED
@@ -3,6 +3,17 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [0.130.0-admin-updates.9](https://github.com/thebyte9/blaze/compare/v0.130.0-admin-updates.8...v0.130.0-admin-updates.9) (2023-07-03)
7
+
8
+
9
+ ### Features
10
+
11
+ * filteryBy on cards allow for id prop which fetches related data on parent to render ([#3975](https://github.com/thebyte9/blaze/issues/3975)) ([332f99f](https://github.com/thebyte9/blaze/commit/332f99f84e10328f86996b5d0f0a54a5f24a6693))
12
+
13
+
14
+
15
+
16
+
6
17
  # [0.130.0-admin-updates.8](https://github.com/thebyte9/blaze/compare/v0.130.0-admin-updates.7...v0.130.0-admin-updates.8) (2023-06-29)
7
18
 
8
19
 
@@ -146,6 +146,12 @@ var CardsRender = function CardsRender(_ref) {
146
146
  schemaLoading = _useGetEntitySchemasA3.loading,
147
147
  schemaError = _useGetEntitySchemasA3.error;
148
148
  var updatedFilterBy = (0, _helpers.getUpdatedFilterBy)(inheritedFilters, parentEntityData, parentSchema, filterEntitySchema, parentId, variableProps);
149
+ var updatedItemsToDisplay = (0, _helpers2.getUpdatedItemsToDisplay)({
150
+ itemsToDisplay: itemsToDisplay,
151
+ inheritedFilters: inheritedFilters,
152
+ parentSchema: parentSchema,
153
+ parentEntityData: parentEntityData
154
+ });
149
155
  var _filterQuerySetup = (0, _helpers2.filterQuerySetup)({
150
156
  getEntitySchemas: Object.values(requiredSchema),
151
157
  entity: primaryEntityToUse,
@@ -154,21 +160,22 @@ var CardsRender = function CardsRender(_ref) {
154
160
  docType: docTypes,
155
161
  filterOperator: filterOperator,
156
162
  filterEntityRelations: filterEntityRelations,
157
- itemsToDisplay: itemsToDisplay,
163
+ itemsToDisplay: updatedItemsToDisplay,
158
164
  entitySameAsCurrentItemEntity: entitySameAsCurrentItemEntity,
159
165
  useRandomSort: useRandomSort
160
166
  }),
161
167
  limit = _filterQuerySetup.limit,
162
168
  variables = _filterQuerySetup.variables;
169
+ var hasNoFiltersOrItemsToDisplay = !updatedItemsToDisplay.length && !updatedFilterBy;
163
170
  var _useQuery2 = (0, _client.useQuery)(action, {
164
171
  variables: variables,
165
172
  fetchPolicy: useRandomSort ? 'cache-and-network' : 'cache-first',
166
- skip: (0, _helpers2.shouldReturn)(!updatedFilterBy, _loading, _load, schemaLoading, _error, _err, schemaError)
173
+ skip: (0, _helpers2.shouldReturn)(hasNoFiltersOrItemsToDisplay, _loading, _load, schemaLoading, _error, _err, schemaError)
167
174
  }),
168
175
  cardData = _useQuery2.data,
169
176
  cardsError = _useQuery2.error,
170
177
  cardsLoading = _useQuery2.loading;
171
- var imageIds = itemsToDisplay.map(function (_ref4) {
178
+ var imageIds = updatedItemsToDisplay.map(function (_ref4) {
172
179
  var imageId = _ref4.imageId;
173
180
  return imageId;
174
181
  }).filter(Boolean);
@@ -177,7 +184,7 @@ var CardsRender = function CardsRender(_ref) {
177
184
  imagesLoading = _useGetImages.loading;
178
185
  var isLoading = (0, _helpers2.shouldReturn)(_loading, _load, schemaLoading, cardsLoading, imagesLoading);
179
186
  var hasError = (0, _helpers2.shouldReturn)(_error, _err, schemaError);
180
- if (!updatedFilterBy) return null;
187
+ if (hasNoFiltersOrItemsToDisplay) return null;
181
188
  if (isLoading) return null;
182
189
  if (hasError) return null;
183
190
  if (cardsError) return cardsError.message;
@@ -185,13 +192,13 @@ var CardsRender = function CardsRender(_ref) {
185
192
  if (!cardDataResults || !cardDataResults.length) return null;
186
193
  cardDataResults = entitySameAsCurrentItemEntity ? (0, _helpers.removeExtraItems)(cardDataResults, limit, parentId) : cardDataResults;
187
194
  if (!cardDataResults.length) return null;
188
- var orderedData = useRandomSort ? cardDataResults : (0, _helpers.sortResponseData)(cardDataResults, itemsToDisplay);
195
+ var orderedData = useRandomSort ? cardDataResults : (0, _helpers.sortResponseData)(cardDataResults, updatedItemsToDisplay);
189
196
  var _splitChildren = (0, _helpers.splitChildren)(children, cardDataResults, graphqlEntityMap, {
190
197
  name: variableProps.name
191
198
  }),
192
199
  regularChildren = _splitChildren.regularChildren,
193
200
  gtmChildren = _splitChildren.gtmChildren;
194
- var updatedCards = (0, _helpers.appendImages)(imagesData, orderedData, itemsToDisplay);
201
+ var updatedCards = (0, _helpers.appendImages)(imagesData, orderedData, updatedItemsToDisplay);
195
202
  return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, gtmChildren && (0, _helpers.renderChildren)(gtmChildren), /*#__PURE__*/_react["default"].createElement(CardsContainer, (0, _extends2["default"])({
196
203
  cardData: updatedCards,
197
204
  entity: primaryEntityToUse,
@@ -1 +1 @@
1
- {"version":3,"file":"CardsRender.js","names":["_react","_interopRequireWildcard","require","_client","_dynamic","_interopRequireDefault","_propTypes","_nextjsComponents","_query","_constants","_hooks","_helpers","_helpers2","_excluded","ownKeys","object","enumerableOnly","keys","Object","getOwnPropertySymbols","symbols","filter","sym","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","target","i","arguments","length","source","forEach","key","_defineProperty2","getOwnPropertyDescriptors","defineProperties","defineProperty","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","_typeof2","cache","has","get","newObj","hasPropertyDescriptor","prototype","hasOwnProperty","call","desc","set","CardsContainer","dynamic","Promise","resolve","then","CardsRender","_ref","legacyEntity","entity","entities","entityFields","itemsToDisplay","children","otherProps","_objectWithoutProperties2","_useContext","useContext","MainContext","isPreview","_otherProps$parent","parent","parentId","itemId","parentEntity","itemEntity","_otherProps$filterBy","filterBy","_otherProps$filterByP","filterByProperty","sortby","sort","_otherProps$sortPrope","sortProperties","_otherProps$operator","operator","filterOperator","AND","useRandomSort","_getUpdatedSortProper","getUpdatedSortProperties","_getUpdatedSortProper2","_slicedToArray2","updatedSortProperties","sortbyFilters","variableProps","entitiesToUse","primaryEntityToUse","unpublishedParentEntityName","getUnpublishedEntityName","allEntityNames","concat","_toConsumableArray2","uniqueEntityNames","Set","_useGetEntitySchemasA","useGetEntitySchemasAsObj","_useGetEntitySchemasA2","data","mainSchemas","_loading","loading","_error","error","parentSchema","filterEntitySchema","entitiesTypes","map","ent","getEntityData","graphqlEntityMap","reduce","acc","entityType","docTypes","_ref2","type","docType","entityTypes","_ref3","eType","_filtersSetup","filtersSetup","currentSchema","itemEntityUpdated","getAction","queryProps","inheritedFilters","entitySameAsCurrentItemEntity","action","filterEntityRelations","_useQuery","useQuery","generateSingleItemQuery","variables","id","skip","shouldSkipSingleQuery","_useQuery$data","_useQuery$data2","_useQuery$data2$entit","entityData","parentEntityData","_err","_load","_useGetEntitySchemasA3","getRequiredSchemas","_useGetEntitySchemasA4","requiredSchema","schemaLoading","schemaError","updatedFilterBy","getUpdatedFilterBy","_filterQuerySetup","filterQuerySetup","getEntitySchemas","values","limit","_useQuery2","fetchPolicy","shouldReturn","cardData","cardsError","cardsLoading","imageIds","_ref4","imageId","Boolean","_useGetImages","useGetImages","imagesData","imagesLoading","isLoading","hasError","message","cardDataResults","SEARCH_PUBLISHED_CONTENT","results","removeExtraItems","orderedData","sortResponseData","_splitChildren","splitChildren","name","regularChildren","gtmChildren","updatedCards","appendImages","createElement","Fragment","renderChildren","_extends2","cardChildren","propTypes","PropTypes","oneOfType","arrayOf","node","string","isRequired","array","defaultProps","_default","exports"],"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,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,UAAA,GAAAD,sBAAA,CAAAH,OAAA;AACA,IAAAK,iBAAA,GAAAL,OAAA;AACA,IAAAM,MAAA,GAAAN,OAAA;AACA,IAAAO,UAAA,GAAAP,OAAA;AACA,IAAAQ,MAAA,GAAAR,OAAA;AACA,IAAAS,QAAA,GAAAT,OAAA;AAWA,IAAAU,SAAA,GAAAV,OAAA;AAMmB,IAAAW,SAAA;AAAA,SAAAC,QAAAC,MAAA,EAAAC,cAAA,QAAAC,IAAA,GAAAC,MAAA,CAAAD,IAAA,CAAAF,MAAA,OAAAG,MAAA,CAAAC,qBAAA,QAAAC,OAAA,GAAAF,MAAA,CAAAC,qBAAA,C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":3,"file":"CardsRender.js","names":["_react","_interopRequireWildcard","require","_client","_dynamic","_interopRequireDefault","_propTypes","_nextjsComponents","_query","_constants","_hooks","_helpers","_helpers2","_excluded","ownKeys","object","enumerableOnly","keys","Object","getOwnPropertySymbols","symbols","filter","sym","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","target","i","arguments","length","source","forEach","key","_defineProperty2","getOwnPropertyDescriptors","defineProperties","defineProperty","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","_typeof2","cache","has","get","newObj","hasPropertyDescriptor","prototype","hasOwnProperty","call","desc","set","CardsContainer","dynamic","Promise","resolve","then","CardsRender","_ref","legacyEntity","entity","entities","entityFields","itemsToDisplay","children","otherProps","_objectWithoutProperties2","_useContext","useContext","MainContext","isPreview","_otherProps$parent","parent","parentId","itemId","parentEntity","itemEntity","_otherProps$filterBy","filterBy","_otherProps$filterByP","filterByProperty","sortby","sort","_otherProps$sortPrope","sortProperties","_otherProps$operator","operator","filterOperator","AND","useRandomSort","_getUpdatedSortProper","getUpdatedSortProperties","_getUpdatedSortProper2","_slicedToArray2","updatedSortProperties","sortbyFilters","variableProps","entitiesToUse","primaryEntityToUse","unpublishedParentEntityName","getUnpublishedEntityName","allEntityNames","concat","_toConsumableArray2","uniqueEntityNames","Set","_useGetEntitySchemasA","useGetEntitySchemasAsObj","_useGetEntitySchemasA2","data","mainSchemas","_loading","loading","_error","error","parentSchema","filterEntitySchema","entitiesTypes","map","ent","getEntityData","graphqlEntityMap","reduce","acc","entityType","docTypes","_ref2","type","docType","entityTypes","_ref3","eType","_filtersSetup","filtersSetup","currentSchema","itemEntityUpdated","getAction","queryProps","inheritedFilters","entitySameAsCurrentItemEntity","action","filterEntityRelations","_useQuery","useQuery","generateSingleItemQuery","variables","id","skip","shouldSkipSingleQuery","_useQuery$data","_useQuery$data2","_useQuery$data2$entit","entityData","parentEntityData","_err","_load","_useGetEntitySchemasA3","getRequiredSchemas","_useGetEntitySchemasA4","requiredSchema","schemaLoading","schemaError","updatedFilterBy","getUpdatedFilterBy","updatedItemsToDisplay","getUpdatedItemsToDisplay","_filterQuerySetup","filterQuerySetup","getEntitySchemas","values","limit","hasNoFiltersOrItemsToDisplay","_useQuery2","fetchPolicy","shouldReturn","cardData","cardsError","cardsLoading","imageIds","_ref4","imageId","Boolean","_useGetImages","useGetImages","imagesData","imagesLoading","isLoading","hasError","message","cardDataResults","SEARCH_PUBLISHED_CONTENT","results","removeExtraItems","orderedData","sortResponseData","_splitChildren","splitChildren","name","regularChildren","gtmChildren","updatedCards","appendImages","createElement","Fragment","renderChildren","_extends2","cardChildren","propTypes","PropTypes","oneOfType","arrayOf","node","string","isRequired","array","defaultProps","_default","exports"],"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,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,UAAA,GAAAD,sBAAA,CAAAH,OAAA;AACA,IAAAK,iBAAA,GAAAL,OAAA;AACA,IAAAM,MAAA,GAAAN,OAAA;AACA,IAAAO,UAAA,GAAAP,OAAA;AACA,IAAAQ,MAAA,GAAAR,OAAA;AACA,IAAAS,QAAA,GAAAT,OAAA;AAWA,IAAAU,SAAA,GAAAV,OAAA;AAOmB,IAAAW,SAAA;AAAA,SAAAC,QAAAC,MAAA,EAAAC,cAAA,QAAAC,IAAA,GAAAC,MAAA,CAAAD,IAAA,CAAAF,MAAA,OAAAG,MAAA,CAAAC,qBAAA,QAAAC,OAAA,GAAAF,MAAA,CAAAC,qBAAA,CAAAJ,MAAA,GAAAC,cAAA,KAAAI,OAAA,GAAAA,OAAA,CAAAC,MAAA,WAAAC,GAAA,WAAAJ,MAAA,CAAAK,wBAAA,CAAAR,MAAA,EAAAO,GAAA,EAAAE,UAAA,OAAAP,IAAA,CAAAQ,IAAA,CAAAC,KAAA,CAAAT,IAAA,EAAAG,OAAA,YAAAH,IAAA;AAAA,SAAAU,cAAAC,MAAA,aAAAC,CAAA,MAAAA,CAAA,GAAAC,SAAA,CAAAC,MAAA,EAAAF,CAAA,UAAAG,MAAA,WA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el/runtime/helpers/interopRequireDefault");
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports["default"] = void 0;
9
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
10
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
11
+ require("core-js/modules/es.array.find.js");
12
+ require("core-js/modules/es.object.to-string.js");
13
+ require("core-js/modules/es.array.index-of.js");
14
+ require("core-js/modules/es.object.keys.js");
15
+ require("core-js/modules/es.array.is-array.js");
16
+ require("core-js/modules/es.array.for-each.js");
17
+ require("core-js/modules/web.dom-collections.for-each.js");
18
+ var getUpdatedItemsToDisplay = function getUpdatedItemsToDisplay(_ref) {
19
+ var parentSchema = _ref.parentSchema,
20
+ parentEntityData = _ref.parentEntityData,
21
+ _ref$itemsToDisplay = _ref.itemsToDisplay,
22
+ itemsToDisplay = _ref$itemsToDisplay === void 0 ? [] : _ref$itemsToDisplay,
23
+ _ref$inheritedFilters = _ref.inheritedFilters,
24
+ inheritedFilters = _ref$inheritedFilters === void 0 ? [] : _ref$inheritedFilters;
25
+ var idProp = inheritedFilters.find(function (filter) {
26
+ return filter.indexOf('id/') === 0;
27
+ });
28
+ if (!idProp || !parentSchema || !parentEntityData) return itemsToDisplay;
29
+ var properties = parentSchema.properties;
30
+ var _idProp$split = idProp.split('/'),
31
+ _idProp$split2 = (0, _slicedToArray2["default"])(_idProp$split, 2),
32
+ entityKey = _idProp$split2[1];
33
+ if (!properties || !entityKey) return itemsToDisplay;
34
+ var queryValue = Object.keys(properties).find(function (propKey) {
35
+ return properties[propKey] && properties[propKey].relation && properties[propKey].relation.entityIdentifier === entityKey;
36
+ });
37
+ var parentValues = parentEntityData[queryValue];
38
+ if (!parentValues) return itemsToDisplay;
39
+ var updatedItemsToDisplay = (0, _toConsumableArray2["default"])(itemsToDisplay);
40
+ if (Array.isArray(parentValues)) {
41
+ parentValues.forEach(function (value) {
42
+ updatedItemsToDisplay.push({
43
+ displayItems: [value]
44
+ });
45
+ });
46
+ } else {
47
+ updatedItemsToDisplay.push({
48
+ displayItems: [parentValues]
49
+ });
50
+ }
51
+ return updatedItemsToDisplay;
52
+ };
53
+ var _default = getUpdatedItemsToDisplay;
54
+ exports["default"] = _default;
55
+ //# sourceMappingURL=get-updated-items-to-display.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-updated-items-to-display.js","names":["getUpdatedItemsToDisplay","_ref","parentSchema","parentEntityData","_ref$itemsToDisplay","itemsToDisplay","_ref$inheritedFilters","inheritedFilters","idProp","find","filter","indexOf","properties","_idProp$split","split","_idProp$split2","_slicedToArray2","entityKey","queryValue","Object","keys","propKey","relation","entityIdentifier","parentValues","updatedItemsToDisplay","_toConsumableArray2","Array","isArray","forEach","value","push","displayItems","_default","exports"],"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,IAAMA,wBAAwB,GAAG,SAA3BA,wBAAwBA,CAAAC,IAAA,EAKxB;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C/BA,YAAY,CAACK,OAAO,CAAC,UAAAC,KAAK,EAAI;MAC5BL,qBAAqB,CAACM,IAAI,CAAC;QAAEC,YAAY,EAAE,CAACF,KAAK;MAAE,CAAC,CAAC;IACvD,CAAC,CAAC;EACJ,CAAC,MAAM;IACLL,qBAAqB,CAACM,IAAI,CAAC;MAAEC,YAAY,EAAE,CAACR,YAAY;IAAE,CAAC,CAAC;EAC9D;EACA,OAAOC,qBAAqB;AAC9B,CAAC;AAAC,IAAAQ,QAAA,GAEajC,wBAAwB;AAAAkC,OAAA,cAAAD,QAAA"}
@@ -29,6 +29,12 @@ Object.defineProperty(exports, "getPublishedListingUrl", {
29
29
  return _getPublishedListingUrl["default"];
30
30
  }
31
31
  });
32
+ Object.defineProperty(exports, "getUpdatedItemsToDisplay", {
33
+ enumerable: true,
34
+ get: function get() {
35
+ return _getUpdatedItemsToDisplay["default"];
36
+ }
37
+ });
32
38
  Object.defineProperty(exports, "getUpdatedSortProperties", {
33
39
  enumerable: true,
34
40
  get: function get() {
@@ -61,4 +67,5 @@ var _filterQuerySetup = _interopRequireDefault(require("./filter-query-setup"));
61
67
  var _shouldReturn = _interopRequireDefault(require("./should-return"));
62
68
  var _shouldSkipSingleQuery = _interopRequireDefault(require("./should-skip-single-query"));
63
69
  var _getUpdatedSortProperties = _interopRequireDefault(require("./get-updated-sort-properties"));
70
+ var _getUpdatedItemsToDisplay = _interopRequireDefault(require("./get-updated-items-to-display"));
64
71
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["_getPublishedListingUrl","_interopRequireDefault","require","_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,IAAAA,uBAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,kBAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,sBAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,aAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,iBAAA,GAAAL,sBAAA,CAAAC,OAAA;AACA,IAAAK,aAAA,GAAAN,sBAAA,CAAAC,OAAA;AACA,IAAAM,sBAAA,GAAAP,sBAAA,CAAAC,OAAA;AACA,IAAAO,yBAAA,GAAAR,sBAAA,CAAAC,OAAA"}
1
+ {"version":3,"file":"index.js","names":["_getPublishedListingUrl","_interopRequireDefault","require","_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,IAAAA,uBAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,kBAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,sBAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,aAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,iBAAA,GAAAL,sBAAA,CAAAC,OAAA;AACA,IAAAK,aAAA,GAAAN,sBAAA,CAAAC,OAAA;AACA,IAAAM,sBAAA,GAAAP,sBAAA,CAAAC,OAAA;AACA,IAAAO,yBAAA,GAAAR,sBAAA,CAAAC,OAAA;AACA,IAAAQ,yBAAA,GAAAT,sBAAA,CAAAC,OAAA"}
@@ -27,7 +27,7 @@ var SearchContentItems = function SearchContentItems(_ref) {
27
27
  key: id
28
28
  }, /*#__PURE__*/_react["default"].createElement("div", {
29
29
  className: "search-content--results__wrapper"
30
- }, (image === null || image === void 0 ? void 0 : image.url) ? /*#__PURE__*/_react["default"].createElement(_LazyImage["default"], {
30
+ }, image !== null && image !== void 0 && image.url ? /*#__PURE__*/_react["default"].createElement(_LazyImage["default"], {
31
31
  src: image.url,
32
32
  alt: name,
33
33
  className: "search-content--results__image",
@@ -1 +1 @@
1
- {"version":3,"file":"SearchContentItems.js","names":["_react","_interopRequireDefault","require","_BlazeLink","_LazyImage","SearchContentItems","_ref","_ref$results","results","onClick","map","item","url","id","name","image","createElement","href","key","className","src","alt","sizeKey","_default","exports"],"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}</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AAAC,IAAAS,QAAA,GAEUlB,kBAAkB;AAAAmB,OAAA,cAAAD,QAAA"}
1
+ {"version":3,"file":"SearchContentItems.js","names":["_react","_interopRequireDefault","require","_BlazeLink","_LazyImage","SearchContentItems","_ref","_ref$results","results","onClick","map","item","url","id","name","image","createElement","href","key","className","src","alt","sizeKey","_default","exports"],"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,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,UAAA,GAAAH,sBAAA,CAAAC,OAAA;AAEA,IAAMG,kBAAkB,GAAG,SAArBA,kBAAkBA,CAAAC,IAAA;EAAA,IAAAC,YAAA,GAAAD,IAAA,CAAME,OAAO;IAAPA,OAAO,GAAAD,YAAA,cAAG,EAAE,GAAAA,YAAA;IAAEE,OAAO,GAAAH,IAAA,CAAPG,OAAO;EAAA,OACjDD,OAAO,CAACE,GAAG,CAAC,UAAAC,IAAI,EAAI;IAClB,IAAI,CAACA,IAAI,CAACC,GAAG,EAAE,OAAO,IAAI;IAE1B,IAAQC,EAAE,GAAuBF,IAAI,CAA7BE,EAAE;MAAEC,IAAI,GAAiBH,IAAI,CAAzBG,IAAI;MAAEC,KAAK,GAAUJ,IAAI,CAAnBI,KAAK;MAAEH,GAAG,GAAKD,IAAI,CAAZC,GAAG;IAE5B,oBACEZ,MAAA,YAAAgB,aAAA,CAACb,UAAA,WAAS;MAACc,IAAI,EAAEL,GAAI;MAACH,OAAO,EAAEA,OAAQ;MAACS,GAAG,EAAEL;IAAG,gBAC9Cb,MAAA,YAAAgB,aAAA;MAAKG,SAAS,EAAC;IAAkC,GAC9CJ,KAAK,aAALA,KAAK,eAALA,KAAK,CAAEH,GAAG,gBACTZ,MAAA,YAAAgB,aAAA,CAACZ,UAAA,WAAS;MACRgB,GAAG,EAAEL,KAAK,CAACH,GAAI;MACfS,GAAG,EAAEP,IAAK;MACVK,SAAS,EAAC,gCAAgC;MAC1CG,OAAO,EAAC;IAAe,CACxB,CAAC,GACA,IAAI,eACRtB,MAAA,YAAAgB,aAAA;MAAMG,SAAS,EAAC;IAAgC,GAAEL,IAAW,CAC1D,CACI,CAAC;EAEhB,CAAC,CAAC;AAAA;AAAC,IAAAS,QAAA,GAEUlB,kBAAkB;AAAAmB,OAAA,cAAAD,QAAA"}
@@ -19,6 +19,7 @@ require("core-js/modules/es.array.is-array.js");
19
19
  var _lodash = _interopRequireDefault(require("lodash.flatten"));
20
20
  var _isFilterEntitysId = _interopRequireDefault(require("./is-filter-entitys-id"));
21
21
  var _getFilterProps2 = _interopRequireDefault(require("./get-filter-props"));
22
+ var _constants = require("../constants");
22
23
  var getRelationData = function getRelationData(entityData, relationName, currentRelationNames) {
23
24
  if (!entityData) return null;
24
25
  if (currentRelationNames && currentRelationNames.length) {
@@ -57,6 +58,7 @@ var buildInheritedFilters = function buildInheritedFilters(entityData, inherited
57
58
  relationEntityName = _getFilterProps.relationEntityName,
58
59
  relationForeignKeys = _getFilterProps.relationForeignKeys,
59
60
  shouldIgnoreFilter = _getFilterProps.shouldIgnoreFilter;
61
+ if (filterName === _constants.ID) return;
60
62
  var relationData = getRelationData(entityData, relationName, relationForeignKeys);
61
63
  if (currentEntityId === entityName && (0, _isFilterEntitysId["default"])(filterName, currentEntityId) || shouldIgnoreFilter) {
62
64
  relationFilters.push("".concat(filterName, "/").concat(itemId));
@@ -1 +1 @@
1
- {"version":3,"file":"build-inherited-filters.js","names":["_lodash","_interopRequireDefault","require","_isFilterEntitysId","_getFilterProps2","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","_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';\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,IAAAA,OAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,kBAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,gBAAA,GAAAH,sBAAA,CAAAC,OAAA;AAEA,IAAMG,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,kBAA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ACG,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,IAAAgB,QAAA,GAEarB,qBAAqB;AAAAsB,OAAA,cAAAD,QAAA"}
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,IAAA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AAA,CAAIO,MAAM,CAAE,CAAC;IACjD;IAEA,IAAI,CAACjB,YAAY,EAAE;IAEnB,IAAMD,WAAW,GAAGiC,KAAK,CAACC,OAAO,CAACjC,YAAY,CAAC;IAC/C,IAAME,YAAY,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,GAEatB,qBAAqB;AAAAuB,OAAA,cAAAD,QAAA"}
@@ -45,7 +45,11 @@ var buildSetFilters = function buildSetFilters(_ref) {
45
45
  getCheckboxFilters(checkboxFilters, _constants.SPONSORED);
46
46
  }
47
47
  var shouldApplyFilterValues = filterBy.length && filterByProperty.length;
48
- var listFilterValues = shouldApplyFilterValues ? getFilterValues(filterBy) : {};
48
+ if (!shouldApplyFilterValues) return {
49
+ checkboxFilters: checkboxFilters,
50
+ listFilterValues: {}
51
+ };
52
+ var listFilterValues = getFilterValues(filterBy);
49
53
  return {
50
54
  checkboxFilters: checkboxFilters,
51
55
  listFilterValues: listFilterValues
@@ -1 +1 @@
1
- {"version":3,"file":"build-set-filters.js","names":["_constants","require","getCheckboxFilters","checkboxFilters","name","push","getFilterValues","filterBy","reduce","acc","filter","_filter$split","split","_filter$split2","_toArray2","fieldName","values","slice","value","join","previousValue","finalValue","concat","_toConsumableArray2","buildSetFilters","_ref","_ref$filterBy","_ref$filterByProperty","filterByProperty","filterByFeatured","filterBySponsored","FEATURED","SPONSORED","shouldApplyFilterValues","length","listFilterValues","_default","exports"],"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,IAAAA,UAAA,GAAAC,OAAA;AAEA,IAAMC,kBA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,iBAAiB,EAAE;IACrB5B,kBAAkB,CAACC,eAAe,EAAE6B,oBAAS,CAAC;EAChD;EAEA,IAAMC,uBAAuB,GAAG1B,QAAQ,CAAC2B,MAAM,IAAIN,gBAAgB,CAACM,MAAM;EAC1E,IAAMC,gBAAgB,GAAGF,uBAAuB,GAAG3B,eAAe,CAACC,QAAQ,CAAC,GAAG,CAAC,CAAC;EAEjF,OAAO;IAAEJ,eAAe,EAAfA,eAAe;IAAEgC,gBAAgB,EAAhBA;EAAiB,CAAC;AAC9C,CAAC;AAAC,IAAAC,QAAA,GAEaZ,eAAe;AAAAa,OAAA,cAAAD,QAAA"}
1
+ {"version":3,"file":"build-set-filters.js","names":["_constants","require","getCheckboxFilters","checkboxFilters","name","push","getFilterValues","filterBy","reduce","acc","filter","_filter$split","split","_filter$split2","_toArray2","fieldName","values","slice","value","join","previousValue","finalValue","concat","_toConsumableArray2","buildSetFilters","_ref","_ref$filterBy","_ref$filterByProperty","filterByProperty","filterByFeatured","filterBySponsored","FEATURED","SPONSORED","shouldApplyFilterValues","length","listFilterValues","_default","exports"],"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 { checkboxFilters, listFilterValues };\n};\n\nexport default buildSetFilters;\n"],"mappings":";;;;;;;;;;;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AAEA,IAAMC,kBAAkB,GAAG,SAArBA,kBAAkBA,CAAIC,eAAe,EAAEC,IAAI,EAAK;EACpDD,eAAe,CAACE,IAAI,CAACD,IAAI,CAAC;AAC5B,CAAC;AAED,IAAME,eAAe,GAAG,SAAlBA,eAAeA,CAAGC,QAAQ;EAAA,OAC9BA,QAAQ,CAACC,MAAM,CAAC,UAACC,GAAG,EAAEC,MAAM,EAAK;IAC/B,IAAAC,aAAA,GAA+BD,MAAM,CAACE,KAAK,CAAC,GAAG,CAAC;MAAAC,cAAA,OAAAC,SAAA,aAAAH,aAAA;MAAzCI,SAAS,GAAAF,cAAA;MAAKG,MAAM,GAAAH,cAAA,CAAAI,KAAA;IAC3B,IAAMC,KAAK,GAAGF,MAAM,CAACG,IAAI,CAAC,GAAG,CAAC;IAC9B,IAAMC,aAAa,GAAGX,GAAG,CAACM,SAAS,CAAC;IACpC,IAAMM,UAAU,GAAGD,aAAa,MAAAE,MAAA,KAAAC,mBAAA,aAAOH,aAAa,IAAEF,KAAK,KAAI,CAACA,KAAK,CAAC;IAEtET,GAAG,CAACM,SAAS,CAAC,GAAGM,UAAU;IAC3B,OAAOZ,GAAG;EACZ,CAAC,EAAE,CAAC,CAAC,CAAC;AAAA;AAER,IAAMe,eAAe,GAAG,SAAlBA,eAAeA,CAAAC,IAAA,EAKf;EAAA,IAAAC,aAAA,GAAAD,IAAA,CAJJlB,QAAQ;IAARA,QAAQ,GAAAmB,aAAA,cAAG,EAAE,GAAAA,aAAA;IAAAC,qBAAA,GAAAF,IAAA,CACbG,gBAAgB;IAAhBA,gBAAgB,GAAAD,qBAAA,cAAG,EAAE,GAAAA,qBAAA;IACrBE,gBAAgB,GAAAJ,IAAA,CAAhBI,gBAAgB;IAChBC,iBAAiB,GAAAL,IAAA,CAAjBK,iBAAiB;EAEjB,IAAM3B,eAAe,GAAG,EAAE;EAE1B,IAAI0B,gBAAgB,EAAE;IACpB3B,kBAAkB,CAACC,eAAe,EAAE4B,mBAAQ,CAAC;EAC/C;EACA,IAAID,iBAAiB,EAAE;IACrB5B,kBAAkB,CAACC,eAAe,EAAE6B,oBAAS,CAAC;EAChD;EAEA,IAAMC,uBAAuB,GAAG1B,QAAQ,CAAC2B,MAAM,IAAIN,gBAAgB,CAACM,MAAM;EAC1E,IAAI,CAACD,uBAAuB,EAAE,OAAO;IAAE9B,eAAe,EAAfA,eAAe;IAAEgC,gBAAgB,EAAE,CAAC;EAAE,CAAC;EAE9E,IAAMA,gBAAgB,GAAG7B,eAAe,CAACC,QAAQ,CAAC;EAClD,OAAO;IAAEJ,eAAe,EAAfA,eAAe;IAAEgC,gBAAgB,EAAhBA;EAAiB,CAAC;AAC9C,CAAC;AAAC,IAAAC,QAAA,GAEaZ,eAAe;AAAAa,OAAA,cAAAD,QAAA"}
@@ -10,12 +10,17 @@ require("core-js/modules/es.array.reduce.js");
10
10
  require("core-js/modules/es.object.to-string.js");
11
11
  require("core-js/modules/es.array.concat.js");
12
12
  require("core-js/modules/es.array.join.js");
13
+ require("core-js/modules/es.array.find.js");
14
+ require("core-js/modules/es.object.keys.js");
13
15
  var _isFilterEntitysId = _interopRequireDefault(require("./is-filter-entitys-id"));
14
16
  var _getFilterProps2 = _interopRequireDefault(require("./get-filter-props"));
15
17
  var _constants = require("../constants");
16
- var getQueryProps = function getQueryProps(inheritedFilters, currentSchema, filterEntitySchema) {
18
+ var getQueryProps = function getQueryProps(inheritedFilters, currentSchema) {
19
+ var filterEntitySchema = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
17
20
  if (!currentSchema || !inheritedFilters.length) return _constants.ID;
18
- var currentEntityId = currentSchema.identifier;
21
+ var currentEntityId = currentSchema.identifier,
22
+ properties = currentSchema.properties;
23
+ var filterEntityId = filterEntitySchema.identifier;
19
24
  return inheritedFilters.reduce(function (acc, filter) {
20
25
  var _getFilterProps = (0, _getFilterProps2["default"])(filter, currentSchema, filterEntitySchema),
21
26
  filterName = _getFilterProps.filterName,
@@ -29,6 +34,12 @@ var getQueryProps = function getQueryProps(inheritedFilters, currentSchema, filt
29
34
  if (relationForeignKeys && relationForeignKeys.length) {
30
35
  return "".concat(acc, " ").concat(relationForeignKeys.join(' '));
31
36
  }
37
+ if (filterName === _constants.ID) {
38
+ var queryValue = Object.keys(properties).find(function (propKey) {
39
+ return properties[propKey] && properties[propKey].relation && properties[propKey].relation.entityIdentifier === filterEntityId;
40
+ });
41
+ if (queryValue) return "".concat(acc, " ").concat(queryValue, " ");
42
+ }
32
43
  var queryProp = relationEntityName ? "".concat(relationName, " { ").concat(relationProp, " }") : filterName;
33
44
  var queryPropFinalValue = isEntityItself && (0, _isFilterEntitysId["default"])(filterName, currentEntityId) ? _constants.ID : queryProp;
34
45
  return "".concat(acc, " ").concat(queryPropFinalValue, " ");
@@ -1 +1 @@
1
- {"version":3,"file":"get-query-props.js","names":["_isFilterEntitysId","_interopRequireDefault","require","_getFilterProps2","_constants","getQueryProps","inheritedFilters","currentSchema","filterEntitySchema","length","ID","currentEntityId","identifier","reduce","acc","filter","_getFilterProps","getFilterProps","filterName","relationName","relationProp","relationEntityName","isEntityItself","relationForeignKeys","shouldIgnoreFilter","concat","join","queryProp","queryPropFinalValue","isFilterEntitysId","_default","exports"],"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,IAAAA,kBAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,gBAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,UAAA,GAAAF,OAAA;AAEA,IAAMG,aAAa,GAAG,SAAhBA,aAAaA,CAAIC,gBAAgB,EAAEC,aAAa,EAAEC,kBAAkB,EAAK;EAC7E,IAAI,CAACD,aAAa,IAAI,CAACD,gBAAgB,CAACG,MAAM,EAAE,OAAOC,aAAE;EAEzD,IAAoBC,eAAe,GAAKJ,aAAa,CAA7CK,UAAU;EAElB,OAAON,gBAAgB,CAACO,MAAM,CAAC,UAACC,GAAG,EAAEC,MAAM,EAAK;IAC9C,IAAAC,eAAA,GAQI,IAAAC,2BAAc,EAACF,MAAM,EAAER,aAAa,EAAEC,kBAAkB,CAAC;MAP3DU,UAAU,GAAAF,eAAA,CAAVE,UAAU;MACVC,YAAY,GAAAH,eAAA,CAAZG,YAAY;MACZC,YAAY,GAAAJ,eAAA,CAAZI,YAAY;MACZC,kBAAkB,GAAAL,eAAA,CAAlBK,kBAAkB;MAClBC,cAAc,GAAAN,eAAA,CAAdM,cAAc;MACdC,mBAAmB,GAAAP,eAAA,CAAnBO,mBAAmB;MACnBC,kBAAkB,GAAAR,eAAA,CAAlBQ,kBAAkB;IAGpB,IAAIA,kBAAkB,EAAE,OAAOV,GAAG;IAClC,IAAIS,mBAAmB,IAAIA,mBAAmB,CAACd,MAAM,EAAE;MACrD,UAAAgB,MAAA,CAAUX,GAAG,OAAAW,MAAA,CAAIF,mBAAmB,CAACG,IAAI,CAAC,GAAG,CAAC;IAChD;IAEA,IAAMC,SAAS,GAAGN,kBAAkB,MAAAI,MAAA,CAAMN,YAAY,SAAAM,MAAA,CAAML,YAAY,UAAOF,UAAU;IACzF,IAAMU,mBAAmB,GACvBN,cAAc,IAAI,IAAAO,6BAAiB,EAACX,UAAU,EAAEP,eAAe,CAAC,GAAGD,aAAE,GAAGiB,SAAS;IAEnF,UAAAF,MAAA,CAAUX,GAAG,OAAAW,MAAA,CAAIG,mBAAmB;EACtC,CAAC,EAAElB,aAAE,CAAC;AACR,CAAC;AAAC,IAAAoB,QAAA,GAEazB,aAAa;AAAA0B,OAAA,cAAAD,QAAA"}
1
+ {"version":3,"file":"get-query-props.js","names":["_isFilterEntitysId","_interopRequireDefault","require","_getFilterProps2","_constants","getQueryProps","inheritedFilters","currentSchema","filterEntitySchema","arguments","length","undefined","ID","currentEntityId","identifier","properties","filterEntityId","reduce","acc","filter","_getFilterProps","getFilterProps","filterName","relationName","relationProp","relationEntityName","isEntityItself","relationForeignKeys","shouldIgnoreFilter","concat","join","queryValue","Object","keys","find","propKey","relation","entityIdentifier","queryProp","queryPropFinalValue","isFilterEntitysId","_default","exports"],"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,IAAAA,kBAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,gBAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,UAAA,GAAAF,OAAA;AAEA,IAAMG,aAAa,GAAG,SAAhBA,aAAaA,CAAIC,gBAAgB,EAAEC,aAAa,EAA8B;EAAA,IAA5BC,kBAAkB,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;EAC7E,IAAI,CAACF,aAAa,IAAI,CAACD,gBAAgB,CAACI,MAAM,EAAE,OAAOE,aAAE;EAEzD,IAAoBC,eAAe,GAAiBN,aAAa,CAAzDO,UAAU;IAAmBC,UAAU,GAAKR,aAAa,CAA5BQ,UAAU;EAC/C,IAAoBC,cAAc,GAAKR,kBAAkB,CAAjDM,UAAU;EAElB,OAAOR,gBAAgB,CAACW,MAAM,CAAC,UAACC,GAAG,EAAEC,MAAM,EAAK;IAC9C,IAAAC,eAAA,GAQI,IAAAC,2BAAc,EAACF,MAAM,EAAEZ,aAAa,EAAEC,kBAAkB,CAAC;MAP3Dc,UAAU,GAAAF,eAAA,CAAVE,UAAU;MACVC,YAAY,GAAAH,eAAA,CAAZG,YAAY;MACZC,YAAY,GAAAJ,eAAA,CAAZI,YAAY;MACZC,kBAAkB,GAAAL,eAAA,CAAlBK,kBAAkB;MAClBC,cAAc,GAAAN,eAAA,CAAdM,cAAc;MACdC,mBAAmB,GAAAP,eAAA,CAAnBO,mBAAmB;MACnBC,kBAAkB,GAAAR,eAAA,CAAlBQ,kBAAkB;IAEpB,IAAIA,kBAAkB,EAAE,OAAOV,GAAG;IAClC,IAAIS,mBAAmB,IAAIA,mBAAmB,CAACjB,MAAM,EAAE;MACrD,UAAAmB,MAAA,CAAUX,GAAG,OAAAW,MAAA,CAAIF,mBAAmB,CAACG,IAAI,CAAC,GAAG,CAAC;IAChD;IACA,IAAIR,UAAU,KAAKV,aAAE,EAAE;MACrB,IAAMmB,UAAU,GAAGC,MAAM,CAACC,IAAI,CAAClB,UAAU,CAAC,CAACmB,IAAI,CAC7C,UAAAC,OAAO;QAAA,OACLpB,UAAU,CAACoB,OAAO,CAAC,IACnBpB,UAAU,CAACoB,OAAO,CAAC,CAACC,QAAQ,IAC5BrB,UAAU,CAACoB,OAAO,CAAC,CAACC,QAAQ,CAACC,gBAAgB,KAAKrB,cAAc;MAAA,CACpE,CAAC;MACD,IAAIe,UAAU,EAAE,UAAAF,MAAA,CAAUX,GAAG,OAAAW,MAAA,CAAIE,UAAU;IAC7C;IACA,IAAMO,SAAS,GAAGb,kBAAkB,MAAAI,MAAA,CAAMN,YAAY,SAAAM,MAAA,CAAML,YAAY,UAAOF,UAAU;IACzF,IAAMiB,mBAAmB,GACvBb,cAAc,IAAI,IAAAc,6BAAiB,EAAClB,UAAU,EAAET,eAAe,CAAC,GAAGD,aAAE,GAAG0B,SAAS;IAEnF,UAAAT,MAAA,CAAUX,GAAG,OAAAW,MAAA,CAAIU,mBAAmB;EACtC,CAAC,EAAE3B,aAAE,CAAC;AACR,CAAC;AAAC,IAAA6B,QAAA,GAEapC,aAAa;AAAAqC,OAAA,cAAAD,QAAA"}
@@ -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,kBAAkB,EAClBC,aAAa,EACbC,kBAAkB,EAClBC,gBAAgB,EAChBC,wBAAwB,EACxBC,cAAc,EACdC,aAAa,EACbC,gBAAgB,EAChBC,YAAY,QACP,eAAe;AACtB,SACEC,YAAY,EACZC,gBAAgB,EAChBC,qBAAqB,EACrBC,YAAY,EACZC,wBAAwB,QACnB,WAAW;AAElB,MAAMC,cAAc,GAAGtB,OAAO,CAAC,MAAM,MAAM,CAAC,kBAAkB,CAAC,CAAC;AAEhE,MAAMuB,WAAW,GAAGC,IAAA,IAOd;EAAA,IAPe;MACnBC,MAAM,EAAEC,YAAY;MACpBC,QAAQ;MACRC,YAAY;MACZC,cAAc;MACdC;IAEF,CAAC,GAAAN,IAAA;IADIO,UAAU,GAAAC,wBAAA,CAAAR,IAAA,EAAAS,SAAA;EAEb,MAAM;IAAEC;EAAU,CAAC,GAAGpC,UAAU,CAACI,WAAW,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;IAC3BkE,WAAW,EAAEA,WAAY;IACzBM,YAAY,EAAEP,eAAgB;IAC9BjD,gBAAgB,EAAEA;EAAiB,GAC/BnB,aAAa,CAClB,CACD,CAAC;AAEP,CAAC;AAED3B,WAAW,CAACuG,SAAS,GAAG;EACtBhG,QAAQ,EAAE7B,SAAS,CAAC8H,SAAS,CAAC,CAAC9H,SAAS,CAAC+H,OAAO,CAAC/H,SAAS,CAACgI,IAAI,CAAC,EAAEhI,SAAS,CAACgI,IAAI,CAAC,CAAC;EAClFxG,MAAM,EAAExB,SAAS,CAACiI,MAAM,CAACC,UAAU;EACnCvG,YAAY,EAAE3B,SAAS,CAACiI,MAAM,CAACC,UAAU;EACzCtG,cAAc,EAAE5B,SAAS,CAACmI,KAAK;EAC/BzG,QAAQ,EAAE1B,SAAS,CAACmI;AACtB,CAAC;AAED7G,WAAW,CAAC8G,YAAY,GAAG;EACzBvG,QAAQ,EAAE,EAAE;EACZD,cAAc,EAAE,EAAE;EAClBF,QAAQ,EAAE;AACZ,CAAC;AAED,eAAeJ,WAAW"}
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","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,kBAAkB,EAClBC,gBAAgB,EAChBC,wBAAwB,EACxBC,cAAc,EACdC,aAAa,EACbC,gBAAgB,EAChBC,YAAY,QACP,eAAe;AACtB,SACEC,YAAY,EACZC,gBAAgB,EAChBC,qBAAqB,EACrBC,YAAY,EACZC,wBAAwB,EACxBC,wBAAwB,QACnB,WAAW;AAElB,MAAMC,cAAc,GAAGvB,OAAO,CAAC,MAAM,MAAM,CAAC,kBAAkB,CAAC,CAAC;AAEhE,MAAMwB,WAAW,GAAGC,IAAA,IAOd;EAAA,IAPe;MACnBC,MAAM,EAAEC,YAAY;MACpBC,QAAQ;MACRC,YAAY;MACZC,cAAc;MACdC;IAEF,CAAC,GAAAN,IAAA;IADIO,UAAU,GAAAC,wBAAA,CAAAR,IAAA,EAAAS,SAAA;EAEb,MAAM;IAAEC;EAAU,CAAC,GAAGrC,UAAU,CAACI,WAAW,CAAC;EAC7C,M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hI,KAAA,CAAAiI,QAAA,QACGJ,WAAW,IAAI7G,cAAc,CAAC6G,WAAW,CAAC,eAC3C7H,KAAA,CAAAgI,aAAA,CAACtG,cAAc,EAAAwG,QAAA;IACbtB,QAAQ,EAAEmB,YAAa;IACvBlG,MAAM,EAAE4B,kBAAmB;IAC3BoE,WAAW,EAAEA,WAAY;IACzBM,YAAY,EAAEP,eAAgB;IAC9BnD,gBAAgB,EAAEA;EAAiB,GAC/BnB,aAAa,CAClB,CACD,CAAC;AAEP,CAAC;AAED3B,WAAW,CAACyG,SAAS,GAAG;EACtBlG,QAAQ,EAAE9B,SAAS,CAACiI,SAAS,CAAC,CAACjI,SAAS,CAACkI,OAAO,CAAClI,SAAS,CAACmI,IAAI,CAAC,EAAEnI,SAAS,CAACmI,IAAI,CAAC,CAAC;EAClF1G,MAAM,EAAEzB,SAAS,CAACoI,MAAM,CAACC,UAAU;EACnCzG,YAAY,EAAE5B,SAAS,CAACoI,MAAM,CAACC,UAAU;EACzCxG,cAAc,EAAE7B,SAAS,CAACsI,KAAK;EAC/B3G,QAAQ,EAAE3B,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,Y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}
@@ -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[relationPro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G,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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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"}
@@ -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 { 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,CA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
  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 getQue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,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.8",
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": "4b393fc952a6c63e502d86863a62d56f5f32f69f"
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
@@ -31,8 +31,9 @@ const buildSetFilters = ({
31
31
  }
32
32
 
33
33
  const shouldApplyFilterValues = filterBy.length && filterByProperty.length;
34
- const listFilterValues = shouldApplyFilterValues ? getFilterValues(filterBy) : {};
34
+ if (!shouldApplyFilterValues) return { checkboxFilters, listFilterValues: {} };
35
35
 
36
+ const listFilterValues = getFilterValues(filterBy);
36
37
  return { checkboxFilters, listFilterValues };
37
38
  };
38
39
 
@@ -2,10 +2,11 @@ import isFilterEntitysId from './is-filter-entitys-id';
2
2
  import getFilterProps from './get-filter-props';
3
3
  import { ID } from '../constants';
4
4
 
5
- const getQueryProps = (inheritedFilters, currentSchema, filterEntitySchema) => {
5
+ const getQueryProps = (inheritedFilters, currentSchema, filterEntitySchema = {}) => {
6
6
  if (!currentSchema || !inheritedFilters.length) return ID;
7
7
 
8
- const { identifier: currentEntityId } = currentSchema;
8
+ const { identifier: currentEntityId, properties } = currentSchema;
9
+ const { identifier: filterEntityId } = filterEntitySchema;
9
10
 
10
11
  return inheritedFilters.reduce((acc, filter) => {
11
12
  const {
@@ -17,12 +18,19 @@ const getQueryProps = (inheritedFilters, currentSchema, filterEntitySchema) => {
17
18
  relationForeignKeys,
18
19
  shouldIgnoreFilter
19
20
  } = getFilterProps(filter, currentSchema, filterEntitySchema);
20
-
21
21
  if (shouldIgnoreFilter) return acc;
22
22
  if (relationForeignKeys && relationForeignKeys.length) {
23
23
  return `${acc} ${relationForeignKeys.join(' ')}`;
24
24
  }
25
-
25
+ if (filterName === ID) {
26
+ const queryValue = Object.keys(properties).find(
27
+ propKey =>
28
+ properties[propKey] &&
29
+ properties[propKey].relation &&
30
+ properties[propKey].relation.entityIdentifier === filterEntityId
31
+ );
32
+ if (queryValue) return `${acc} ${queryValue} `;
33
+ }
26
34
  const queryProp = relationEntityName ? `${relationName} { ${relationProp} }` : filterName;
27
35
  const queryPropFinalValue =
28
36
  isEntityItself && isFilterEntitysId(filterName, currentEntityId) ? ID : queryProp;
@@ -0,0 +1,72 @@
1
+ import '@testing-library/jest-dom/extend-expect';
2
+ import getUpdatedItemsToDisplay from '../../../../../../src/components/Card/helpers/get-updated-items-to-display';
3
+
4
+ const mockedProps = {
5
+ itemsToDisplay: [
6
+ {
7
+ displayItems: ['54321']
8
+ }
9
+ ],
10
+ parentEntityData: {
11
+ authorIds: ['12345']
12
+ },
13
+ parentSchema: {
14
+ properties: {
15
+ authorIds: {
16
+ relation: {
17
+ entityIdentifier: 'author'
18
+ }
19
+ }
20
+ }
21
+ },
22
+ inheritedFilters: ['id/author']
23
+ };
24
+
25
+ describe('getUpdatedItemsToDisplay helper function', () => {
26
+ it('should return empty array if no props passed', () => {
27
+ const emptyArray = getUpdatedItemsToDisplay({});
28
+ expect(emptyArray).toEqual([]);
29
+ });
30
+
31
+ it('should return old itemsToDisplay itemsToDisplay if no idProp match, no parentSchema or no parentEntityData', () => {
32
+ const onlyItemsToDisplayPassed = getUpdatedItemsToDisplay({
33
+ itemsToDisplay: mockedProps.itemsToDisplay
34
+ });
35
+ const noIdPropMatch = getUpdatedItemsToDisplay({
36
+ ...mockedProps,
37
+ inheritedFilters: ['notid/author']
38
+ });
39
+ const noParentSchema = getUpdatedItemsToDisplay({
40
+ ...mockedProps,
41
+ parentSchema: null
42
+ });
43
+ const noParentEntityData = getUpdatedItemsToDisplay({
44
+ ...mockedProps,
45
+ parentEntityData: null
46
+ });
47
+ expect(onlyItemsToDisplayPassed).toEqual(mockedProps.itemsToDisplay);
48
+ expect(noIdPropMatch).toEqual(mockedProps.itemsToDisplay);
49
+ expect(noParentSchema).toEqual(mockedProps.itemsToDisplay);
50
+ expect(noParentEntityData).toEqual(mockedProps.itemsToDisplay);
51
+ });
52
+
53
+ it('should return old itemsToDisplay if parentSchema has no propMatch with idProp entity', () => {
54
+ const sameItemsToDisplay = getUpdatedItemsToDisplay({
55
+ ...mockedProps,
56
+ inheritedFilters: ['id/noentitymatch']
57
+ });
58
+ expect(sameItemsToDisplay).toEqual(mockedProps.itemsToDisplay);
59
+ });
60
+
61
+ it('should return updated itemsToDisplay otherwise', () => {
62
+ const sameItemsToDisplay = getUpdatedItemsToDisplay({
63
+ ...mockedProps
64
+ });
65
+ expect(sameItemsToDisplay).toEqual([
66
+ ...mockedProps.itemsToDisplay,
67
+ {
68
+ displayItems: ['12345']
69
+ }
70
+ ]);
71
+ });
72
+ });