@blaze-cms/react-page-builder 0.130.1 → 0.131.0-admin-updates.1
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 +31 -0
- package/lib/components/Card/CardsRender.js +13 -6
- package/lib/components/Card/CardsRender.js.map +1 -1
- package/lib/components/Card/helpers/get-updated-items-to-display.js +55 -0
- package/lib/components/Card/helpers/get-updated-items-to-display.js.map +1 -0
- package/lib/components/Card/helpers/index.js +7 -0
- package/lib/components/Card/helpers/index.js.map +1 -1
- package/lib/components/Code/Code.js +7 -3
- package/lib/components/Code/Code.js.map +1 -1
- package/lib/components/DataSummary/helpers/build-loop-props-content.js +3 -1
- package/lib/components/DataSummary/helpers/build-loop-props-content.js.map +1 -1
- package/lib/components/DataSummary/helpers/build-props-to-display-with-content.js +3 -2
- package/lib/components/DataSummary/helpers/build-props-to-display-with-content.js.map +1 -1
- package/lib/components/List/ListFactory.js +16 -11
- package/lib/components/List/ListFactory.js.map +1 -1
- package/lib/components/List/helpers/get-list-query.js +43 -0
- package/lib/components/List/helpers/get-list-query.js.map +1 -0
- package/lib/components/List/helpers/get-list-specific-search-filter.js +21 -0
- package/lib/components/List/helpers/get-list-specific-search-filter.js.map +1 -0
- package/lib/components/List/helpers/index.js +14 -0
- package/lib/components/List/helpers/index.js.map +1 -1
- package/lib/components/List/helpers/strip-query-key.js +14 -0
- package/lib/components/List/helpers/strip-query-key.js.map +1 -0
- package/lib/components/SearchContent/SearchContent.js +8 -6
- package/lib/components/SearchContent/SearchContent.js.map +1 -1
- package/lib/components/SearchFilter/SearchFilter/SearchFilter.js +17 -11
- package/lib/components/SearchFilter/SearchFilter/SearchFilter.js.map +1 -1
- package/lib/components/SearchFilter/SearchFilterContainer.js +63 -85
- package/lib/components/SearchFilter/SearchFilterContainer.js.map +1 -1
- package/lib/components/SearchFilter/helpers/build-filters-query.js +3 -1
- package/lib/components/SearchFilter/helpers/build-filters-query.js.map +1 -1
- package/lib/components/SearchFilter/helpers/build-new-url.js +17 -0
- package/lib/components/SearchFilter/helpers/build-new-url.js.map +1 -0
- package/lib/components/SearchFilter/helpers/build-url-query.js +48 -0
- package/lib/components/SearchFilter/helpers/build-url-query.js.map +1 -0
- package/lib/components/SearchFilter/helpers/get-filter-ranges-and-checkboxes-values.js +32 -0
- package/lib/components/SearchFilter/helpers/get-filter-ranges-and-checkboxes-values.js.map +1 -0
- package/lib/components/SearchFilter/helpers/get-filter-values.js +31 -0
- package/lib/components/SearchFilter/helpers/get-filter-values.js.map +1 -0
- package/lib/components/SearchFilter/helpers/index.js +18 -11
- package/lib/components/SearchFilter/helpers/index.js.map +1 -1
- package/lib/components/SearchFilter/index.js.map +1 -1
- package/lib/components/SearchFilter/searchFilterReducer.js +45 -0
- package/lib/components/SearchFilter/searchFilterReducer.js.map +1 -0
- package/lib/components/SearchFilterSort/SearchFilterSort.js +31 -11
- package/lib/components/SearchFilterSort/SearchFilterSort.js.map +1 -1
- package/lib/components/SearchFilterSort/helpers/handle-sort-update.js +19 -5
- package/lib/components/SearchFilterSort/helpers/handle-sort-update.js.map +1 -1
- package/lib/components/SearchFilterSort/helpers/update-sort.js +9 -5
- package/lib/components/SearchFilterSort/helpers/update-sort.js.map +1 -1
- package/lib/helpers/build-inherited-filters.js +2 -0
- package/lib/helpers/build-inherited-filters.js.map +1 -1
- package/lib/helpers/build-props-query.js +5 -2
- package/lib/helpers/build-props-query.js.map +1 -1
- package/lib/helpers/build-query-key.js +16 -0
- package/lib/helpers/build-query-key.js.map +1 -0
- package/lib/helpers/build-set-filters.js +5 -1
- package/lib/helpers/build-set-filters.js.map +1 -1
- package/lib/helpers/get-query-filters.js +6 -8
- package/lib/helpers/get-query-filters.js.map +1 -1
- package/lib/helpers/get-query-props.js +13 -2
- package/lib/helpers/get-query-props.js.map +1 -1
- package/lib/helpers/get-wrapped-value-with-link.js +2 -3
- package/lib/helpers/get-wrapped-value-with-link.js.map +1 -1
- package/lib/helpers/index.js +14 -0
- package/lib/helpers/index.js.map +1 -1
- package/lib/helpers/parse-props-to-display.js +13 -8
- package/lib/helpers/parse-props-to-display.js.map +1 -1
- package/lib/helpers/process-data-summary-value.js +56 -0
- package/lib/helpers/process-data-summary-value.js.map +1 -0
- package/lib-es/components/Card/CardsRender.js +14 -7
- package/lib-es/components/Card/CardsRender.js.map +1 -1
- package/lib-es/components/Card/helpers/get-updated-items-to-display.js +32 -0
- package/lib-es/components/Card/helpers/get-updated-items-to-display.js.map +1 -0
- package/lib-es/components/Card/helpers/index.js +1 -0
- package/lib-es/components/Card/helpers/index.js.map +1 -1
- package/lib-es/components/Code/Code.js +8 -4
- package/lib-es/components/Code/Code.js.map +1 -1
- package/lib-es/components/DataSummary/helpers/build-loop-props-content.js +3 -1
- package/lib-es/components/DataSummary/helpers/build-loop-props-content.js.map +1 -1
- package/lib-es/components/DataSummary/helpers/build-props-to-display-with-content.js +4 -3
- package/lib-es/components/DataSummary/helpers/build-props-to-display-with-content.js.map +1 -1
- package/lib-es/components/List/ListFactory.js +16 -12
- package/lib-es/components/List/ListFactory.js.map +1 -1
- package/lib-es/components/List/helpers/get-list-query.js +24 -0
- package/lib-es/components/List/helpers/get-list-query.js.map +1 -0
- package/lib-es/components/List/helpers/get-list-specific-search-filter.js +12 -0
- package/lib-es/components/List/helpers/get-list-specific-search-filter.js.map +1 -0
- package/lib-es/components/List/helpers/index.js +2 -0
- package/lib-es/components/List/helpers/index.js.map +1 -1
- package/lib-es/components/List/helpers/strip-query-key.js +6 -0
- package/lib-es/components/List/helpers/strip-query-key.js.map +1 -0
- package/lib-es/components/SearchContent/SearchContent.js +8 -6
- package/lib-es/components/SearchContent/SearchContent.js.map +1 -1
- package/lib-es/components/SearchFilter/SearchFilter/SearchFilter.js +18 -11
- package/lib-es/components/SearchFilter/SearchFilter/SearchFilter.js.map +1 -1
- package/lib-es/components/SearchFilter/SearchFilterContainer.js +47 -72
- package/lib-es/components/SearchFilter/SearchFilterContainer.js.map +1 -1
- package/lib-es/components/SearchFilter/helpers/build-filters-query.js +2 -0
- package/lib-es/components/SearchFilter/helpers/build-filters-query.js.map +1 -1
- package/lib-es/components/SearchFilter/helpers/build-new-url.js +8 -0
- package/lib-es/components/SearchFilter/helpers/build-new-url.js.map +1 -0
- package/lib-es/components/SearchFilter/helpers/build-url-query.js +30 -0
- package/lib-es/components/SearchFilter/helpers/build-url-query.js.map +1 -0
- package/lib-es/components/SearchFilter/helpers/get-filter-ranges-and-checkboxes-values.js +18 -0
- package/lib-es/components/SearchFilter/helpers/get-filter-ranges-and-checkboxes-values.js.map +1 -0
- package/lib-es/components/SearchFilter/helpers/get-filter-values.js +19 -0
- package/lib-es/components/SearchFilter/helpers/get-filter-values.js.map +1 -0
- package/lib-es/components/SearchFilter/helpers/index.js +5 -4
- package/lib-es/components/SearchFilter/helpers/index.js.map +1 -1
- package/lib-es/components/SearchFilter/index.js +2 -2
- package/lib-es/components/SearchFilter/index.js.map +1 -1
- package/lib-es/components/SearchFilter/searchFilterReducer.js +28 -0
- package/lib-es/components/SearchFilter/searchFilterReducer.js.map +1 -0
- package/lib-es/components/SearchFilterSort/SearchFilterSort.js +26 -10
- package/lib-es/components/SearchFilterSort/SearchFilterSort.js.map +1 -1
- package/lib-es/components/SearchFilterSort/helpers/handle-sort-update.js +21 -4
- package/lib-es/components/SearchFilterSort/helpers/handle-sort-update.js.map +1 -1
- package/lib-es/components/SearchFilterSort/helpers/update-sort.js +8 -4
- package/lib-es/components/SearchFilterSort/helpers/update-sort.js.map +1 -1
- package/lib-es/helpers/build-inherited-filters.js +2 -0
- package/lib-es/helpers/build-inherited-filters.js.map +1 -1
- package/lib-es/helpers/build-props-query.js +4 -2
- package/lib-es/helpers/build-props-query.js.map +1 -1
- package/lib-es/helpers/build-query-key.js +7 -0
- package/lib-es/helpers/build-query-key.js.map +1 -0
- package/lib-es/helpers/build-set-filters.js +5 -1
- package/lib-es/helpers/build-set-filters.js.map +1 -1
- package/lib-es/helpers/get-query-filters.js +6 -8
- package/lib-es/helpers/get-query-filters.js.map +1 -1
- package/lib-es/helpers/get-query-props.js +10 -2
- package/lib-es/helpers/get-query-props.js.map +1 -1
- package/lib-es/helpers/get-wrapped-value-with-link.js +2 -2
- package/lib-es/helpers/get-wrapped-value-with-link.js.map +1 -1
- package/lib-es/helpers/index.js +2 -0
- package/lib-es/helpers/index.js.map +1 -1
- package/lib-es/helpers/parse-props-to-display.js +12 -9
- package/lib-es/helpers/parse-props-to-display.js.map +1 -1
- package/lib-es/helpers/process-data-summary-value.js +36 -0
- package/lib-es/helpers/process-data-summary-value.js.map +1 -0
- package/package.json +10 -10
- package/src/components/Card/CardsRender.js +27 -7
- package/src/components/Card/helpers/get-updated-items-to-display.js +32 -0
- package/src/components/Card/helpers/index.js +1 -0
- package/src/components/Code/Code.js +7 -3
- package/src/components/DataSummary/helpers/build-loop-props-content.js +4 -1
- package/src/components/DataSummary/helpers/build-props-to-display-with-content.js +6 -3
- package/src/components/List/ListFactory.js +25 -15
- package/src/components/List/helpers/get-list-query.js +28 -0
- package/src/components/List/helpers/get-list-specific-search-filter.js +10 -0
- package/src/components/List/helpers/index.js +2 -0
- package/src/components/List/helpers/strip-query-key.js +6 -0
- package/src/components/SearchContent/SearchContent.js +8 -6
- package/src/components/SearchFilter/SearchFilter/SearchFilter.js +21 -12
- package/src/components/SearchFilter/SearchFilterContainer.js +57 -69
- package/src/components/SearchFilter/helpers/build-filters-query.js +9 -1
- package/src/components/SearchFilter/helpers/build-new-url.js +8 -0
- package/src/components/SearchFilter/helpers/build-url-query.js +31 -0
- package/src/components/SearchFilter/helpers/get-filter-ranges-and-checkboxes-values.js +17 -0
- package/src/components/SearchFilter/helpers/get-filter-values.js +21 -0
- package/src/components/SearchFilter/helpers/index.js +9 -7
- package/src/components/SearchFilter/index.js +2 -2
- package/src/components/SearchFilter/searchFilterReducer.js +15 -0
- package/src/components/SearchFilterSort/SearchFilterSort.js +18 -8
- package/src/components/SearchFilterSort/helpers/handle-sort-update.js +14 -5
- package/src/components/SearchFilterSort/helpers/update-sort.js +7 -3
- package/src/helpers/build-inherited-filters.js +3 -1
- package/src/helpers/build-props-query.js +4 -2
- package/src/helpers/build-query-key.js +7 -0
- package/src/helpers/build-set-filters.js +2 -1
- package/src/helpers/get-query-filters.js +4 -4
- package/src/helpers/get-query-props.js +12 -4
- package/src/helpers/get-wrapped-value-with-link.js +6 -3
- package/src/helpers/index.js +2 -0
- package/src/helpers/parse-props-to-display.js +25 -21
- package/src/helpers/process-data-summary-value.js +22 -0
- package/tests/helpers/mocks.js +3 -5
- package/tests/unit/src/components/Card/helpers/get-updated-items-to-display.test.js +72 -0
- package/tests/unit/src/components/Code/Code.test.js +5 -0
- package/tests/unit/src/components/Code/__snapshots__/Code.test.js.snap +8 -0
- package/tests/unit/src/components/DataSummary/helpers/build-loop-props-content.test.js +9 -0
- package/tests/unit/src/components/SearchFilter/__snapshots__/SearchFilterContainer.test.js.snap +1 -7
- package/tests/unit/src/components/SearchFilter/helpers/build-new-query.test.js +10 -10
- package/tests/unit/src/components/SearchFilter/helpers/build-query.test.js +24 -7
- package/tests/unit/src/components/SearchFilter/helpers/get-initial-filter-values.test.js +10 -10
- package/tests/unit/src/components/SearchFilterSort/SearchFilterSort.test.js +4 -1
- package/tests/unit/src/components/SearchFilterSort/helpers/handle-sort-update.test.js +26 -19
- package/tests/unit/src/components/SearchFilterSort/helpers/update-sort.test.js +10 -1
- package/tests/unit/src/helpers/__snapshots__/get-wrapped-value-with-link.test.js.snap +18 -0
- package/tests/unit/src/helpers/build-props-query.test.js +25 -0
- package/tests/unit/src/helpers/get-wrapped-value-with-link.test.js +2 -2
- package/tests/unit/src/helpers/parse-props-to-display.test.js +4 -0
- package/tests/unit/src/helpers/prcoess-data-summary-value.test.js +52 -0
- package/lib/components/SearchFilter/helpers/build-new-query.js +0 -15
- package/lib/components/SearchFilter/helpers/build-new-query.js.map +0 -1
- package/lib/components/SearchFilter/helpers/build-query.js +0 -37
- package/lib/components/SearchFilter/helpers/build-query.js.map +0 -1
- package/lib/components/SearchFilter/helpers/get-initial-filter-values.js +0 -43
- package/lib/components/SearchFilter/helpers/get-initial-filter-values.js.map +0 -1
- package/lib-es/components/SearchFilter/helpers/build-new-query.js +0 -6
- package/lib-es/components/SearchFilter/helpers/build-new-query.js.map +0 -1
- package/lib-es/components/SearchFilter/helpers/build-query.js +0 -23
- package/lib-es/components/SearchFilter/helpers/build-query.js.map +0 -1
- package/lib-es/components/SearchFilter/helpers/get-initial-filter-values.js +0 -26
- package/lib-es/components/SearchFilter/helpers/get-initial-filter-values.js.map +0 -1
- package/src/components/SearchFilter/helpers/build-new-query.js +0 -6
- package/src/components/SearchFilter/helpers/build-query.js +0 -26
- package/src/components/SearchFilter/helpers/get-initial-filter-values.js +0 -30
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-props-to-display.js","names":["React","Fragment","at","isObject","getParsedPropValues","getSanitizedPropValues","BOLD_TAG","BLANK_SPACE_UNICODE_STRING","parsePropsToDisplay","props","propsToDisplay","filter","Boolean","map","bold","propertiesToDisplay","prefix","suffix","shouldStrip","enableLink","
|
|
1
|
+
{"version":3,"file":"parse-props-to-display.js","names":["React","Fragment","at","isObject","getParsedPropValues","getSanitizedPropValues","BOLD_TAG","BLANK_SPACE_UNICODE_STRING","processDataSummaryValue","parsePropsToDisplay","props","propsToDisplay","filter","Boolean","map","options","currentIndex","bold","propertiesToDisplay","prefix","suffix","shouldStrip","enableLink","Wrapper","parsedPropValues","sanitizedPropValues","length","stringEndBlank","processedValue","Array","isArray","value","createElement"],"sources":["../../src/helpers/parse-props-to-display.js"],"sourcesContent":["import React, { Fragment } from 'react';\nimport at from 'lodash.at';\nimport isObject from './is-object';\nimport getParsedPropValues from './get-parsed-prop-values';\nimport getSanitizedPropValues from './get-sanitized-prop-values';\nimport { BOLD_TAG, BLANK_SPACE_UNICODE_STRING } from '../constants';\nimport processDataSummaryValue from './process-data-summary-value';\n\n// TODO this helper should be removed if database is wiped clean and all elements change to new props struc\nconst parsePropsToDisplay = (props = {}, propsToDisplay = []) => {\n if (!isObject(propsToDisplay[0])) return at(props, propsToDisplay).filter(Boolean);\n\n return propsToDisplay.map((options, currentIndex) => {\n const { bold, propertiesToDisplay, prefix, suffix, shouldStrip, enableLink } = options;\n const Wrapper = bold ? BOLD_TAG : Fragment;\n\n const parsedPropValues = getParsedPropValues({\n propertiesToDisplay,\n props,\n enableLink,\n shouldStrip\n });\n\n const sanitizedPropValues = getSanitizedPropValues(parsedPropValues);\n if (!sanitizedPropValues || !sanitizedPropValues.length) return null;\n const stringEndBlank =\n currentIndex + 1 === propsToDisplay.length ? '' : BLANK_SPACE_UNICODE_STRING;\n\n const processedValue = Array.isArray(sanitizedPropValues)\n ? sanitizedPropValues.map(value => processDataSummaryValue(value, options))\n : processDataSummaryValue(sanitizedPropValues, options);\n\n return (\n <Wrapper>\n {prefix} {processedValue} {suffix}\n {stringEndBlank}\n </Wrapper>\n );\n });\n};\n\nexport default parsePropsToDisplay;\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,QAAQ,QAAQ,OAAO;AACvC,OAAOC,EAAE,MAAM,WAAW;AAC1B,OAAOC,QAAQ,MAAM,aAAa;AAClC,OAAOC,mBAAmB,MAAM,0BAA0B;AAC1D,OAAOC,sBAAsB,MAAM,6BAA6B;AAChE,SAASC,QAAQ,EAAEC,0BAA0B,QAAQ,cAAc;AACnE,OAAOC,uBAAuB,MAAM,8BAA8B;;AAElE;AACA,MAAMC,mBAAmB,GAAGA,CAACC,KAAK,GAAG,CAAC,CAAC,EAAEC,cAAc,GAAG,EAAE,KAAK;EAC/D,IAAI,CAACR,QAAQ,CAACQ,cAAc,CAAC,CAAC,CAAC,CAAC,EAAE,OAAOT,EAAE,CAACQ,KAAK,EAAEC,cAAc,CAAC,CAACC,MAAM,CAACC,OAAO,CAAC;EAElF,OAAOF,cAAc,CAACG,GAAG,CAAC,CAACC,OAAO,EAAEC,YAAY,KAAK;IACnD,MAAM;MAAEC,IAAI;MAAEC,mBAAmB;MAAEC,MAAM;MAAEC,MAAM;MAAEC,WAAW;MAAEC;IAAW,CAAC,GAAGP,OAAO;IACtF,MAAMQ,OAAO,GAAGN,IAAI,GAAGX,QAAQ,GAAGL,QAAQ;IAE1C,MAAMuB,gBAAgB,GAAGpB,mBAAmB,CAAC;MAC3Cc,mBAAmB;MACnBR,KAAK;MACLY,UAAU;MACVD;IACF,CAAC,CAAC;IAEF,MAAMI,mBAAmB,GAAGpB,sBAAsB,CAACmB,gBAAgB,CAAC;IACpE,IAAI,CAACC,mBAAmB,IAAI,CAACA,mBAAmB,CAACC,MAAM,EAAE,OAAO,IAAI;IACpE,MAAMC,cAAc,GAClBX,YAAY,GAAG,CAAC,KAAKL,cAAc,CAACe,MAAM,GAAG,EAAE,GAAGnB,0BAA0B;IAE9E,MAAMqB,cAAc,GAAGC,KAAK,CAACC,OAAO,CAACL,mBAAmB,CAAC,GACrDA,mBAAmB,CAACX,GAAG,CAACiB,KAAK,IAAIvB,uBAAuB,CAACuB,KAAK,EAAEhB,OAAO,CAAC,CAAC,GACzEP,uBAAuB,CAACiB,mBAAmB,EAAEV,OAAO,CAAC;IAEzD,oBACEf,KAAA,CAAAgC,aAAA,CAACT,OAAO,QACLJ,MAAM,EAAC,GAAC,EAACS,cAAc,EAAC,GAAC,EAACR,MAAM,EAChCO,cACM,CAAC;EAEd,CAAC,CAAC;AACJ,CAAC;AAED,eAAelB,mBAAmB"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
4
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
5
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
6
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import components from '../components';
|
|
9
|
+
const {
|
|
10
|
+
code: Code
|
|
11
|
+
} = components;
|
|
12
|
+
const renderCode = value => /*#__PURE__*/React.createElement(Code, {
|
|
13
|
+
code: value,
|
|
14
|
+
disableWrapper: true
|
|
15
|
+
});
|
|
16
|
+
const processDataSummaryValue = (objPropValue, {
|
|
17
|
+
isHtml
|
|
18
|
+
}) => {
|
|
19
|
+
let pValue = objPropValue;
|
|
20
|
+
if (isHtml) {
|
|
21
|
+
pValue = Array.isArray(objPropValue) ? objPropValue.map(_ref => {
|
|
22
|
+
let {
|
|
23
|
+
keyField,
|
|
24
|
+
[keyField]: value
|
|
25
|
+
} = _ref,
|
|
26
|
+
otherProps = _objectWithoutProperties(_ref, ["keyField", keyField].map(_toPropertyKey));
|
|
27
|
+
return _objectSpread({
|
|
28
|
+
[keyField]: renderCode(value),
|
|
29
|
+
keyField
|
|
30
|
+
}, otherProps);
|
|
31
|
+
}) : renderCode(objPropValue);
|
|
32
|
+
}
|
|
33
|
+
return pValue;
|
|
34
|
+
};
|
|
35
|
+
export default processDataSummaryValue;
|
|
36
|
+
//# sourceMappingURL=process-data-summary-value.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"process-data-summary-value.js","names":["React","components","code","Code","renderCode","value","createElement","disableWrapper","processDataSummaryValue","objPropValue","isHtml","pValue","Array","isArray","map","_ref","keyField","otherProps","_objectWithoutProperties","_toPropertyKey","_objectSpread"],"sources":["../../src/helpers/process-data-summary-value.js"],"sourcesContent":["import React from 'react';\nimport components from '../components';\n\nconst { code: Code } = components;\n\nconst renderCode = value => <Code code={value} disableWrapper />;\n\nconst processDataSummaryValue = (objPropValue, { isHtml }) => {\n let pValue = objPropValue;\n if (isHtml) {\n pValue = Array.isArray(objPropValue)\n ? objPropValue.map(({ keyField, [keyField]: value, ...otherProps }) => ({\n [keyField]: renderCode(value),\n keyField,\n ...otherProps\n }))\n : renderCode(objPropValue);\n }\n return pValue;\n};\n\nexport default processDataSummaryValue;\n"],"mappings":";;;;;;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,UAAU,MAAM,eAAe;AAEtC,MAAM;EAAEC,IAAI,EAAEC;AAAK,CAAC,GAAGF,UAAU;AAEjC,MAAMG,UAAU,GAAGC,KAAK,iBAAIL,KAAA,CAAAM,aAAA,CAACH,IAAI;EAACD,IAAI,EAAEG,KAAM;EAACE,cAAc;AAAA,CAAE,CAAC;AAEhE,MAAMC,uBAAuB,GAAGA,CAACC,YAAY,EAAE;EAAEC;AAAO,CAAC,KAAK;EAC5D,IAAIC,MAAM,GAAGF,YAAY;EACzB,IAAIC,MAAM,EAAE;IACVC,MAAM,GAAGC,KAAK,CAACC,OAAO,CAACJ,YAAY,CAAC,GAChCA,YAAY,CAACK,GAAG,CAACC,IAAA;MAAA,IAAC;UAAEC,QAAQ;UAAE,CAACA,QAAQ,GAAGX;QAAqB,CAAC,GAAAU,IAAA;QAAZE,UAAU,GAAAC,wBAAA,CAAAH,IAAA,eAA/BC,QAAQ,EAAAF,GAAA,CAAAK,cAAA;MAAA,OAAAC,aAAA;QACrC,CAACJ,QAAQ,GAAGZ,UAAU,CAACC,KAAK,CAAC;QAC7BW;MAAQ,GACLC,UAAU;IAAA,CACb,CAAC,GACHb,UAAU,CAACK,YAAY,CAAC;EAC9B;EACA,OAAOE,MAAM;AACf,CAAC;AAED,eAAeH,uBAAuB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blaze-cms/react-page-builder",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.131.0-admin-updates.1",
|
|
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": "
|
|
31
|
-
"@blaze-cms/core-errors": "
|
|
32
|
-
"@blaze-cms/core-errors-ui": "
|
|
30
|
+
"@blaze-cms/core-auth-ui": "0.131.0-admin-updates.0",
|
|
31
|
+
"@blaze-cms/core-errors": "0.131.0-admin-updates.0",
|
|
32
|
+
"@blaze-cms/core-errors-ui": "0.131.0-admin-updates.0",
|
|
33
33
|
"@blaze-cms/image-cdn-react": "0.3.0-alpha.5",
|
|
34
|
-
"@blaze-cms/nextjs-components": "
|
|
35
|
-
"@blaze-cms/plugin-search-ui": "
|
|
36
|
-
"@blaze-cms/setup-ui": "
|
|
37
|
-
"@blaze-cms/utils": "
|
|
38
|
-
"@blaze-cms/utils-handlebars": "
|
|
34
|
+
"@blaze-cms/nextjs-components": "0.131.0-admin-updates.0",
|
|
35
|
+
"@blaze-cms/plugin-search-ui": "0.131.0-admin-updates.0",
|
|
36
|
+
"@blaze-cms/setup-ui": "0.131.0-admin-updates.0",
|
|
37
|
+
"@blaze-cms/utils": "0.131.0-admin-updates.0",
|
|
38
|
+
"@blaze-cms/utils-handlebars": "0.131.0-admin-updates.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",
|
|
@@ -89,5 +89,5 @@
|
|
|
89
89
|
"lib/*",
|
|
90
90
|
"lib-es/*"
|
|
91
91
|
],
|
|
92
|
-
"gitHead": "
|
|
92
|
+
"gitHead": "757ebc0ab43b06c8a34d0348724f5b9bbbf097a3"
|
|
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(
|
|
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 =
|
|
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 (
|
|
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,
|
|
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,
|
|
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';
|
|
@@ -7,26 +7,30 @@ import { getClassModifiers } from '../../utils';
|
|
|
7
7
|
import { CODE } from '../../constants';
|
|
8
8
|
import { wrapScriptTags } from './helpers';
|
|
9
9
|
|
|
10
|
-
const Code = memo(({ code: embedCode, parserOptions, ...otherProps }) => {
|
|
10
|
+
const Code = memo(({ code: embedCode, parserOptions, disableWrapper, ...otherProps }) => {
|
|
11
11
|
if (!embedCode) return null;
|
|
12
12
|
|
|
13
13
|
const parsedCode = parseHTML(embedCode, parserOptions);
|
|
14
14
|
const wrappedCode = wrapScriptTags(parsedCode);
|
|
15
15
|
const modifiers = getClassModifiers(CODE, { ...otherProps });
|
|
16
16
|
|
|
17
|
+
if (disableWrapper) return wrappedCode;
|
|
18
|
+
|
|
17
19
|
return <Wrapper modifiers={modifiers}>{wrappedCode}</Wrapper>;
|
|
18
20
|
});
|
|
19
21
|
|
|
20
22
|
Code.propTypes = {
|
|
21
23
|
code: PropTypes.string,
|
|
22
24
|
modifier: PropTypes.string,
|
|
23
|
-
parserOptions: PropTypes.object
|
|
25
|
+
parserOptions: PropTypes.object,
|
|
26
|
+
disableWrapper: PropTypes.bool
|
|
24
27
|
};
|
|
25
28
|
|
|
26
29
|
Code.defaultProps = {
|
|
27
30
|
code: '',
|
|
28
31
|
modifier: '',
|
|
29
|
-
parserOptions: {}
|
|
32
|
+
parserOptions: {},
|
|
33
|
+
disableWrapper: false
|
|
30
34
|
};
|
|
31
35
|
|
|
32
36
|
export default withTitle(Code);
|
|
@@ -3,6 +3,7 @@ import flatten from 'lodash.flatten';
|
|
|
3
3
|
import getLinkToPublishedContent from './get-link-to-published-content';
|
|
4
4
|
import getLoopPropsLimit from './get-loop-props-limit';
|
|
5
5
|
import getPropValue from './get-prop-value';
|
|
6
|
+
import { processDataSummaryValue } from '../../../helpers';
|
|
6
7
|
|
|
7
8
|
const getLoopValue = value => {
|
|
8
9
|
const { keyField } = value;
|
|
@@ -46,8 +47,10 @@ const buildLoopPropsContent = (loopProps = [], propsToDisplay = [], limit = 0, d
|
|
|
46
47
|
const loopValue = loopValues[key];
|
|
47
48
|
const propValue = loopValue ? getLoopValue(loopValue[i]) : regularValues[key];
|
|
48
49
|
if (!propValue) return null;
|
|
50
|
+
|
|
51
|
+
const processedValue = processDataSummaryValue(propValue, options);
|
|
49
52
|
const linkToPublishedContent = getLinkToPublishedContent(key, data);
|
|
50
|
-
return [upperFirst(label),
|
|
53
|
+
return [upperFirst(label), processedValue, linkToPublishedContent, modifier];
|
|
51
54
|
});
|
|
52
55
|
})
|
|
53
56
|
).filter(Boolean);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import upperFirst from 'lodash.upperfirst';
|
|
2
2
|
import flatten from 'lodash.flatten';
|
|
3
|
-
import { isObject } from '../../../helpers';
|
|
3
|
+
import { isObject, processDataSummaryValue } from '../../../helpers';
|
|
4
4
|
import getLinkToPublishedContent from './get-link-to-published-content';
|
|
5
5
|
import getPropValue from './get-prop-value';
|
|
6
6
|
import getLinkBasedOnValue from './get-link-based-on-value';
|
|
@@ -27,15 +27,18 @@ const buildPropsToDisplayWithContent = (props, propsToDisplay = []) => {
|
|
|
27
27
|
const objPropValue = getPropValue(key, props, options);
|
|
28
28
|
if (!objPropValue) return null;
|
|
29
29
|
|
|
30
|
-
const
|
|
30
|
+
const processedValue = processDataSummaryValue(objPropValue, options);
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
const link = getLink(enableLink, key, props, processedValue);
|
|
33
|
+
|
|
34
|
+
return [upperFirst(label), processedValue, link, modifier];
|
|
33
35
|
});
|
|
34
36
|
})
|
|
35
37
|
).filter(Boolean);
|
|
36
38
|
};
|
|
37
39
|
|
|
38
40
|
export default buildPropsToDisplayWithContent;
|
|
41
|
+
|
|
39
42
|
function getLink(enableLink, key, props, objPropValue) {
|
|
40
43
|
let link = '';
|
|
41
44
|
if (enableLink) {
|
|
@@ -7,7 +7,13 @@ import { MainContext } from '@blaze-cms/nextjs-components';
|
|
|
7
7
|
import { generateSingleItemQuery, getItemList } from '../../application/query';
|
|
8
8
|
import ListBuilder from './ListBuilder';
|
|
9
9
|
import { AZ_LIST_TYPE } from './constants';
|
|
10
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
getAzQueryFilter,
|
|
12
|
+
getSortProps,
|
|
13
|
+
hasRequiredItemListDetails,
|
|
14
|
+
getListSpecificSearchFilter,
|
|
15
|
+
getListQuery
|
|
16
|
+
} from './helpers';
|
|
11
17
|
import {
|
|
12
18
|
getGenericProps,
|
|
13
19
|
getRequiredSchemas,
|
|
@@ -37,7 +43,7 @@ const ListFactory = props => {
|
|
|
37
43
|
type,
|
|
38
44
|
sortby: defaultSortBy,
|
|
39
45
|
sort: defaultSort,
|
|
40
|
-
|
|
46
|
+
allSearchFilters,
|
|
41
47
|
operator: filterOperator,
|
|
42
48
|
sortProperties,
|
|
43
49
|
itemListName
|
|
@@ -46,11 +52,13 @@ const ListFactory = props => {
|
|
|
46
52
|
const router = useRouter();
|
|
47
53
|
const { asPath } = router;
|
|
48
54
|
const parsedQuery = asPath.replace(/%5D/g, ']').replace(/%5B/g, '[');
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
} = parseUrl(parsedQuery);
|
|
55
|
+
const [searchFilter, hasListSpecificFilters] = getListSpecificSearchFilter(
|
|
56
|
+
allSearchFilters,
|
|
57
|
+
name
|
|
58
|
+
);
|
|
59
|
+
const { query, url, query: { itemListId: queryItemListId } = {} } = parseUrl(parsedQuery);
|
|
60
|
+
const updatedQuery = getListQuery(query, hasListSpecificFilters, name);
|
|
61
|
+
const { sort: querySort, sortby: querySortBy } = updatedQuery;
|
|
54
62
|
const { sortbyFilters, updatedSortProperties } = getSortProps({
|
|
55
63
|
querySort,
|
|
56
64
|
sortProperties,
|
|
@@ -62,8 +70,8 @@ const ListFactory = props => {
|
|
|
62
70
|
const itemListId = getItemListId(itemListName, queryItemListId);
|
|
63
71
|
const { itemEntity: parentEntity, itemId: parentId } = parent;
|
|
64
72
|
const updatedParentEntity = getUnpublishedEntityName(parentEntity);
|
|
65
|
-
const paginationIndex = getPaginationIndex(
|
|
66
|
-
const azFilter = getAzQueryFilter(
|
|
73
|
+
const paginationIndex = getPaginationIndex(updatedQuery, name);
|
|
74
|
+
const azFilter = getAzQueryFilter(updatedQuery, name);
|
|
67
75
|
|
|
68
76
|
const entitiesToUse = entities && entities.length ? entities : [legacyEntity];
|
|
69
77
|
const [filterEntity] = entitiesToUse;
|
|
@@ -123,10 +131,12 @@ const ListFactory = props => {
|
|
|
123
131
|
const [textFilter] = getSearchFilterType(searchFilter, TEXT_SEARCH);
|
|
124
132
|
const shouldApplyTextFilter = textFilter && textFilter.propsToDisplay.length;
|
|
125
133
|
const operator = shouldApplyTextFilter ? getElasticsearchOperator(textFilter) : AND_OPERATOR;
|
|
126
|
-
const valuesText = shouldApplyTextFilter
|
|
127
|
-
|
|
134
|
+
const valuesText = shouldApplyTextFilter
|
|
135
|
+
? buildSearchValuesText(textFilter, updatedQuery, name)
|
|
136
|
+
: [];
|
|
137
|
+
const { valuesAnd, valuesOr } = getQueryFilters(searchFilter, updatedQuery, name);
|
|
128
138
|
const isTextSearchFilterApplied = !!(
|
|
129
|
-
|
|
139
|
+
updatedQuery.search_term &&
|
|
130
140
|
searchFilter &&
|
|
131
141
|
getSearchFilterType(searchFilter, TEXT_SEARCH).length
|
|
132
142
|
);
|
|
@@ -139,7 +149,7 @@ const ListFactory = props => {
|
|
|
139
149
|
const listProps = {
|
|
140
150
|
...props,
|
|
141
151
|
...genericProps,
|
|
142
|
-
query,
|
|
152
|
+
query: updatedQuery,
|
|
143
153
|
url,
|
|
144
154
|
isCard,
|
|
145
155
|
isAZ,
|
|
@@ -179,7 +189,7 @@ ListFactory.propTypes = {
|
|
|
179
189
|
name: PropTypes.string,
|
|
180
190
|
sortby: PropTypes.array,
|
|
181
191
|
sort: PropTypes.string,
|
|
182
|
-
|
|
192
|
+
allSearchFilters: PropTypes.array,
|
|
183
193
|
sortProperties: PropTypes.array,
|
|
184
194
|
itemListName: PropTypes.string
|
|
185
195
|
};
|
|
@@ -195,7 +205,7 @@ ListFactory.defaultProps = {
|
|
|
195
205
|
sortProperties: [],
|
|
196
206
|
sort: '',
|
|
197
207
|
operator: AND,
|
|
198
|
-
|
|
208
|
+
allSearchFilters: [],
|
|
199
209
|
itemListName: ''
|
|
200
210
|
};
|
|
201
211
|
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import stripQueryKey from './strip-query-key';
|
|
2
|
+
|
|
3
|
+
const getListQuery = (query, hasListSpecificFilters, name) => {
|
|
4
|
+
const updatedQuery = {};
|
|
5
|
+
const listKey = `pb[${name}]`;
|
|
6
|
+
const paginationKey = `${listKey}[page]`;
|
|
7
|
+
const sortKey = `${listKey}[sort]`;
|
|
8
|
+
const sortByKey = `${listKey}[sortby]`;
|
|
9
|
+
|
|
10
|
+
Object.keys(query).forEach(queryKey => {
|
|
11
|
+
const isListKey = queryKey.indexOf(`${listKey}`) !== -1;
|
|
12
|
+
const decodedQueryValue = Array.isArray(query[queryKey])
|
|
13
|
+
? query[queryKey].map(value => decodeURIComponent(value))
|
|
14
|
+
: decodeURIComponent(query[queryKey]);
|
|
15
|
+
if (hasListSpecificFilters) {
|
|
16
|
+
const strippedKey = stripQueryKey(queryKey, listKey, paginationKey);
|
|
17
|
+
if (isListKey) updatedQuery[strippedKey] = decodedQueryValue;
|
|
18
|
+
} else {
|
|
19
|
+
if (queryKey.indexOf('pb[') === -1) updatedQuery[queryKey] = decodedQueryValue;
|
|
20
|
+
if (queryKey.indexOf(paginationKey) !== -1) updatedQuery[queryKey] = decodedQueryValue;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
updatedQuery.sort = query[sortKey] || query.sort;
|
|
24
|
+
updatedQuery.sortby = query[sortByKey] || query.sortby;
|
|
25
|
+
return updatedQuery;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export default getListQuery;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const getListSpecificSearchFilter = (searchFilters, listName) => {
|
|
2
|
+
const searchFilterMatch = searchFilters.find(
|
|
3
|
+
({ settings: { listComponentName } }) => listComponentName === listName
|
|
4
|
+
);
|
|
5
|
+
const hasListSpecificFilters = !!searchFilterMatch;
|
|
6
|
+
const searchFilterToUse = searchFilterMatch || searchFilters[0] || {};
|
|
7
|
+
return [searchFilterToUse, hasListSpecificFilters];
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export default getListSpecificSearchFilter;
|
|
@@ -7,3 +7,5 @@ export { default as getItemsPerPageToUse } from './get-items-per-page-to-use';
|
|
|
7
7
|
export { default as getSortProps } from './get-sort-props';
|
|
8
8
|
export { default as hasRequiredItemListDetails } from './has-required-item-list-details';
|
|
9
9
|
export { default as getListComponent } from './get-list-component';
|
|
10
|
+
export { default as getListQuery } from './get-list-query';
|
|
11
|
+
export { default as getListSpecificSearchFilter } from './get-list-specific-search-filter';
|
|
@@ -10,12 +10,12 @@ const SearchContent = ({
|
|
|
10
10
|
searchInputAlignment,
|
|
11
11
|
searchInputWrapperMobile,
|
|
12
12
|
searchInputWrapperDesktop,
|
|
13
|
-
collapsible,
|
|
14
13
|
isMobile,
|
|
15
14
|
placeholder,
|
|
16
|
-
modifier
|
|
15
|
+
modifier,
|
|
16
|
+
collapsedSearch
|
|
17
17
|
}) => {
|
|
18
|
-
const [collapsed, setCollapsed] = useState(
|
|
18
|
+
const [collapsed, setCollapsed] = useState(collapsedSearch);
|
|
19
19
|
const router = useRouter();
|
|
20
20
|
|
|
21
21
|
const { results, searchTerm, setSearchTerm, debouncedSearchTerm } = useDebounceSearch({
|
|
@@ -50,7 +50,7 @@ const SearchContent = ({
|
|
|
50
50
|
};
|
|
51
51
|
|
|
52
52
|
const handleOnBlur = () => {
|
|
53
|
-
if (!
|
|
53
|
+
if (!collapsedSearch) return;
|
|
54
54
|
if (!debouncedSearchTerm || debouncedSearchTerm === '') setCollapsed(true);
|
|
55
55
|
};
|
|
56
56
|
|
|
@@ -120,7 +120,8 @@ SearchContent.propTypes = {
|
|
|
120
120
|
isMobile: PropTypes.bool,
|
|
121
121
|
collapsible: PropTypes.bool,
|
|
122
122
|
entities: PropTypes.array.isRequired,
|
|
123
|
-
modifier: PropTypes.string
|
|
123
|
+
modifier: PropTypes.string,
|
|
124
|
+
collapsedSearch: PropTypes.bool
|
|
124
125
|
};
|
|
125
126
|
|
|
126
127
|
SearchContent.defaultProps = {
|
|
@@ -130,7 +131,8 @@ SearchContent.defaultProps = {
|
|
|
130
131
|
placeholder: '',
|
|
131
132
|
isMobile: false,
|
|
132
133
|
collapsible: false,
|
|
133
|
-
modifier: ''
|
|
134
|
+
modifier: '',
|
|
135
|
+
collapsedSearch: false
|
|
134
136
|
};
|
|
135
137
|
|
|
136
138
|
export default SearchContent;
|
|
@@ -5,8 +5,8 @@ import debounce from 'lodash.debounce';
|
|
|
5
5
|
import FiltersList from './FiltersList';
|
|
6
6
|
import {
|
|
7
7
|
isDeviceDesktop,
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
buildUrlQuery,
|
|
9
|
+
getFilterValues,
|
|
10
10
|
getResponsiveFilterClassnames
|
|
11
11
|
} from '../helpers';
|
|
12
12
|
import CloseMobileForm from './CloseMobileForm';
|
|
@@ -16,6 +16,7 @@ import { SEARCH, REFINE, MORE_FILTERS_CLASSES } from '../constants';
|
|
|
16
16
|
|
|
17
17
|
const SearchFilter = ({
|
|
18
18
|
searchFilterRef,
|
|
19
|
+
listComponentName,
|
|
19
20
|
data,
|
|
20
21
|
filters,
|
|
21
22
|
hasUrl,
|
|
@@ -28,13 +29,14 @@ const SearchFilter = ({
|
|
|
28
29
|
groupAfterDesktop,
|
|
29
30
|
groupAfterMobile,
|
|
30
31
|
filterValues,
|
|
31
|
-
setAppliedFilters
|
|
32
|
+
setAppliedFilters,
|
|
33
|
+
query
|
|
32
34
|
}) => {
|
|
33
35
|
const [moreFiltersMobileCollapsed, setMoreFiltersMobileCollapsed] = useState(true);
|
|
34
36
|
const [moreFiltersDesktopCollapsed, setMoreFiltersDesktopCollapsed] = useState(true);
|
|
35
37
|
|
|
36
|
-
const doSubmit =
|
|
37
|
-
const newQuery =
|
|
38
|
+
const doSubmit = newValues => {
|
|
39
|
+
const newQuery = buildUrlQuery(newValues, filters, listComponentName, query);
|
|
38
40
|
handleSearch(newQuery);
|
|
39
41
|
setMoreFiltersDesktopCollapsed(true);
|
|
40
42
|
setMoreFiltersMobileCollapsed(true);
|
|
@@ -69,7 +71,7 @@ const SearchFilter = ({
|
|
|
69
71
|
const formId = `filter-${name}-form`;
|
|
70
72
|
|
|
71
73
|
const handleReset = () => {
|
|
72
|
-
const newValues =
|
|
74
|
+
const newValues = getFilterValues(null, filters, {});
|
|
73
75
|
setAppliedFilters({ newValues, type: 'reset' });
|
|
74
76
|
doSubmit(newValues);
|
|
75
77
|
};
|
|
@@ -79,7 +81,7 @@ const SearchFilter = ({
|
|
|
79
81
|
};
|
|
80
82
|
|
|
81
83
|
const shouldGroup = !!(groupAfterDesktop || groupAfterMobile);
|
|
82
|
-
|
|
84
|
+
|
|
83
85
|
return (
|
|
84
86
|
<>
|
|
85
87
|
<form
|
|
@@ -89,7 +91,7 @@ const SearchFilter = ({
|
|
|
89
91
|
id={formId}
|
|
90
92
|
onSubmit={e => {
|
|
91
93
|
e.preventDefault();
|
|
92
|
-
doSubmit();
|
|
94
|
+
doSubmit(filterValues);
|
|
93
95
|
}}>
|
|
94
96
|
{displaySearchFilter && (
|
|
95
97
|
<CloseMobileForm handleClose={() => setDisplaySearchFilter(false)} />
|
|
@@ -101,7 +103,7 @@ const SearchFilter = ({
|
|
|
101
103
|
<div className="filter__wrapper filter__wrapper--search-refine">
|
|
102
104
|
{!shouldGroup && (
|
|
103
105
|
<FiltersList
|
|
104
|
-
shouldSearch={
|
|
106
|
+
shouldSearch={!hasUrl}
|
|
105
107
|
data={data}
|
|
106
108
|
filters={filters}
|
|
107
109
|
hasUrl={hasUrl}
|
|
@@ -114,7 +116,7 @@ const SearchFilter = ({
|
|
|
114
116
|
{shouldGroup && (
|
|
115
117
|
<>
|
|
116
118
|
<FiltersList
|
|
117
|
-
shouldSearch={
|
|
119
|
+
shouldSearch={!hasUrl}
|
|
118
120
|
data={data}
|
|
119
121
|
filters={filters.slice(0, groupAfterMobile)}
|
|
120
122
|
hasUrl={hasUrl}
|
|
@@ -136,7 +138,7 @@ const SearchFilter = ({
|
|
|
136
138
|
<div className={moreFiltersMobileWrapperClass}>
|
|
137
139
|
<div className={MORE_FILTERS_CLASSES.MOBILE_CONTENT}>
|
|
138
140
|
<FiltersList
|
|
139
|
-
shouldSearch={
|
|
141
|
+
shouldSearch={!hasUrl && isDeviceDesktop()}
|
|
140
142
|
data={data}
|
|
141
143
|
filters={filters.slice(
|
|
142
144
|
groupAfterMobile,
|
|
@@ -233,7 +235,14 @@ SearchFilter.propTypes = {
|
|
|
233
235
|
groupAfterDesktop: PropTypes.number.isRequired,
|
|
234
236
|
groupAfterMobile: PropTypes.number.isRequired,
|
|
235
237
|
filterValues: PropTypes.object.isRequired,
|
|
236
|
-
setAppliedFilters: PropTypes.func.isRequired
|
|
238
|
+
setAppliedFilters: PropTypes.func.isRequired,
|
|
239
|
+
listComponentName: PropTypes.string,
|
|
240
|
+
query: PropTypes.object
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
SearchFilter.defaultProps = {
|
|
244
|
+
listComponentName: '',
|
|
245
|
+
query: {}
|
|
237
246
|
};
|
|
238
247
|
|
|
239
248
|
export default SearchFilter;
|