Skip to content

Commit

Permalink
Fix problems with creating columns in portfoliowebpart [skip-ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
Remi749 committed Jan 22, 2024
1 parent 30dd19f commit 079d79a
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export function useList(props: IListProps<any>) {
const onRenderItemColumn = useOnRenderItemColumn()
const onRenderDetailsHeader = useOnRenderDetailsHeader(props)
const columns = useMemo(
() => [...props.columns, addColumn].filter((col) => !col.data?.isHidden),
() => [...props.columns, addColumn].filter((col) => !col?.data?.isHidden),
[props.columns]
)
const layoutMode = props.isListLayoutModeJustified
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,7 @@ export const ColumnFormPanel: FC = () => {
required={true}
>
<ColumnSearchPropertyField
label={strings.SearchPropertyLabel}
description={strings.SearchPropertyDescription}
required={true}
placeholder={strings.SearchPropertyPlaceholder}
value={column.get('fieldName')}
onChange={(value) => setColumn('fieldName', value)}
disabled={isEditing}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,9 @@ export const ColumnFormPanel: FC = () => {
value={column.get('sortOrder')?.toString()}
type='number'
defaultValue='100'
min={40}
max={400}
min={10}
max={990}
step={2}
disabled={isEditing}
onChange={(_, data) => setColumn('sortOrder', parseInt(data.value))}
placeholder={strings.Placeholder.TextField}
/>
Expand All @@ -98,19 +97,18 @@ export const ColumnFormPanel: FC = () => {
required={true}
>
<ColumnSearchPropertyField
styles={{ field: styles.field, root: { padding: 0 } }}
placeholder={strings.SearchPropertyPlaceholder}
value={column.get('fieldName')}
onChange={(value) => setColumn('fieldName', value)}
disabled={isEditing}
managedProperties={context.state.managedProperties}
// managedProperties={context.state.managedProperties} - AutoComplete doesn't properly when trying to create a new by just typing. Removed for now to use input instead.
/>
{columnMessages.get('fieldName') && (
{/* {columnMessages.get('fieldName') && (
<UserMessage
title={strings.SearchPropertyFoundTitle}
text={columnMessages.get('fieldName')}
/>
)}
)} */}
</FieldContainer>
<FieldContainer
iconName='TextNumberFormat'
Expand Down Expand Up @@ -140,6 +138,22 @@ export const ColumnFormPanel: FC = () => {
placeholder={strings.Placeholder.TextField}
/>
</FieldContainer>
<FieldContainer
iconName='NumberSymbolSquare'
label={strings.MaxWidthLabel}
description={strings.MaxWidthDescription}
>
<Input
value={column.get('maxWidth')?.toString()}
type='number'
defaultValue='120'
min={column.get('minWidth') ?? 40}
max={400}
step={2}
onChange={(_, data) => setColumn('maxWidth', parseInt(data.value))}
placeholder={strings.Placeholder.TextField}
/>
</FieldContainer>
<ColumnDataTypeField
label={strings.ColumnRenderLabel}
description={strings.PortfolioOverviewColumnRenderDescription}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,11 @@ export function useColumnFormPanel() {
GtManagedProperty: column.get('fieldName'),
GtFieldDataType: colummData.renderAs ?? 'Text',
GtColMinWidth: column.get('minWidth'),
GtColMaxWidth: column.get('maxWidth'),
GtShowFieldFrontpage: colummData.visibility.includes('Frontpage'),
GtShowFieldPortfolio: colummData.visibility.includes('Portfolio'),
GtShowFieldProjectStatus: colummData.visibility.includes('ProjectStatus'),
GtIsGroupable: colummData.isGroupable,
GtIsGroupable: column.get('isGroupable'),
GtIsRefinable: column.get('isRefinable')
}
if (colummData.dataTypeProperties) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export class SPProjectColumnItem {
public GtFieldDataTypeProperties?: string = ''
public GtFieldOverrides?: string = ''
public GtColMinWidth?: number = 0
public GtColMaxWidth?: number = 0
public GtIsRefinable?: boolean = false
public GtIsGroupable?: boolean = false
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<pnp:FieldRef ID="68568356-6f3c-4ebe-a738-70cec5c76f46" Name="GtFieldCustomSort" UpdateChildren="true" />
<pnp:FieldRef ID="e1c9ede0-2406-4aa3-9ba5-fff1ae93d082" Name="GtFieldOverrides" UpdateChildren="true" />
<pnp:FieldRef ID="a156e8b6-fc02-475c-a377-47c6795fed1d" Name="GtColMinWidth" UpdateChildren="true" />
<pnp:FieldRef ID="27c60000-e004-4932-aeaa-6045e197ff87" Name="GtColMaxWidth" UpdateChildren="true" />
<pnp:FieldRef ID="0956cadc-1268-4bc1-9baf-5d2e16190d06" Name="GtIsRefinable" UpdateChildren="true" />
<pnp:FieldRef ID="b77be89a-346f-4897-b519-e55eedbc0aa9" Name="GtIsGroupable" UpdateChildren="true" />
</pnp:FieldRefs>
Expand Down
1 change: 1 addition & 0 deletions Templates/Portfolio/Objects/Lists/Prosjektkolonner.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<FieldRef Name="GtShowFieldPortfolio" />
<FieldRef Name="GtFieldDataType" />
<FieldRef Name="GtColMinWidth" />
<FieldRef Name="GtColMaxWidth" />
<FieldRef Name="GtIsRefinable" />
<FieldRef Name="GtIsGroupable" />
</ViewFields>
Expand Down

0 comments on commit 079d79a

Please sign in to comment.