-
Notifications
You must be signed in to change notification settings - Fork 12
[Data Object Grid][Advanced columns] Add improvements #2322
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
3cd5d66
07d3951
55feb81
c0c9227
c7e074f
3bb0e08
d656219
caa5743
525a00a
868e3db
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| /** | ||
| * This source file is available under the terms of the | ||
| * Pimcore Open Core License (POCL) | ||
| * Full copyright and license information is available in | ||
| * LICENSE.md which is distributed with this source code. | ||
| * | ||
| * @copyright Copyright (c) Pimcore GmbH (https://www.pimcore.com) | ||
| * @license Pimcore Open Core License (POCL) | ||
| */ | ||
|
|
||
| import { isNil, isUndefined } from 'lodash' | ||
| import { useTranslation } from 'react-i18next' | ||
| import type { DropdownMenuProps } from '@Pimcore/components/dropdown/dropdown' | ||
| import type { DynamicTypePipelineAbstract } from '@Pimcore/modules/element/dynamic-types/definitions/pipelines/dynamic-type-pipeline-abstract' | ||
| import { useNumberedList } from '@Pimcore/components/form/controls/numbered-list/provider/numbered-list/use-numbered-list' | ||
|
|
||
| interface IUseTransformersMenuItemsReturn { | ||
| transformersMenuItems: DropdownMenuProps['items'] | ||
| } | ||
|
|
||
| const TRANSFORMERS_GROUP = { | ||
| boolean: ['booleanFormatter'], | ||
| date: ['dateFormatter'], | ||
| string: ['anonymizer', 'blur', 'caseChange', 'combine', 'explode', 'stringReplace', 'substring', 'trim'], | ||
| other: ['elementCounter', 'twigOperator'] | ||
| } | ||
|
|
||
| export const useTransformersMenuItems = (availableDynamicTypes?: DynamicTypePipelineAbstract[]): IUseTransformersMenuItemsReturn => { | ||
| if (isUndefined(availableDynamicTypes)) return { transformersMenuItems: [] } | ||
|
|
||
| const { t } = useTranslation() | ||
| const { operations } = useNumberedList() | ||
|
|
||
| const groupedIds = new Set(Object.values(TRANSFORMERS_GROUP).flat()) | ||
| const ungroupedTransformers = availableDynamicTypes | ||
| .map(dynamicType => dynamicType.id) | ||
| .filter(id => !groupedIds.has(id)) | ||
|
|
||
| if (ungroupedTransformers.length > 0) { | ||
| TRANSFORMERS_GROUP.other = [ | ||
| ...TRANSFORMERS_GROUP.other, | ||
| ...ungroupedTransformers | ||
| ] | ||
| } | ||
|
|
||
| const transformersMenuItems: DropdownMenuProps['items'] = Object.entries(TRANSFORMERS_GROUP).map(([groupKey, transformerIds]) => ({ | ||
| key: `${groupKey}Transformers`, | ||
| label: t(`grid.advanced-column.advancedColumns.group.${groupKey}`), | ||
| children: availableDynamicTypes | ||
| .filter(dynamicType => transformerIds.includes(dynamicType.id)) | ||
| .map(dynamicType => ({ | ||
| key: dynamicType.id, | ||
| label: t(`grid.advanced-column.advancedColumns.${dynamicType.id}`), | ||
| onClick: () => { operations.add({ key: dynamicType.id }) } | ||
| })) | ||
| .filter(item => !isNil(item)) | ||
| })) | ||
|
|
||
| return { transformersMenuItems } | ||
| } |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.