Skip to content

Commit

Permalink
reverted changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ValeriaMaltseva committed Nov 22, 2024
1 parent 0c00f12 commit a7220f0
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
/* eslint-disable max-lines */

import React, { createContext, useEffect, useMemo, useState } from 'react'
import { isEmpty } from 'lodash'
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 { type RowSelectionState, type SortingState } from '@tanstack/react-table'
import { isEmptyValue } from '@Pimcore/utils/type-utils'

interface ICommonListProviderProps {
children: React.ReactNode
Expand Down Expand Up @@ -122,7 +122,7 @@ export const ListFilterOptionsProvider = ({ children }: ListFilterOptionsProvide
const filterOptions = useMemo(() => Object.values(filterOptionsMap).reduce((acc, curr) => {
acc.columnFilters = [...acc.columnFilters as [], ...curr.columnFilters as []]

if (!isEmpty(curr.includeDescendants)) {
if (!isEmptyValue(curr.includeDescendants)) {
acc.includeDescendants = curr.includeDescendants
}

Expand Down
32 changes: 32 additions & 0 deletions assets/js/src/core/utils/type-utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/**
* Pimcore
*
* This source file is available under two different licenses:
* - Pimcore Open Core License (POCL)
* - Pimcore Commercial License (PCL)
* Full copyright and license information is available in
* LICENSE.md which is distributed with this source code.
*
* @copyright Copyright (c) Pimcore GmbH (http://www.pimcore.org)
* @license https://github.com/pimcore/studio-ui-bundle/blob/1.x/LICENSE.md POCL and PCL
*/

export const isEmptyValue = (value: unknown): boolean => {
if (value === null || value === undefined) {
return true
}

if (typeof value === 'object' && !Array.isArray(value)) {
return Object.keys(value).length === 0
}

if (typeof value === 'object' && Array.isArray(value)) {
return value.length === 0
}

if (typeof value === 'string') {
return value.trim().length === 0
}

return false
}

0 comments on commit a7220f0

Please sign in to comment.