Skip to content

Commit 4b5872c

Browse files
authored
[Tag Filtering] - Add Search (#3459)
* add tag filter search * expand tag folder when I am seraching but folder was collapsed * Automatic frontend build
1 parent 24461fd commit 4b5872c

747 files changed

Lines changed: 30092 additions & 6 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

assets/js/src/core/modules/asset/listing/decorator/tag-filter/view-layer/components/sidebar/tabs/tag-filters/tags-tree-filters-container.tsx

Lines changed: 41 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,32 +8,59 @@
88
* @license Pimcore Open Core License (POCL)
99
*/
1010

11-
import React, { type Key } from 'react'
11+
import React, { type Key, useState } from 'react'
1212
import { Content } from '@Pimcore/components/content/content'
1313
import { Flex } from '@Pimcore/components/flex/flex'
1414
import { TreeElement } from '@Pimcore/components/tree-element/tree-element'
15+
import { SearchInput } from '@Pimcore/components/search-input/search-input'
1516
import {
1617
createTreeStructure
1718
} from '@Pimcore/modules/element/editor/shared-tab-manager/tabs/tags/components/tags-tree/create-tree-structure'
1819
import {
1920
useTagGetCollectionQuery
2021
} from '@Pimcore/modules/element/editor/shared-tab-manager/tabs/tags/tags-api-slice-enhanced'
21-
export const TagsTreeFiltersContainer = ({ checkedKeys, setCheckedKeys }: { checkedKeys: any, setCheckedKeys: any }): React.JSX.Element => {
22+
import { isEmpty, isUndefined } from 'lodash'
23+
import { useTranslation } from 'react-i18next'
24+
25+
interface TagsTreeFiltersContainerProps {
26+
checkedKeys: Key[]
27+
setCheckedKeys: (keys: Key[]) => void
28+
}
29+
30+
export const TagsTreeFiltersContainer = ({ checkedKeys, setCheckedKeys }: TagsTreeFiltersContainerProps): React.JSX.Element => {
31+
const { t } = useTranslation()
32+
const [filter, setFilter] = useState<string>('')
33+
const [expandedKeys, setExpandedKeys] = useState<Key[]>([0])
2234
const { data: tags, isLoading: tagsLoading } = useTagGetCollectionQuery({
2335
page: 1,
24-
pageSize: 9999
36+
pageSize: 9999,
37+
filter
2538
})
2639

40+
const treeData = !isUndefined(tags?.items)
41+
? createTreeStructure({ tags: tags.items, loadingNodes: new Set<string>() })
42+
: []
43+
44+
const handleSearch = (value: string): void => {
45+
setFilter(value)
46+
47+
if (!isEmpty(value)) {
48+
setExpandedKeys((prevKeys) => {
49+
const hasRoot = prevKeys.some((key) => String(key) === '0')
50+
51+
return hasRoot ? prevKeys : [0, ...prevKeys]
52+
})
53+
}
54+
}
55+
2756
if (tagsLoading) {
2857
return <Content loading />
2958
}
3059

31-
if (tags?.items === undefined) {
60+
if (isUndefined(tags?.items)) {
3261
return <div>Failed to load tags</div>
3362
}
3463

35-
const treeData = createTreeStructure({ tags: tags.items, loadingNodes: new Set<string>() })
36-
3764
const handleCheck = (currentCheckedKeys: { checked: Key[], halfChecked: Key[] }): void => {
3865
const checkedKeysList = currentCheckedKeys.checked
3966

@@ -47,10 +74,18 @@ export const TagsTreeFiltersContainer = ({ checkedKeys, setCheckedKeys }: { chec
4774
gap={ 'small' }
4875
vertical
4976
>
77+
<SearchInput
78+
loading={ tagsLoading }
79+
onSearch={ handleSearch }
80+
placeholder={ t('search') }
81+
/>
82+
5083
<TreeElement
5184
checkStrictly
5285
checkedKeys={ { checked: checkedKeys, halfChecked: [] } }
86+
defaultExpandedKeys={ expandedKeys }
5387
onCheck={ handleCheck }
88+
onExpand={ (keys) => { setExpandedKeys(keys) } }
5489
treeData={ treeData }
5590
withCustomSwitcherIcon
5691
/>

public/build/0443ea0a-04ef-4091-826c-09c00ee310f0/documentEditorIframe.html

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/build/0443ea0a-04ef-4091-826c-09c00ee310f0/entrypoints.json

Lines changed: 22 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/build/0443ea0a-04ef-4091-826c-09c00ee310f0/exposeRemote.js

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/build/0443ea0a-04ef-4091-826c-09c00ee310f0/main.html

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/build/0443ea0a-04ef-4091-826c-09c00ee310f0/manifest.json

Lines changed: 33 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/build/0443ea0a-04ef-4091-826c-09c00ee310f0/mf-manifest.json

Lines changed: 43 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/build/0443ea0a-04ef-4091-826c-09c00ee310f0/mf-stats.json

Lines changed: 51 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)