Skip to content

Commit 1adeb72

Browse files
limaagabrielbrianchandotcom
authored andcommitted
LPD-81222 Group filters in CMS Contents FDS via prop transformer
1 parent 6c371f6 commit 1adeb72

3 files changed

Lines changed: 17 additions & 2 deletions

File tree

modules/apps/frontend-js/frontend-js-item-selector-web/src/main/resources/META-INF/resources/item_selector/getCMSItemSelectorFilters.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,12 +134,18 @@ export function getCMSItemSelectorFilters(
134134

135135
/**
136136
* Returns the grouped filters configuration for CMS Item Selector data sets.
137+
*
138+
* The space/group filter ID can be customized via spaceFilterId so the same
139+
* groupings can be reused by data sets that register the space filter under a
140+
* different ID (e.g. the CMS "Contents" FDS uses "scopeGroupId").
137141
*/
138-
export function getCMSItemSelectorGroupedFilters(): IGroupedFilterConfig[] {
142+
export function getCMSItemSelectorGroupedFilters(
143+
spaceFilterId: 'groupIds' | 'scopeGroupId' = 'groupIds'
144+
): IGroupedFilterConfig[] {
139145
return [
140146
{
141147
filters: [
142-
'groupIds',
148+
spaceFilterId,
143149
'objectDefinitionExternalReferenceCode',
144150
'taxonomyCategoryIds',
145151
'keywords',

modules/apps/frontend-js/frontend-js-item-selector-web/test/getCMSItemSelectorFilters.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,13 @@ describe('getCMSItemSelectorFilters', () => {
8282

8383
expect(groupedFilters.length).toBe(2);
8484
expect(groupedFilters[0].filters.length).toBe(6);
85+
expect(groupedFilters[0].filters[0]).toBe('groupIds');
8586
expect(groupedFilters[1].filters.length).toBe(6);
8687
});
88+
89+
it('lets the caller override the space filter id', () => {
90+
const groupedFilters = getCMSItemSelectorGroupedFilters('scopeGroupId');
91+
92+
expect(groupedFilters[0].filters[0]).toBe('scopeGroupId');
93+
});
8794
});

modules/apps/site/site-cms-site-initializer/src/main/resources/META-INF/resources/js/main_view/props_transformer/AssetsFDSPropsTransformer.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
IView,
1010
replaceTokens,
1111
} from '@liferay/frontend-data-set-web';
12+
import {getCMSItemSelectorGroupedFilters} from '@liferay/frontend-js-item-selector-web';
1213
import {sub} from 'frontend-js-web';
1314
import React from 'react';
1415

@@ -310,6 +311,7 @@ export default function AssetsFDSPropsTransformer({
310311
} as IInternalRenderer,
311312
],
312313
},
314+
groupedFilters: getCMSItemSelectorGroupedFilters('scopeGroupId'),
313315
hideManagementBarInEmptyState: true,
314316
infoPanelComponent: (items: {items: ISearchAssetObjectEntry[]}) => (
315317
<AssetTypeInfoPanel

0 commit comments

Comments
 (0)