@blaze-cms/react-page-builder 0.133.0-project-admin-customisations.0 → 0.133.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +76 -6
- package/lib/components/Button.js +3 -1
- package/lib/components/Button.js.map +1 -1
- package/lib/components/ContentGroupSection/ContentGroupSection.js +4 -1
- package/lib/components/ContentGroupSection/ContentGroupSection.js.map +1 -1
- package/lib/components/DataSummary/helpers/build-loop-props-content.js +2 -3
- package/lib/components/DataSummary/helpers/build-loop-props-content.js.map +1 -1
- package/lib/components/DataSummary/helpers/get-link-to-published-content.js +0 -2
- package/lib/components/DataSummary/helpers/get-link-to-published-content.js.map +1 -1
- package/lib/components/List/helpers/get-sort-props.js +9 -6
- package/lib/components/List/helpers/get-sort-props.js.map +1 -1
- package/lib/components/SearchFilter/SearchFilter/SearchFilter.js +2 -2
- package/lib/components/SearchFilter/SearchFilter/SearchFilter.js.map +1 -1
- package/lib/components/SearchFilter/SearchFilterContainer.js +58 -22
- package/lib/components/SearchFilter/SearchFilterContainer.js.map +1 -1
- package/lib/components/SearchFilter/helpers/build-filters-query.js +18 -16
- package/lib/components/SearchFilter/helpers/build-filters-query.js.map +1 -1
- package/lib/components/SearchFilter/helpers/build-url-query.js +3 -2
- package/lib/components/SearchFilter/helpers/build-url-query.js.map +1 -1
- package/lib/components/SearchFilter/helpers/get-initial-filter-values.js +33 -0
- package/lib/components/SearchFilter/helpers/get-initial-filter-values.js.map +1 -0
- package/lib/components/SearchFilter/helpers/get-updated-filter-by.js +38 -0
- package/lib/components/SearchFilter/helpers/get-updated-filter-by.js.map +1 -0
- package/lib/components/SearchFilter/helpers/index.js +8 -1
- package/lib/components/SearchFilter/helpers/index.js.map +1 -1
- package/lib/components/SocialFollow/sf.config.js +2 -1
- package/lib/components/SocialFollow/sf.config.js.map +1 -1
- package/lib/helpers/build-raw-query.js +7 -6
- package/lib/helpers/build-raw-query.js.map +1 -1
- package/lib/helpers/build-sort-values.js +4 -1
- package/lib/helpers/build-sort-values.js.map +1 -1
- package/lib-es/components/Button.js +2 -1
- package/lib-es/components/Button.js.map +1 -1
- package/lib-es/components/ContentGroupSection/ContentGroupSection.js +8 -4
- package/lib-es/components/ContentGroupSection/ContentGroupSection.js.map +1 -1
- package/lib-es/components/DataSummary/helpers/build-loop-props-content.js +2 -3
- package/lib-es/components/DataSummary/helpers/build-loop-props-content.js.map +1 -1
- package/lib-es/components/DataSummary/helpers/get-link-to-published-content.js +1 -2
- package/lib-es/components/DataSummary/helpers/get-link-to-published-content.js.map +1 -1
- package/lib-es/components/List/helpers/get-sort-props.js +9 -6
- package/lib-es/components/List/helpers/get-sort-props.js.map +1 -1
- package/lib-es/components/SearchFilter/SearchFilter/SearchFilter.js +3 -3
- package/lib-es/components/SearchFilter/SearchFilter/SearchFilter.js.map +1 -1
- package/lib-es/components/SearchFilter/SearchFilterContainer.js +54 -13
- package/lib-es/components/SearchFilter/SearchFilterContainer.js.map +1 -1
- package/lib-es/components/SearchFilter/helpers/build-filters-query.js +18 -16
- package/lib-es/components/SearchFilter/helpers/build-filters-query.js.map +1 -1
- package/lib-es/components/SearchFilter/helpers/build-url-query.js +1 -2
- package/lib-es/components/SearchFilter/helpers/build-url-query.js.map +1 -1
- package/lib-es/components/SearchFilter/helpers/get-initial-filter-values.js +21 -0
- package/lib-es/components/SearchFilter/helpers/get-initial-filter-values.js.map +1 -0
- package/lib-es/components/SearchFilter/helpers/get-updated-filter-by.js +19 -0
- package/lib-es/components/SearchFilter/helpers/get-updated-filter-by.js.map +1 -0
- package/lib-es/components/SearchFilter/helpers/index.js +3 -2
- package/lib-es/components/SearchFilter/helpers/index.js.map +1 -1
- package/lib-es/components/SocialFollow/sf.config.js +3 -2
- package/lib-es/components/SocialFollow/sf.config.js.map +1 -1
- package/lib-es/helpers/build-raw-query.js +5 -4
- package/lib-es/helpers/build-raw-query.js.map +1 -1
- package/lib-es/helpers/build-sort-values.js +1 -1
- package/lib-es/helpers/build-sort-values.js.map +1 -1
- package/package.json +11 -11
- package/src/components/Button.js +6 -1
- package/src/components/ContentGroupSection/ContentGroupSection.js +1 -1
- package/src/components/DataSummary/helpers/build-loop-props-content.js +2 -3
- package/src/components/DataSummary/helpers/get-link-to-published-content.js +1 -4
- package/src/components/List/helpers/get-sort-props.js +4 -6
- package/src/components/SearchFilter/SearchFilter/SearchFilter.js +6 -3
- package/src/components/SearchFilter/SearchFilterContainer.js +42 -14
- package/src/components/SearchFilter/helpers/build-filters-query.js +23 -20
- package/src/components/SearchFilter/helpers/build-url-query.js +1 -3
- package/src/components/SearchFilter/helpers/get-initial-filter-values.js +24 -0
- package/src/components/SearchFilter/helpers/get-updated-filter-by.js +18 -0
- package/src/components/SearchFilter/helpers/index.js +5 -3
- package/src/components/SocialFollow/sf.config.js +2 -2
- package/src/helpers/build-raw-query.js +5 -1
- package/src/helpers/build-sort-values.js +1 -1
- package/tests/unit/src/components/DataSummary/helpers/build-loop-props-content.test.js +0 -41
- package/tests/unit/src/components/DataSummary/helpers/get-link-to-published-content.test.js +0 -21
- package/tests/unit/src/components/List/helpers/get-sort-props.test.js +23 -0
- package/tests/unit/src/components/SearchFilter/helpers/build-query.test.js +6 -0
- package/tests/unit/src/components/SearchFilter/helpers/get-updated-filter-by.test.js +28 -0
- package/tests/unit/src/components/SocialFollow/__snapshots__/SocialFollow.test.js.snap +1 -1
- package/tests/unit/src/helpers/build-raw-query.test.js +70 -1
- package/tests/unit/src/helpers/build-sort-values.test.js +20 -0
- package/tests/unit/src/helpers/get-generic-render-variables.test.js +25 -0
- package/tests/unit/src/components/PlaceholderIcon/__snapshots__/index.test.js.snap +0 -72
- package/tests/unit/src/components/PlaceholderIcon/index.test.js +0 -20
- /package/tests/unit/src/components/SearchFilter/helpers/{build-new-query.test.js → build-new-url.test.js} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-updated-filter-by.js","names":["getUpdatedFilterBy","filterBy","filterByProperty","parentData","length","updatedFilterBy","updatedFilterByProperty","forEach","property","key","split","filterData","Array","isArray","dat","push"],"sources":["../../../../src/components/SearchFilter/helpers/get-updated-filter-by.js"],"sourcesContent":["const getUpdatedFilterBy = (filterBy, filterByProperty, parentData) => {\n if (!parentData || (filterBy && filterBy.length))\n return { updatedFilterBy: filterBy, updatedFilterByProperty: filterByProperty };\n\n const updatedFilterBy = [];\n filterByProperty.forEach(property => {\n const [key] = property.split('/');\n const filterData = parentData[key];\n\n if (!filterData) return;\n if (Array.isArray(filterData)) filterData.forEach(dat => updatedFilterBy.push(`${key}/${dat}`));\n else updatedFilterBy.push(`${key}/${filterData}`);\n });\n\n return { updatedFilterBy, updatedFilterByProperty: filterByProperty };\n};\n\nexport default getUpdatedFilterBy;\n"],"mappings":"AAAA,MAAMA,kBAAkB,GAAGA,CAACC,QAAQ,EAAEC,gBAAgB,EAAEC,UAAU,KAAK;EACrE,IAAI,CAACA,UAAU,IAAKF,QAAQ,IAAIA,QAAQ,CAACG,MAAO,EAC9C,OAAO;IAAEC,eAAe,EAAEJ,QAAQ;IAAEK,uBAAuB,EAAEJ;EAAiB,CAAC;EAEjF,MAAMG,eAAe,GAAG,EAAE;EAC1BH,gBAAgB,CAACK,OAAO,CAACC,QAAQ,IAAI;IACnC,MAAM,CAACC,GAAG,CAAC,GAAGD,QAAQ,CAACE,KAAK,CAAC,GAAG,CAAC;IACjC,MAAMC,UAAU,GAAGR,UAAU,CAACM,GAAG,CAAC;IAElC,IAAI,CAACE,UAAU,EAAE;IACjB,IAAIC,KAAK,CAACC,OAAO,CAACF,UAAU,CAAC,EAAEA,UAAU,CAACJ,OAAO,CAACO,GAAG,IAAIT,eAAe,CAACU,IAAI,CAAE,GAAEN,GAAI,IAAGK,GAAI,EAAC,CAAC,CAAC,CAAC,KAC3FT,eAAe,CAACU,IAAI,CAAE,GAAEN,GAAI,IAAGE,UAAW,EAAC,CAAC;EACnD,CAAC,CAAC;EAEF,OAAO;IAAEN,eAAe;IAAEC,uBAAuB,EAAEJ;EAAiB,CAAC;AACvE,CAAC;AAED,eAAeF,kBAAkB"}
|
|
@@ -12,8 +12,9 @@ import getSelectOptions from './get-select-options';
|
|
|
12
12
|
import isDeviceDesktop from './is-device-desktop';
|
|
13
13
|
import getFilterValues from './get-filter-values';
|
|
14
14
|
import getFilterValueFromQuery from './get-filter-value-from-query';
|
|
15
|
-
import buildUrlQuery from './build-url-query';
|
|
16
15
|
import buildFiltersQuery from './build-filters-query';
|
|
17
16
|
import getFilterRangesAndCheckboxesValues from './get-filter-ranges-and-checkboxes-values';
|
|
18
|
-
|
|
17
|
+
import getUpdatedFilterBy from './get-updated-filter-by';
|
|
18
|
+
import buildUrlQuery from './build-url-query';
|
|
19
|
+
export { buildNewUrl, buildRawQueryStringified, decodeValue, encodeValue, checkIfRangeUpdated, getResponsiveFilterClassnames, getDisplayValue, calculateStep, calculateMinMax, getIntersectedProp, getRangeValue, getSelectOptions, isDeviceDesktop, getFilterValues, getFilterValueFromQuery, buildFiltersQuery, getFilterRangesAndCheckboxesValues, getUpdatedFilterBy, buildUrlQuery };
|
|
19
20
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["buildNewUrl","buildRawQueryStringified","decodeValue","encodeValue","checkIfRangeUpdated","getResponsiveFilterClassnames","getDisplayValue","calculateStep","calculateMinMax","getIntersectedProp","getRangeValue","getSelectOptions","isDeviceDesktop","getFilterValues","getFilterValueFromQuery","
|
|
1
|
+
{"version":3,"file":"index.js","names":["buildNewUrl","buildRawQueryStringified","decodeValue","encodeValue","checkIfRangeUpdated","getResponsiveFilterClassnames","getDisplayValue","calculateStep","calculateMinMax","getIntersectedProp","getRangeValue","getSelectOptions","isDeviceDesktop","getFilterValues","getFilterValueFromQuery","buildFiltersQuery","getFilterRangesAndCheckboxesValues","getUpdatedFilterBy","buildUrlQuery"],"sources":["../../../../src/components/SearchFilter/helpers/index.js"],"sourcesContent":["import buildNewUrl from './build-new-url';\nimport buildRawQueryStringified from './build-raw-query-stringified';\nimport { decodeValue, encodeValue } from './decode-encode';\nimport checkIfRangeUpdated from './check-if-range-updated';\nimport getResponsiveFilterClassnames from './get-responsive-filter-classnames';\nimport getDisplayValue from './get-display-value';\nimport calculateStep from './calculate-step';\nimport calculateMinMax from './calculate-min-max';\nimport getIntersectedProp from './get-intersected-prop';\nimport getRangeValue from './get-range-value';\nimport getSelectOptions from './get-select-options';\nimport isDeviceDesktop from './is-device-desktop';\nimport getFilterValues from './get-filter-values';\nimport getFilterValueFromQuery from './get-filter-value-from-query';\nimport buildFiltersQuery from './build-filters-query';\nimport getFilterRangesAndCheckboxesValues from './get-filter-ranges-and-checkboxes-values';\nimport getUpdatedFilterBy from './get-updated-filter-by';\nimport buildUrlQuery from './build-url-query';\n\nexport {\n buildNewUrl,\n buildRawQueryStringified,\n decodeValue,\n encodeValue,\n checkIfRangeUpdated,\n getResponsiveFilterClassnames,\n getDisplayValue,\n calculateStep,\n calculateMinMax,\n getIntersectedProp,\n getRangeValue,\n getSelectOptions,\n isDeviceDesktop,\n getFilterValues,\n getFilterValueFromQuery,\n buildFiltersQuery,\n getFilterRangesAndCheckboxesValues,\n getUpdatedFilterBy,\n buildUrlQuery\n};\n"],"mappings":"AAAA,OAAOA,WAAW,MAAM,iBAAiB;AACzC,OAAOC,wBAAwB,MAAM,+BAA+B;AACpE,SAASC,WAAW,EAAEC,WAAW,QAAQ,iBAAiB;AAC1D,OAAOC,mBAAmB,MAAM,0BAA0B;AAC1D,OAAOC,6BAA6B,MAAM,oCAAoC;AAC9E,OAAOC,eAAe,MAAM,qBAAqB;AACjD,OAAOC,aAAa,MAAM,kBAAkB;AAC5C,OAAOC,eAAe,MAAM,qBAAqB;AACjD,OAAOC,kBAAkB,MAAM,wBAAwB;AACvD,OAAOC,aAAa,MAAM,mBAAmB;AAC7C,OAAOC,gBAAgB,MAAM,sBAAsB;AACnD,OAAOC,eAAe,MAAM,qBAAqB;AACjD,OAAOC,eAAe,MAAM,qBAAqB;AACjD,OAAOC,uBAAuB,MAAM,+BAA+B;AACnE,OAAOC,iBAAiB,MAAM,uBAAuB;AACrD,OAAOC,kCAAkC,MAAM,2CAA2C;AAC1F,OAAOC,kBAAkB,MAAM,yBAAyB;AACxD,OAAOC,aAAa,MAAM,mBAAmB;AAE7C,SACElB,WAAW,EACXC,wBAAwB,EACxBC,WAAW,EACXC,WAAW,EACXC,mBAAmB,EACnBC,6BAA6B,EAC7BC,eAAe,EACfC,aAAa,EACbC,eAAe,EACfC,kBAAkB,EAClBC,aAAa,EACbC,gBAAgB,EAChBC,eAAe,EACfC,eAAe,EACfC,uBAAuB,EACvBC,iBAAiB,EACjBC,kCAAkC,EAClCC,kBAAkB,EAClBC,aAAa"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { FaFacebookF,
|
|
1
|
+
import { FaFacebookF, FaPinterestP, FaInstagram, FaLinkedinIn, FaYoutube, FaTiktok } from 'react-icons/fa';
|
|
2
|
+
import { FaXTwitter } from 'react-icons/fa6';
|
|
2
3
|
export const BASE_CLASS_NAME_FOLLOW = 'social__list-item social__list-item--follow';
|
|
3
4
|
export const PORTRAIT = 'portrait';
|
|
4
5
|
export const LANDSCAPE = 'landscape';
|
|
@@ -12,7 +13,7 @@ export const SOCIAL_NETWORKS = {
|
|
|
12
13
|
twitter: {
|
|
13
14
|
name: 'Twitter',
|
|
14
15
|
className: 'twitter',
|
|
15
|
-
Icon:
|
|
16
|
+
Icon: FaXTwitter,
|
|
16
17
|
spanClassName: 'hidden'
|
|
17
18
|
},
|
|
18
19
|
pinterest: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sf.config.js","names":["FaFacebookF","
|
|
1
|
+
{"version":3,"file":"sf.config.js","names":["FaFacebookF","FaPinterestP","FaInstagram","FaLinkedinIn","FaYoutube","FaTiktok","FaXTwitter","BASE_CLASS_NAME_FOLLOW","PORTRAIT","LANDSCAPE","SOCIAL_NETWORKS","facebook","name","className","Icon","spanClassName","twitter","pinterest","instagram","linkedin","youtube","tiktok"],"sources":["../../../src/components/SocialFollow/sf.config.js"],"sourcesContent":["import {\n FaFacebookF,\n FaPinterestP,\n FaInstagram,\n FaLinkedinIn,\n FaYoutube,\n FaTiktok\n} from 'react-icons/fa';\nimport { FaXTwitter } from 'react-icons/fa6';\n\nexport const BASE_CLASS_NAME_FOLLOW = 'social__list-item social__list-item--follow';\nexport const PORTRAIT = 'portrait';\nexport const LANDSCAPE = 'landscape';\n\nexport const SOCIAL_NETWORKS = {\n facebook: {\n name: 'Facebook',\n className: 'facebook',\n Icon: FaFacebookF,\n spanClassName: 'hidden'\n },\n twitter: {\n name: 'Twitter',\n className: 'twitter',\n Icon: FaXTwitter,\n spanClassName: 'hidden'\n },\n pinterest: {\n name: 'Pinterest',\n className: 'pinterest',\n Icon: FaPinterestP,\n spanClassName: 'hidden'\n },\n instagram: {\n name: 'Instagram',\n className: 'instagram',\n Icon: FaInstagram,\n spanClassName: 'hidden'\n },\n linkedin: {\n name: 'Linkedin',\n className: 'linkedin',\n Icon: FaLinkedinIn,\n spanClassName: 'hidden'\n },\n youtube: {\n name: 'YouTube',\n className: 'youtube',\n Icon: FaYoutube,\n spanClassName: 'hidden'\n },\n tiktok: {\n name: 'TikTok',\n className: 'tiktok',\n Icon: FaTiktok,\n spanClassName: 'hidden'\n }\n};\n"],"mappings":"AAAA,SACEA,WAAW,EACXC,YAAY,EACZC,WAAW,EACXC,YAAY,EACZC,SAAS,EACTC,QAAQ,QACH,gBAAgB;AACvB,SAASC,UAAU,QAAQ,iBAAiB;AAE5C,OAAO,MAAMC,sBAAsB,GAAG,6CAA6C;AACnF,OAAO,MAAMC,QAAQ,GAAG,UAAU;AAClC,OAAO,MAAMC,SAAS,GAAG,WAAW;AAEpC,OAAO,MAAMC,eAAe,GAAG;EAC7BC,QAAQ,EAAE;IACRC,IAAI,EAAE,UAAU;IAChBC,SAAS,EAAE,UAAU;IACrBC,IAAI,EAAEd,WAAW;IACjBe,aAAa,EAAE;EACjB,CAAC;EACDC,OAAO,EAAE;IACPJ,IAAI,EAAE,SAAS;IACfC,SAAS,EAAE,SAAS;IACpBC,IAAI,EAAER,UAAU;IAChBS,aAAa,EAAE;EACjB,CAAC;EACDE,SAAS,EAAE;IACTL,IAAI,EAAE,WAAW;IACjBC,SAAS,EAAE,WAAW;IACtBC,IAAI,EAAEb,YAAY;IAClBc,aAAa,EAAE;EACjB,CAAC;EACDG,SAAS,EAAE;IACTN,IAAI,EAAE,WAAW;IACjBC,SAAS,EAAE,WAAW;IACtBC,IAAI,EAAEZ,WAAW;IACjBa,aAAa,EAAE;EACjB,CAAC;EACDI,QAAQ,EAAE;IACRP,IAAI,EAAE,UAAU;IAChBC,SAAS,EAAE,UAAU;IACrBC,IAAI,EAAEX,YAAY;IAClBY,aAAa,EAAE;EACjB,CAAC;EACDK,OAAO,EAAE;IACPR,IAAI,EAAE,SAAS;IACfC,SAAS,EAAE,SAAS;IACpBC,IAAI,EAAEV,SAAS;IACfW,aAAa,EAAE;EACjB,CAAC;EACDM,MAAM,EAAE;IACNT,IAAI,EAAE,QAAQ;IACdC,SAAS,EAAE,QAAQ;IACnBC,IAAI,EAAET,QAAQ;IACdU,aAAa,EAAE;EACjB;AACF,CAAC"}
|
|
@@ -32,11 +32,12 @@ const buildRawQuery = ({
|
|
|
32
32
|
isAZ,
|
|
33
33
|
sortProperties = []
|
|
34
34
|
} = azOptions || {};
|
|
35
|
-
const [
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
const sortPropertyToUse = isAZ && sortProperties[0] && sortProperties[0].isScore ? 1 : 0;
|
|
36
|
+
const {
|
|
37
|
+
propsToDisplay: [azSortProp] = []
|
|
38
|
+
} = sortProperties[sortPropertyToUse] || {
|
|
38
39
|
propsToDisplay: []
|
|
39
|
-
}
|
|
40
|
+
};
|
|
40
41
|
const azSortProperty = azSortProp || AZ_DEFAULT_PROP;
|
|
41
42
|
const searchValuesTextCheckboxSelectJoined = operator === AND_OPERATOR ? [...searchValuesText, ...searchValuesCheckboxSelectRange] : [];
|
|
42
43
|
let searchValuesTextCheckboxOr = searchValuesText;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-raw-query.js","names":["buildRawQueryBase","getItemsToDisplayIds","getExtraAzBits","buildAzFilter","AND_OPERATOR","AZ_DEFAULT_PROP","buildRawQuery","docType","operator","searchValues","filterData","id","itemsToDisplay","shouldApplySort","azOptions","searchValuesText","searchValuesCheckboxSelectRange","searchValuesCheckboxOr","filterValues","filterOperator","relations","stringProps","azFilter","isAZ","sortProperties","propsToDisplay","azSortProp","azSortProperty","searchValuesTextCheckboxSelectJoined","searchValuesTextCheckboxOr","length","finalValue","finalValueWithCheckboxOrValues","must","bool","should","finalValueIfNoCheckboxOrValues","mustValues","query","_objectSpread","azQueryBits","itemsToDisplayIds","push","ids","values","sort","_script","type","script","lang","source","params","sortOrder","order"],"sources":["../../src/helpers/build-raw-query.js"],"sourcesContent":["import buildRawQueryBase from './build-raw-query-base';\nimport getItemsToDisplayIds from './get-items-to-display-ids';\nimport getExtraAzBits from './get-extra-az-bits';\nimport buildAzFilter from './build-az-filter';\nimport { AND_OPERATOR, AZ_DEFAULT_PROP } from '../constants';\n\nconst buildRawQuery = ({\n docType,\n operator,\n searchValues,\n filterData,\n id,\n itemsToDisplay,\n shouldApplySort,\n azOptions\n}) => {\n const {\n searchValuesText,\n searchValuesCheckboxSelectRange,\n searchValuesCheckboxOr\n } = searchValues;\n const { filterValues, filterOperator, relations, stringProps, azFilter } = filterData;\n const { isAZ, sortProperties = [] } = azOptions || {};\n const [{ propsToDisplay: [azSortProp] } = {
|
|
1
|
+
{"version":3,"file":"build-raw-query.js","names":["buildRawQueryBase","getItemsToDisplayIds","getExtraAzBits","buildAzFilter","AND_OPERATOR","AZ_DEFAULT_PROP","buildRawQuery","docType","operator","searchValues","filterData","id","itemsToDisplay","shouldApplySort","azOptions","searchValuesText","searchValuesCheckboxSelectRange","searchValuesCheckboxOr","filterValues","filterOperator","relations","stringProps","azFilter","isAZ","sortProperties","sortPropertyToUse","isScore","propsToDisplay","azSortProp","azSortProperty","searchValuesTextCheckboxSelectJoined","searchValuesTextCheckboxOr","length","finalValue","finalValueWithCheckboxOrValues","must","bool","should","finalValueIfNoCheckboxOrValues","mustValues","query","_objectSpread","azQueryBits","itemsToDisplayIds","push","ids","values","sort","_script","type","script","lang","source","params","sortOrder","order"],"sources":["../../src/helpers/build-raw-query.js"],"sourcesContent":["import buildRawQueryBase from './build-raw-query-base';\nimport getItemsToDisplayIds from './get-items-to-display-ids';\nimport getExtraAzBits from './get-extra-az-bits';\nimport buildAzFilter from './build-az-filter';\nimport { AND_OPERATOR, AZ_DEFAULT_PROP } from '../constants';\n\nconst buildRawQuery = ({\n docType,\n operator,\n searchValues,\n filterData,\n id,\n itemsToDisplay,\n shouldApplySort,\n azOptions\n}) => {\n const {\n searchValuesText,\n searchValuesCheckboxSelectRange,\n searchValuesCheckboxOr\n } = searchValues;\n const { filterValues, filterOperator, relations, stringProps, azFilter } = filterData;\n\n const { isAZ, sortProperties = [] } = azOptions || {};\n const sortPropertyToUse = isAZ && sortProperties[0] && sortProperties[0].isScore ? 1 : 0;\n const { propsToDisplay: [azSortProp] = [] } = sortProperties[sortPropertyToUse] || {\n propsToDisplay: []\n };\n const azSortProperty = azSortProp || AZ_DEFAULT_PROP;\n\n const searchValuesTextCheckboxSelectJoined =\n operator === AND_OPERATOR ? [...searchValuesText, ...searchValuesCheckboxSelectRange] : [];\n let searchValuesTextCheckboxOr = searchValuesText;\n if (searchValuesCheckboxOr.length) {\n searchValuesTextCheckboxOr = [...searchValuesText, ...searchValuesCheckboxOr];\n }\n\n let finalValue;\n\n if (searchValuesTextCheckboxSelectJoined.length) {\n const finalValueWithCheckboxOrValues = {\n must: [...searchValuesTextCheckboxSelectJoined, { bool: { should: searchValuesCheckboxOr } }]\n };\n const finalValueIfNoCheckboxOrValues = { must: searchValuesTextCheckboxSelectJoined };\n finalValue = searchValuesCheckboxOr.length\n ? finalValueWithCheckboxOrValues\n : finalValueIfNoCheckboxOrValues;\n } else {\n finalValue = {\n must: [...searchValuesCheckboxSelectRange, { bool: { should: searchValuesTextCheckboxOr } }]\n };\n }\n const mustValues = [\n {\n bool: finalValue\n }\n ];\n\n buildAzFilter(azFilter, mustValues, azSortProperty);\n\n const query = {\n bool: {\n must: mustValues,\n ...buildRawQueryBase({ docType, id, filterValues, filterOperator, relations, stringProps })\n }\n };\n const azQueryBits = getExtraAzBits({ ...azOptions, azSortProperty, azFilter });\n\n if (itemsToDisplay && itemsToDisplay.length) {\n const itemsToDisplayIds = getItemsToDisplayIds(itemsToDisplay);\n\n query.bool.must.push({ ids: { values: itemsToDisplayIds } });\n if (shouldApplySort) {\n return {\n query,\n sort: {\n _script: {\n type: 'number',\n script: {\n lang: 'painless',\n source:\n \"!doc['id.keyword'].empty ? params.sortOrder.indexOf(doc['id.keyword'].value) : 0\",\n params: {\n sortOrder: itemsToDisplayIds\n }\n },\n order: 'asc'\n }\n },\n ...azQueryBits\n };\n }\n }\n\n return isAZ\n ? {\n query,\n ...azQueryBits\n }\n : query;\n};\n\nexport default buildRawQuery;\n"],"mappings":"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"}
|
|
@@ -25,7 +25,7 @@ const buildSortValues = (sortFilters, relations, stringProps, useSortObject) =>
|
|
|
25
25
|
if (!sort) return null;
|
|
26
26
|
const sortFieldName = getSortbyFieldName(relations, propsToDisplay, stringProps);
|
|
27
27
|
return sortFieldName ? `${sortFieldName}:${sort.toLowerCase()}` : null;
|
|
28
|
-
}).filter(
|
|
28
|
+
}).filter((item, index, arr) => !item ? false : arr.indexOf(item) === index).join(',');
|
|
29
29
|
return {
|
|
30
30
|
sort: sortValues
|
|
31
31
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-sort-values.js","names":["getSortbyFieldName","buildAzSort","sortFilters","relations","stringProps","sortValues","forEach","sort","propsToDisplay","sortFieldName","toLowerCase","buildSortValues","useSortObject","length","map","isScore","filter","
|
|
1
|
+
{"version":3,"file":"build-sort-values.js","names":["getSortbyFieldName","buildAzSort","sortFilters","relations","stringProps","sortValues","forEach","sort","propsToDisplay","sortFieldName","toLowerCase","buildSortValues","useSortObject","length","map","isScore","filter","item","index","arr","indexOf","join"],"sources":["../../src/helpers/build-sort-values.js"],"sourcesContent":["import getSortbyFieldName from './get-sort-by-field-name';\n\nconst buildAzSort = (sortFilters, relations, stringProps) => {\n const sortValues = {};\n sortFilters.forEach(({ sort, propsToDisplay }) => {\n if (!sort) return;\n const sortFieldName = getSortbyFieldName(relations, propsToDisplay, stringProps);\n if (sortFieldName) sortValues[sortFieldName] = sort.toLowerCase();\n });\n\n return sortValues;\n};\n\nconst buildSortValues = (sortFilters, relations, stringProps, useSortObject) => {\n if (!sortFilters || !sortFilters.length) return useSortObject ? null : { sort: [] };\n if (useSortObject) return buildAzSort(sortFilters, relations, stringProps);\n\n const sortValues = sortFilters\n .map(({ sort, propsToDisplay, isScore }) => {\n if (isScore) return '_score';\n if (!sort) return null;\n\n const sortFieldName = getSortbyFieldName(relations, propsToDisplay, stringProps);\n return sortFieldName ? `${sortFieldName}:${sort.toLowerCase()}` : null;\n })\n .filter((item, index, arr) => (!item ? false : arr.indexOf(item) === index))\n .join(',');\n\n return { sort: sortValues };\n};\n\nexport default buildSortValues;\n"],"mappings":"AAAA,OAAOA,kBAAkB,MAAM,0BAA0B;AAEzD,MAAMC,WAAW,GAAGA,CAACC,WAAW,EAAEC,SAAS,EAAEC,WAAW,KAAK;EAC3D,MAAMC,UAAU,GAAG,CAAC,CAAC;EACrBH,WAAW,CAACI,OAAO,CAAC,CAAC;IAAEC,IAAI;IAAEC;EAAe,CAAC,KAAK;IAChD,IAAI,CAACD,IAAI,EAAE;IACX,MAAME,aAAa,GAAGT,kBAAkB,CAACG,SAAS,EAAEK,cAAc,EAAEJ,WAAW,CAAC;IAChF,IAAIK,aAAa,EAAEJ,UAAU,CAACI,aAAa,CAAC,GAAGF,IAAI,CAACG,WAAW,CAAC,CAAC;EACnE,CAAC,CAAC;EAEF,OAAOL,UAAU;AACnB,CAAC;AAED,MAAMM,eAAe,GAAGA,CAACT,WAAW,EAAEC,SAAS,EAAEC,WAAW,EAAEQ,aAAa,KAAK;EAC9E,IAAI,CAACV,WAAW,IAAI,CAACA,WAAW,CAACW,MAAM,EAAE,OAAOD,aAAa,GAAG,IAAI,GAAG;IAAEL,IAAI,EAAE;EAAG,CAAC;EACnF,IAAIK,aAAa,EAAE,OAAOX,WAAW,CAACC,WAAW,EAAEC,SAAS,EAAEC,WAAW,CAAC;EAE1E,MAAMC,UAAU,GAAGH,WAAW,CAC3BY,GAAG,CAAC,CAAC;IAAEP,IAAI;IAAEC,cAAc;IAAEO;EAAQ,CAAC,KAAK;IAC1C,IAAIA,OAAO,EAAE,OAAO,QAAQ;IAC5B,IAAI,CAACR,IAAI,EAAE,OAAO,IAAI;IAEtB,MAAME,aAAa,GAAGT,kBAAkB,CAACG,SAAS,EAAEK,cAAc,EAAEJ,WAAW,CAAC;IAChF,OAAOK,aAAa,GAAI,GAAEA,aAAc,IAAGF,IAAI,CAACG,WAAW,CAAC,CAAE,EAAC,GAAG,IAAI;EACxE,CAAC,CAAC,CACDM,MAAM,CAAC,CAACC,IAAI,EAAEC,KAAK,EAAEC,GAAG,KAAM,CAACF,IAAI,GAAG,KAAK,GAAGE,GAAG,CAACC,OAAO,CAACH,IAAI,CAAC,KAAKC,KAAM,CAAC,CAC3EG,IAAI,CAAC,GAAG,CAAC;EAEZ,OAAO;IAAEd,IAAI,EAAEF;EAAW,CAAC;AAC7B,CAAC;AAED,eAAeM,eAAe"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blaze-cms/react-page-builder",
|
|
3
|
-
"version": "0.133.0
|
|
3
|
+
"version": "0.133.0",
|
|
4
4
|
"description": "Blaze react page builder",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "lib-es/index.js",
|
|
@@ -27,15 +27,15 @@
|
|
|
27
27
|
},
|
|
28
28
|
"license": "GPL-3.0",
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@blaze-cms/core-auth-ui": "0.
|
|
31
|
-
"@blaze-cms/core-errors": "0.
|
|
32
|
-
"@blaze-cms/core-errors-ui": "0.
|
|
30
|
+
"@blaze-cms/core-auth-ui": "^0.131.0",
|
|
31
|
+
"@blaze-cms/core-errors": "^0.131.0",
|
|
32
|
+
"@blaze-cms/core-errors-ui": "^0.131.0",
|
|
33
33
|
"@blaze-cms/image-cdn-react": "0.3.0-alpha.5",
|
|
34
|
-
"@blaze-cms/nextjs-components": "0.133.0
|
|
35
|
-
"@blaze-cms/plugin-search-ui": "0.133.0
|
|
36
|
-
"@blaze-cms/setup-ui": "0.
|
|
37
|
-
"@blaze-cms/utils": "0.
|
|
38
|
-
"@blaze-cms/utils-handlebars": "0.133.0
|
|
34
|
+
"@blaze-cms/nextjs-components": "^0.133.0",
|
|
35
|
+
"@blaze-cms/plugin-search-ui": "^0.133.0",
|
|
36
|
+
"@blaze-cms/setup-ui": "^0.131.0",
|
|
37
|
+
"@blaze-cms/utils": "^0.131.0",
|
|
38
|
+
"@blaze-cms/utils-handlebars": "^0.133.0",
|
|
39
39
|
"@blaze-react/breadcrumb": "0.8.0-alpha.60",
|
|
40
40
|
"@blaze-react/button": "0.5.19",
|
|
41
41
|
"@blaze-react/checkboxes": "0.5.31",
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"next": "12.x",
|
|
76
76
|
"prop-types": "^15.7.2",
|
|
77
77
|
"react": "^17.0.2",
|
|
78
|
-
"react-icons": "
|
|
78
|
+
"react-icons": "^4.11.0"
|
|
79
79
|
},
|
|
80
80
|
"devDependencies": {
|
|
81
81
|
"@testing-library/jest-dom": "^5.11.3",
|
|
@@ -89,5 +89,5 @@
|
|
|
89
89
|
"lib/*",
|
|
90
90
|
"lib-es/*"
|
|
91
91
|
],
|
|
92
|
-
"gitHead": "
|
|
92
|
+
"gitHead": "d1265256eafcf99954599ab9b12d1cc165929cb9"
|
|
93
93
|
}
|
package/src/components/Button.js
CHANGED
|
@@ -60,7 +60,12 @@ const Button = props => {
|
|
|
60
60
|
const logout = () => {
|
|
61
61
|
handleLogout(client);
|
|
62
62
|
if (hasChildren(children)) return setShowChildren(true);
|
|
63
|
-
|
|
63
|
+
|
|
64
|
+
if (!urlToUse) return router.reload();
|
|
65
|
+
|
|
66
|
+
return urlToUse.startsWith('/')
|
|
67
|
+
? router.push('/Resolver', urlToUse)
|
|
68
|
+
: (window.location.href = urlToUse);
|
|
64
69
|
};
|
|
65
70
|
|
|
66
71
|
const handleClick = () => {
|
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import { hasChildren } from '../../helpers';
|
|
4
4
|
|
|
5
|
-
const ContentGroupSection = ({ children, name }) => {
|
|
5
|
+
const ContentGroupSection = ({ children, name, ...props }) => {
|
|
6
6
|
if (!hasChildren(children)) return null;
|
|
7
7
|
|
|
8
8
|
return (
|
|
@@ -45,12 +45,11 @@ const buildLoopPropsContent = (loopProps = [], propsToDisplay = [], limit = 0, d
|
|
|
45
45
|
|
|
46
46
|
return propertiesToDisplay.map(key => {
|
|
47
47
|
const loopValue = loopValues[key];
|
|
48
|
-
const
|
|
49
|
-
const propValue = loopValueItem ? getLoopValue(loopValueItem) : regularValues[key];
|
|
48
|
+
const propValue = loopValue ? getLoopValue(loopValue[i]) : regularValues[key];
|
|
50
49
|
if (!propValue) return null;
|
|
51
50
|
|
|
52
51
|
const processedValue = processDataSummaryValue(propValue, options);
|
|
53
|
-
const linkToPublishedContent = getLinkToPublishedContent(key, data
|
|
52
|
+
const linkToPublishedContent = getLinkToPublishedContent(key, data);
|
|
54
53
|
return [upperFirst(label), processedValue, linkToPublishedContent, modifier];
|
|
55
54
|
});
|
|
56
55
|
})
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
const getLinkToPublishedContent = (key = '', props = {}
|
|
1
|
+
const getLinkToPublishedContent = (key = '', props = {}) => {
|
|
2
2
|
const [baseKey] = key.split('.');
|
|
3
3
|
if (!props[baseKey]) return '';
|
|
4
|
-
|
|
5
|
-
if (currentValue && typeof currentValue.url !== 'undefined') return currentValue.url;
|
|
6
|
-
|
|
7
4
|
const content = Array.isArray(props[baseKey]) ? props[baseKey][0] : props[baseKey];
|
|
8
5
|
return content && content.url ? content.url : '';
|
|
9
6
|
};
|
|
@@ -6,14 +6,12 @@ const getSortProps = ({
|
|
|
6
6
|
defaultSortBy,
|
|
7
7
|
isTextSearchFilterApplied
|
|
8
8
|
}) => {
|
|
9
|
-
const sort = querySort || (sortProperties.length ? null : defaultSort);
|
|
10
|
-
let sortby = null;
|
|
11
|
-
if (querySortBy) sortby = [querySortBy];
|
|
12
|
-
else if (!sortProperties.length) sortby = defaultSortBy;
|
|
13
|
-
|
|
14
9
|
const updatedSortProperties = [...sortProperties];
|
|
10
|
+
if (!querySort && !sortProperties.length) {
|
|
11
|
+
updatedSortProperties.unshift({ sort: defaultSort, propsToDisplay: defaultSortBy });
|
|
12
|
+
}
|
|
15
13
|
if (isTextSearchFilterApplied) updatedSortProperties.unshift({ isScore: true });
|
|
16
|
-
if (
|
|
14
|
+
if (querySort) updatedSortProperties.unshift({ sort: querySort, propsToDisplay: [querySortBy] });
|
|
17
15
|
|
|
18
16
|
const sortbyFilters = updatedSortProperties
|
|
19
17
|
.map(({ propsToDisplay: filterProps }) => filterProps)
|
|
@@ -3,7 +3,8 @@ import PropTypes from 'prop-types';
|
|
|
3
3
|
import classnames from 'classnames';
|
|
4
4
|
import debounce from 'lodash.debounce';
|
|
5
5
|
import FiltersList from './FiltersList';
|
|
6
|
-
import { isDeviceDesktop,
|
|
6
|
+
import { isDeviceDesktop, getResponsiveFilterClassnames, buildUrlQuery } from '../helpers';
|
|
7
|
+
|
|
7
8
|
import CloseMobileForm from './CloseMobileForm';
|
|
8
9
|
import ResetDesktopForm from './ResetDesktopForm';
|
|
9
10
|
import MobileFormToolbar from './MobileFormToolbar';
|
|
@@ -31,7 +32,9 @@ const SearchFilter = ({
|
|
|
31
32
|
const [moreFiltersDesktopCollapsed, setMoreFiltersDesktopCollapsed] = useState(true);
|
|
32
33
|
|
|
33
34
|
const doSubmit = newValues => {
|
|
34
|
-
const newQuery =
|
|
35
|
+
const newQuery = filterValues
|
|
36
|
+
? buildUrlQuery(newValues, filters, listComponentName, query)
|
|
37
|
+
: '';
|
|
35
38
|
handleSearch(newQuery);
|
|
36
39
|
setMoreFiltersDesktopCollapsed(true);
|
|
37
40
|
setMoreFiltersMobileCollapsed(true);
|
|
@@ -152,7 +155,7 @@ const SearchFilter = ({
|
|
|
152
155
|
onClick={() =>
|
|
153
156
|
setMoreFiltersDesktopCollapsed(!moreFiltersDesktopCollapsed)
|
|
154
157
|
}>
|
|
155
|
-
More filters
|
|
158
|
+
{moreFiltersDesktopCollapsed ? 'More filters' : 'Less filters'}
|
|
156
159
|
</button>
|
|
157
160
|
)}
|
|
158
161
|
|
|
@@ -1,22 +1,25 @@
|
|
|
1
|
-
import React, { useState, useRef, useReducer,
|
|
1
|
+
import React, { useState, useEffect, useRef, useReducer, useContext } from 'react';
|
|
2
|
+
import { MainContext } from '@blaze-cms/nextjs-components';
|
|
2
3
|
import { useRouter } from 'next/router';
|
|
3
4
|
import { useQuery } from '@apollo/client';
|
|
4
5
|
import PropTypes from 'prop-types';
|
|
5
6
|
import { parseUrl } from 'query-string';
|
|
6
7
|
import SearchFilter from './SearchFilter';
|
|
7
8
|
import { withTitle } from '../../HOC';
|
|
8
|
-
import { getSearchPublishedContent } from '../../application/query';
|
|
9
|
+
import { getSearchPublishedContent, generateSingleItemQuery } from '../../application/query';
|
|
9
10
|
import {
|
|
10
11
|
buildNewUrl,
|
|
11
12
|
buildRawQueryStringified,
|
|
12
13
|
getFilterValues,
|
|
13
14
|
buildFiltersQuery,
|
|
14
|
-
getFilterRangesAndCheckboxesValues
|
|
15
|
+
getFilterRangesAndCheckboxesValues,
|
|
16
|
+
getUpdatedFilterBy
|
|
15
17
|
} from './helpers';
|
|
16
|
-
import { getEntityData } from '../../helpers';
|
|
18
|
+
import { getEntityData, getInheritedFilters, getQueryProps } from '../../helpers';
|
|
17
19
|
import { RAW_RESULTS } from './constants';
|
|
18
20
|
import { SCROLL_OFFSET } from '../../constants';
|
|
19
21
|
import searchFilterReducer from './searchFilterReducer';
|
|
22
|
+
import { useGetEntitySchemasAsObj } from '../../hooks';
|
|
20
23
|
|
|
21
24
|
const getFiltersUrlQuery = (query, listName) => {
|
|
22
25
|
if (!listName) return query;
|
|
@@ -46,18 +49,20 @@ const SearchFilterContainer = ({
|
|
|
46
49
|
filterBy,
|
|
47
50
|
filterByProperty,
|
|
48
51
|
shouldAddFilters,
|
|
49
|
-
listComponentName
|
|
52
|
+
listComponentName,
|
|
53
|
+
parent
|
|
50
54
|
}) => {
|
|
55
|
+
const { isPreview } = useContext(MainContext);
|
|
51
56
|
const router = useRouter();
|
|
52
57
|
const { asPath } = router;
|
|
53
58
|
const searchFilterRef = useRef(null);
|
|
54
59
|
const [key, setKey] = useState(`filter-${name}`);
|
|
55
60
|
const [displaySearchFilter, setDisplaySearchFilter] = useState(false);
|
|
56
61
|
const [urlPath, setUrlPath] = useState(asPath); // used as asPath can take too long to update
|
|
62
|
+
const [filterValues, dispatch] = useReducer(searchFilterReducer, null);
|
|
57
63
|
const { url: currentUrl, query } = parseUrl(urlPath);
|
|
58
64
|
const updatedQuery = getFiltersUrlQuery(query, listComponentName);
|
|
59
|
-
|
|
60
|
-
const [filterValues, dispatch] = useReducer(searchFilterReducer, null);
|
|
65
|
+
const { itemId: parentId, itemEntity: parentEntity } = parent;
|
|
61
66
|
|
|
62
67
|
useEffect(
|
|
63
68
|
() => {
|
|
@@ -65,6 +70,27 @@ const SearchFilterContainer = ({
|
|
|
65
70
|
},
|
|
66
71
|
[asPath]
|
|
67
72
|
);
|
|
73
|
+
const { data: mainSchemas = {}, loading: schemasLoading } = useGetEntitySchemasAsObj([
|
|
74
|
+
parentEntity,
|
|
75
|
+
entity
|
|
76
|
+
]);
|
|
77
|
+
const { [parentEntity]: parentSchema = {}, [entity]: filterEntitySchema = {} } = mainSchemas;
|
|
78
|
+
const { actions = {} } = parentSchema || {};
|
|
79
|
+
const getAction = isPreview ? actions.get : actions.getPublished;
|
|
80
|
+
const inheritedFilters = getInheritedFilters(filterBy, filterByProperty);
|
|
81
|
+
const queryProps = getQueryProps(inheritedFilters, parentSchema, filterEntitySchema);
|
|
82
|
+
const { data: { entityData: parentData } = {}, loading: parentQueryLoading } = useQuery(
|
|
83
|
+
generateSingleItemQuery(getAction, queryProps),
|
|
84
|
+
{
|
|
85
|
+
variables: { id: parentId },
|
|
86
|
+
skip: schemasLoading || !inheritedFilters.length
|
|
87
|
+
}
|
|
88
|
+
);
|
|
89
|
+
const { updatedFilterBy, updatedFilterByProperty } = getUpdatedFilterBy(
|
|
90
|
+
filterBy,
|
|
91
|
+
filterByProperty,
|
|
92
|
+
parentData
|
|
93
|
+
);
|
|
68
94
|
|
|
69
95
|
const action = getSearchPublishedContent(RAW_RESULTS);
|
|
70
96
|
const [checkboxSelectValues, rangeValues] = getFilterRangesAndCheckboxesValues(filters);
|
|
@@ -73,9 +99,9 @@ const SearchFilterContainer = ({
|
|
|
73
99
|
|
|
74
100
|
const filtersQuery = buildFiltersQuery({
|
|
75
101
|
shouldAddFilters,
|
|
76
|
-
query: filterValues
|
|
77
|
-
filterBy,
|
|
78
|
-
filterByProperty,
|
|
102
|
+
query: filterValues,
|
|
103
|
+
filterBy: updatedFilterBy,
|
|
104
|
+
filterByProperty: updatedFilterByProperty,
|
|
79
105
|
rangeValues,
|
|
80
106
|
queryKeys: Object.keys(updatedQuery)
|
|
81
107
|
});
|
|
@@ -89,7 +115,7 @@ const SearchFilterContainer = ({
|
|
|
89
115
|
|
|
90
116
|
const { data, error, loading } = useQuery(action, {
|
|
91
117
|
variables: { rawQueryStringified, limit: 0 }, // we only want aggs so limit=0 for no search results
|
|
92
|
-
skip: !rawQueryStringified
|
|
118
|
+
skip: !rawQueryStringified || parentQueryLoading
|
|
93
119
|
});
|
|
94
120
|
|
|
95
121
|
if (error) return error.message;
|
|
@@ -98,7 +124,7 @@ const SearchFilterContainer = ({
|
|
|
98
124
|
const { searchPublishedContent: { rawResults: { aggregations: filterData } = {} } = {} } =
|
|
99
125
|
data || {};
|
|
100
126
|
|
|
101
|
-
if (!filterValues && !loading && (filterData || !rawQueryStringified)) {
|
|
127
|
+
if (!filterValues && !loading && !parentQueryLoading && (filterData || !rawQueryStringified)) {
|
|
102
128
|
const newValues = getFilterValues(filterData, filters, updatedQuery);
|
|
103
129
|
dispatch({ newValues, shouldSearch: false, type: 'update' });
|
|
104
130
|
return null;
|
|
@@ -171,7 +197,8 @@ SearchFilterContainer.propTypes = {
|
|
|
171
197
|
filterBy: PropTypes.array,
|
|
172
198
|
filterByProperty: PropTypes.array,
|
|
173
199
|
shouldAddFilters: PropTypes.bool,
|
|
174
|
-
listComponentName: PropTypes.string
|
|
200
|
+
listComponentName: PropTypes.string,
|
|
201
|
+
parent: PropTypes.object
|
|
175
202
|
};
|
|
176
203
|
|
|
177
204
|
SearchFilterContainer.defaultProps = {
|
|
@@ -184,7 +211,8 @@ SearchFilterContainer.defaultProps = {
|
|
|
184
211
|
filterBy: [],
|
|
185
212
|
filterByProperty: [],
|
|
186
213
|
shouldAddFilters: false,
|
|
187
|
-
listComponentName: ''
|
|
214
|
+
listComponentName: '',
|
|
215
|
+
parent: {}
|
|
188
216
|
};
|
|
189
217
|
|
|
190
218
|
export default withTitle(SearchFilterContainer);
|
|
@@ -29,38 +29,41 @@ const builFilterObject = ({ queryKey, value, filters, isRange, isInQuery }) => {
|
|
|
29
29
|
filters.push({ match: { [key]: filterValue } });
|
|
30
30
|
});
|
|
31
31
|
};
|
|
32
|
+
|
|
32
33
|
const buildFiltersQuery = ({
|
|
33
34
|
shouldAddFilters,
|
|
34
|
-
|
|
35
|
+
|
|
35
36
|
filterBy,
|
|
36
37
|
filterByProperty,
|
|
37
38
|
rangeValues,
|
|
38
|
-
queryKeys
|
|
39
|
+
queryKeys,
|
|
40
|
+
query
|
|
39
41
|
}) => {
|
|
40
42
|
if (!shouldAddFilters) return [];
|
|
41
43
|
const mustFilters = [];
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
if (query) {
|
|
45
|
+
Object.keys(query).forEach(queryKey => {
|
|
46
|
+
if (QUERY_KEYS_TO_IGNORE.includes(queryKey)) return;
|
|
47
|
+
if (!queryKey || !query[queryKey]) return;
|
|
48
|
+
const queryValue = query[queryKey];
|
|
46
49
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
50
|
+
const isRange = rangeValues.includes(queryKey);
|
|
51
|
+
const isInQuery = queryKeys.includes(queryKey);
|
|
52
|
+
builFilterObject({ queryKey, value: queryValue, filters: mustFilters, isRange, isInQuery });
|
|
53
|
+
});
|
|
54
|
+
}
|
|
51
55
|
|
|
52
56
|
if (filterByProperty && filterByProperty.length) {
|
|
53
|
-
filterByProperty
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
mustFilters.push({ match: { [filterByKeyword]: filteryByValue } });
|
|
62
|
-
});
|
|
57
|
+
filterByProperty.forEach(filterByPropOption => {
|
|
58
|
+
const [filterByPropKey] = filterByPropOption.split('/');
|
|
59
|
+
filterBy.forEach(filterByOption => {
|
|
60
|
+
if (filterByOption.indexOf(filterByPropKey) === -1) return;
|
|
61
|
+
const [, filteryByValue] = filterByOption.split('/');
|
|
62
|
+
const filterByKeyword = `${filterByPropKey}.keyword`;
|
|
63
|
+
if (!filteryByValue) return;
|
|
64
|
+
mustFilters.push({ match: { [filterByKeyword]: filteryByValue } });
|
|
63
65
|
});
|
|
66
|
+
});
|
|
64
67
|
}
|
|
65
68
|
|
|
66
69
|
return mustFilters;
|
|
@@ -2,9 +2,7 @@ import { SEARCH_TERM, TEXT_SEARCH } from '../constants';
|
|
|
2
2
|
import parseFilterValue from './parse-filter-value';
|
|
3
3
|
import { buildQueryKey } from '../../../helpers';
|
|
4
4
|
|
|
5
|
-
const buildUrlQuery = (filterValues, filters, listComponentName = '', query = {}) => {
|
|
6
|
-
if (!filterValues) return '';
|
|
7
|
-
|
|
5
|
+
const buildUrlQuery = (filterValues = {}, filters = [], listComponentName = '', query = {}) => {
|
|
8
6
|
const newQuery = [];
|
|
9
7
|
const queryKeys = [];
|
|
10
8
|
const searchValue = filterValues[SEARCH_TERM];
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { SEARCH_TERM, TEXT_SEARCH } from '../constants';
|
|
2
|
+
import getFilterValueFromQuery from './get-filter-value-from-query';
|
|
3
|
+
import { buildQueryKey } from '../../../helpers';
|
|
4
|
+
|
|
5
|
+
const getInitialFilterValues = (filterData, filters, query, listComponentName) => {
|
|
6
|
+
const filterValues = {};
|
|
7
|
+
const searchQueryKey = buildQueryKey(SEARCH_TERM, listComponentName);
|
|
8
|
+
filterValues[SEARCH_TERM] = query[searchQueryKey] || '';
|
|
9
|
+
|
|
10
|
+
filters.forEach(filterProps => {
|
|
11
|
+
const {
|
|
12
|
+
propsToDisplay: [key],
|
|
13
|
+
type
|
|
14
|
+
} = filterProps;
|
|
15
|
+
if (type === TEXT_SEARCH) return;
|
|
16
|
+
const data = filterData && filterData[key] ? filterData[key] : {};
|
|
17
|
+
const queryKey = buildQueryKey(key, listComponentName);
|
|
18
|
+
filterValues[key] = getFilterValueFromQuery(queryKey, filterProps, data, query);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
return filterValues;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export default getInitialFilterValues;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const getUpdatedFilterBy = (filterBy, filterByProperty, parentData) => {
|
|
2
|
+
if (!parentData || (filterBy && filterBy.length))
|
|
3
|
+
return { updatedFilterBy: filterBy, updatedFilterByProperty: filterByProperty };
|
|
4
|
+
|
|
5
|
+
const updatedFilterBy = [];
|
|
6
|
+
filterByProperty.forEach(property => {
|
|
7
|
+
const [key] = property.split('/');
|
|
8
|
+
const filterData = parentData[key];
|
|
9
|
+
|
|
10
|
+
if (!filterData) return;
|
|
11
|
+
if (Array.isArray(filterData)) filterData.forEach(dat => updatedFilterBy.push(`${key}/${dat}`));
|
|
12
|
+
else updatedFilterBy.push(`${key}/${filterData}`);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
return { updatedFilterBy, updatedFilterByProperty: filterByProperty };
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export default getUpdatedFilterBy;
|
|
@@ -12,12 +12,12 @@ import getSelectOptions from './get-select-options';
|
|
|
12
12
|
import isDeviceDesktop from './is-device-desktop';
|
|
13
13
|
import getFilterValues from './get-filter-values';
|
|
14
14
|
import getFilterValueFromQuery from './get-filter-value-from-query';
|
|
15
|
-
import buildUrlQuery from './build-url-query';
|
|
16
15
|
import buildFiltersQuery from './build-filters-query';
|
|
17
16
|
import getFilterRangesAndCheckboxesValues from './get-filter-ranges-and-checkboxes-values';
|
|
17
|
+
import getUpdatedFilterBy from './get-updated-filter-by';
|
|
18
|
+
import buildUrlQuery from './build-url-query';
|
|
18
19
|
|
|
19
20
|
export {
|
|
20
|
-
buildUrlQuery,
|
|
21
21
|
buildNewUrl,
|
|
22
22
|
buildRawQueryStringified,
|
|
23
23
|
decodeValue,
|
|
@@ -34,5 +34,7 @@ export {
|
|
|
34
34
|
getFilterValues,
|
|
35
35
|
getFilterValueFromQuery,
|
|
36
36
|
buildFiltersQuery,
|
|
37
|
-
getFilterRangesAndCheckboxesValues
|
|
37
|
+
getFilterRangesAndCheckboxesValues,
|
|
38
|
+
getUpdatedFilterBy,
|
|
39
|
+
buildUrlQuery
|
|
38
40
|
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
FaFacebookF,
|
|
3
|
-
FaTwitter,
|
|
4
3
|
FaPinterestP,
|
|
5
4
|
FaInstagram,
|
|
6
5
|
FaLinkedinIn,
|
|
7
6
|
FaYoutube,
|
|
8
7
|
FaTiktok
|
|
9
8
|
} from 'react-icons/fa';
|
|
9
|
+
import { FaXTwitter } from 'react-icons/fa6';
|
|
10
10
|
|
|
11
11
|
export const BASE_CLASS_NAME_FOLLOW = 'social__list-item social__list-item--follow';
|
|
12
12
|
export const PORTRAIT = 'portrait';
|
|
@@ -22,7 +22,7 @@ export const SOCIAL_NETWORKS = {
|
|
|
22
22
|
twitter: {
|
|
23
23
|
name: 'Twitter',
|
|
24
24
|
className: 'twitter',
|
|
25
|
-
Icon:
|
|
25
|
+
Icon: FaXTwitter,
|
|
26
26
|
spanClassName: 'hidden'
|
|
27
27
|
},
|
|
28
28
|
pinterest: {
|
|
@@ -20,8 +20,12 @@ const buildRawQuery = ({
|
|
|
20
20
|
searchValuesCheckboxOr
|
|
21
21
|
} = searchValues;
|
|
22
22
|
const { filterValues, filterOperator, relations, stringProps, azFilter } = filterData;
|
|
23
|
+
|
|
23
24
|
const { isAZ, sortProperties = [] } = azOptions || {};
|
|
24
|
-
const
|
|
25
|
+
const sortPropertyToUse = isAZ && sortProperties[0] && sortProperties[0].isScore ? 1 : 0;
|
|
26
|
+
const { propsToDisplay: [azSortProp] = [] } = sortProperties[sortPropertyToUse] || {
|
|
27
|
+
propsToDisplay: []
|
|
28
|
+
};
|
|
25
29
|
const azSortProperty = azSortProp || AZ_DEFAULT_PROP;
|
|
26
30
|
|
|
27
31
|
const searchValuesTextCheckboxSelectJoined =
|
|
@@ -23,7 +23,7 @@ const buildSortValues = (sortFilters, relations, stringProps, useSortObject) =>
|
|
|
23
23
|
const sortFieldName = getSortbyFieldName(relations, propsToDisplay, stringProps);
|
|
24
24
|
return sortFieldName ? `${sortFieldName}:${sort.toLowerCase()}` : null;
|
|
25
25
|
})
|
|
26
|
-
.filter(
|
|
26
|
+
.filter((item, index, arr) => (!item ? false : arr.indexOf(item) === index))
|
|
27
27
|
.join(',');
|
|
28
28
|
|
|
29
29
|
return { sort: sortValues };
|