Skip to content

Commit

Permalink
Merge branch '1.x' of github.com:pimcore/studio-ui-bundle into 175-gr…
Browse files Browse the repository at this point in the history
…id-config
  • Loading branch information
vin0401 committed Nov 25, 2024
2 parents 0687016 + d449a88 commit 9f34faa
Show file tree
Hide file tree
Showing 57 changed files with 2,698 additions and 108 deletions.
32 changes: 28 additions & 4 deletions assets/js/src/core/app/config/services/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { ComponentRegistry } from '@Pimcore/modules/app/component-registry/compo
import { ObjectTabManager } from '@Pimcore/modules/data-object/editor/types/object/tab-manager/object-tab-manager'
import { DynamicTypeFieldFilterRegistry } from '@Pimcore/modules/element/dynamic-types/defintinitions/field-filters/dynamic-type-field-filter-registry'
import { DynamicTypeListingRegistry } from '@Pimcore/modules/element/dynamic-types/defintinitions/listing/dynamic-type-listing-registry'
import { DynamicTypeListingAssetLink } from '@Pimcore/modules/element/dynamic-types/defintinitions/listing/types/dynamic-type-listing-asset-link'
import { serviceIds } from '@Pimcore/app/config/services/service-ids'
import { DynamicTypeFieldFilterText } from '@Pimcore/modules/element/dynamic-types/defintinitions/field-filters/types/text/dynamic-type-field-filter-text'
import { DynamicTypeFieldFilterNumber } from '@Pimcore/modules/element/dynamic-types/defintinitions/field-filters/types/number/dynamic-type-field-filter-number'
Expand Down Expand Up @@ -104,10 +105,27 @@ import { DynamicTypeObjectDataGeoPolygon } from '@Pimcore/modules/element/dynami
import { DynamicTypeObjectDataGeoPolyLine } from '@Pimcore/modules/element/dynamic-types/defintinitions/objects/data-related/types/dynamic-type-object-data-geopolyline'
import { DynamicTypeObjectDataBlock } from '@Pimcore/modules/element/dynamic-types/defintinitions/objects/data-related/types/dynamic-type-object-data-block'
import { DynamicTypeObjectDataLocalizedFields } from '@Pimcore/modules/element/dynamic-types/defintinitions/objects/data-related/types/dynamic-type-object-data-localized-fields'
import { DynamicTypeGridCellAsset } from '@Pimcore/modules/element/dynamic-types/defintinitions/grid-cell/types/asset/dynamic-type-grid-cell-asset'
import { DynamicTypeGridCellObject } from '@Pimcore/modules/element/dynamic-types/defintinitions/grid-cell/types/object/dynamic-type-grid-cell-object'
import { DynamicTypeGridCellDocument } from '@Pimcore/modules/element/dynamic-types/defintinitions/grid-cell/types/document/dynamic-type-grid-cell-document'
import { DynamicTypeGridCellLanguageSelect } from '@Pimcore/modules/element/dynamic-types/defintinitions/grid-cell/types/language-select/dynamic-type-grid-cell-language-select'
import {
DynamicTypeBatchEditRegistry
} from '@Pimcore/modules/element/dynamic-types/defintinitions/batch-edits/dynamic-type-batch-edit-registry'
import {
DynamicTypeBatchEditText
} from '@Pimcore/modules/element/dynamic-types/defintinitions/batch-edits/types/text/dynamic-type-batch-edit-text'
import {
DynamicTypeBatchEditTextArea
} from '@Pimcore/modules/element/dynamic-types/defintinitions/batch-edits/types/text/dynamic-type-batch-edit-text-area'
import {
DynamicTypeGridCellAsset
} from '@Pimcore/modules/element/dynamic-types/defintinitions/grid-cell/types/asset/dynamic-type-grid-cell-asset'
import {
DynamicTypeGridCellObject
} from '@Pimcore/modules/element/dynamic-types/defintinitions/grid-cell/types/object/dynamic-type-grid-cell-object'
import {
DynamicTypeGridCellDocument
} from '@Pimcore/modules/element/dynamic-types/defintinitions/grid-cell/types/document/dynamic-type-grid-cell-document'
import {
DynamicTypeGridCellLanguageSelect
} from '@Pimcore/modules/element/dynamic-types/defintinitions/grid-cell/types/language-select/dynamic-type-grid-cell-language-select'

// Widget manager
container.bind(serviceIds.widgetManager).to(WidgetRegistry).inSingletonScope()
Expand Down Expand Up @@ -139,6 +157,11 @@ container.bind(serviceIds['DynamicTypes/FieldFilter/Number']).to(DynamicTypeFiel
container.bind(serviceIds['DynamicTypes/FieldFilter/Select']).to(DynamicTypeFieldFilterSelect).inSingletonScope()
container.bind(serviceIds['DynamicTypes/FieldFilter/Datetime']).to(DynamicTypeFieldFilterDatetime).inSingletonScope()

// dynamic types batch edit
container.bind(serviceIds['DynamicTypes/BatchEditRegistry']).to(DynamicTypeBatchEditRegistry).inSingletonScope()
container.bind(serviceIds['DynamicTypes/BatchEdit/Text']).to(DynamicTypeBatchEditText).inSingletonScope()
container.bind(serviceIds['DynamicTypes/BatchEdit/TextArea']).to(DynamicTypeBatchEditTextArea).inSingletonScope()

// dynamic types grid cells
container.bind(serviceIds['DynamicTypes/GridCellRegistry']).to(DynamicTypeGridCellRegistry).inSingletonScope()
container.bind(serviceIds['DynamicTypes/GridCell/Text']).to(DynamicTypeGridCellText).inSingletonScope()
Expand Down Expand Up @@ -169,6 +192,7 @@ container.bind(serviceIds['DynamicTypes/GridCell/LanguageSelect']).to(DynamicTyp

// dynamic types listing
container.bind(serviceIds['DynamicTypes/ListingRegistry']).to(DynamicTypeListingRegistry).inSingletonScope()
container.bind(serviceIds['DynamicTypes/Listing/AssetLink']).to(DynamicTypeListingAssetLink).inSingletonScope()

// Metadata registry
container.bind(serviceIds['DynamicTypes/MetadataRegistry']).to(DynamicTypeMetaDataRegistry).inSingletonScope()
Expand Down
5 changes: 5 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 @@ -13,6 +13,7 @@

export const dynamicTypeRegistriesServiceIds = {
'DynamicTypes/FieldFilterRegistry': 'DynamicTypes/FieldFilterRegistry',
'DynamicTypes/BatchEditRegistry': 'DynamicTypes/BatchEditRegistry',
'DynamicTypes/GridCellRegistry': 'DynamicTypes/GridCellRegistry',
'DynamicTypes/ListingRegistry': 'DynamicTypes/ListingRegistry',
'DynamicTypes/MetadataRegistry': 'DynamicTypes/MetadataRegistry',
Expand Down Expand Up @@ -55,6 +56,9 @@ export const serviceIds = {
'DynamicTypes/FieldFilter/Select': 'DynamicTypes/FieldFilter/Select',
'DynamicTypes/FieldFilter/Datetime': 'DynamicTypes/FieldFilter/Datetime',

'DynamicTypes/BatchEdit/Text': 'DynamicTypes/BatchEdit/Text',
'DynamicTypes/BatchEdit/TextArea': 'DynamicTypes/BatchEdit/TextArea',

'DynamicTypes/GridCell/Text': 'DynamicTypes/GridCell/Text',
'DynamicTypes/GridCell/Textarea': 'DynamicTypes/GridCell/Textarea',
'DynamicTypes/GridCell/Select': 'DynamicTypes/GridCell/Select',
Expand Down Expand Up @@ -82,6 +86,7 @@ export const serviceIds = {
'DynamicTypes/GridCell/LanguageSelect': 'DynamicTypes/GridCell/LanguageSelect',

'DynamicTypes/Listing/Text': 'DynamicTypes/Listing/Text',
'DynamicTypes/Listing/AssetLink': 'DynamicTypes/Listing/AssetLink',
'DynamicTypes/Listing/Select': 'DynamicTypes/Listing/Select',

'DynamicTypes/Metadata/Asset': 'DynamicTypes/Metadata/Asset',
Expand Down
12 changes: 6 additions & 6 deletions assets/js/src/core/components/flex/flex.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
import React from 'react'
import { Flex as AntFlex, type FlexProps as AntFlexProps, theme } from 'antd'
import cn from 'classnames'
import { isString, isNumber, isObject } from 'lodash'
import { mapGapToTokenValue } from '@Pimcore/components/flex/utils/mapGapToTokenValue'
import { isString, isNumber, isObject } from '@Pimcore/utils/type-utils'
import { useStyles } from '@Pimcore/components/flex/flex.styles'
import { type GapRowColGroupType, type GapType } from '@Pimcore/types/components/types'
import { type GapType } from '@Pimcore/types/components/types'

export interface FlexProps extends Omit<AntFlexProps, 'gap'> {
gap?: GapType
Expand All @@ -43,17 +43,17 @@ export const Flex = ({ gap = 0, className, rootClassName, children, ...props }:
*/
function calculateGap (gap: GapType): { x: number, y: number } {
const getGapValue = (gap: GapType): number => {
return isNumber(gap) ? gap as number : mapGapToTokenValue({ token, gap })
return isNumber(gap) ? gap : mapGapToTokenValue({ token, gap })
}

if (isString(gap)) return { x: getGapValue(gap), y: getGapValue(gap) }

if (isNumber(gap)) return { x: gap as number, y: gap as number }
if (isNumber(gap)) return { x: gap, y: gap }

if (isObject(gap)) {
return {
x: getGapValue((gap as GapRowColGroupType).x),
y: getGapValue((gap as GapRowColGroupType).y)
x: getGapValue((gap).x),
y: getGapValue((gap).y)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
import React, { useState } from 'react'
import type { FetchBaseQueryError } from '@reduxjs/toolkit/query'
import { Tooltip } from 'antd'
import { isObject } from 'lodash'
import TextArea from 'antd/es/input/TextArea'
import { Flex } from '@Pimcore/components/flex/flex'
import { Text } from '@Pimcore/components/text/text'
import { Alert } from '@Pimcore/components/alert/alert'
import { isObject } from '@Pimcore/utils/type-utils'
import { useStyles } from './pql-query-input.styles'
import { Icon } from '../icon/icon'

Expand All @@ -40,7 +40,7 @@ export const PQLQueryInput = ({ value, handleChange, handleBlur, errorData, isSh
const getDescription = (): string => {
const error = errorData?.data

if (error !== null && isObject(error) && 'message' in (error as object)) {
if (error !== null && isObject(error) && 'message' in error) {
return (error as { message: string }).message
}

Expand Down
8 changes: 4 additions & 4 deletions assets/js/src/core/components/select/select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import React, { forwardRef, useRef, useImperativeHandle, useState } from 'react'
import type { RefSelectProps } from 'antd/es/select'
import { Checkbox, Select as AntdSelect, type SelectProps as AntdSelectProps } from 'antd'
import cn from 'classnames'
import { isString, isEmpty } from 'lodash'
import { Icon } from '@Pimcore/components/icon/icon'
import { isEmptyValue, isString } from '@Pimcore/utils/type-utils'
import { useStyles } from './select.styles'

interface SelectProps extends AntdSelectProps {
Expand All @@ -35,7 +35,7 @@ export const Select = forwardRef<RefSelectProps, SelectProps>(({ customIcon, cus

const { styles } = useStyles({ width })

const withCustomIcon = !isEmptyValue(customIcon)
const withCustomIcon = !isEmpty(customIcon)
const isStatusWarning = status === 'warning'
const isStatusError = status === 'error'

Expand All @@ -55,8 +55,8 @@ export const Select = forwardRef<RefSelectProps, SelectProps>(({ customIcon, cus
const handleClick = (): void => { setIsActive(!isActive) }

const getSuffixIcon = (): React.JSX.Element => {
const isShowCustomIcon = !isEmptyValue(customArrowIcon) && isString(customArrowIcon)
const iconToShow = isShowCustomIcon ? customArrowIcon! : (isActive ? 'chevron-up' : 'chevron-down')
const isShowCustomIcon = !isEmpty(customArrowIcon) && isString(customArrowIcon)
const iconToShow = isShowCustomIcon ? customArrowIcon : (isActive ? 'chevron-up' : 'chevron-down')

return (
<Icon
Expand Down
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 @@ -14,14 +14,17 @@
import React from 'react'
import { ListContainerInner } from './list-container-inner'
import { ListProvider } from './list-provider'
import { DynamicTypeRegistryProvider } from '@Pimcore/modules/element/dynamic-types/registry/provider/dynamic-type-registry-provider'
import {
DynamicTypeRegistryProvider
} from '@Pimcore/modules/element/dynamic-types/registry/provider/dynamic-type-registry-provider'

const ListContainer = (): React.JSX.Element => {
return (
<ListProvider>
<DynamicTypeRegistryProvider serviceIds={ [
'DynamicTypes/MetadataRegistry',
'DynamicTypes/ListingRegistry'
'DynamicTypes/ListingRegistry',
'DynamicTypes/BatchEditRegistry'
] }
>
<ListContainerInner />
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 @@ -12,6 +12,7 @@
*/

import React from 'react'
import { isEmpty } from 'lodash'
import { useListGridAvailableColumns, getFormattedDropDownMenu } from '../../../hooks/use-list'
import { useDynamicTypeResolver } from '@Pimcore/modules/element/dynamic-types/resolver/hooks/use-dynamic-type-resolver'
import { Space } from 'antd'
Expand All @@ -21,7 +22,6 @@ import { type GridColumnConfiguration } from 'src/sdk/main'
import { FieldFiltersListContainer } from './field-filters-list-container'
import { useFilters } from '../hooks/use-filters'
import { Dropdown } from '@Pimcore/components/dropdown/dropdown'
import { isEmptyValue } from '@Pimcore/utils/type-utils'

const FILTER_FIELD_KEY_IGNORE_LIST = ['size']

Expand Down Expand Up @@ -60,7 +60,7 @@ export const FieldFiltersContainer = (): React.JSX.Element => {
>
<FieldFiltersListContainer columns={ columns } />

{!isEmptyValue(filteredDropDownMenu) && (
{!isEmpty(filteredDropDownMenu) && (
<Dropdown menu={ { items: getFormattedDropDownMenu(filteredDropDownMenu, handleColumnClick) } }>
<IconTextButton
icon={ { value: 'PlusCircleOutlined' } }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export interface DefaultFilterProps {

export const DefaultFilter = ({ column }: DefaultFilterProps): React.JSX.Element => {
const { frontendType, type } = column

const { getComponentRenderer } = useDynamicTypeResolver()
const { ComponentRenderer } = getComponentRenderer({ target: 'FIELD_FILTER', dynamicTypeIds: [type, frontendType!] })

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ import { Content } from '@Pimcore/components/content/content'
import {
DEFAULT_IS_INCLUDE_DESCENDANTS_VALUE
} from '@Pimcore/modules/asset/editor/types/folder/tab-manager/tabs/list/constants/filters'
import { isEmptyValue } from '@Pimcore/utils/type-utils'
import { isEmpty } from 'lodash'

export const FilterContainerInner = (): React.JSX.Element => {
const [isAdvancedMode, setIsAdvancedMode] = useState<boolean>(false)

const { resetFilters, filterOptions, filterError } = useFilters()
const { setFilterOptions } = useListFilterOptions()
const { isIncludeDescendants, setIsIncludeDescendants, handleChangeIsIncludeDescendants } = useIncludeDescendantsFilter()
const { isShowOnlyDirectChildren, setIsShowOnlyDirectChildren, handleChangeIsIncludeDescendants } = useIncludeDescendantsFilter()
const {
pqlQueryValue,
setPQLQueryValue,
Expand All @@ -54,15 +54,15 @@ export const FilterContainerInner = (): React.JSX.Element => {
const { searchValue, setSearchValue, handleChangeSearchValue, handleSaveSearchValue } = useSearchFilter()

useEffect(() => {
if (!isEmptyValue(filterError)) {
if (!isEmpty(filterError)) {
setIsShowPQLQueryError(true)
}
}, [filterError])

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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ import { Dropdown, type DropdownMenuProps } from '@Pimcore/components/dropdown/d
import React from 'react'
import { useTranslation } from 'react-i18next'
import { Tooltip } from 'antd'
import { isEmpty } from 'lodash'
import { IconTextButton } from '@Pimcore/components/icon-text-button/icon-text-button'
import { GridConfigList } from '../grid-config-list'
import { type IListGridConfigContext } from '../../../list-provider'
import { Compact } from '@Pimcore/components/compact/compact'
import { IconButton } from '@Pimcore/components/icon-button/icon-button'
import { isEmptyValue } from '@Pimcore/utils/type-utils'
import { Icon } from '@Pimcore/components/icon/icon'

export interface EditViewProps {
Expand Down Expand Up @@ -107,7 +107,7 @@ export const EditView = ({ onCancelClick, gridConfig, onApplyClick, onEditConfig
>
<GridConfigList columns={ columns } />

{!isEmptyValue(addColumnMenu) && (
{!isEmpty(addColumnMenu) && (
<Dropdown menu={ { items: addColumnMenu } }>
<IconTextButton
icon={ { value: 'PlusCircleOutlined' } }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export const BatchEditModal = ({ batchEditModalOpen, setBatchEditModalOpen }: Ba

const onColumnClick = (column: GridColumnConfiguration): void => {
const locale = column.locale ?? null
addOrUpdateBatchEdit(column.key, column.type, locale, column.localizable, '')
addOrUpdateBatchEdit(column.key, column.type, column.frontendType, locale, column.localizable, '')
}

const applyChanges = (): void => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import React, { useState, createContext, useMemo } from 'react'
export interface BatchEdit {
key: string
type: string
frontendType: string | undefined
locale: string | null
localizable: boolean
value: string
Expand Down
Loading

0 comments on commit 9f34faa

Please sign in to comment.