Skip to content

[Data Object][Grid] missing drop down options for filters #1397

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

Merged
merged 14 commits into from
May 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 5 additions & 1 deletion assets/js/src/core/app/config/services/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import { DynamicTypeFieldFilterRegistry } from '@Pimcore/modules/element/dynamic
import { DynamicTypeListingRegistry } from '@Pimcore/modules/element/dynamic-types/definitions/listing/dynamic-type-listing-registry'
import { DynamicTypeListingAssetLink } from '@Pimcore/modules/element/dynamic-types/definitions/listing/types/dynamic-type-listing-asset-link'
import { serviceIds } from '@Pimcore/app/config/services/service-ids'
import { DynamicTypeFieldFilterObjectAdapter } from '@Pimcore/modules/element/dynamic-types/definitions/field-filters/types/data-object-adapter/dynamic-type-field-filter-data-object-adapter'
import { DynamicTypeFieldFilterDataObjectObjectBrick } from '@Pimcore/modules/element/dynamic-types/definitions/field-filters/types/data-object-brick/dynamic-type-field-filter-data-object-object-brick'
import { DynamicTypeFieldFilterText } from '@Pimcore/modules/element/dynamic-types/definitions/field-filters/types/text/dynamic-type-field-filter-text'
import { DynamicTypeFieldFilterNumber } from '@Pimcore/modules/element/dynamic-types/definitions/field-filters/types/number/dynamic-type-field-filter-number'
import { DynamicTypeFieldFilterSelect } from '@Pimcore/modules/element/dynamic-types/definitions/field-filters/types/select/dynamic-type-field-filter-select'
Expand Down Expand Up @@ -145,7 +147,7 @@ import { DynamicTypeGridCellDataObjectAdapter } from '@Pimcore/modules/element/d
import { MainNavRegistry } from '@Pimcore/modules/app/base-layout/main-nav/services/main-nav-registry'
import { DynamicTypeGridCellDataObjectActions } from '@Pimcore/modules/element/dynamic-types/definitions/grid-cell/types/data-object-actions/dynamic-type-grid-cell-data-object-actions'
import { DynamicTypeGridCellDataObjectObjectBrick } from '@Pimcore/modules/element/dynamic-types/definitions/grid-cell/types/data-object-object-brick/dynamic-type-grid-cell-data-object-adapter'
import { DynamicTypeBatchEditDataObjectAdapter } from '@Pimcore/modules/element/dynamic-types/definitions/batch-edits/types/data-object-adapter/dynamic-type-batch-edit-data-object-adpater'
import { DynamicTypeBatchEditDataObjectAdapter } from '@Pimcore/modules/element/dynamic-types/definitions/batch-edits/types/data-object-adapter/dynamic-type-batch-edit-data-object-adapter'
import { DynamicTypeBatchEditDataObjectObjectBrick } from '@Pimcore/modules/element/dynamic-types/definitions/batch-edits/types/data-object-object-brick/dynamic-type-batch-edit-data-object-object-brick'
import { DynamicTypeAssetRegistry } from '@Pimcore/modules/element/dynamic-types/definitions/asset/dynamic-type-asset-registry'
import { DynamicTypeAssetImage } from '@Pimcore/modules/element/dynamic-types/definitions/asset/types/dynamic-type-asset-image'
Expand Down Expand Up @@ -204,6 +206,8 @@ container.bind(serviceIds.iconLibrary).to(IconLibrary).inSingletonScope()

// dynamic types field filters
container.bind(serviceIds['DynamicTypes/FieldFilterRegistry']).to(DynamicTypeFieldFilterRegistry).inSingletonScope()
container.bind(serviceIds['DynamicTypes/FieldFilter/DataObjectAdapter']).to(DynamicTypeFieldFilterObjectAdapter).inSingletonScope()
container.bind(serviceIds['DynamicTypes/FieldFilter/DataObjectObjectBrick']).to(DynamicTypeFieldFilterDataObjectObjectBrick).inSingletonScope()
container.bind(serviceIds['DynamicTypes/FieldFilter/Text']).to(DynamicTypeFieldFilterText).inSingletonScope()
container.bind(serviceIds['DynamicTypes/FieldFilter/Number']).to(DynamicTypeFieldFilterNumber).inSingletonScope()
container.bind(serviceIds['DynamicTypes/FieldFilter/Select']).to(DynamicTypeFieldFilterSelect).inSingletonScope()
Expand Down
2 changes: 2 additions & 0 deletions assets/js/src/core/app/config/services/service-ids.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ export const serviceIds = {
// dynamic types
...dynamicTypeRegistriesServiceIds,

'DynamicTypes/FieldFilter/DataObjectAdapter': 'DynamicTypes/FieldFilter/DataObjectAdapter',
'DynamicTypes/FieldFilter/DataObjectObjectBrick': 'DynamicTypes/FieldFilter/DataObjectObjectBrick',
'DynamicTypes/FieldFilter/Text': 'DynamicTypes/FieldFilter/Text',
'DynamicTypes/FieldFilter/Number': 'DynamicTypes/FieldFilter/Number',
'DynamicTypes/FieldFilter/Select': 'DynamicTypes/FieldFilter/Select',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export interface IDynamicFilter {
type: string
data: any
frontendType?: string
filterType?: string
config?: any
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
type AbstractBatchEditDefinition,
type DynamicTypeBatchEditAbstract
} from '@Pimcore/modules/element/dynamic-types/definitions/batch-edits/dynamic-type-batch-edit-abstract'
import { DynamicTypeBatchEditDataObjectAdapterComponent } from '../../components/data-object-adpater/dynamic-type-batch-edit-data-object-adapter-component'
import { DynamicTypeBatchEditDataObjectAdapterComponent } from '@Pimcore/modules/element/dynamic-types/definitions/batch-edits/components/data-object-adapter/dynamic-type-batch-edit-data-object-adapter-component'

@injectable()
export class DynamicTypeBatchEditDataObjectAdapter implements DynamicTypeBatchEditAbstract {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/**
* 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 React from 'react'
import { Alert } from 'antd'
import { type AbstractFieldFilterDefinition } from '../dynamic-type-field-filter-abstract'
import { useDynamicFilter } from '@Pimcore/components/dynamic-filter/provider/use-dynamic-filter'
import { useInjection } from '@Pimcore/app/depency-injection'
import type { DynamicTypeFieldFilterRegistry } from '@Pimcore/modules/element/dynamic-types/definitions/field-filters/dynamic-type-field-filter-registry'
import { serviceIds } from '@Pimcore/app/config/services/service-ids'

export interface DynamicTypeFieldFilterObjectAdapterProps extends AbstractFieldFilterDefinition {}

export const DynamicTypeFieldFilterObjectAdapterComponent = (): React.JSX.Element => {
const { config } = useDynamicFilter()

if (!('fieldDefinition' in config)) {
throw new Error('Field definition is missing in config')
}

const { fieldDefinition } = config
const currentFieldType: string = fieldDefinition?.fieldType ?? fieldDefinition?.fieldtype ?? 'unknown'
const objectDataRegistry = useInjection<DynamicTypeFieldFilterRegistry>(serviceIds['DynamicTypes/FieldFilterRegistry'])

if (!objectDataRegistry.hasDynamicType(currentFieldType)) {
return (
<Alert
message={ `Unknown data type: ${currentFieldType}` }
type="warning"
/>
)
}

const objectDataType = objectDataRegistry.getDynamicType(currentFieldType)

return objectDataType.getFieldFilterComponent(fieldDefinition as AbstractFieldFilterDefinition)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/**
* 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 React from 'react'
import { Alert } from 'antd'
import { type AbstractFieldFilterDefinition } from '../dynamic-type-field-filter-abstract'
import { useDynamicFilter } from '@Pimcore/components/dynamic-filter/provider/use-dynamic-filter'
import { useInjection } from '@Pimcore/app/depency-injection'
import type { DynamicTypeFieldFilterRegistry } from '@Pimcore/modules/element/dynamic-types/definitions/field-filters/dynamic-type-field-filter-registry'
import { serviceIds } from '@Pimcore/app/config/services/service-ids'

export interface DynamicTypeFieldFilterObjectBrickProps extends AbstractFieldFilterDefinition {}

export const DynamicTypeFieldFilterObjectBrickComponent = (): React.JSX.Element => {
const { config } = useDynamicFilter()

if (!('fieldDefinition' in config)) {
throw new Error('Field definition is missing in config')
}

const { fieldDefinition } = config
const currentFieldType: string = fieldDefinition?.fieldType ?? fieldDefinition?.fieldtype ?? 'unknown'
const objectDataRegistry = useInjection<DynamicTypeFieldFilterRegistry>(serviceIds['DynamicTypes/FieldFilterRegistry'])

if (!objectDataRegistry.hasDynamicType(currentFieldType)) {
return (
<Alert
message={ `Unknown data type: ${currentFieldType}` }
type="warning"
/>
)
}

const objectDataType = objectDataRegistry.getDynamicType(currentFieldType)

return objectDataType.getFieldFilterComponent(fieldDefinition as AbstractFieldFilterDefinition)
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,24 @@

import React, { useEffect, useState } from 'react'
import { type DefaultOptionType } from 'antd/es/select'
import { Select } from '@Pimcore/components/select/select'
import { Select, type SelectProps } from '@Pimcore/components/select/select'
import { type AbstractFieldFilterDefinition } from '../dynamic-type-field-filter-abstract'
import { useDynamicFilter } from '@Pimcore/components/dynamic-filter/provider/use-dynamic-filter'

export interface DynamicTypeFieldFilterSelectProps extends AbstractFieldFilterDefinition {}
export interface DynamicTypeFieldFilterSelectProps extends AbstractFieldFilterDefinition {
options: SelectProps['options']
}

export const DynamicTypeFieldFilterSelectComponent = (props: DynamicTypeFieldFilterSelectProps): React.JSX.Element => {
const { setData, data, config } = useDynamicFilter()
const { setData, data } = useDynamicFilter()
const [_value, setValue] = useState(data)
const options: DefaultOptionType[] = []

if (config.options !== undefined) {
for (const option of config.options) {
if (props.options !== undefined) {
for (const option of props.options) {
options.push({
label: option,
value: option
label: option?.key,
value: option?.value
})
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,13 @@ export interface AbstractFieldFilterDefinition {}
export abstract class DynamicTypeFieldFilterAbstract implements DynamicTypeAbstract {
abstract readonly id: string
abstract getFieldFilterComponent (props: AbstractFieldFilterDefinition): ReactElement<AbstractFieldFilterDefinition>

shouldOverrideFilterType (): boolean {
return false
}

getFieldFilterType (): string {
// This method intentionally returns an empty value to avoid duplication in classes that do not override it
return ''
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/**
* 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 React, { type ReactElement } from 'react'
import { injectable } from 'inversify'
import { DynamicTypeFieldFilterAbstract } from '../../dynamic-type-field-filter-abstract'
import {
DynamicTypeFieldFilterObjectAdapterComponent,
type DynamicTypeFieldFilterObjectAdapterProps
} from '@Pimcore/modules/element/dynamic-types/definitions/field-filters/components/dynamic-type-field-filter-object-adapter'

@injectable()
export class DynamicTypeFieldFilterObjectAdapter extends DynamicTypeFieldFilterAbstract {
id = 'dataobject.adapter'

shouldOverrideFilterType (): boolean {
return true
}

getFieldFilterComponent (props: DynamicTypeFieldFilterObjectAdapterProps): ReactElement<DynamicTypeFieldFilterObjectAdapterProps> {
return (
<DynamicTypeFieldFilterObjectAdapterComponent { ...props } />
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/**
* 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 React, { type ReactElement } from 'react'
import { injectable } from 'inversify'
import { DynamicTypeFieldFilterAbstract } from '../../dynamic-type-field-filter-abstract'
import {
DynamicTypeFieldFilterObjectBrickComponent,
type DynamicTypeFieldFilterObjectBrickProps
} from '@Pimcore/modules/element/dynamic-types/definitions/field-filters/components/dynamic-type-field-filter-object-object-brick'

@injectable()
export class DynamicTypeFieldFilterDataObjectObjectBrick extends DynamicTypeFieldFilterAbstract {
id = 'dataobject.objectbrick'

shouldOverrideFilterType (): boolean {
return true
}

getFieldFilterComponent (props: DynamicTypeFieldFilterObjectBrickProps): ReactElement<DynamicTypeFieldFilterObjectBrickProps> {
return (
<DynamicTypeFieldFilterObjectBrickComponent { ...props } />
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,18 @@
*/

import React, { type ReactElement } from 'react'
import { type DynamicTypeFieldFilterAbstract } from '../../dynamic-type-field-filter-abstract'
import { DynamicTypeFieldFilterAbstract } from '../../dynamic-type-field-filter-abstract'
import { DynamicTypeFieldFilterDatetimeComponent, type DynamicTypeFieldFilterDatetimeProps } from '../../components/dynamic-type-field-filter-datetime-component'
import { injectable } from 'inversify'

@injectable()
export class DynamicTypeFieldFilterDatetime implements DynamicTypeFieldFilterAbstract {
export class DynamicTypeFieldFilterDatetime extends DynamicTypeFieldFilterAbstract {
id = 'datetime'

getFieldFilterType (): string {
return 'system.datetime'
}

getFieldFilterComponent (props: DynamicTypeFieldFilterDatetimeProps): ReactElement<DynamicTypeFieldFilterDatetimeProps> {
return (
<DynamicTypeFieldFilterDatetimeComponent { ...props } />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,18 @@
*/

import React, { type ReactElement } from 'react'
import { type DynamicTypeFieldFilterAbstract } from '../../dynamic-type-field-filter-abstract'
import { DynamicTypeFieldFilterAbstract } from '../../dynamic-type-field-filter-abstract'
import { DynamicTypeFieldFilterNumberComponent, type DynamicTypeFieldFilterNumberProps } from '../../components/dynamic-type-field-filter-number-component'
import { injectable } from 'inversify'

@injectable()
export class DynamicTypeFieldFilterNumber implements DynamicTypeFieldFilterAbstract {
export class DynamicTypeFieldFilterNumber extends DynamicTypeFieldFilterAbstract {
id = 'id'

getFieldFilterType (): string {
return 'system.id'
}

getFieldFilterComponent (props: DynamicTypeFieldFilterNumberProps): ReactElement<DynamicTypeFieldFilterNumberProps> {
return (
<DynamicTypeFieldFilterNumberComponent { ...props } />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,18 @@
*/

import React, { type ReactElement } from 'react'
import { type DynamicTypeFieldFilterAbstract } from '../../dynamic-type-field-filter-abstract'
import { DynamicTypeFieldFilterAbstract } from '../../dynamic-type-field-filter-abstract'
import { DynamicTypeFieldFilterSelectComponent, type DynamicTypeFieldFilterSelectProps } from '../../components/dynamic-type-field-filter-select-component'
import { injectable } from 'inversify'

@injectable()
export class DynamicTypeFieldFilterSelect implements DynamicTypeFieldFilterAbstract {
export class DynamicTypeFieldFilterSelect extends DynamicTypeFieldFilterAbstract {
id = 'select'

getFieldFilterType (): string {
return 'system.string'
}

getFieldFilterComponent (props: DynamicTypeFieldFilterSelectProps): ReactElement<DynamicTypeFieldFilterSelectProps> {
return (
<DynamicTypeFieldFilterSelectComponent { ...props } />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,18 @@
*/

import React, { type ReactElement } from 'react'
import { type DynamicTypeFieldFilterAbstract } from '../../dynamic-type-field-filter-abstract'
import { DynamicTypeFieldFilterAbstract } from '../../dynamic-type-field-filter-abstract'
import { DynamicTypeFieldFilterTextComponent, type DynamicTypeFieldFilterTextProps } from '../../components/dynamic-type-field-filter-text-component'
import { injectable } from 'inversify'

@injectable()
export class DynamicTypeFieldFilterText implements DynamicTypeFieldFilterAbstract {
export class DynamicTypeFieldFilterText extends DynamicTypeFieldFilterAbstract {
id = 'input'

getFieldFilterType (): string {
return 'system.string'
}

getFieldFilterComponent (props: DynamicTypeFieldFilterTextProps): ReactElement<DynamicTypeFieldFilterTextProps> {
return (
<DynamicTypeFieldFilterTextComponent { ...props } />
Expand Down
6 changes: 5 additions & 1 deletion assets/js/src/core/modules/element/dynamic-types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import { container } from '@Pimcore/app/depency-injection'
import { moduleSystem } from '@Pimcore/app/module-system/module-system'
import { type DynamicTypeFieldFilterRegistry } from './definitions/field-filters/dynamic-type-field-filter-registry'
import { serviceIds } from '@Pimcore/app/config/services/service-ids'
import { type DynamicTypeFieldFilterObjectAdapter } from './definitions/field-filters/types/data-object-adapter/dynamic-type-field-filter-data-object-adapter'
import { type DynamicTypeFieldFilterDataObjectObjectBrick } from '@Pimcore/modules/element/dynamic-types/definitions/field-filters/types/data-object-brick/dynamic-type-field-filter-data-object-object-brick'
import { type DynamicTypeFieldFilterText } from './definitions/field-filters/types/text/dynamic-type-field-filter-text'
import { type DynamicTypeFieldFilterNumber } from './definitions/field-filters/types/number/dynamic-type-field-filter-number'
import { type DynamicTypeFieldFilterSelect } from './definitions/field-filters/types/select/dynamic-type-field-filter-select'
Expand Down Expand Up @@ -132,7 +134,7 @@ import { type DynamicTypeObjectDataObjectBrick } from './definitions/objects/dat
import { type DynamicTypeGridCellDataObjectAdapter } from './definitions/grid-cell/types/data-object-adapter/dynamic-type-grid-cell-data-object-adapter'
import { type DynamicTypeGridCellDataObjectActions } from './definitions/grid-cell/types/data-object-actions/dynamic-type-grid-cell-data-object-actions'
import { type DynamicTypeGridCellDataObjectObjectBrick } from './definitions/grid-cell/types/data-object-object-brick/dynamic-type-grid-cell-data-object-adapter'
import { type DynamicTypeBatchEditDataObjectAdapter } from './definitions/batch-edits/types/data-object-adapter/dynamic-type-batch-edit-data-object-adpater'
import { type DynamicTypeBatchEditDataObjectAdapter } from './definitions/batch-edits/types/data-object-adapter/dynamic-type-batch-edit-data-object-adapter'
import { type DynamicTypeBatchEditDataObjectObjectBrick } from './definitions/batch-edits/types/data-object-object-brick/dynamic-type-batch-edit-data-object-object-brick'
import { type DynamicTypeAssetRegistry } from './definitions/asset/dynamic-type-asset-registry'
import { type DynamicTypeAssetArchive } from './definitions/asset/types/dynamic-type-asset-archive'
Expand All @@ -154,6 +156,8 @@ moduleSystem.registerModule({
onInit () {
const fieldFilterRegistry = container.get<DynamicTypeFieldFilterRegistry>(serviceIds['DynamicTypes/FieldFilterRegistry'])

fieldFilterRegistry.registerDynamicType(container.get<DynamicTypeFieldFilterObjectAdapter>(serviceIds['DynamicTypes/FieldFilter/DataObjectAdapter']))
fieldFilterRegistry.registerDynamicType(container.get<DynamicTypeFieldFilterDataObjectObjectBrick>(serviceIds['DynamicTypes/FieldFilter/DataObjectObjectBrick']))
fieldFilterRegistry.registerDynamicType(container.get<DynamicTypeFieldFilterText>(serviceIds['DynamicTypes/FieldFilter/Text']))
fieldFilterRegistry.registerDynamicType(container.get<DynamicTypeFieldFilterNumber>(serviceIds['DynamicTypes/FieldFilter/Number']))
fieldFilterRegistry.registerDynamicType(container.get<DynamicTypeFieldFilterSelect>(serviceIds['DynamicTypes/FieldFilter/Select']))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export interface FieldFilter {
key: string
type: string
filterValue: any
filterType?: string
}

export interface FieldFiltersData {
Expand Down
Loading