Skip to content
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

Fix the logic of the includeDescendants filter #726

Open
wants to merge 2 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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import type { FilterOptions, TagFilterOptions } from '../types/filterTypes'

export const DEFAULT_IS_INCLUDE_DESCENDANTS_VALUE: boolean = false
export const DEFAULT_IS_INCLUDE_DESCENDANTS_VALUE: boolean = true

export const defaultFilterOptions: FilterOptions = {
columnFilters: [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import React, { createContext, useEffect, useMemo, useState } from 'react'
import { type AssetGetGridApiResponse, type GridColumnConfiguration, type GridDetailedConfiguration } from '@Pimcore/modules/asset/asset-api-slice-enhanced'
import { type FilterOptions, type TagFilterOptions } from './types/filterTypes'
import { defaultFilterOptions } from './constants/filters'
import { DEFAULT_IS_INCLUDE_DESCENDANTS_VALUE, defaultFilterOptions } from './constants/filters'
import { type RowSelectionState, type SortingState } from '@tanstack/react-table'
import { isEmptyValue } from '@Pimcore/utils/type-utils'

Expand Down Expand Up @@ -127,7 +127,7 @@ export const ListFilterOptionsProvider = ({ children }: ListFilterOptionsProvide
}

return acc
}, { columnFilters: [], includeDescendants: false }), [filterOptionsMap])
}, { columnFilters: [], includeDescendants: DEFAULT_IS_INCLUDE_DESCENDANTS_VALUE }), [filterOptionsMap])

return useMemo(() => (
<ListFilterOptionsContext.Provider value={ { filterOptions, setFilterOptions } }>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const FilterContainerInner = (): React.JSX.Element => {

const { resetFilters, filterOptions, filterError } = useFilters()
const { setFilterOptions } = useListFilterOptions()
const { isIncludeDescendants, setIsIncludeDescendants, handleChangeIsIncludeDescendants } = useIncludeDescendantsFilter()
const { isShowOnlyDirectChildren, setIsShowOnlyDirectChildren, handleChangeIsIncludeDescendants } = useIncludeDescendantsFilter()
const {
pqlQueryValue,
setPQLQueryValue,
Expand All @@ -62,7 +62,7 @@ export const FilterContainerInner = (): React.JSX.Element => {
const handleApplyClick = (): void => { setFilterOptions('filters', filterOptions) }

const handleResetAllFiltersClick = (): void => {
setIsIncludeDescendants(DEFAULT_IS_INCLUDE_DESCENDANTS_VALUE)
setIsShowOnlyDirectChildren(!DEFAULT_IS_INCLUDE_DESCENDANTS_VALUE)
setPQLQueryValue('')
setSearchValue('')
setIsShowPQLQueryError(false)
Expand Down Expand Up @@ -131,7 +131,7 @@ export const FilterContainerInner = (): React.JSX.Element => {
/>

<Checkbox
checked={ isIncludeDescendants }
checked={ isShowOnlyDirectChildren }
onChange={ handleChangeIsIncludeDescendants }
>
only direct children
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,27 @@ import type { CheckboxChangeEvent } from 'antd/es/checkbox'
import { useFilters } from './use-filters'

interface IUseIncludeDescendantsFilterHookReturn {
isIncludeDescendants: boolean
setIsIncludeDescendants: (value: boolean) => void
isShowOnlyDirectChildren: boolean
setIsShowOnlyDirectChildren: (value: boolean) => void
handleChangeIsIncludeDescendants: (e: CheckboxChangeEvent) => void
}

export const useIncludeDescendantsFilter = (): IUseIncludeDescendantsFilterHookReturn => {
const [isIncludeDescendants, setIsIncludeDescendants] = useState<boolean>(false)
const [isShowOnlyDirectChildren, setIsShowOnlyDirectChildren] = useState<boolean>(false)

const { updateIsIncludeDescendants } = useFilters()

const handleChangeIsIncludeDescendants = (e: CheckboxChangeEvent): void => {
const includeDescendantsValue = e.target.checked
const showOnlyDirectChildValue = e.target.checked
const includeDescendantsValue = !showOnlyDirectChildValue

setIsIncludeDescendants(includeDescendantsValue)
setIsShowOnlyDirectChildren(showOnlyDirectChildValue)
updateIsIncludeDescendants(includeDescendantsValue)
}

return {
isIncludeDescendants,
setIsIncludeDescendants,
isShowOnlyDirectChildren,
setIsShowOnlyDirectChildren,
handleChangeIsIncludeDescendants
}
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"entrypoints": {
"main": {
"js": [
"/bundles/pimcorestudioui/build/534df091-d0b1-4d64-ac7e-401ffc66fc2d/main.js"
]
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"bundles/pimcorestudioui/build/534df091-d0b1-4d64-ac7e-401ffc66fc2d/main.js": "/bundles/pimcorestudioui/build/534df091-d0b1-4d64-ac7e-401ffc66fc2d/main.js"
}

Large diffs are not rendered by default.

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions public/build/6c2d4651-90a5-4e5d-892a-081dcf4d5c62/entrypoints.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"entrypoints": {
"core-dll": {
"css": [
"/bundles/pimcorestudioui/build/6c2d4651-90a5-4e5d-892a-081dcf4d5c62/core-dll.css"
],
"js": [
"/bundles/pimcorestudioui/build/6c2d4651-90a5-4e5d-892a-081dcf4d5c62/core-dll.js"
]
}
}
}
Loading