@blaze-cms/react-page-builder 0.139.0-alpha.0 → 0.139.0-alpha.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 +11 -0
- package/lib/helpers/build-checkbox-filters.js +38 -0
- package/lib/helpers/build-checkbox-filters.js.map +1 -0
- package/lib/helpers/build-raw-query-base.js +4 -12
- package/lib/helpers/build-raw-query-base.js.map +1 -1
- package/lib/helpers/build-set-filters.js +3 -9
- package/lib/helpers/build-set-filters.js.map +1 -1
- package/lib/helpers/get-checkbox-filters.js +15 -0
- package/lib/helpers/get-checkbox-filters.js.map +1 -0
- package/lib-es/helpers/build-checkbox-filters.js +28 -0
- package/lib-es/helpers/build-checkbox-filters.js.map +1 -0
- package/lib-es/helpers/build-raw-query-base.js +1 -8
- package/lib-es/helpers/build-raw-query-base.js.map +1 -1
- package/lib-es/helpers/build-set-filters.js +3 -9
- package/lib-es/helpers/build-set-filters.js.map +1 -1
- package/lib-es/helpers/get-checkbox-filters.js +7 -0
- package/lib-es/helpers/get-checkbox-filters.js.map +1 -0
- package/package.json +2 -2
- package/src/helpers/build-checkbox-filters.js +23 -0
- package/src/helpers/build-raw-query-base.js +1 -6
- package/src/helpers/build-set-filters.js +3 -11
- package/src/helpers/get-checkbox-filters.js +7 -0
- package/tests/unit/src/helpers/build-checkbox-filters.test.js +27 -0
- package/tests/unit/src/helpers/get-checkbox-filters.test.js +33 -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.139.0-alpha.1](https://github.com/thebyte9/blaze/compare/v0.139.0-alpha.0...v0.139.0-alpha.1) (2023-12-20)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* added new filter options for sponsored and featured ([#4172](https://github.com/thebyte9/blaze/issues/4172)) ([11051f6](https://github.com/thebyte9/blaze/commit/11051f630c3fb0b74aa9d79e1e154151d438cc69))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
# [0.139.0-alpha.0](https://github.com/thebyte9/blaze/compare/v0.138.0...v0.139.0-alpha.0) (2023-12-19)
|
|
7
18
|
|
|
8
19
|
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
require("core-js/modules/es.object.define-property.js");
|
|
4
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports["default"] = void 0;
|
|
9
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
|
+
require("core-js/modules/es.array.reduce.js");
|
|
11
|
+
require("core-js/modules/es.object.to-string.js");
|
|
12
|
+
var getFilterValue = function getFilterValue(value) {
|
|
13
|
+
// To be updated with future filter options
|
|
14
|
+
switch (value) {
|
|
15
|
+
case 'not':
|
|
16
|
+
return false;
|
|
17
|
+
case 'on':
|
|
18
|
+
return true;
|
|
19
|
+
default:
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
var buildCheckboxFilters = function buildCheckboxFilters(checkboxFilters) {
|
|
24
|
+
return checkboxFilters.reduce(function (acc, checkboxFilter) {
|
|
25
|
+
if (typeof checkboxFilter === 'string') acc.push({
|
|
26
|
+
match: (0, _defineProperty2["default"])({}, checkboxFilter, true)
|
|
27
|
+
});else {
|
|
28
|
+
var filterValue = getFilterValue(checkboxFilter[1]);
|
|
29
|
+
acc.push({
|
|
30
|
+
match: (0, _defineProperty2["default"])({}, checkboxFilter[0], filterValue)
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
return acc;
|
|
34
|
+
}, []);
|
|
35
|
+
};
|
|
36
|
+
var _default = buildCheckboxFilters;
|
|
37
|
+
exports["default"] = _default;
|
|
38
|
+
//# sourceMappingURL=build-checkbox-filters.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-checkbox-filters.js","names":["getFilterValue","value","buildCheckboxFilters","checkboxFilters","reduce","acc","checkboxFilter","push","match","_defineProperty2","filterValue","_default","exports"],"sources":["../../src/helpers/build-checkbox-filters.js"],"sourcesContent":["const getFilterValue = value => {\n // To be updated with future filter options\n switch (value) {\n case 'not':\n return false;\n case 'on':\n return true;\n default:\n return true;\n }\n};\n\nconst buildCheckboxFilters = checkboxFilters =>\n checkboxFilters.reduce((acc, checkboxFilter) => {\n if (typeof checkboxFilter === 'string') acc.push({ match: { [checkboxFilter]: true } });\n else {\n const filterValue = getFilterValue(checkboxFilter[1]);\n acc.push({ match: { [checkboxFilter[0]]: filterValue } });\n }\n return acc;\n }, []);\n\nexport default buildCheckboxFilters;\n"],"mappings":";;;;;;;;;;;AAAA,IAAMA,cAAc,GAAG,SAAjBA,cAAcA,CAAGC,KAAK,EAAI;EAC9B;EACA,QAAQA,KAAK;IACX,KAAK,KAAK;MACR,OAAO,KAAK;IACd,KAAK,IAAI;MACP,OAAO,IAAI;IACb;MACE,OAAO,IAAI;EACf;AACF,CAAC;AAED,IAAMC,oBAAoB,GAAG,SAAvBA,oBAAoBA,CAAGC,eAAe;EAAA,OAC1CA,eAAe,CAACC,MAAM,CAAC,UAACC,GAAG,EAAEC,cAAc,EAAK;IAC9C,IAAI,OAAOA,cAAc,KAAK,QAAQ,EAAED,GAAG,CAACE,IAAI,CAAC;MAAEC,KAAK,MAAAC,gBAAA,iBAAKH,cAAc,EAAG,IAAI;IAAG,CAAC,CAAC,CAAC,KACnF;MACH,IAAMI,WAAW,GAAGV,cAAc,CAACM,cAAc,CAAC,CAAC,CAAC,CAAC;MACrDD,GAAG,CAACE,IAAI,CAAC;QAAEC,KAAK,MAAAC,gBAAA,iBAAKH,cAAc,CAAC,CAAC,CAAC,EAAGI,WAAW;MAAG,CAAC,CAAC;IAC3D;IACA,OAAOL,GAAG;EACZ,CAAC,EAAE,EAAE,CAAC;AAAA;AAAC,IAAAM,QAAA,GAEMT,oBAAoB;AAAAU,OAAA,cAAAD,QAAA"}
|
|
@@ -13,29 +13,21 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
13
13
|
});
|
|
14
14
|
exports["default"] = void 0;
|
|
15
15
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
16
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
17
16
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
18
|
-
require("
|
|
19
|
-
require("core-js/modules/es.object.to-string.js");
|
|
17
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
20
18
|
require("core-js/modules/es.object.keys.js");
|
|
21
19
|
require("core-js/modules/es.array.map.js");
|
|
22
20
|
require("core-js/modules/es.array.includes.js");
|
|
23
21
|
require("core-js/modules/es.string.includes.js");
|
|
24
22
|
require("core-js/modules/es.array.filter.js");
|
|
23
|
+
require("core-js/modules/es.object.to-string.js");
|
|
25
24
|
require("core-js/modules/es.array.concat.js");
|
|
26
25
|
require("core-js/modules/es.array.is-array.js");
|
|
27
26
|
var _getItemsToDisplayIds = _interopRequireDefault(require("./get-items-to-display-ids"));
|
|
28
27
|
var _constants = require("../constants");
|
|
28
|
+
var _buildCheckboxFilters = _interopRequireDefault(require("./build-checkbox-filters"));
|
|
29
29
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
30
30
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
31
|
-
var buildCheckboxFilters = function buildCheckboxFilters(checkboxFilters) {
|
|
32
|
-
return checkboxFilters.reduce(function (acc, checkboxFilter) {
|
|
33
|
-
acc.push({
|
|
34
|
-
match: (0, _defineProperty2["default"])({}, checkboxFilter, true)
|
|
35
|
-
});
|
|
36
|
-
return acc;
|
|
37
|
-
}, []);
|
|
38
|
-
};
|
|
39
31
|
var buildFilterValues = function buildFilterValues(listFilterValues, relations, stringProps) {
|
|
40
32
|
var listFilterValuesKeys = Object.keys(listFilterValues);
|
|
41
33
|
return listFilterValuesKeys.map(function (key) {
|
|
@@ -112,7 +104,7 @@ var buildRawQueryBase = function buildRawQueryBase(_ref3) {
|
|
|
112
104
|
_ref3$addListFiltersT = _ref3.addListFiltersToQuery,
|
|
113
105
|
addListFiltersToQuery = _ref3$addListFiltersT === void 0 ? false : _ref3$addListFiltersT;
|
|
114
106
|
var listFilterFinalValues = buildFilterValues(listFilterValues, relations, stringProps);
|
|
115
|
-
var checkboxFiltersValue =
|
|
107
|
+
var checkboxFiltersValue = (0, _buildCheckboxFilters["default"])(checkboxFilters);
|
|
116
108
|
var itemsToDisplayValues = buildItemsToDisplayValues(itemsToDisplay);
|
|
117
109
|
var isOperatorOr = filterOperator === _constants.OR;
|
|
118
110
|
var queryFilters = [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-raw-query-base.js","names":["_getItemsToDisplayIds","_interopRequireDefault","require","_constants","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty2","getOwnPropertyDescriptors","defineProperties","defineProperty","
|
|
1
|
+
{"version":3,"file":"build-raw-query-base.js","names":["_getItemsToDisplayIds","_interopRequireDefault","require","_constants","_buildCheckboxFilters","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty2","getOwnPropertyDescriptors","defineProperties","defineProperty","buildFilterValues","listFilterValues","relations","stringProps","listFilterValuesKeys","map","key","values","el","updatedKey","isRelation","includes","_key$split","split","_key$split2","_slicedToArray2","relationName","relationProp","_relations$filter","_ref","localField","_relations$filter2","relation","_ref2","_ref2$entityIdentifie","entityIdentifier","concat","fieldName","KEYWORD","match","bool","should","buildItemsToDisplayValues","itemsToDisplay","itemToDisplayIds","getItemsToDisplayIds","ids","buildShouldValues","docTypes","Array","isArray","docType","buildRawQueryBase","_ref3","_ref4","id","_ref3$filterValues","filterValues","_ref3$filterValues2","_ref3$filterValues2$c","checkboxFilters","_ref3$filterValues2$l","filterOperator","_ref3$addListFiltersT","addListFiltersToQuery","listFilterFinalValues","checkboxFiltersValue","buildCheckboxFilters","itemsToDisplayValues","isOperatorOr","OR","queryFilters","baseBoolObject","minimum_should_match","must","_toConsumableArray2","OR_OPERATOR","_baseBoolObject$must","mustNot","undefined","queryFilter","must_not","_default","exports"],"sources":["../../src/helpers/build-raw-query-base.js"],"sourcesContent":["import getItemsToDisplayIds from './get-items-to-display-ids';\nimport { OR, OR_OPERATOR, KEYWORD } from '../constants';\nimport buildCheckboxFilters from './build-checkbox-filters';\n\nconst buildFilterValues = (listFilterValues, relations, stringProps) => {\n const listFilterValuesKeys = Object.keys(listFilterValues);\n\n return listFilterValuesKeys.map(key => {\n const values = listFilterValues[key].map(el => {\n let updatedKey = key;\n\n const isRelation = key.includes('.');\n\n if (isRelation) {\n const [relationName, relationProp] = key.split('.');\n const [relation] = relations.filter(({ localField }) => localField === relationName);\n const { entityIdentifier = '' } = relation || {};\n if (entityIdentifier && entityIdentifier !== relationName)\n updatedKey = `${entityIdentifier}.${relationProp}`;\n }\n const fieldName = stringProps.includes(updatedKey) ? `${key}.${KEYWORD}` : key;\n return { match: { [fieldName]: el } };\n });\n return { bool: { should: values } };\n });\n};\n\nconst buildItemsToDisplayValues = itemsToDisplay => {\n if (!itemsToDisplay || !itemsToDisplay.length) return [];\n const itemToDisplayIds = getItemsToDisplayIds(itemsToDisplay);\n return [{ ids: { values: itemToDisplayIds } }];\n};\n\nconst buildShouldValues = docTypes => {\n if (Array.isArray(docTypes)) {\n return docTypes.map(docType => ({\n match: {\n docType\n }\n }));\n }\n return [\n {\n match: {\n docType: docTypes\n }\n }\n ];\n};\n\nconst buildRawQueryBase = ({\n docType,\n id,\n filterValues: { checkboxFilters = [], listFilterValues = {} } = {},\n filterOperator,\n relations,\n stringProps,\n itemsToDisplay,\n addListFiltersToQuery = false\n}) => {\n const listFilterFinalValues = buildFilterValues(listFilterValues, relations, stringProps);\n const checkboxFiltersValue = buildCheckboxFilters(checkboxFilters);\n const itemsToDisplayValues = buildItemsToDisplayValues(itemsToDisplay);\n const isOperatorOr = filterOperator === OR;\n\n const queryFilters = [];\n const baseBoolObject = {\n should: buildShouldValues(docType),\n minimum_should_match: 1,\n must: [...itemsToDisplayValues, ...checkboxFiltersValue]\n };\n\n if (isOperatorOr) {\n if (addListFiltersToQuery) {\n queryFilters.push(...listFilterFinalValues);\n } else {\n baseBoolObject.must.push({ bool: { [OR_OPERATOR]: [...listFilterFinalValues] } });\n }\n } else {\n baseBoolObject.must.push(...listFilterFinalValues);\n }\n\n const mustNot = id ? [{ ids: { values: [id] } }] : undefined;\n\n const queryFilter = queryFilters.length\n ? { [OR_OPERATOR]: queryFilters, minimum_should_match: 1 }\n : {};\n return {\n ...queryFilter,\n filter: {\n bool: baseBoolObject\n },\n must_not: mustNot\n };\n};\n\nexport default buildRawQueryBase;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,qBAAA,GAAAC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OAAO,GAAGvB,EAAE,GAAG,CAAC;IAAET,GAAG,EAAE;MAAE7B,MAAM,EAAE,CAACsC,EAAE;IAAE;EAAE,CAAC,CAAC,GAAGwB,SAAS;EAE5D,IAAMC,WAAW,GAAGT,YAAY,CAACnE,MAAM,IAAAkD,KAAA,WAAAhD,gBAAA,aAAAgD,KAAA,EAChCsB,sBAAW,EAAGL,YAAY,OAAAjE,gBAAA,aAAAgD,KAAA,0BAAwB,CAAC,GAAAA,KAAA,IACtD,CAAC,CAAC;EACN,OAAApD,aAAA,CAAAA,aAAA,KACK8E,WAAW;IACdnF,MAAM,EAAE;MACN2C,IAAI,EAAEgC;IACR,CAAC;IACDS,QAAQ,EAAEH;EAAO;AAErB,CAAC;AAAC,IAAAI,QAAA,GAEa9B,iBAAiB;AAAA+B,OAAA,cAAAD,QAAA"}
|
|
@@ -14,9 +14,7 @@ require("core-js/modules/es.array.slice.js");
|
|
|
14
14
|
require("core-js/modules/es.array.join.js");
|
|
15
15
|
require("core-js/modules/es.array.concat.js");
|
|
16
16
|
var _constants = require("../constants");
|
|
17
|
-
var
|
|
18
|
-
checkboxFilters.push(name);
|
|
19
|
-
};
|
|
17
|
+
var _getCheckboxFilters = _interopRequireDefault(require("./get-checkbox-filters"));
|
|
20
18
|
var getFilterValues = function getFilterValues(filterBy) {
|
|
21
19
|
return filterBy.reduce(function (acc, filter) {
|
|
22
20
|
var _filter$split = filter.split('/'),
|
|
@@ -38,12 +36,8 @@ var buildSetFilters = function buildSetFilters(_ref) {
|
|
|
38
36
|
filterByFeatured = _ref.filterByFeatured,
|
|
39
37
|
filterBySponsored = _ref.filterBySponsored;
|
|
40
38
|
var checkboxFilters = [];
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
if (filterBySponsored) {
|
|
45
|
-
getCheckboxFilters(checkboxFilters, _constants.SPONSORED);
|
|
46
|
-
}
|
|
39
|
+
(0, _getCheckboxFilters["default"])(checkboxFilters, _constants.FEATURED, filterByFeatured);
|
|
40
|
+
(0, _getCheckboxFilters["default"])(checkboxFilters, _constants.SPONSORED, filterBySponsored);
|
|
47
41
|
var shouldApplyFilterValues = filterBy.length && filterByProperty.length;
|
|
48
42
|
if (!shouldApplyFilterValues) return {
|
|
49
43
|
checkboxFilters: checkboxFilters,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-set-filters.js","names":["_constants","require","
|
|
1
|
+
{"version":3,"file":"build-set-filters.js","names":["_constants","require","_getCheckboxFilters","_interopRequireDefault","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","checkboxFilters","getCheckboxFilters","FEATURED","SPONSORED","shouldApplyFilterValues","length","listFilterValues","_default","exports"],"sources":["../../src/helpers/build-set-filters.js"],"sourcesContent":["import { FEATURED, SPONSORED } from '../constants';\nimport getCheckboxFilters from './get-checkbox-filters';\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 getCheckboxFilters(checkboxFilters, FEATURED, filterByFeatured);\n getCheckboxFilters(checkboxFilters, SPONSORED, filterBySponsored);\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;AACA,IAAAC,mBAAA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AAC6B,MAAM,IAAIR,gBAAgB,CAACQ,MAAM;EAC1E,IAAI,CAACD,uBAAuB,EAAE,OAAO;IAAEJ,eAAe,EAAfA,eAAe;IAAEM,gBAAgB,EAAE,CAAC;EAAE,CAAC;EAE9E,IAAMA,gBAAgB,GAAG/B,eAAe,CAACC,QAAQ,CAAC;EAClD,OAAO;IAAEwB,eAAe,EAAfA,eAAe;IAAEM,gBAAgB,EAAhBA;EAAiB,CAAC;AAC9C,CAAC;AAAC,IAAAC,QAAA,GAEad,eAAe;AAAAe,OAAA,cAAAD,QAAA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
require("core-js/modules/es.object.define-property.js");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports["default"] = void 0;
|
|
8
|
+
var getCheckboxFilters = function getCheckboxFilters(checkboxFilters, name, value) {
|
|
9
|
+
if (typeof value === 'string') {
|
|
10
|
+
if (value !== 'off') checkboxFilters.push([name, value]);
|
|
11
|
+
} else if (value) checkboxFilters.push(name);
|
|
12
|
+
};
|
|
13
|
+
var _default = getCheckboxFilters;
|
|
14
|
+
exports["default"] = _default;
|
|
15
|
+
//# sourceMappingURL=get-checkbox-filters.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-checkbox-filters.js","names":["getCheckboxFilters","checkboxFilters","name","value","push","_default","exports"],"sources":["../../src/helpers/get-checkbox-filters.js"],"sourcesContent":["const getCheckboxFilters = (checkboxFilters, name, value) => {\n if (typeof value === 'string') {\n if (value !== 'off') checkboxFilters.push([name, value]);\n } else if (value) checkboxFilters.push(name);\n};\n\nexport default getCheckboxFilters;\n"],"mappings":";;;;;;;AAAA,IAAMA,kBAAkB,GAAG,SAArBA,kBAAkBA,CAAIC,eAAe,EAAEC,IAAI,EAAEC,KAAK,EAAK;EAC3D,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IAC7B,IAAIA,KAAK,KAAK,KAAK,EAAEF,eAAe,CAACG,IAAI,CAAC,CAACF,IAAI,EAAEC,KAAK,CAAC,CAAC;EAC1D,CAAC,MAAM,IAAIA,KAAK,EAAEF,eAAe,CAACG,IAAI,CAACF,IAAI,CAAC;AAC9C,CAAC;AAAC,IAAAG,QAAA,GAEaL,kBAAkB;AAAAM,OAAA,cAAAD,QAAA"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const getFilterValue = value => {
|
|
2
|
+
// To be updated with future filter options
|
|
3
|
+
switch (value) {
|
|
4
|
+
case 'not':
|
|
5
|
+
return false;
|
|
6
|
+
case 'on':
|
|
7
|
+
return true;
|
|
8
|
+
default:
|
|
9
|
+
return true;
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
const buildCheckboxFilters = checkboxFilters => checkboxFilters.reduce((acc, checkboxFilter) => {
|
|
13
|
+
if (typeof checkboxFilter === 'string') acc.push({
|
|
14
|
+
match: {
|
|
15
|
+
[checkboxFilter]: true
|
|
16
|
+
}
|
|
17
|
+
});else {
|
|
18
|
+
const filterValue = getFilterValue(checkboxFilter[1]);
|
|
19
|
+
acc.push({
|
|
20
|
+
match: {
|
|
21
|
+
[checkboxFilter[0]]: filterValue
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
return acc;
|
|
26
|
+
}, []);
|
|
27
|
+
export default buildCheckboxFilters;
|
|
28
|
+
//# sourceMappingURL=build-checkbox-filters.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-checkbox-filters.js","names":["getFilterValue","value","buildCheckboxFilters","checkboxFilters","reduce","acc","checkboxFilter","push","match","filterValue"],"sources":["../../src/helpers/build-checkbox-filters.js"],"sourcesContent":["const getFilterValue = value => {\n // To be updated with future filter options\n switch (value) {\n case 'not':\n return false;\n case 'on':\n return true;\n default:\n return true;\n }\n};\n\nconst buildCheckboxFilters = checkboxFilters =>\n checkboxFilters.reduce((acc, checkboxFilter) => {\n if (typeof checkboxFilter === 'string') acc.push({ match: { [checkboxFilter]: true } });\n else {\n const filterValue = getFilterValue(checkboxFilter[1]);\n acc.push({ match: { [checkboxFilter[0]]: filterValue } });\n }\n return acc;\n }, []);\n\nexport default buildCheckboxFilters;\n"],"mappings":"AAAA,MAAMA,cAAc,GAAGC,KAAK,IAAI;EAC9B;EACA,QAAQA,KAAK;IACX,KAAK,KAAK;MACR,OAAO,KAAK;IACd,KAAK,IAAI;MACP,OAAO,IAAI;IACb;MACE,OAAO,IAAI;EACf;AACF,CAAC;AAED,MAAMC,oBAAoB,GAAGC,eAAe,IAC1CA,eAAe,CAACC,MAAM,CAAC,CAACC,GAAG,EAAEC,cAAc,KAAK;EAC9C,IAAI,OAAOA,cAAc,KAAK,QAAQ,EAAED,GAAG,CAACE,IAAI,CAAC;IAAEC,KAAK,EAAE;MAAE,CAACF,cAAc,GAAG;IAAK;EAAE,CAAC,CAAC,CAAC,KACnF;IACH,MAAMG,WAAW,GAAGT,cAAc,CAACM,cAAc,CAAC,CAAC,CAAC,CAAC;IACrDD,GAAG,CAACE,IAAI,CAAC;MAAEC,KAAK,EAAE;QAAE,CAACF,cAAc,CAAC,CAAC,CAAC,GAAGG;MAAY;IAAE,CAAC,CAAC;EAC3D;EACA,OAAOJ,GAAG;AACZ,CAAC,EAAE,EAAE,CAAC;AAER,eAAeH,oBAAoB"}
|
|
@@ -3,14 +3,7 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
|
|
|
3
3
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
4
|
import getItemsToDisplayIds from './get-items-to-display-ids';
|
|
5
5
|
import { OR, OR_OPERATOR, KEYWORD } from '../constants';
|
|
6
|
-
|
|
7
|
-
acc.push({
|
|
8
|
-
match: {
|
|
9
|
-
[checkboxFilter]: true
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
return acc;
|
|
13
|
-
}, []);
|
|
6
|
+
import buildCheckboxFilters from './build-checkbox-filters';
|
|
14
7
|
const buildFilterValues = (listFilterValues, relations, stringProps) => {
|
|
15
8
|
const listFilterValuesKeys = Object.keys(listFilterValues);
|
|
16
9
|
return listFilterValuesKeys.map(key => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-raw-query-base.js","names":["getItemsToDisplayIds","OR","OR_OPERATOR","KEYWORD","buildCheckboxFilters","
|
|
1
|
+
{"version":3,"file":"build-raw-query-base.js","names":["getItemsToDisplayIds","OR","OR_OPERATOR","KEYWORD","buildCheckboxFilters","buildFilterValues","listFilterValues","relations","stringProps","listFilterValuesKeys","Object","keys","map","key","values","el","updatedKey","isRelation","includes","relationName","relationProp","split","relation","filter","localField","entityIdentifier","fieldName","match","bool","should","buildItemsToDisplayValues","itemsToDisplay","length","itemToDisplayIds","ids","buildShouldValues","docTypes","Array","isArray","docType","buildRawQueryBase","id","filterValues","checkboxFilters","filterOperator","addListFiltersToQuery","listFilterFinalValues","checkboxFiltersValue","itemsToDisplayValues","isOperatorOr","queryFilters","baseBoolObject","minimum_should_match","must","push","mustNot","undefined","queryFilter","_objectSpread","must_not"],"sources":["../../src/helpers/build-raw-query-base.js"],"sourcesContent":["import getItemsToDisplayIds from './get-items-to-display-ids';\nimport { OR, OR_OPERATOR, KEYWORD } from '../constants';\nimport buildCheckboxFilters from './build-checkbox-filters';\n\nconst buildFilterValues = (listFilterValues, relations, stringProps) => {\n const listFilterValuesKeys = Object.keys(listFilterValues);\n\n return listFilterValuesKeys.map(key => {\n const values = listFilterValues[key].map(el => {\n let updatedKey = key;\n\n const isRelation = key.includes('.');\n\n if (isRelation) {\n const [relationName, relationProp] = key.split('.');\n const [relation] = relations.filter(({ localField }) => localField === relationName);\n const { entityIdentifier = '' } = relation || {};\n if (entityIdentifier && entityIdentifier !== relationName)\n updatedKey = `${entityIdentifier}.${relationProp}`;\n }\n const fieldName = stringProps.includes(updatedKey) ? `${key}.${KEYWORD}` : key;\n return { match: { [fieldName]: el } };\n });\n return { bool: { should: values } };\n });\n};\n\nconst buildItemsToDisplayValues = itemsToDisplay => {\n if (!itemsToDisplay || !itemsToDisplay.length) return [];\n const itemToDisplayIds = getItemsToDisplayIds(itemsToDisplay);\n return [{ ids: { values: itemToDisplayIds } }];\n};\n\nconst buildShouldValues = docTypes => {\n if (Array.isArray(docTypes)) {\n return docTypes.map(docType => ({\n match: {\n docType\n }\n }));\n }\n return [\n {\n match: {\n docType: docTypes\n }\n }\n ];\n};\n\nconst buildRawQueryBase = ({\n docType,\n id,\n filterValues: { checkboxFilters = [], listFilterValues = {} } = {},\n filterOperator,\n relations,\n stringProps,\n itemsToDisplay,\n addListFiltersToQuery = false\n}) => {\n const listFilterFinalValues = buildFilterValues(listFilterValues, relations, stringProps);\n const checkboxFiltersValue = buildCheckboxFilters(checkboxFilters);\n const itemsToDisplayValues = buildItemsToDisplayValues(itemsToDisplay);\n const isOperatorOr = filterOperator === OR;\n\n const queryFilters = [];\n const baseBoolObject = {\n should: buildShouldValues(docType),\n minimum_should_match: 1,\n must: [...itemsToDisplayValues, ...checkboxFiltersValue]\n };\n\n if (isOperatorOr) {\n if (addListFiltersToQuery) {\n queryFilters.push(...listFilterFinalValues);\n } else {\n baseBoolObject.must.push({ bool: { [OR_OPERATOR]: [...listFilterFinalValues] } });\n }\n } else {\n baseBoolObject.must.push(...listFilterFinalValues);\n }\n\n const mustNot = id ? [{ ids: { values: [id] } }] : undefined;\n\n const queryFilter = queryFilters.length\n ? { [OR_OPERATOR]: queryFilters, minimum_should_match: 1 }\n : {};\n return {\n ...queryFilter,\n filter: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,iBAAiB,CAACI,OAAO,CAAC;IAClCa,oBAAoB,EAAE,CAAC;IACvBC,IAAI,EAAE,CAAC,GAAGL,oBAAoB,EAAE,GAAGD,oBAAoB;EACzD,CAAC;EAED,IAAIE,YAAY,EAAE;IAChB,IAAIJ,qBAAqB,EAAE;MACzBK,YAAY,CAACI,IAAI,CAAC,GAAGR,qBAAqB,CAAC;IAC7C,CAAC,MAAM;MACLK,cAAc,CAACE,IAAI,CAACC,IAAI,CAAC;QAAE1B,IAAI,EAAE;UAAE,CAAC1B,WAAW,GAAG,CAAC,GAAG4C,qBAAqB;QAAE;MAAE,CAAC,CAAC;IACnF;EACF,CAAC,MAAM;IACLK,cAAc,CAACE,IAAI,CAACC,IAAI,CAAC,GAAGR,qBAAqB,CAAC;EACpD;EAEA,MAAMS,OAAO,GAAGd,EAAE,GAAG,CAAC;IAAEP,GAAG,EAAE;MAAEpB,MAAM,EAAE,CAAC2B,EAAE;IAAE;EAAE,CAAC,CAAC,GAAGe,SAAS;EAE5D,MAAMC,WAAW,GAAGP,YAAY,CAAClB,MAAM,GACnC;IAAE,CAAC9B,WAAW,GAAGgD,YAAY;IAAEE,oBAAoB,EAAE;EAAE,CAAC,GACxD,CAAC,CAAC;EACN,OAAAM,aAAA,CAAAA,aAAA,KACKD,WAAW;IACdlC,MAAM,EAAE;MACNK,IAAI,EAAEuB;IACR,CAAC;IACDQ,QAAQ,EAAEJ;EAAO;AAErB,CAAC;AAED,eAAef,iBAAiB"}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { FEATURED, SPONSORED } from '../constants';
|
|
2
|
-
|
|
3
|
-
checkboxFilters.push(name);
|
|
4
|
-
};
|
|
2
|
+
import getCheckboxFilters from './get-checkbox-filters';
|
|
5
3
|
const getFilterValues = filterBy => filterBy.reduce((acc, filter) => {
|
|
6
4
|
const [fieldName, ...values] = filter.split('/');
|
|
7
5
|
const value = values.join('/');
|
|
@@ -17,12 +15,8 @@ const buildSetFilters = ({
|
|
|
17
15
|
filterBySponsored
|
|
18
16
|
}) => {
|
|
19
17
|
const checkboxFilters = [];
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
if (filterBySponsored) {
|
|
24
|
-
getCheckboxFilters(checkboxFilters, SPONSORED);
|
|
25
|
-
}
|
|
18
|
+
getCheckboxFilters(checkboxFilters, FEATURED, filterByFeatured);
|
|
19
|
+
getCheckboxFilters(checkboxFilters, SPONSORED, filterBySponsored);
|
|
26
20
|
const shouldApplyFilterValues = filterBy.length && filterByProperty.length;
|
|
27
21
|
if (!shouldApplyFilterValues) return {
|
|
28
22
|
checkboxFilters,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-set-filters.js","names":["FEATURED","SPONSORED","getCheckboxFilters","
|
|
1
|
+
{"version":3,"file":"build-set-filters.js","names":["FEATURED","SPONSORED","getCheckboxFilters","getFilterValues","filterBy","reduce","acc","filter","fieldName","values","split","value","join","previousValue","finalValue","buildSetFilters","filterByProperty","filterByFeatured","filterBySponsored","checkboxFilters","shouldApplyFilterValues","length","listFilterValues"],"sources":["../../src/helpers/build-set-filters.js"],"sourcesContent":["import { FEATURED, SPONSORED } from '../constants';\nimport getCheckboxFilters from './get-checkbox-filters';\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 getCheckboxFilters(checkboxFilters, FEATURED, filterByFeatured);\n getCheckboxFilters(checkboxFilters, SPONSORED, filterBySponsored);\n\n const shouldApplyFilterValues = filterBy.length && filterByProperty.length;\n if (!shouldApplyFilterValues) return { checkboxFilters, listFilterValues: {} };\n\n const listFilterValues = getFilterValues(filterBy);\n return { check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AAe"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
const getCheckboxFilters = (checkboxFilters, name, value) => {
|
|
2
|
+
if (typeof value === 'string') {
|
|
3
|
+
if (value !== 'off') checkboxFilters.push([name, value]);
|
|
4
|
+
} else if (value) checkboxFilters.push(name);
|
|
5
|
+
};
|
|
6
|
+
export default getCheckboxFilters;
|
|
7
|
+
//# sourceMappingURL=get-checkbox-filters.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-checkbox-filters.js","names":["getCheckboxFilters","checkboxFilters","name","value","push"],"sources":["../../src/helpers/get-checkbox-filters.js"],"sourcesContent":["const getCheckboxFilters = (checkboxFilters, name, value) => {\n if (typeof value === 'string') {\n if (value !== 'off') checkboxFilters.push([name, value]);\n } else if (value) checkboxFilters.push(name);\n};\n\nexport default getCheckboxFilters;\n"],"mappings":"AAAA,MAAMA,kBAAkB,GAAGA,CAACC,eAAe,EAAEC,IAAI,EAAEC,KAAK,KAAK;EAC3D,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IAC7B,IAAIA,KAAK,KAAK,KAAK,EAAEF,eAAe,CAACG,IAAI,CAAC,CAACF,IAAI,EAAEC,KAAK,CAAC,CAAC;EAC1D,CAAC,MAAM,IAAIA,KAAK,EAAEF,eAAe,CAACG,IAAI,CAACF,IAAI,CAAC;AAC9C,CAAC;AAED,eAAeF,kBAAkB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blaze-cms/react-page-builder",
|
|
3
|
-
"version": "0.139.0-alpha.
|
|
3
|
+
"version": "0.139.0-alpha.1",
|
|
4
4
|
"description": "Blaze react page builder",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "lib-es/index.js",
|
|
@@ -89,5 +89,5 @@
|
|
|
89
89
|
"lib/*",
|
|
90
90
|
"lib-es/*"
|
|
91
91
|
],
|
|
92
|
-
"gitHead": "
|
|
92
|
+
"gitHead": "1cee8a2d2777b141287f3f59844156f56fa97f80"
|
|
93
93
|
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const getFilterValue = value => {
|
|
2
|
+
// To be updated with future filter options
|
|
3
|
+
switch (value) {
|
|
4
|
+
case 'not':
|
|
5
|
+
return false;
|
|
6
|
+
case 'on':
|
|
7
|
+
return true;
|
|
8
|
+
default:
|
|
9
|
+
return true;
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const buildCheckboxFilters = checkboxFilters =>
|
|
14
|
+
checkboxFilters.reduce((acc, checkboxFilter) => {
|
|
15
|
+
if (typeof checkboxFilter === 'string') acc.push({ match: { [checkboxFilter]: true } });
|
|
16
|
+
else {
|
|
17
|
+
const filterValue = getFilterValue(checkboxFilter[1]);
|
|
18
|
+
acc.push({ match: { [checkboxFilter[0]]: filterValue } });
|
|
19
|
+
}
|
|
20
|
+
return acc;
|
|
21
|
+
}, []);
|
|
22
|
+
|
|
23
|
+
export default buildCheckboxFilters;
|
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
import getItemsToDisplayIds from './get-items-to-display-ids';
|
|
2
2
|
import { OR, OR_OPERATOR, KEYWORD } from '../constants';
|
|
3
|
-
|
|
4
|
-
const buildCheckboxFilters = checkboxFilters =>
|
|
5
|
-
checkboxFilters.reduce((acc, checkboxFilter) => {
|
|
6
|
-
acc.push({ match: { [checkboxFilter]: true } });
|
|
7
|
-
return acc;
|
|
8
|
-
}, []);
|
|
3
|
+
import buildCheckboxFilters from './build-checkbox-filters';
|
|
9
4
|
|
|
10
5
|
const buildFilterValues = (listFilterValues, relations, stringProps) => {
|
|
11
6
|
const listFilterValuesKeys = Object.keys(listFilterValues);
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import { FEATURED, SPONSORED } from '../constants';
|
|
2
|
-
|
|
3
|
-
const getCheckboxFilters = (checkboxFilters, name) => {
|
|
4
|
-
checkboxFilters.push(name);
|
|
5
|
-
};
|
|
2
|
+
import getCheckboxFilters from './get-checkbox-filters';
|
|
6
3
|
|
|
7
4
|
const getFilterValues = filterBy =>
|
|
8
5
|
filterBy.reduce((acc, filter) => {
|
|
@@ -22,13 +19,8 @@ const buildSetFilters = ({
|
|
|
22
19
|
filterBySponsored
|
|
23
20
|
}) => {
|
|
24
21
|
const checkboxFilters = [];
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
getCheckboxFilters(checkboxFilters, FEATURED);
|
|
28
|
-
}
|
|
29
|
-
if (filterBySponsored) {
|
|
30
|
-
getCheckboxFilters(checkboxFilters, SPONSORED);
|
|
31
|
-
}
|
|
22
|
+
getCheckboxFilters(checkboxFilters, FEATURED, filterByFeatured);
|
|
23
|
+
getCheckboxFilters(checkboxFilters, SPONSORED, filterBySponsored);
|
|
32
24
|
|
|
33
25
|
const shouldApplyFilterValues = filterBy.length && filterByProperty.length;
|
|
34
26
|
if (!shouldApplyFilterValues) return { checkboxFilters, listFilterValues: {} };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import buildCheckboxFilters from '../../../../src/helpers/build-checkbox-filters';
|
|
2
|
+
|
|
3
|
+
describe('buildCheckboxFilters helper', () => {
|
|
4
|
+
it('should build filter if value is a string', () => {
|
|
5
|
+
const checkboxFilters = ['filterName'];
|
|
6
|
+
const result = buildCheckboxFilters(checkboxFilters);
|
|
7
|
+
expect(result).toEqual([{ match: { filterName: true } }]);
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
it('should handle new array filters', () => {
|
|
11
|
+
const checkboxFilters = [['filterName', 'not'], ['secondFilter', 'on']];
|
|
12
|
+
const result = buildCheckboxFilters(checkboxFilters);
|
|
13
|
+
expect(result).toEqual([{ match: { filterName: false } }, { match: { secondFilter: true } }]);
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it('builds checkbox filters with a mix of string and array elements', () => {
|
|
17
|
+
const checkboxFilters = ['filterName', ['filterType', 'not']];
|
|
18
|
+
const result = buildCheckboxFilters(checkboxFilters);
|
|
19
|
+
expect(result).toEqual([{ match: { filterName: true } }, { match: { filterType: false } }]);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it('handles empty array input', () => {
|
|
23
|
+
const checkboxFilters = [];
|
|
24
|
+
const result = buildCheckboxFilters(checkboxFilters);
|
|
25
|
+
expect(result).toEqual([]);
|
|
26
|
+
});
|
|
27
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import getCheckboxFilters from '../../../../src/helpers/get-checkbox-filters';
|
|
2
|
+
|
|
3
|
+
describe('getCheckboxFilters helper', () => {
|
|
4
|
+
it('adds [name, value] to checkboxFilters when value is a non-"off" string', () => {
|
|
5
|
+
const checkboxFilters = [];
|
|
6
|
+
getCheckboxFilters(checkboxFilters, 'filterName', 'on');
|
|
7
|
+
expect(checkboxFilters).toEqual([['filterName', 'on']]);
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
it('does not add to checkboxFilters when value is "off"', () => {
|
|
11
|
+
const checkboxFilters = [];
|
|
12
|
+
getCheckboxFilters(checkboxFilters, 'filterName', 'off');
|
|
13
|
+
expect(checkboxFilters).toEqual([]);
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it('does not add to checkboxFilters when value is falsy', () => {
|
|
17
|
+
const checkboxFilters = [];
|
|
18
|
+
getCheckboxFilters(checkboxFilters, 'filterName', null);
|
|
19
|
+
expect(checkboxFilters).toEqual([]);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it('adds name to checkboxFilters when value is truthy and not a string', () => {
|
|
23
|
+
const checkboxFilters = [];
|
|
24
|
+
getCheckboxFilters(checkboxFilters, 'filterName', true);
|
|
25
|
+
expect(checkboxFilters).toEqual(['filterName']);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it('adds name to checkboxFilters when value is truthy and not a string', () => {
|
|
29
|
+
const checkboxFilters = [];
|
|
30
|
+
getCheckboxFilters(checkboxFilters, 'filterName', true);
|
|
31
|
+
expect(checkboxFilters).toEqual(['filterName']);
|
|
32
|
+
});
|
|
33
|
+
});
|