Skip to content

Add checkbox and textarea to field filters #1534

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

Open
wants to merge 12 commits into
base: 1.x
Choose a base branch
from
Open
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
  •  
  •  
  •  
4 changes: 4 additions & 0 deletions assets/js/src/core/app/config/services/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ import { EmailTabManager } from '@Pimcore/modules/document/editor/types/email/ta
import { HardlinkTabManager } from '@Pimcore/modules/document/editor/types/hardlink/tab-manager/hardlink-tab-manager'
import { LinkTabManager } from '@Pimcore/modules/document/editor/types/link/tab-manager/link-tab-manager'
import { SnippetTabManager } from '@Pimcore/modules/document/editor/types/snippet/tab-manager/snippet-tab-manager'
import { DynamicTypeFieldFilterCheckbox } from '@Pimcore/modules/element/dynamic-types/definitions/field-filters/types/checkbox/dynamic-type-field-filter-checkbox'
import { DynamicTypeFieldFilterTextArea } from '@Pimcore/modules/element/dynamic-types/definitions/field-filters/types/text-area/dynamic-type-field-filter-text-area'

// Main nav
container.bind(serviceIds.mainNavRegistry).to(MainNavRegistry).inSingletonScope()
Expand Down Expand Up @@ -209,9 +211,11 @@ container.bind(serviceIds['DynamicTypes/FieldFilterRegistry']).to(DynamicTypeFie
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/Textarea']).to(DynamicTypeFieldFilterTextArea).inSingletonScope()
container.bind(serviceIds['DynamicTypes/FieldFilter/Number']).to(DynamicTypeFieldFilterNumber).inSingletonScope()
container.bind(serviceIds['DynamicTypes/FieldFilter/Select']).to(DynamicTypeFieldFilterSelect).inSingletonScope()
container.bind(serviceIds['DynamicTypes/FieldFilter/Datetime']).to(DynamicTypeFieldFilterDatetime).inSingletonScope()
container.bind(serviceIds['DynamicTypes/FieldFilter/Checkbox']).to(DynamicTypeFieldFilterCheckbox).inSingletonScope()

// dynamic types batch edit
container.bind(serviceIds['DynamicTypes/BatchEditRegistry']).to(DynamicTypeBatchEditRegistry).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 @@ -65,9 +65,11 @@ export const serviceIds = {
'DynamicTypes/FieldFilter/DataObjectAdapter': 'DynamicTypes/FieldFilter/DataObjectAdapter',
'DynamicTypes/FieldFilter/DataObjectObjectBrick': 'DynamicTypes/FieldFilter/DataObjectObjectBrick',
'DynamicTypes/FieldFilter/Text': 'DynamicTypes/FieldFilter/Text',
'DynamicTypes/FieldFilter/Textarea': 'DynamicTypes/FieldFilter/Textarea',
'DynamicTypes/FieldFilter/Number': 'DynamicTypes/FieldFilter/Number',
'DynamicTypes/FieldFilter/Select': 'DynamicTypes/FieldFilter/Select',
'DynamicTypes/FieldFilter/Datetime': 'DynamicTypes/FieldFilter/Datetime',
'DynamicTypes/FieldFilter/Checkbox': 'DynamicTypes/FieldFilter/Checkbox',

'DynamicTypes/BatchEdit/Text': 'DynamicTypes/BatchEdit/Text',
'DynamicTypes/BatchEdit/TextArea': 'DynamicTypes/BatchEdit/TextArea',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/**
* 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, { useEffect } from 'react'
import { type AbstractFieldFilterDefinition } from '../dynamic-type-field-filter-abstract'
import { useDynamicFilter } from '@Pimcore/components/dynamic-filter/provider/use-dynamic-filter'
import { Segmented } from '@sdk/components'

export interface DynamicTypeFieldFilterCheckboxProps extends AbstractFieldFilterDefinition {
checked?: boolean
}

export const DynamicTypeFieldFilterCheckboxComponent = (props: DynamicTypeFieldFilterCheckboxProps): React.JSX.Element => {
const { setData, data } = useDynamicFilter()

useEffect(() => {
setData(false)
}, [])

const handleChange = (val: 'true' | 'false'): void => {
const boolValue = val === 'true'
setData(boolValue)
}

return (
<Segmented
onChange={ handleChange }
options={ [
{ label: 'True', value: 'true' },
{ label: 'False', value: 'false' }
] }
value={ (data === true) ? 'true' : 'false' }
/>

)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/**
* 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, { useEffect, useState } from 'react'
import { type AbstractFieldFilterDefinition } from '../dynamic-type-field-filter-abstract'
import { useDynamicFilter } from '@Pimcore/components/dynamic-filter/provider/use-dynamic-filter'
import { TextArea } from '@sdk/components'

export interface DynamicTypeFieldFilterTextAreaProps extends AbstractFieldFilterDefinition {}

export const DynamicTypeFieldFilterTextAreaComponent = (): React.JSX.Element => {
const { data, setData } = useDynamicFilter()
const [_value, setValue] = useState(data)

useEffect(() => {
setValue(data)
}, [data])

useEffect(() => {
setData('')
}, [])

return (
<TextArea
onBlur={ onBlur }
onChange={ (event) => { setValue(event.target.value) } }
value={ _value }
/>
)

function onBlur (): void {
setData(_value)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/**
* 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 { injectable } from 'inversify'
import React, { type ReactElement } from 'react'
import { DynamicTypeFieldFilterCheckboxComponent, type DynamicTypeFieldFilterCheckboxProps } from '../../components/dynamic-type-field-filter-checkbox-component'
import { DynamicTypeFieldFilterAbstract } from '../../dynamic-type-field-filter-abstract'

@injectable()
export class DynamicTypeFieldFilterCheckbox extends DynamicTypeFieldFilterAbstract {
id = 'checkbox'

getFieldFilterType (): string {
return 'system.string'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That should work for assets, since he will just fallback to the frontend type "metadata.checkbox".

But not sure how this will behave for data-objects, I guess we need some kind of new filter here:
https://github.com/pimcore/studio-backend-bundle/blob/1.x/doc/03_Grid.md#columnfilter

Something like system.checkbox?
I'm pretty sue @ValeriaMaltseva and @martineiber can help you here.

}

getFieldFilterComponent (props: DynamicTypeFieldFilterCheckboxProps): ReactElement<DynamicTypeFieldFilterCheckboxProps> {
return (
<DynamicTypeFieldFilterCheckboxComponent { ...props } />
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/**
* 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 { injectable } from 'inversify'
import React, { type ReactElement } from 'react'
import { DynamicTypeFieldFilterTextAreaComponent, type DynamicTypeFieldFilterTextAreaProps } from '../../components/dynamic-type-field-filter-text-area-component'
import { DynamicTypeFieldFilterAbstract } from '../../dynamic-type-field-filter-abstract'

@injectable()
export class DynamicTypeFieldFilterTextArea extends DynamicTypeFieldFilterAbstract {
id = 'textarea'

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

getFieldFilterComponent (props: DynamicTypeFieldFilterTextAreaProps): ReactElement<DynamicTypeFieldFilterTextAreaProps> {
return (
<DynamicTypeFieldFilterTextAreaComponent { ...props } />
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class DynamicTypeMetaDataCheckbox extends DynamicTypeMetadataAbstract {
visibleInTypeSelection: boolean = true

@inject(serviceIds['DynamicTypes/GridCell/Checkbox']) protected dynamicTypeGridCellType: DynamicTypeGridCellAbstract
@inject(serviceIds['DynamicTypes/FieldFilter/Text']) protected dynamicTypeFieldFilterType: DynamicTypeFieldFilterAbstract
@inject(serviceIds['DynamicTypes/FieldFilter/Checkbox']) protected dynamicTypeFieldFilterType: DynamicTypeFieldFilterAbstract

getVersionPreviewComponent (data: boolean | null): React.JSX.Element {
return <span>{ data === true ? '✓' : '-' }</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class DynamicTypeMetaDataTextarea extends DynamicTypeMetadataAbstract {
visibleInTypeSelection: boolean = true

@inject(serviceIds['DynamicTypes/GridCell/Textarea']) protected dynamicTypeGridCellType: DynamicTypeGridCellAbstract
@inject(serviceIds['DynamicTypes/FieldFilter/Text']) protected dynamicTypeFieldFilterType: DynamicTypeFieldFilterAbstract
@inject(serviceIds['DynamicTypes/FieldFilter/Textarea']) protected dynamicTypeFieldFilterType: DynamicTypeFieldFilterAbstract

getVersionPreviewComponent (data: string): JSX.Element {
return respectLineBreak(data, false)
Expand Down
3 changes: 3 additions & 0 deletions assets/js/src/core/modules/element/dynamic-types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ import { type DynamicTypeObjectObject } from './definitions/objects/types/dynami
import { type DynamicTypeObjectVariant } from './definitions/objects/types/dynamic-type-object-variant'
import { type DynamicTypeObjectDataClassificationStore } from './definitions/objects/data-related/types/dynamic-type-object-data-classification-store'
import { type DynamicTypeGridCellBoolean } from './definitions/grid-cell/types/boolean/dynamic-type-grid-cell-boolean'
import { type DynamicTypeFieldFilterCheckbox } from './definitions/field-filters/types/checkbox/dynamic-type-field-filter-checkbox'

moduleSystem.registerModule({
onInit () {
Expand All @@ -159,9 +160,11 @@ moduleSystem.registerModule({
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<DynamicTypeFieldFilterText>(serviceIds['DynamicTypes/FieldFilter/Textarea']))
fieldFilterRegistry.registerDynamicType(container.get<DynamicTypeFieldFilterNumber>(serviceIds['DynamicTypes/FieldFilter/Number']))
fieldFilterRegistry.registerDynamicType(container.get<DynamicTypeFieldFilterSelect>(serviceIds['DynamicTypes/FieldFilter/Select']))
fieldFilterRegistry.registerDynamicType(container.get<DynamicTypeFieldFilterDatetime>(serviceIds['DynamicTypes/FieldFilter/Datetime']))
fieldFilterRegistry.registerDynamicType(container.get<DynamicTypeFieldFilterCheckbox>(serviceIds['DynamicTypes/FieldFilter/Checkbox']))

const batchEditRegistry = container.get<DynamicTypeBatchEditRegistry>(serviceIds['DynamicTypes/BatchEditRegistry'])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ export const FieldFiltersContainer = (): React.JSX.Element => {
icon={ { value: 'new' } }
type='link'
>
{ t('listing.add-column') }
{t('listing.add-column')}
</IconTextButton>
</Dropdown>
</Space>
Expand Down
1 change: 1 addition & 0 deletions assets/js/src/sdk/modules/element/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export * from '@Pimcore/modules/element/dynamic-types/definitions/batch-edits/ty
export * from '@Pimcore/modules/element/dynamic-types/definitions/batch-edits/types/text/dynamic-type-batch-edit-text'
export * from '@Pimcore/modules/element/dynamic-types/definitions/batch-edits/types/text/dynamic-type-batch-edit-text-area'

export * from '@Pimcore/modules/element/dynamic-types/definitions/field-filters/components/dynamic-type-field-filter-checkbox-component'
export * from '@Pimcore/modules/element/dynamic-types/definitions/field-filters/components/dynamic-type-field-filter-datetime-component'
export * from '@Pimcore/modules/element/dynamic-types/definitions/field-filters/components/dynamic-type-field-filter-number-component'
export * from '@Pimcore/modules/element/dynamic-types/definitions/field-filters/components/dynamic-type-field-filter-select-component'
Expand Down
17 changes: 0 additions & 17 deletions public/build/567b0ed8-c2d3-4d0c-aa6f-28e1cb44921b/entrypoints.json

This file was deleted.

Loading