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

Respecting width/height settings and scrollbar in table related data types #879

Merged
merged 4 commits into from
Jan 16, 2025
Merged
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 @@ -30,12 +30,16 @@ import { Box } from '@Pimcore/components/box/box'
import { useFormModal } from '@Pimcore/components/modal/form-modal/hooks/use-form-modal'
import cn from 'classnames'
import { useDownload } from '@Pimcore/modules/asset/actions/download/use-download'
import { toCssDimension } from '@Pimcore/utils/css'
import { Content } from '@Pimcore/components/content/content'

interface ManyToManyRelationGridProps {
value?: ManyToManyRelationValue | null
deleteItem: (id: number, type: string) => void
assetInlineDownloadAllowed: boolean
disabled?: boolean
width: number | string | null
height: number | string | null
}

export const ManyToManyRelationGrid = forwardRef(function ManyToManyRelationGrid (props: ManyToManyRelationGridProps, ref: MutableRefObject<HTMLDivElement>): React.JSX.Element {
Expand Down Expand Up @@ -170,12 +174,25 @@ export const ManyToManyRelationGrid = forwardRef(function ManyToManyRelationGrid
className={ cn(...getStateClasses()) }
ref={ ref }
>
<Grid
autoWidth
columns={ columns }
data={ getDataArray() }
resizable
/>
<Content
style={ {
width: toCssDimension(props.width),
height: toCssDimension(props.height)
} }
>
<div
style={ {
maxWidth: 'calc(100% - 2px)'
} }
>
<Grid
autoWidth
columns={ columns }
data={ getDataArray() }
resizable
/>
</div>
</Content>
</div>
)
})
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ import {
dndIsValidData,
type IRelationAllowedTypesDataComponent
} from '@Pimcore/modules/element/dynamic-types/defintinitions/objects/data-related/helpers/relations/allowed-types'
import { toCssDimension } from '@Pimcore/utils/css'
import { Content } from '@Pimcore/components/content/content'

export interface ManyToManyRelationClassDefinitionProps {
assetUploadPath?: string | null
Expand Down Expand Up @@ -69,19 +71,27 @@ export const ManyToManyRelation = (props: ManyToManyRelationProps): React.JSX.El
assetInlineDownloadAllowed={ props.assetInlineDownloadAllowed ?? false }
deleteItem={ deleteItem }
disabled={ props.disabled }
height={ props.height }
value={ displayedValue }
width={ props.width }
/>
</Droppable>
<ManyToManyRelationToolbar
addAssets={ addAssets }
allowClear={ props.allowToClearRelation && props.disabled !== true }
assetUploadPath={ props.assetUploadPath }
empty={ () => { setValue(null) } }
enableUpload={ props.assetsAllowed === true && props.disabled !== true }
onSearch={ onSearch }
uploadMaxItems={ maxRemainingItems !== undefined && maxRemainingItems > 0 ? maxRemainingItems : (props.maxItems ?? undefined) }
uploadShowMaxItemsError={ maxRemainingItems !== undefined && maxRemainingItems <= 0 }
/>
<Content
style={ {
width: toCssDimension(props.width)
} }
>
<ManyToManyRelationToolbar
addAssets={ addAssets }
allowClear={ props.allowToClearRelation && props.disabled !== true }
assetUploadPath={ props.assetUploadPath }
empty={ () => { setValue(null) } }
enableUpload={ props.assetsAllowed === true && props.disabled !== true }
onSearch={ onSearch }
uploadMaxItems={ maxRemainingItems !== undefined && maxRemainingItems > 0 ? maxRemainingItems : (props.maxItems ?? undefined) }
uploadShowMaxItemsError={ maxRemainingItems !== undefined && maxRemainingItems <= 0 }
/>
</Content>
</>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export const StructuredTableGrid = (props: StructuredTableGridProps): React.JSX.
}

const applyColWidth = (colWidth?: number | null): number => {
return !_.isEmpty(colWidth) && colWidth! > 0 ? colWidth! : 100
return Number(colWidth) > 0 ? Number(colWidth) : 100
}

const columns: Array<ColumnDef<any>> = [
Expand All @@ -68,12 +68,15 @@ export const StructuredTableGrid = (props: StructuredTableGridProps): React.JSX.
size: applyColWidth(col.width),
meta: {
type: mapColType(col.type),
editable: props.disabled !== true
editable: props.disabled !== true,
autoWidth: true
}
})
)
})

console.log('columns', columns, props.cols)

const rows = props.rows.map((row) => {
const rowData = {
rowLabel: t(row.label)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import { IconButton } from '@Pimcore/components/icon-button/icon-button'
import { Tooltip } from 'antd'
import { useTranslation } from 'react-i18next'
import { useFormModal } from '@Pimcore/components/modal/form-modal/hooks/use-form-modal'
import { toCssDimension } from '@Pimcore/utils/css'
import { Content } from '@Pimcore/components/content/content'

export interface StructuredTableProps {
disabled?: boolean
Expand All @@ -29,6 +31,8 @@ export interface StructuredTableProps {
labelFirstCell: string | null
value?: StructuredTableValue | null
onChange?: (value: StructuredTableValue | null) => void
width?: number | string | null
height?: number | string | null
}

export interface StructuredTableRow {
Expand Down Expand Up @@ -98,17 +102,24 @@ export const StructuredTable = (props: StructuredTableProps): React.JSX.Element

return (
<>
<StructuredTableGrid
castColumnValue={ castColumnValue }
cols={ props.cols }
disabled={ props.disabled }
key={ key }
labelFirstCell={ props.labelFirstCell }
labelWidth={ props.labelWidth }
onChange={ onChange }
rows={ props.rows }
value={ value }
/>
<Content
style={ {
width: toCssDimension(props.width),
height: toCssDimension(props.height)
} }
>
<StructuredTableGrid
castColumnValue={ castColumnValue }
cols={ props.cols }
disabled={ props.disabled }
key={ key }
labelFirstCell={ props.labelFirstCell }
labelWidth={ props.labelWidth }
onChange={ onChange }
rows={ props.rows }
value={ value }
/>
</Content>
{ props.disabled !== true && (
<Box padding="extra-small">
<Tooltip title={ t('empty') }>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import { useTableValue, type TableValue } from './hooks/use-table-value'
import { getCopyData, getPasteData } from './utils/copy-paste'
import { ButtonGroup } from '@Pimcore/components/button-group/button-group'
import { IconTextButton } from '@Pimcore/components/icon-text-button/icon-text-button'
import { Content } from '@Pimcore/components/content/content'
import { toCssDimension } from '@Pimcore/utils/css'

export interface TableProps {
rows: number | null
Expand All @@ -33,6 +35,8 @@ export interface TableProps {
rowsFixed?: boolean
columnConfigActivated?: boolean
columnConfig?: Array<{ key: string, label: string }>
width?: number | string | null
height?: number | string | null
}

export const Table = (props: TableProps): React.JSX.Element => {
Expand Down Expand Up @@ -194,17 +198,24 @@ export const Table = (props: TableProps): React.JSX.Element => {

return (
<>
<TableGrid
cols={ cols }
columnConfig={ props.columnConfig }
columnConfigActivated={ columnConfigActivated }
disabled={ props.disabled }
key={ key }
onActiveCellChange={ setActiveCell }
onChange={ setValue }
rows={ rows }
value={ value }
/>
<Content
style={ {
width: toCssDimension(props.width === 320 ? undefined : props.width), // the default table width does not make sense in studio, 100% width is better
height: toCssDimension(props.height)
} }
>
<TableGrid
cols={ cols }
columnConfig={ props.columnConfig }
columnConfigActivated={ columnConfigActivated }
disabled={ props.disabled }
key={ key }
onActiveCellChange={ setActiveCell }
onChange={ setValue }
rows={ rows }
value={ value }
/>
</Content>
<Box padding="extra-small">
<ButtonGroup items={ items } />
</Box>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"entrypoints": {
"vendor": {
"js": [
"/bundles/pimcorestudioui/build/01b67b86-7f5e-4c02-91c0-549435ee0fa8/vendor.js"
]
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"bundles/pimcorestudioui/build/01b67b86-7f5e-4c02-91c0-549435ee0fa8/vendor.js": "/bundles/pimcorestudioui/build/01b67b86-7f5e-4c02-91c0-549435ee0fa8/vendor.js"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"entrypoints": {
"main": {
"js": [
"/bundles/pimcorestudioui/build/2c87abaf-4844-4a9b-ba0f-092904673f89/main.js"
]
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"bundles/pimcorestudioui/build/2c87abaf-4844-4a9b-ba0f-092904673f89/main.js": "/bundles/pimcorestudioui/build/2c87abaf-4844-4a9b-ba0f-092904673f89/main.js"
}
12 changes: 0 additions & 12 deletions public/build/833fabb1-3415-4de7-96f0-26eb186d4fb1/entrypoints.json

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions public/build/cd85825b-749a-4e36-a132-8b2782bc2ae9/entrypoints.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"entrypoints": {
"core-dll": {
"css": [
"/bundles/pimcorestudioui/build/cd85825b-749a-4e36-a132-8b2782bc2ae9/core-dll.css"
],
"js": [
"/bundles/pimcorestudioui/build/cd85825b-749a-4e36-a132-8b2782bc2ae9/core-dll.js"
]
}
}
}
Loading
Loading