@blaze-cms/react-page-builder 0.132.0 → 0.133.0-admin-updates.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 +13 -0
- package/lib/components/Banner/BannerRender.js +2 -2
- package/lib/components/Banner/BannerRender.js.map +1 -1
- package/lib/components/Banner/helpers.js +2 -2
- package/lib/components/Banner/helpers.js.map +1 -1
- package/lib/components/BlazeLink.js +2 -2
- package/lib/components/BlazeLink.js.map +1 -1
- package/lib/components/Button.js +2 -2
- package/lib/components/Button.js.map +1 -1
- package/lib/components/Card/CardsContainer.js +2 -2
- package/lib/components/Card/CardsContainer.js.map +1 -1
- package/lib/components/Card/CardsRender.js +2 -2
- package/lib/components/Card/CardsRender.js.map +1 -1
- package/lib/components/Card/helpers/filter-query-setup.js +11 -5
- package/lib/components/Card/helpers/filter-query-setup.js.map +1 -1
- package/lib/components/ClickWrapper.js +2 -2
- package/lib/components/ClickWrapper.js.map +1 -1
- package/lib/components/Code/Code.js +2 -2
- package/lib/components/Code/Code.js.map +1 -1
- package/lib/components/DataSummary/helpers/build-loop-props-content.js +3 -2
- package/lib/components/DataSummary/helpers/build-loop-props-content.js.map +1 -1
- package/lib/components/DataSummary/helpers/get-link-to-published-content.js +2 -0
- package/lib/components/DataSummary/helpers/get-link-to-published-content.js.map +1 -1
- package/lib/components/Image/Image.js +2 -2
- package/lib/components/Image/Image.js.map +1 -1
- package/lib/components/Layout/Layout.js +2 -2
- package/lib/components/Layout/Layout.js.map +1 -1
- package/lib/components/List/ListBuilder.js +46 -26
- package/lib/components/List/ListBuilder.js.map +1 -1
- package/lib/components/List/ListFactory.js +5 -5
- package/lib/components/List/ListFactory.js.map +1 -1
- package/lib/components/List/components/Cards/CardsRender.js +2 -2
- package/lib/components/List/components/Cards/CardsRender.js.map +1 -1
- package/lib/components/List/components/Full/FullRender.js +2 -2
- package/lib/components/List/components/Full/FullRender.js.map +1 -1
- package/lib/components/List/components/Full/FullRenderItem.js +2 -2
- package/lib/components/List/components/Full/FullRenderItem.js.map +1 -1
- package/lib/components/List/components/Pagination/ListPagination.js +2 -2
- package/lib/components/List/components/Pagination/ListPagination.js.map +1 -1
- package/lib/components/List/helpers/build-az-url.js +2 -2
- package/lib/components/List/helpers/build-az-url.js.map +1 -1
- package/lib/components/List/helpers/build-pagination-url.js +2 -2
- package/lib/components/List/helpers/build-pagination-url.js.map +1 -1
- package/lib/components/List/helpers/get-list-query.js +6 -2
- package/lib/components/List/helpers/get-list-query.js.map +1 -1
- package/lib/components/List/helpers/get-sort-props.js +5 -1
- package/lib/components/List/helpers/get-sort-props.js.map +1 -1
- package/lib/components/SearchFilter/components/Range.js +2 -2
- package/lib/components/SearchFilter/components/Range.js.map +1 -1
- package/lib/components/SearchFilter/searchFilterReducer.js +2 -2
- package/lib/components/SearchFilterSort/helpers/update-sort.js +2 -2
- package/lib/components/SearchFilterSort/helpers/update-sort.js.map +1 -1
- package/lib/components/TextBlock/index.js +2 -2
- package/lib/components/TextBlock/index.js.map +1 -1
- package/lib/components/Video/Video.js +2 -2
- package/lib/components/Video/Video.js.map +1 -1
- package/lib/components/Video/providers/JWPlayer/JWPlayerProvider.js +2 -2
- package/lib/components/Video/providers/JWPlayer/JWPlayerProvider.js.map +1 -1
- package/lib/constants/index.js +4 -34
- package/lib/constants/index.js.map +1 -1
- package/lib/helpers/append-images.js +2 -2
- package/lib/helpers/build-az-filter.js +8 -7
- package/lib/helpers/build-az-filter.js.map +1 -1
- package/lib/helpers/build-raw-query-base.js +2 -2
- package/lib/helpers/build-raw-query-base.js.map +1 -1
- package/lib/helpers/build-raw-query.js +29 -8
- package/lib/helpers/build-raw-query.js.map +1 -1
- package/lib/helpers/build-sort-values.js +49 -0
- package/lib/helpers/build-sort-values.js.map +1 -0
- package/lib/helpers/get-banner-data.js +2 -2
- package/lib/helpers/get-click-wrapper-options.js +2 -2
- package/lib/helpers/get-click-wrapper-options.js.map +1 -1
- package/lib/helpers/get-entities-with-banner.js +2 -2
- package/lib/helpers/get-entities-with-banner.js.map +1 -1
- package/lib/helpers/get-extra-az-bits.js +46 -3
- package/lib/helpers/get-extra-az-bits.js.map +1 -1
- package/lib/helpers/get-generic-props.js +2 -2
- package/lib/helpers/get-generic-props.js.map +1 -1
- package/lib/helpers/get-generic-render-variables.js +30 -37
- package/lib/helpers/get-generic-render-variables.js.map +1 -1
- package/lib/helpers/inject-multiple-banners/get-banners-for-nodes/get-banners-for-nodes.js +2 -2
- package/lib/helpers/inject-multiple-banners/get-banners-for-nodes/get-banners-for-nodes.js.map +1 -1
- package/lib/helpers/process-data-summary-value.js +2 -2
- package/lib/helpers/process-data-summary-value.js.map +1 -1
- package/lib/helpers/remove-unwanted-characters.js +2 -2
- package/lib/helpers/render-children.js +2 -2
- package/lib/helpers/render-children.js.map +1 -1
- package/lib/helpers/split-children.js +2 -2
- package/lib/helpers/update-childrens-parent.js +2 -2
- package/lib/hooks/helpers/append-gtm-classname.js +2 -2
- package/lib/hooks/helpers/append-gtm-classname.js.map +1 -1
- package/lib/hooks/helpers/buildPBComponents.js +2 -2
- package/lib/hooks/helpers/buildPBComponents.js.map +1 -1
- package/lib/hooks/helpers/get-lightbox-images.js +2 -2
- package/lib/hooks/helpers/get-lightbox-images.js.map +1 -1
- package/lib/hooks/helpers/inject-element-banners.js +2 -2
- package/lib/hooks/helpers/inject-element-banners.js.map +1 -1
- package/lib/hooks/helpers/inject-textblock-banners.js +2 -2
- package/lib/hooks/helpers/inject-textblock-banners.js.map +1 -1
- package/lib/utils/get-class-modifiers.js +2 -2
- package/lib/utils/get-class-modifiers.js.map +1 -1
- package/lib-es/components/Banner/BannerRender.js +2 -2
- package/lib-es/components/Banner/helpers.js +2 -2
- package/lib-es/components/BlazeLink.js +2 -2
- package/lib-es/components/Button.js +2 -2
- package/lib-es/components/Card/CardsContainer.js +2 -2
- package/lib-es/components/Card/CardsRender.js +2 -2
- package/lib-es/components/Card/helpers/filter-query-setup.js +11 -5
- package/lib-es/components/Card/helpers/filter-query-setup.js.map +1 -1
- package/lib-es/components/ClickWrapper.js +2 -2
- package/lib-es/components/Code/Code.js +2 -2
- package/lib-es/components/DataSummary/helpers/build-loop-props-content.js +3 -2
- 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 +2 -1
- package/lib-es/components/DataSummary/helpers/get-link-to-published-content.js.map +1 -1
- package/lib-es/components/Image/Image.js +2 -2
- package/lib-es/components/Layout/Layout.js +2 -2
- package/lib-es/components/List/ListBuilder.js +46 -26
- package/lib-es/components/List/ListBuilder.js.map +1 -1
- package/lib-es/components/List/ListFactory.js +5 -5
- package/lib-es/components/List/ListFactory.js.map +1 -1
- package/lib-es/components/List/components/Cards/CardsRender.js +2 -2
- package/lib-es/components/List/components/Full/FullRender.js +2 -2
- package/lib-es/components/List/components/Full/FullRenderItem.js +2 -2
- package/lib-es/components/List/components/Pagination/ListPagination.js +2 -2
- package/lib-es/components/List/helpers/build-az-url.js +2 -2
- package/lib-es/components/List/helpers/build-pagination-url.js +2 -2
- package/lib-es/components/List/helpers/get-list-query.js +5 -2
- package/lib-es/components/List/helpers/get-list-query.js.map +1 -1
- package/lib-es/components/List/helpers/get-sort-props.js +5 -1
- package/lib-es/components/List/helpers/get-sort-props.js.map +1 -1
- package/lib-es/components/SearchFilter/components/Range.js +2 -2
- package/lib-es/components/SearchFilter/searchFilterReducer.js +2 -2
- package/lib-es/components/SearchFilterSort/helpers/update-sort.js +2 -2
- package/lib-es/components/TextBlock/index.js +2 -2
- package/lib-es/components/Video/Video.js +2 -2
- package/lib-es/components/Video/providers/JWPlayer/JWPlayerProvider.js +2 -2
- package/lib-es/constants/index.js +2 -31
- package/lib-es/constants/index.js.map +1 -1
- package/lib-es/helpers/append-images.js +2 -2
- package/lib-es/helpers/build-az-filter.js +3 -2
- package/lib-es/helpers/build-az-filter.js.map +1 -1
- package/lib-es/helpers/build-raw-query-base.js +2 -2
- package/lib-es/helpers/build-raw-query.js +26 -8
- package/lib-es/helpers/build-raw-query.js.map +1 -1
- package/lib-es/helpers/build-sort-values.js +34 -0
- package/lib-es/helpers/build-sort-values.js.map +1 -0
- package/lib-es/helpers/get-banner-data.js +2 -2
- package/lib-es/helpers/get-click-wrapper-options.js +2 -2
- package/lib-es/helpers/get-entities-with-banner.js +2 -2
- package/lib-es/helpers/get-extra-az-bits.js +48 -2
- package/lib-es/helpers/get-extra-az-bits.js.map +1 -1
- package/lib-es/helpers/get-generic-props.js +2 -2
- package/lib-es/helpers/get-generic-render-variables.js +24 -28
- package/lib-es/helpers/get-generic-render-variables.js.map +1 -1
- package/lib-es/helpers/inject-multiple-banners/get-banners-for-nodes/get-banners-for-nodes.js +2 -2
- package/lib-es/helpers/process-data-summary-value.js +2 -2
- package/lib-es/helpers/remove-unwanted-characters.js +2 -2
- package/lib-es/helpers/render-children.js +2 -2
- package/lib-es/helpers/split-children.js +2 -2
- package/lib-es/helpers/update-childrens-parent.js +2 -2
- package/lib-es/hooks/helpers/append-gtm-classname.js +2 -2
- package/lib-es/hooks/helpers/buildPBComponents.js +2 -2
- package/lib-es/hooks/helpers/get-lightbox-images.js +2 -2
- package/lib-es/hooks/helpers/inject-element-banners.js +2 -2
- package/lib-es/hooks/helpers/inject-textblock-banners.js +2 -2
- package/lib-es/utils/get-class-modifiers.js +2 -2
- package/package.json +10 -10
- package/src/components/Card/helpers/filter-query-setup.js +4 -5
- package/src/components/DataSummary/helpers/build-loop-props-content.js +3 -2
- package/src/components/DataSummary/helpers/get-link-to-published-content.js +4 -1
- package/src/components/List/ListBuilder.js +46 -55
- package/src/components/List/ListFactory.js +9 -7
- package/src/components/List/helpers/get-list-query.js +5 -2
- package/src/components/List/helpers/get-sort-props.js +9 -1
- package/src/constants/index.js +2 -32
- package/src/helpers/build-az-filter.js +3 -2
- package/src/helpers/build-raw-query.js +9 -7
- package/src/helpers/build-sort-values.js +32 -0
- package/src/helpers/get-extra-az-bits.js +40 -2
- package/src/helpers/get-generic-render-variables.js +20 -27
- package/tests/unit/src/components/DataSummary/helpers/build-loop-props-content.test.js +41 -0
- package/tests/unit/src/components/DataSummary/helpers/get-link-to-published-content.test.js +21 -0
- package/tests/unit/src/components/List/helpers/get-list-query.test.js +55 -0
- package/tests/unit/src/components/List/helpers/get-sort-props.test.js +18 -0
- package/tests/unit/src/components/PlaceholderIcon/__snapshots__/index.test.js.snap +72 -0
- package/tests/unit/src/components/PlaceholderIcon/index.test.js +20 -0
- package/tests/unit/src/constants/__snapshots__/index.test.js.snap +3 -0
- package/tests/unit/src/constants/index.test.js +7 -0
- package/tests/unit/src/helpers/__snapshots__/get-extra-az-bits.test.js.snap +137 -0
- package/tests/unit/src/helpers/build-az-query.test.js +4 -3
- package/tests/unit/src/helpers/build-raw-query.test.js +82 -58
- package/tests/unit/src/helpers/build-sort-values.test.js +34 -0
- package/tests/unit/src/helpers/get-extra-az-bits.test.js +36 -6
- package/tests/unit/src/helpers/get-generic-render-variables.test.js +50 -53
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
function ownKeys(
|
|
3
|
-
function _objectSpread(
|
|
2
|
+
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; }
|
|
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 { BUTTON, BUTTON_ICON, CLASS_MODIFIERS, ICON_BUTTON, LINK, CODE } from '../constants';
|
|
5
5
|
import COMPONENTS_DEFAULT_VALUES from '../constants/componentsDefaultValues';
|
|
6
6
|
const {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blaze-cms/react-page-builder",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.133.0-admin-updates.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": "
|
|
31
|
-
"@blaze-cms/core-errors": "
|
|
32
|
-
"@blaze-cms/core-errors-ui": "
|
|
30
|
+
"@blaze-cms/core-auth-ui": "0.133.0-admin-updates.0",
|
|
31
|
+
"@blaze-cms/core-errors": "0.133.0-admin-updates.0",
|
|
32
|
+
"@blaze-cms/core-errors-ui": "0.133.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.133.0-admin-updates.0",
|
|
35
|
+
"@blaze-cms/plugin-search-ui": "0.133.0-admin-updates.0",
|
|
36
|
+
"@blaze-cms/setup-ui": "0.133.0-admin-updates.0",
|
|
37
|
+
"@blaze-cms/utils": "0.133.0-admin-updates.0",
|
|
38
|
+
"@blaze-cms/utils-handlebars": "0.133.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": "ddc99c4cd4e1858a1985f581d2c010b31815ba82"
|
|
93
93
|
}
|
|
@@ -39,14 +39,13 @@ const filterQuerySetup = ({
|
|
|
39
39
|
const { limit: settingsLimit } = variableProps;
|
|
40
40
|
const limit = settingsLimit || DEFAULT_LIMIT; // all falsey should use default
|
|
41
41
|
const requestLimit = entitySameAsCurrentItemEntity ? Number(limit) + 1 : limit;
|
|
42
|
-
const variables = getGenericRenderVariables(
|
|
43
|
-
filterEntityRelations,
|
|
44
|
-
{ ...variableProps, limit: requestLimit },
|
|
42
|
+
const variables = getGenericRenderVariables({
|
|
43
|
+
relations: filterEntityRelations,
|
|
44
|
+
filterProps: { ...variableProps, limit: requestLimit },
|
|
45
45
|
stringProps,
|
|
46
46
|
rawQuery,
|
|
47
|
-
false,
|
|
48
47
|
useRandomSort
|
|
49
|
-
);
|
|
48
|
+
});
|
|
50
49
|
|
|
51
50
|
return { variables, limit };
|
|
52
51
|
};
|
|
@@ -45,11 +45,12 @@ const buildLoopPropsContent = (loopProps = [], propsToDisplay = [], limit = 0, d
|
|
|
45
45
|
|
|
46
46
|
return propertiesToDisplay.map(key => {
|
|
47
47
|
const loopValue = loopValues[key];
|
|
48
|
-
const
|
|
48
|
+
const loopValueItem = loopValue && loopValue[i];
|
|
49
|
+
const propValue = loopValueItem ? getLoopValue(loopValueItem) : regularValues[key];
|
|
49
50
|
if (!propValue) return null;
|
|
50
51
|
|
|
51
52
|
const processedValue = processDataSummaryValue(propValue, options);
|
|
52
|
-
const linkToPublishedContent = getLinkToPublishedContent(key, data);
|
|
53
|
+
const linkToPublishedContent = getLinkToPublishedContent(key, data, loopValueItem);
|
|
53
54
|
return [upperFirst(label), processedValue, linkToPublishedContent, modifier];
|
|
54
55
|
});
|
|
55
56
|
})
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
const getLinkToPublishedContent = (key = '', props = {}) => {
|
|
1
|
+
const getLinkToPublishedContent = (key = '', props = {}, currentValue = null) => {
|
|
2
2
|
const [baseKey] = key.split('.');
|
|
3
3
|
if (!props[baseKey]) return '';
|
|
4
|
+
|
|
5
|
+
if (currentValue && typeof currentValue.url !== 'undefined') return currentValue.url;
|
|
6
|
+
|
|
4
7
|
const content = Array.isArray(props[baseKey]) ? props[baseKey][0] : props[baseKey];
|
|
5
8
|
return content && content.url ? content.url : '';
|
|
6
9
|
};
|
|
@@ -27,7 +27,6 @@ const ListBuilder = props => {
|
|
|
27
27
|
inheritedFilters,
|
|
28
28
|
paginationType,
|
|
29
29
|
entities,
|
|
30
|
-
isTextSearchFilterApplied,
|
|
31
30
|
parent: { itemId },
|
|
32
31
|
itemsPerPage,
|
|
33
32
|
itemsToDisplay,
|
|
@@ -86,37 +85,42 @@ const ListBuilder = props => {
|
|
|
86
85
|
|
|
87
86
|
const { relations = [] } = filterEntitySchema;
|
|
88
87
|
const stringProps = getStringTypeProps(entity, relations, Object.values(requiredSchema));
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
88
|
+
const filterData = {
|
|
89
|
+
filterValues,
|
|
90
|
+
filterOperator,
|
|
91
|
+
relations,
|
|
92
|
+
stringProps
|
|
93
|
+
};
|
|
94
|
+
const azRawQuery = buildRawQuery({
|
|
95
|
+
docType: docTypes,
|
|
92
96
|
operator,
|
|
93
97
|
searchValues,
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
itemId,
|
|
101
|
-
itemsToDisplayToUse,
|
|
102
|
-
shouldApplyDefaultSort,
|
|
103
|
-
{ shouldReturnAggs: true, isAZ }
|
|
104
|
-
);
|
|
98
|
+
filterData,
|
|
99
|
+
id: itemId,
|
|
100
|
+
itemsToDisplay: itemsToDisplayToUse,
|
|
101
|
+
shouldApplySort: shouldApplyDefaultSort,
|
|
102
|
+
azOptions: { shouldReturnAggs: true, isAZ, sortProperties }
|
|
103
|
+
});
|
|
105
104
|
|
|
106
|
-
const
|
|
105
|
+
const filterProps = {
|
|
106
|
+
...props,
|
|
107
|
+
limit: itemsPerPageToUse,
|
|
108
|
+
offset: initialOffset,
|
|
109
|
+
sort,
|
|
110
|
+
sortby,
|
|
111
|
+
sortProperties
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
const propsForVariables = {
|
|
107
115
|
relations,
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
stringProps,
|
|
117
|
-
azRawQuery,
|
|
118
|
-
isTextSearchFilterApplied
|
|
119
|
-
);
|
|
116
|
+
filterProps,
|
|
117
|
+
stringProps
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
const azVariables = getGenericRenderVariables({
|
|
121
|
+
...propsForVariables,
|
|
122
|
+
rawQuery: azRawQuery
|
|
123
|
+
});
|
|
120
124
|
|
|
121
125
|
const azAction = getSearchPublishedContent(RAW_RESULTS);
|
|
122
126
|
const { data, error, loading } = useQuery(azAction, {
|
|
@@ -129,37 +133,25 @@ const ListBuilder = props => {
|
|
|
129
133
|
const listAggregations = isAZ ? sortAggs(data) : [];
|
|
130
134
|
const updatedAggregations = buildAzAggregations(listAggregations);
|
|
131
135
|
|
|
132
|
-
const rawQuery = buildRawQuery(
|
|
133
|
-
docTypes,
|
|
136
|
+
const rawQuery = buildRawQuery({
|
|
137
|
+
docType: docTypes,
|
|
134
138
|
operator,
|
|
135
139
|
searchValues,
|
|
136
|
-
{
|
|
137
|
-
|
|
138
|
-
filterOperator,
|
|
139
|
-
relations,
|
|
140
|
-
stringProps,
|
|
140
|
+
filterData: {
|
|
141
|
+
...filterData,
|
|
141
142
|
azFilter
|
|
142
143
|
},
|
|
143
|
-
itemId,
|
|
144
|
-
itemsToDisplayToUse,
|
|
145
|
-
shouldApplyDefaultSort,
|
|
146
|
-
{ shouldReturnAggs: false, isAZ }
|
|
147
|
-
|
|
144
|
+
id: itemId,
|
|
145
|
+
itemsToDisplay: itemsToDisplayToUse,
|
|
146
|
+
shouldApplySort: shouldApplyDefaultSort,
|
|
147
|
+
azOptions: { shouldReturnAggs: false, isAZ, sortProperties },
|
|
148
|
+
sortProperties
|
|
149
|
+
});
|
|
148
150
|
|
|
149
|
-
const variables = getGenericRenderVariables(
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
limit: itemsPerPageToUse,
|
|
154
|
-
offset: initialOffset,
|
|
155
|
-
sort,
|
|
156
|
-
sortby,
|
|
157
|
-
sortProperties
|
|
158
|
-
},
|
|
159
|
-
stringProps,
|
|
160
|
-
rawQuery,
|
|
161
|
-
isTextSearchFilterApplied
|
|
162
|
-
);
|
|
151
|
+
const variables = getGenericRenderVariables({
|
|
152
|
+
...propsForVariables,
|
|
153
|
+
rawQuery
|
|
154
|
+
});
|
|
163
155
|
|
|
164
156
|
return (
|
|
165
157
|
<ListRender
|
|
@@ -187,7 +179,6 @@ ListBuilder.propTypes = {
|
|
|
187
179
|
mainSchemas: PropTypes.object.isRequired,
|
|
188
180
|
isCard: PropTypes.bool.isRequired,
|
|
189
181
|
isAZ: PropTypes.bool.isRequired,
|
|
190
|
-
isTextSearchFilterApplied: PropTypes.bool.isRequired,
|
|
191
182
|
parent: PropTypes.object.isRequired,
|
|
192
183
|
itemsPerPage: PropTypes.number.isRequired,
|
|
193
184
|
paginationIndex: PropTypes.number.isRequired,
|
|
@@ -58,13 +58,21 @@ const ListFactory = props => {
|
|
|
58
58
|
);
|
|
59
59
|
const { query, url, query: { itemListId: queryItemListId } = {} } = parseUrl(parsedQuery);
|
|
60
60
|
const updatedQuery = getListQuery(query, hasListSpecificFilters, name);
|
|
61
|
+
const isTextSearchFilterApplied = !!(
|
|
62
|
+
updatedQuery.search_term &&
|
|
63
|
+
searchFilter &&
|
|
64
|
+
getSearchFilterType(searchFilter, TEXT_SEARCH).length
|
|
65
|
+
);
|
|
66
|
+
|
|
61
67
|
const { sort: querySort, sortby: querySortBy } = updatedQuery;
|
|
68
|
+
|
|
62
69
|
const { sortbyFilters, updatedSortProperties } = getSortProps({
|
|
63
70
|
querySort,
|
|
64
71
|
sortProperties,
|
|
65
72
|
defaultSort,
|
|
66
73
|
querySortBy,
|
|
67
|
-
defaultSortBy
|
|
74
|
+
defaultSortBy,
|
|
75
|
+
isTextSearchFilterApplied
|
|
68
76
|
});
|
|
69
77
|
|
|
70
78
|
const itemListId = getItemListId(itemListName, queryItemListId);
|
|
@@ -135,11 +143,6 @@ const ListFactory = props => {
|
|
|
135
143
|
? buildSearchValuesText(textFilter, updatedQuery, name)
|
|
136
144
|
: [];
|
|
137
145
|
const { valuesAnd, valuesOr } = getQueryFilters(searchFilter, updatedQuery, name);
|
|
138
|
-
const isTextSearchFilterApplied = !!(
|
|
139
|
-
updatedQuery.search_term &&
|
|
140
|
-
searchFilter &&
|
|
141
|
-
getSearchFilterType(searchFilter, TEXT_SEARCH).length
|
|
142
|
-
);
|
|
143
146
|
|
|
144
147
|
const searchValues = {
|
|
145
148
|
searchValuesText: valuesText,
|
|
@@ -164,7 +167,6 @@ const ListFactory = props => {
|
|
|
164
167
|
currentSchema,
|
|
165
168
|
omitWrappers,
|
|
166
169
|
operator,
|
|
167
|
-
isTextSearchFilterApplied,
|
|
168
170
|
paginationIndex,
|
|
169
171
|
entityData,
|
|
170
172
|
inheritedFilters,
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import { AZ_QUERY_CONST, PB_QUERY_CONST } from '../../../constants';
|
|
1
2
|
import stripQueryKey from './strip-query-key';
|
|
2
3
|
|
|
3
4
|
const getListQuery = (query, hasListSpecificFilters, name) => {
|
|
4
5
|
const updatedQuery = {};
|
|
5
|
-
const listKey =
|
|
6
|
+
const listKey = `${PB_QUERY_CONST}[${name}]`;
|
|
6
7
|
const paginationKey = `${listKey}[page]`;
|
|
8
|
+
const azFilterKey = `${listKey}${AZ_QUERY_CONST}`;
|
|
7
9
|
const sortKey = `${listKey}[sort]`;
|
|
8
10
|
const sortByKey = `${listKey}[sortby]`;
|
|
9
11
|
|
|
@@ -16,8 +18,9 @@ const getListQuery = (query, hasListSpecificFilters, name) => {
|
|
|
16
18
|
const strippedKey = stripQueryKey(queryKey, listKey, paginationKey);
|
|
17
19
|
if (isListKey) updatedQuery[strippedKey] = decodedQueryValue;
|
|
18
20
|
} else {
|
|
19
|
-
if (queryKey.indexOf(
|
|
21
|
+
if (queryKey.indexOf(`${PB_QUERY_CONST}[`) === -1) updatedQuery[queryKey] = decodedQueryValue;
|
|
20
22
|
if (queryKey.indexOf(paginationKey) !== -1) updatedQuery[queryKey] = decodedQueryValue;
|
|
23
|
+
if (queryKey.indexOf(azFilterKey) !== -1) updatedQuery[queryKey] = decodedQueryValue;
|
|
21
24
|
}
|
|
22
25
|
});
|
|
23
26
|
updatedQuery.sort = query[sortKey] || query.sort;
|
|
@@ -1,10 +1,18 @@
|
|
|
1
|
-
const getSortProps = ({
|
|
1
|
+
const getSortProps = ({
|
|
2
|
+
querySort,
|
|
3
|
+
sortProperties,
|
|
4
|
+
defaultSort,
|
|
5
|
+
querySortBy,
|
|
6
|
+
defaultSortBy,
|
|
7
|
+
isTextSearchFilterApplied
|
|
8
|
+
}) => {
|
|
2
9
|
const sort = querySort || (sortProperties.length ? null : defaultSort);
|
|
3
10
|
let sortby = null;
|
|
4
11
|
if (querySortBy) sortby = [querySortBy];
|
|
5
12
|
else if (!sortProperties.length) sortby = defaultSortBy;
|
|
6
13
|
|
|
7
14
|
const updatedSortProperties = [...sortProperties];
|
|
15
|
+
if (isTextSearchFilterApplied) updatedSortProperties.unshift({ isScore: true });
|
|
8
16
|
if (sort) updatedSortProperties.unshift({ sort, propsToDisplay: sortby });
|
|
9
17
|
|
|
10
18
|
const sortbyFilters = updatedSortProperties
|
package/src/constants/index.js
CHANGED
|
@@ -161,36 +161,7 @@ const AZ = [
|
|
|
161
161
|
'Z'
|
|
162
162
|
];
|
|
163
163
|
|
|
164
|
-
const
|
|
165
|
-
aggs: {
|
|
166
|
-
azCount: {
|
|
167
|
-
terms: {
|
|
168
|
-
script: "doc['name.keyword'].getValue().substring(0,1).toUpperCase()",
|
|
169
|
-
size: 500
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
},
|
|
173
|
-
sort: [{ 'name.keyword': 'asc' }]
|
|
174
|
-
};
|
|
175
|
-
const ALL_AZ_SORT = {
|
|
176
|
-
sort: [
|
|
177
|
-
{
|
|
178
|
-
_script: {
|
|
179
|
-
type: 'number',
|
|
180
|
-
script: {
|
|
181
|
-
lang: 'painless',
|
|
182
|
-
source:
|
|
183
|
-
"int charPos = params.letters.indexOf(doc['name.keyword'].value.substring(0,1).toUpperCase()); charPos > -1 ? charPos : 100",
|
|
184
|
-
params: {
|
|
185
|
-
letters: AZ
|
|
186
|
-
}
|
|
187
|
-
},
|
|
188
|
-
order: 'asc'
|
|
189
|
-
}
|
|
190
|
-
},
|
|
191
|
-
{ 'name.keyword': 'asc' }
|
|
192
|
-
]
|
|
193
|
-
};
|
|
164
|
+
const AZ_DEFAULT_PROP = 'name';
|
|
194
165
|
|
|
195
166
|
const SCROLL_OFFSET = process.env.BLAZE_SCROLL_OFFSET || 50;
|
|
196
167
|
|
|
@@ -302,8 +273,7 @@ export {
|
|
|
302
273
|
PREHEADER_PROP,
|
|
303
274
|
HEADLINE_PROP,
|
|
304
275
|
AZ_QUERY_CONST,
|
|
305
|
-
|
|
306
|
-
ALL_AZ_SORT,
|
|
276
|
+
AZ_DEFAULT_PROP,
|
|
307
277
|
AZ,
|
|
308
278
|
SCROLL_OFFSET,
|
|
309
279
|
ANCHOR_TAG,
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
const buildAzFilter = (azFilter, mustFilters) => {
|
|
1
|
+
const buildAzFilter = (azFilter, mustFilters, azSortProperty) => {
|
|
2
2
|
if (!azFilter) return;
|
|
3
3
|
const filterValue = azFilter === '0' ? '[^a-zA-Z]' : azFilter;
|
|
4
|
+
const azSortProp = `${azSortProperty}.keyword`;
|
|
4
5
|
const azQuery = {
|
|
5
6
|
regexp: {
|
|
6
|
-
|
|
7
|
+
[azSortProp]: {
|
|
7
8
|
value: `${filterValue}.*`,
|
|
8
9
|
case_insensitive: true
|
|
9
10
|
}
|
|
@@ -2,9 +2,9 @@ import buildRawQueryBase from './build-raw-query-base';
|
|
|
2
2
|
import getItemsToDisplayIds from './get-items-to-display-ids';
|
|
3
3
|
import getExtraAzBits from './get-extra-az-bits';
|
|
4
4
|
import buildAzFilter from './build-az-filter';
|
|
5
|
-
import { AND_OPERATOR } from '../constants';
|
|
5
|
+
import { AND_OPERATOR, AZ_DEFAULT_PROP } from '../constants';
|
|
6
6
|
|
|
7
|
-
const buildRawQuery = (
|
|
7
|
+
const buildRawQuery = ({
|
|
8
8
|
docType,
|
|
9
9
|
operator,
|
|
10
10
|
searchValues,
|
|
@@ -13,15 +13,17 @@ const buildRawQuery = (
|
|
|
13
13
|
itemsToDisplay,
|
|
14
14
|
shouldApplySort,
|
|
15
15
|
azOptions
|
|
16
|
-
) => {
|
|
16
|
+
}) => {
|
|
17
17
|
const {
|
|
18
18
|
searchValuesText,
|
|
19
19
|
searchValuesCheckboxSelectRange,
|
|
20
20
|
searchValuesCheckboxOr
|
|
21
21
|
} = searchValues;
|
|
22
|
-
|
|
23
22
|
const { filterValues, filterOperator, relations, stringProps, azFilter } = filterData;
|
|
24
|
-
const {
|
|
23
|
+
const { isAZ, sortProperties = [] } = azOptions || {};
|
|
24
|
+
const [{ propsToDisplay: [azSortProp] } = { propsToDisplay: [] }] = sortProperties;
|
|
25
|
+
const azSortProperty = azSortProp || AZ_DEFAULT_PROP;
|
|
26
|
+
|
|
25
27
|
const searchValuesTextCheckboxSelectJoined =
|
|
26
28
|
operator === AND_OPERATOR ? [...searchValuesText, ...searchValuesCheckboxSelectRange] : [];
|
|
27
29
|
let searchValuesTextCheckboxOr = searchValuesText;
|
|
@@ -50,7 +52,7 @@ const buildRawQuery = (
|
|
|
50
52
|
}
|
|
51
53
|
];
|
|
52
54
|
|
|
53
|
-
buildAzFilter(azFilter, mustValues);
|
|
55
|
+
buildAzFilter(azFilter, mustValues, azSortProperty);
|
|
54
56
|
|
|
55
57
|
const query = {
|
|
56
58
|
bool: {
|
|
@@ -58,7 +60,7 @@ const buildRawQuery = (
|
|
|
58
60
|
...buildRawQueryBase({ docType, id, filterValues, filterOperator, relations, stringProps })
|
|
59
61
|
}
|
|
60
62
|
};
|
|
61
|
-
const azQueryBits = getExtraAzBits(
|
|
63
|
+
const azQueryBits = getExtraAzBits({ ...azOptions, azSortProperty, azFilter });
|
|
62
64
|
|
|
63
65
|
if (itemsToDisplay && itemsToDisplay.length) {
|
|
64
66
|
const itemsToDisplayIds = getItemsToDisplayIds(itemsToDisplay);
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import getSortbyFieldName from './get-sort-by-field-name';
|
|
2
|
+
|
|
3
|
+
const buildAzSort = (sortFilters, relations, stringProps) => {
|
|
4
|
+
const sortValues = {};
|
|
5
|
+
sortFilters.forEach(({ sort, propsToDisplay }) => {
|
|
6
|
+
if (!sort) return;
|
|
7
|
+
const sortFieldName = getSortbyFieldName(relations, propsToDisplay, stringProps);
|
|
8
|
+
if (sortFieldName) sortValues[sortFieldName] = sort.toLowerCase();
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
return sortValues;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const buildSortValues = (sortFilters, relations, stringProps, useSortObject) => {
|
|
15
|
+
if (!sortFilters || !sortFilters.length) return useSortObject ? null : { sort: [] };
|
|
16
|
+
if (useSortObject) return buildAzSort(sortFilters, relations, stringProps);
|
|
17
|
+
|
|
18
|
+
const sortValues = sortFilters
|
|
19
|
+
.map(({ sort, propsToDisplay, isScore }) => {
|
|
20
|
+
if (isScore) return '_score';
|
|
21
|
+
if (!sort) return null;
|
|
22
|
+
|
|
23
|
+
const sortFieldName = getSortbyFieldName(relations, propsToDisplay, stringProps);
|
|
24
|
+
return sortFieldName ? `${sortFieldName}:${sort.toLowerCase()}` : null;
|
|
25
|
+
})
|
|
26
|
+
.filter(Boolean)
|
|
27
|
+
.join(',');
|
|
28
|
+
|
|
29
|
+
return { sort: sortValues };
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export default buildSortValues;
|
|
@@ -1,7 +1,45 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AZ, AZ_DEFAULT_PROP } from '../constants';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
function getAzArgs(azSortProperty) {
|
|
4
|
+
const azProp = `${azSortProperty}.keyword`;
|
|
5
|
+
|
|
6
|
+
const AZ_AGGS = {
|
|
7
|
+
aggs: {
|
|
8
|
+
azCount: {
|
|
9
|
+
terms: {
|
|
10
|
+
script: `doc['${azProp}'].getValue().substring(0,1).toUpperCase()`,
|
|
11
|
+
size: 500
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
sort: [{ [azProp]: 'asc' }]
|
|
16
|
+
};
|
|
17
|
+
const ALL_AZ_SORT = {
|
|
18
|
+
sort: [
|
|
19
|
+
{
|
|
20
|
+
_script: {
|
|
21
|
+
type: 'number',
|
|
22
|
+
script: {
|
|
23
|
+
lang: 'painless',
|
|
24
|
+
source: `int charPos = params.letters.indexOf(doc['${azProp}'].value.substring(0,1).toUpperCase()); charPos > -1 ? charPos : 100`,
|
|
25
|
+
params: {
|
|
26
|
+
letters: AZ
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
order: 'asc'
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
{ [azProp]: 'asc' }
|
|
33
|
+
]
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
return { ALL_AZ_SORT, AZ_AGGS };
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const getExtraAzBits = ({ shouldReturnAggs, isAZ, azSortProperty = AZ_DEFAULT_PROP, azFilter }) => {
|
|
4
40
|
if (!isAZ || (isAZ && azFilter)) return {};
|
|
41
|
+
|
|
42
|
+
const { AZ_AGGS, ALL_AZ_SORT } = getAzArgs(azSortProperty);
|
|
5
43
|
if (shouldReturnAggs) return AZ_AGGS;
|
|
6
44
|
|
|
7
45
|
return ALL_AZ_SORT;
|
|
@@ -1,42 +1,25 @@
|
|
|
1
|
-
import getSortbyFieldName from './get-sort-by-field-name';
|
|
2
1
|
import { DEFAULT_LIMIT, DEFAULT_OFFSET } from '../constants';
|
|
2
|
+
import buildSortValues from './build-sort-values';
|
|
3
3
|
|
|
4
|
-
const
|
|
5
|
-
if (!sortFilters || !sortFilters.length) return { sort: [] };
|
|
6
|
-
|
|
7
|
-
const sortValues = sortFilters
|
|
8
|
-
.map(({ sort, propsToDisplay }) => {
|
|
9
|
-
if (!sort) return null;
|
|
10
|
-
|
|
11
|
-
const sortFieldName = getSortbyFieldName(relations, propsToDisplay, stringProps);
|
|
12
|
-
return sortFieldName ? `${sortFieldName}:${sort.toLowerCase()}` : null;
|
|
13
|
-
})
|
|
14
|
-
.filter(Boolean)
|
|
15
|
-
.join(',');
|
|
16
|
-
|
|
17
|
-
return { sort: sortValues };
|
|
18
|
-
};
|
|
19
|
-
const getCorrectSort = (relations, filterProps, stringProps, isTextSearchApplied) => {
|
|
20
|
-
if (isTextSearchApplied) {
|
|
21
|
-
return {};
|
|
22
|
-
}
|
|
4
|
+
const getCorrectSort = (relations, filterProps, stringProps, useSortObject) => {
|
|
23
5
|
const { sort, sortby, sortProperties = [] } = filterProps;
|
|
24
6
|
|
|
25
7
|
return buildSortValues(
|
|
26
8
|
[{ sort, propsToDisplay: sortby }, ...sortProperties],
|
|
27
9
|
relations,
|
|
28
|
-
stringProps
|
|
10
|
+
stringProps,
|
|
11
|
+
useSortObject
|
|
29
12
|
);
|
|
30
13
|
};
|
|
31
14
|
|
|
32
|
-
const getGenericRenderVariables = (
|
|
15
|
+
const getGenericRenderVariables = ({
|
|
33
16
|
relations,
|
|
34
17
|
filterProps = {},
|
|
35
18
|
stringProps = [],
|
|
36
19
|
rawQuery = {},
|
|
37
|
-
isTextSearchFilterApplied = false,
|
|
38
20
|
useRandomSort = false
|
|
39
|
-
) => {
|
|
21
|
+
}) => {
|
|
22
|
+
const rawQueryCopy = { ...rawQuery };
|
|
40
23
|
const { limit = DEFAULT_LIMIT, offset } = filterProps;
|
|
41
24
|
const limitToUse = Number(limit || DEFAULT_LIMIT);
|
|
42
25
|
const offsetToUse = Number(offset || DEFAULT_OFFSET);
|
|
@@ -45,7 +28,7 @@ const getGenericRenderVariables = (
|
|
|
45
28
|
const rawQueryStringified = JSON.stringify({
|
|
46
29
|
query: {
|
|
47
30
|
function_score: {
|
|
48
|
-
query:
|
|
31
|
+
query: rawQueryCopy && rawQueryCopy.query ? rawQueryCopy.query : rawQueryCopy,
|
|
49
32
|
random_score: {},
|
|
50
33
|
boost_mode: 'replace'
|
|
51
34
|
}
|
|
@@ -59,13 +42,23 @@ const getGenericRenderVariables = (
|
|
|
59
42
|
};
|
|
60
43
|
}
|
|
61
44
|
|
|
62
|
-
const sort = getCorrectSort(relations, filterProps, stringProps,
|
|
45
|
+
const sort = getCorrectSort(relations, filterProps, stringProps, !!rawQueryCopy.sort);
|
|
46
|
+
|
|
47
|
+
if (rawQueryCopy.sort && sort) {
|
|
48
|
+
rawQueryCopy.sort = [...rawQueryCopy.sort, sort];
|
|
49
|
+
|
|
50
|
+
return {
|
|
51
|
+
limit: limitToUse,
|
|
52
|
+
offset: offsetToUse,
|
|
53
|
+
rawQueryStringified: JSON.stringify(rawQueryCopy)
|
|
54
|
+
};
|
|
55
|
+
}
|
|
63
56
|
|
|
64
57
|
return {
|
|
65
58
|
limit: limitToUse,
|
|
66
59
|
offset: offsetToUse,
|
|
67
60
|
...sort,
|
|
68
|
-
rawQueryStringified: JSON.stringify(
|
|
61
|
+
rawQueryStringified: JSON.stringify(rawQueryCopy)
|
|
69
62
|
};
|
|
70
63
|
};
|
|
71
64
|
|
|
@@ -90,4 +90,45 @@ describe('buildLoopPropsContent helper function', () => {
|
|
|
90
90
|
});
|
|
91
91
|
expect.hasAssertions();
|
|
92
92
|
});
|
|
93
|
+
|
|
94
|
+
it('should nested items with urls', () => {
|
|
95
|
+
const data = {
|
|
96
|
+
nestedLoopProp: [
|
|
97
|
+
{
|
|
98
|
+
nestedValue: 'abc',
|
|
99
|
+
url: 'http://blazecms.app/abc'
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
nestedValue: '123',
|
|
103
|
+
url: 'http://blazecms.app/123'
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
nestedValue: 'no url',
|
|
107
|
+
url: null
|
|
108
|
+
}
|
|
109
|
+
]
|
|
110
|
+
};
|
|
111
|
+
const withUrl = buildLoopPropsContent(
|
|
112
|
+
mockedLoopProps,
|
|
113
|
+
[
|
|
114
|
+
{
|
|
115
|
+
bold: false,
|
|
116
|
+
enableLink: true,
|
|
117
|
+
label: '',
|
|
118
|
+
modifier: '',
|
|
119
|
+
prefix: '',
|
|
120
|
+
propertiesToDisplay: ['nestedLoopProp.nestedValue'],
|
|
121
|
+
shouldStrip: true
|
|
122
|
+
}
|
|
123
|
+
],
|
|
124
|
+
0,
|
|
125
|
+
data
|
|
126
|
+
);
|
|
127
|
+
|
|
128
|
+
withUrl.forEach(([, value, url], index) => {
|
|
129
|
+
expect(value).toEqual(data.nestedLoopProp[index].nestedValue);
|
|
130
|
+
expect(url).toEqual(data.nestedLoopProp[index].url || '');
|
|
131
|
+
});
|
|
132
|
+
expect.hasAssertions();
|
|
133
|
+
});
|
|
93
134
|
});
|
|
@@ -38,4 +38,25 @@ describe('get link to published content', () => {
|
|
|
38
38
|
const result = getLinkToPublishedContent(publishedKey, props);
|
|
39
39
|
expect(result).toEqual('');
|
|
40
40
|
});
|
|
41
|
+
|
|
42
|
+
it('should return url from the currentValue', () => {
|
|
43
|
+
const currentValue = { url: 'currentValueUrl' };
|
|
44
|
+
const props = { content: [content] };
|
|
45
|
+
const result = getLinkToPublishedContent(publishedKey, props, currentValue);
|
|
46
|
+
expect(result).toEqual(currentValue.url);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it('should return url from the currentValue even if falsey', () => {
|
|
50
|
+
const currentValue = { url: null };
|
|
51
|
+
const props = { content: [content] };
|
|
52
|
+
const result = getLinkToPublishedContent(publishedKey, props, currentValue);
|
|
53
|
+
expect(result).toEqual(currentValue.url);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it('should not return url from the currentValue if not set', () => {
|
|
57
|
+
const currentValue = {};
|
|
58
|
+
const props = { content: [content] };
|
|
59
|
+
const result = getLinkToPublishedContent(publishedKey, props, currentValue);
|
|
60
|
+
expect(result).toEqual(content.url);
|
|
61
|
+
});
|
|
41
62
|
});
|