Skip to content

Commit

Permalink
Merge branch '1.x' into 753-missing-asset-context-menu-actions-upload…
Browse files Browse the repository at this point in the history
…-new-version

# Conflicts:
#	translations/studio.en.yaml
  • Loading branch information
Corepex committed Dec 2, 2024
2 parents a513397 + 033188c commit c27a721
Show file tree
Hide file tree
Showing 52 changed files with 2,328 additions and 1,904 deletions.
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 @@ -36,6 +36,7 @@ import { DynamicTypeFieldFilterDatetime } from '@Pimcore/modules/element/dynamic
import { DynamicTypeGridCellText } from '@Pimcore/modules/element/dynamic-types/defintinitions/grid-cell/types/text/dynamic-type-grid-cell-text'
import { DynamicTypeGridCellRegistry } from '@Pimcore/modules/element/dynamic-types/defintinitions/grid-cell/dynamic-type-grid-cell-registry'
import { DynamicTypeGridCellTextarea } from '@Pimcore/modules/element/dynamic-types/defintinitions/grid-cell/types/textarea/dynamic-type-grid-cell-text'
import { DynamicTypeGridCellNumber } from '@Pimcore/modules/element/dynamic-types/defintinitions/grid-cell/types/number/dynamic-type-grid-cell-number'
import { DynamicTypeGridCellSelect } from '@Pimcore/modules/element/dynamic-types/defintinitions/grid-cell/types/select/dynamic-type-grid-cell-select'
import { DynamicTypeGridCellCheckbox } from '@Pimcore/modules/element/dynamic-types/defintinitions/grid-cell/types/checkbox/dynamic-type-grid-cell-checkbox'
import { DynamicTypeGridCellDate } from '@Pimcore/modules/element/dynamic-types/defintinitions/grid-cell/types/date/dynamic-type-grid-cell-date'
Expand Down Expand Up @@ -107,6 +108,7 @@ import { DynamicTypeObjectDataGeoBounds } from '@Pimcore/modules/element/dynamic
import { DynamicTypeObjectDataGeoPolygon } from '@Pimcore/modules/element/dynamic-types/defintinitions/objects/data-related/types/dynamic-type-object-data-geopolygon'
import { DynamicTypeObjectDataGeoPolyLine } from '@Pimcore/modules/element/dynamic-types/defintinitions/objects/data-related/types/dynamic-type-object-data-geopolyline'
import { DynamicTypeObjectDataManyToManyRelation } from '@Pimcore/modules/element/dynamic-types/defintinitions/objects/data-related/types/dynamic-type-object-data-many-to-many-relation'
import { DynamicTypeObjectDataStructuredTable } from '@Pimcore/modules/element/dynamic-types/defintinitions/objects/data-related/types/dynamic-type-object-data-structured-table'
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'
Expand Down Expand Up @@ -164,6 +166,7 @@ container.bind(serviceIds['DynamicTypes/BatchEdit/TextArea']).to(DynamicTypeBatc
container.bind(serviceIds['DynamicTypes/GridCellRegistry']).to(DynamicTypeGridCellRegistry).inSingletonScope()
container.bind(serviceIds['DynamicTypes/GridCell/Text']).to(DynamicTypeGridCellText).inSingletonScope()
container.bind(serviceIds['DynamicTypes/GridCell/Textarea']).to(DynamicTypeGridCellTextarea).inSingletonScope()
container.bind(serviceIds['DynamicTypes/GridCell/Number']).to(DynamicTypeGridCellNumber).inSingletonScope()
container.bind(serviceIds['DynamicTypes/GridCell/Select']).to(DynamicTypeGridCellSelect).inSingletonScope()
container.bind(serviceIds['DynamicTypes/GridCell/Checkbox']).to(DynamicTypeGridCellCheckbox).inSingletonScope()
container.bind(serviceIds['DynamicTypes/GridCell/Date']).to(DynamicTypeGridCellDate).inSingletonScope()
Expand Down Expand Up @@ -248,6 +251,7 @@ container.bind(serviceIds['DynamicTypes/ObjectData/GeoBounds']).to(DynamicTypeOb
container.bind(serviceIds['DynamicTypes/ObjectData/GeoPolygon']).to(DynamicTypeObjectDataGeoPolygon).inSingletonScope()
container.bind(serviceIds['DynamicTypes/ObjectData/GeoPolyLine']).to(DynamicTypeObjectDataGeoPolyLine).inSingletonScope()
container.bind(serviceIds['DynamicTypes/ObjectData/ManyToManyRelation']).to(DynamicTypeObjectDataManyToManyRelation).inSingletonScope()
container.bind(serviceIds['DynamicTypes/ObjectData/StructuredTable']).to(DynamicTypeObjectDataStructuredTable).inSingletonScope()
container.bind(serviceIds['DynamicTypes/ObjectData/Block']).to(DynamicTypeObjectDataBlock).inSingletonScope()
container.bind(serviceIds['DynamicTypes/ObjectData/LocalizedFields']).to(DynamicTypeObjectDataLocalizedFields).inSingletonScope()
container.bind(serviceIds['DynamicTypes/ObjectData/FieldCollection']).to(DynamicTypeObjectDataFieldCollection).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 @@ -61,6 +61,7 @@ export const serviceIds = {

'DynamicTypes/GridCell/Text': 'DynamicTypes/GridCell/Text',
'DynamicTypes/GridCell/Textarea': 'DynamicTypes/GridCell/Textarea',
'DynamicTypes/GridCell/Number': 'DynamicTypes/GridCell/Number',
'DynamicTypes/GridCell/Select': 'DynamicTypes/GridCell/Select',
'DynamicTypes/GridCell/Checkbox': 'DynamicTypes/GridCell/Checkbox',
'DynamicTypes/GridCell/Date': 'DynamicTypes/GridCell/Date',
Expand Down Expand Up @@ -142,6 +143,7 @@ export const serviceIds = {
'DynamicTypes/ObjectData/GeoPolygon': 'DynamicTypes/ObjectData/GeoPolygon',
'DynamicTypes/ObjectData/GeoPolyLine': 'DynamicTypes/ObjectData/GeoPolyLine',
'DynamicTypes/ObjectData/ManyToManyRelation': 'DynamicTypes/ObjectData/ManyToManyRelation',
'DynamicTypes/ObjectData/StructuredTable': 'DynamicTypes/ObjectData/StructuredTable',
'DynamicTypes/ObjectData/Block': 'DynamicTypes/ObjectData/Block',
'DynamicTypes/ObjectData/LocalizedFields': 'DynamicTypes/ObjectData/LocalizedFields',
'DynamicTypes/ObjectData/FieldCollection': 'DynamicTypes/ObjectData/FieldCollection',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export interface TreeContextMenuProps {
export interface TreeProps {
nodeId: number
nodeApiHook: any
maxItemsPerNode: number
maxItemsPerNode?: number

renderNode: ElementType<TreeNodeProps>
renderNodeContent: ElementType<TreeNodeContentProps>
Expand Down
10 changes: 7 additions & 3 deletions assets/js/src/core/components/grid/grid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
useReactTable
} from '@tanstack/react-table'
import React, { useEffect, useMemo, useRef, useState } from 'react'
import { isEmpty } from 'lodash'
import { useStyles } from './grid.styles'
import { Resizer } from './resizer/resizer'
import { DefaultCell } from './columns/default-cell'
Expand Down Expand Up @@ -149,9 +150,12 @@ export const Grid = ({ enableMultipleRowSelection = false, modifiedCells = [], s

if (typeof autoColumnRef.current?.clientWidth !== 'undefined') {
newValue.startSize = autoColumnRef.current?.clientWidth
newValue.columnSizingStart.forEach(columnSizing => {
columnSizing[1] = columnWidth
})

if (!isEmpty(newValue?.columnSizingStart)) {
newValue.columnSizingStart.forEach(columnSizing => {
columnSizing[1] = columnWidth
})
}
}

setColumnSizingInfo(newValue)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { verifyUpdate } from '@Pimcore/modules/element/editor/shared-tab-manager
import { type CustomMetadata } from '@Pimcore/modules/asset/draft/hooks/use-custom-metadata'
import { Box } from '@Pimcore/components/box/box'
import { Flex } from '@Pimcore/components/flex/flex'
import { uuid } from '@Pimcore/utils/uuid'

interface CustomMetadataWithActions extends CustomMetadata {
actions: React.ReactNode
Expand All @@ -45,7 +46,7 @@ export const CustomMetadataTable = ({ showDuplicateEntryModal, showMandatoryModa
return data.map((item) => {
return {
...item,
rowId: crypto.randomUUID()
rowId: uuid()
}
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import { type CustomMetadata } from '@Pimcore/modules/asset/draft/hooks/use-cust
import { Space } from '@Pimcore/components/space/space'
import { Select } from '@Pimcore/components/select/select'
import { type DynamicTypeMetaDataRegistry } from '@Pimcore/modules/element/dynamic-types/defintinitions/meta-data/dynamic-type-metadata-registry'
import { uuid } from '@Pimcore/utils/uuid'

export const CustomMetadataTabContainer = (): React.JSX.Element => {
const { t } = useTranslation()
Expand Down Expand Up @@ -100,7 +101,7 @@ export const CustomMetadataTabContainer = (): React.JSX.Element => {
type: typeSelectValue.current,
language: languageSelectValue.current,
data: null,
rowId: crypto.randomUUID()
rowId: uuid()
}

addCustomMetadata(newCustomMetadata)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ interface NodeApiHookReturnType {
export const useNodeApiHook = (node: TreeNodeProps): NodeApiHookReturnType => {
const [additionalQueryParams, setAdditionalQueryParams] = useState<AssetTreeAdditionalTreeProps>()
const { maxItemsPerNode } = useContext(TreeContext)
const apiHookResult = useAssetGetTreeQuery({ parentId: parseInt(node.id), pageSize: maxItemsPerNode, page: 1, ...additionalQueryParams })
const apiHookResult = useAssetGetTreeQuery({ parentId: parseInt(node.id), pageSize: maxItemsPerNode!, page: 1, ...additionalQueryParams })

function dataTransformer (data: AssetGetTreeApiResponse): DataTransformerReturnType {
const nodes: TreeNodeProps[] = []
Expand Down
4 changes: 3 additions & 1 deletion assets/js/src/core/modules/asset/tree/tree-container.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@ import { useAssetHelper } from '@Pimcore/modules/asset/hooks/use-asset-helper'
import { SearchContainer } from './search/search-container'
import { withDraggable } from './node/with-draggable'
import { AssetTreeContextMenu } from '@Pimcore/modules/asset/tree/context-menu/context-menu'
import { useSettings } from '@Pimcore/modules/app/settings/hooks/use-settings'

export interface TreeContainerProps {
id: number
}

const TreeContainer = ({ id = 1, ...props }: TreeContainerProps): React.JSX.Element => {
const { openAsset } = useAssetHelper()
const { asset_tree_paging_limit: assetTreePagingLimit } = useSettings()

async function onSelect (node: TreeNodeProps): Promise<void> {
openAsset({
Expand All @@ -39,7 +41,7 @@ const TreeContainer = ({ id = 1, ...props }: TreeContainerProps): React.JSX.Elem
return (
<ElementTree
contextMenu={ AssetTreeContextMenu }
maxItemsPerNode={ 20 }
maxItemsPerNode={ assetTreePagingLimit }
nodeApiHook={ useNodeApiHook }
nodeId={ id }
onSelect={ onSelect }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ interface NodeApiHookReturnType {
export const useNodeApiHook = (node: TreeNodeProps): NodeApiHookReturnType => {
const [additionalQueryParams, setAdditionalQueryParams] = useState<DataObjectTreeAdditionalTreeProps>()
const { maxItemsPerNode } = useContext(TreeContext)
const apiHookResult = useDataObjectGetTreeQuery({ parentId: parseInt(node.id), pageSize: maxItemsPerNode, page: 1, ...additionalQueryParams })
const apiHookResult = useDataObjectGetTreeQuery({ parentId: parseInt(node.id), pageSize: maxItemsPerNode!, page: 1, ...additionalQueryParams })

function dataTransformer (data: DataObjectGetTreeApiResponse): DataTransformerReturnType {
const nodes: TreeNodeProps[] = []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@ import { withDraggable } from './node/with-draggable'
import { useDataObjectHelper } from '@Pimcore/modules/data-object/hooks/use-data-object-helper'
import { DataObjectTreeContextMenu } from '@Pimcore/modules/data-object/tree/context-menu/context-menu'
import { PagerContainer } from '@Pimcore/modules/element/tree/pager/pager-container'
import { useSettings } from '@Pimcore/modules/app/settings/hooks/use-settings'

export interface TreeContainerProps {
id: number
}

const TreeContainer = ({ id = 1, ...props }: TreeContainerProps): React.JSX.Element => {
const { openDataObject } = useDataObjectHelper()
const { object_tree_paging_limit: dataObjectTreePagingLimit } = useSettings()

async function onSelect (node: TreeNodeProps): Promise<void> {
openDataObject({
Expand All @@ -39,7 +41,7 @@ const TreeContainer = ({ id = 1, ...props }: TreeContainerProps): React.JSX.Elem
return (
<ElementTree
contextMenu={ DataObjectTreeContextMenu }
maxItemsPerNode={ 20 }
maxItemsPerNode={ dataObjectTreePagingLimit }
nodeApiHook={ useNodeApiHook }
nodeId={ id }
onSelect={ onSelect }
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* 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
*/

import { createStyles } from 'antd-style'

export const useStyle = createStyles(({ token, css }) => {
return {
'number-cell': css`
padding: 4px;
`
}
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/**
* 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
*/

import React, { useEffect, useRef, useState } from 'react'
import { InputNumber } from 'antd'
import { useStyle } from './number-cell.styles'
import { type DefaultCellProps } from '@Pimcore/components/grid/columns/default-cell'
import { useEditMode } from '@Pimcore/components/grid/edit-mode/use-edit-mode'
import cn from 'classnames'
import type { InputNumberRef } from 'rc-input-number'

export interface NumberCellProps extends DefaultCellProps {}

export const NumberCell = (props: NumberCellProps): React.JSX.Element => {
const { isInEditMode, disableEditMode, fireOnUpdateCellDataEvent } = useEditMode(props)
const [value, setValue] = useState<number | null>(props.getValue() as number)
const { styles } = useStyle()
const element = useRef<InputNumberRef>(null)

useEffect(() => {
if (isInEditMode) {
element.current?.focus()
}
}, [isInEditMode])

function saveValue (): void {
fireOnUpdateCellDataEvent(value)
disableEditMode()
}

function onKeyDown (event: React.KeyboardEvent<HTMLInputElement>): void {
if (event.key === 'Enter') {
saveValue()
}
}

function onBlur (): void {
saveValue()
}

function getCellContent (): React.JSX.Element {
if (!isInEditMode) {
return (
<>
{ props.getValue() }
</>
)
}

return (
<InputNumber
className="w-full"
defaultValue={ props.getValue() }
onBlur={ onBlur }
onChange={ setValue }
onKeyDown={ onKeyDown }
ref={ element }
value={ value }
/>
)
}

return (
<div className={ cn(styles['number-cell'], 'default-cell__content') }>
{ getCellContent() }
</div>
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
* 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
*/

import React, { type ReactElement } from 'react'
import { type AbstractGridCellDefinition, DynamicTypeGridCellAbstract } from '../../dynamic-type-grid-cell-abstract'
import { NumberCell } from '../../components/number/number-cell'
import { injectable } from 'inversify'

@injectable()
export class DynamicTypeGridCellNumber extends DynamicTypeGridCellAbstract {
readonly id = 'number'

getGridCellComponent (props: AbstractGridCellDefinition): ReactElement<AbstractGridCellDefinition> {
return <NumberCell { ...props } />
}
}
Loading

0 comments on commit c27a721

Please sign in to comment.