fix: table widget issue where editableCell is undefined (#16729)
This commit is contained in:
parent
052986f138
commit
c37a8a4cfe
|
|
@ -73,7 +73,7 @@ export interface TableWidgetProps extends WidgetProps, WithMeta, TableStyles {
|
||||||
transientTableData: {
|
transientTableData: {
|
||||||
[key: string]: Record<string, string>;
|
[key: string]: Record<string, string>;
|
||||||
};
|
};
|
||||||
editableCell: EditableCell;
|
editableCell?: EditableCell;
|
||||||
primaryColor: string;
|
primaryColor: string;
|
||||||
borderRadius: string;
|
borderRadius: string;
|
||||||
boxShadow?: string;
|
boxShadow?: string;
|
||||||
|
|
|
||||||
|
|
@ -321,7 +321,7 @@ class TableWidgetV2 extends BaseWidget<TableWidgetProps, WidgetState> {
|
||||||
/*
|
/*
|
||||||
* Inject the edited cell value from the editableCell object
|
* Inject the edited cell value from the editableCell object
|
||||||
*/
|
*/
|
||||||
if (this.props.editableCell.index === rowIndex) {
|
if (this.props.editableCell?.index === rowIndex) {
|
||||||
const { column, inputValue } = this.props.editableCell;
|
const { column, inputValue } = this.props.editableCell;
|
||||||
|
|
||||||
newRow[column] = inputValue;
|
newRow[column] = inputValue;
|
||||||
|
|
@ -1233,8 +1233,8 @@ class TableWidgetV2 extends BaseWidget<TableWidgetProps, WidgetState> {
|
||||||
const isColumnEditable =
|
const isColumnEditable =
|
||||||
column.isEditable && isColumnTypeEditable(column.columnType);
|
column.isEditable && isColumnTypeEditable(column.columnType);
|
||||||
const isCellEditMode =
|
const isCellEditMode =
|
||||||
props.cell.column.alias === this.props.editableCell.column &&
|
props.cell.column.alias === this.props.editableCell?.column &&
|
||||||
rowIndex === this.props.editableCell.index;
|
rowIndex === this.props.editableCell?.index;
|
||||||
|
|
||||||
switch (column.columnType) {
|
switch (column.columnType) {
|
||||||
case ColumnTypes.BUTTON:
|
case ColumnTypes.BUTTON:
|
||||||
|
|
@ -1588,8 +1588,8 @@ class TableWidgetV2 extends BaseWidget<TableWidgetProps, WidgetState> {
|
||||||
if (isCellEditMode) {
|
if (isCellEditMode) {
|
||||||
validationErrorMessage =
|
validationErrorMessage =
|
||||||
column.validation.isColumnEditableCellRequired &&
|
column.validation.isColumnEditableCellRequired &&
|
||||||
(isNil(this.props.editableCell.inputValue) ||
|
(isNil(this.props.editableCell?.inputValue) ||
|
||||||
this.props.editableCell.inputValue === "")
|
this.props.editableCell?.inputValue === "")
|
||||||
? "This field is required"
|
? "This field is required"
|
||||||
: column.validation?.errorMessage;
|
: column.validation?.errorMessage;
|
||||||
}
|
}
|
||||||
|
|
@ -1640,9 +1640,10 @@ class TableWidgetV2 extends BaseWidget<TableWidgetProps, WidgetState> {
|
||||||
value: value,
|
value: value,
|
||||||
inputValue,
|
inputValue,
|
||||||
});
|
});
|
||||||
|
|
||||||
this.props.updateWidgetMetaProperty("columnEditableCellValue", {
|
this.props.updateWidgetMetaProperty("columnEditableCellValue", {
|
||||||
...this.props.columnEditableCellValue,
|
...this.props.columnEditableCellValue,
|
||||||
[this.props.editableCell.column]: value,
|
[this.props.editableCell?.column || ""]: value,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -1688,11 +1689,11 @@ class TableWidgetV2 extends BaseWidget<TableWidgetProps, WidgetState> {
|
||||||
if (
|
if (
|
||||||
this.props.isEditableCellValid &&
|
this.props.isEditableCellValid &&
|
||||||
action === EditableCellActions.SAVE &&
|
action === EditableCellActions.SAVE &&
|
||||||
value !== this.props.editableCell.initialValue
|
value !== this.props.editableCell?.initialValue
|
||||||
) {
|
) {
|
||||||
this.updateTransientTableData({
|
this.updateTransientTableData({
|
||||||
__original_index__: this.getRowOriginalIndex(rowIndex),
|
__original_index__: this.getRowOriginalIndex(rowIndex),
|
||||||
[alias]: this.props.editableCell.value,
|
[alias]: this.props.editableCell?.value,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (onSubmit) {
|
if (onSubmit) {
|
||||||
|
|
@ -1703,7 +1704,8 @@ class TableWidgetV2 extends BaseWidget<TableWidgetProps, WidgetState> {
|
||||||
eventType: EventType.ON_SUBMIT,
|
eventType: EventType.ON_SUBMIT,
|
||||||
row: {
|
row: {
|
||||||
...this.props.filteredTableData[rowIndex],
|
...this.props.filteredTableData[rowIndex],
|
||||||
[this.props.editableCell.column]: this.props.editableCell.value,
|
[this.props.editableCell?.column || ""]: this.props.editableCell
|
||||||
|
?.value,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -1711,7 +1713,7 @@ class TableWidgetV2 extends BaseWidget<TableWidgetProps, WidgetState> {
|
||||||
this.clearEditableCell();
|
this.clearEditableCell();
|
||||||
} else if (
|
} else if (
|
||||||
action === EditableCellActions.DISCARD ||
|
action === EditableCellActions.DISCARD ||
|
||||||
value === this.props.editableCell.initialValue
|
value === this.props.editableCell?.initialValue
|
||||||
) {
|
) {
|
||||||
this.clearEditableCell();
|
this.clearEditableCell();
|
||||||
}
|
}
|
||||||
|
|
@ -1737,8 +1739,8 @@ class TableWidgetV2 extends BaseWidget<TableWidgetProps, WidgetState> {
|
||||||
|
|
||||||
isColumnCellEditable = (column: ColumnProperties, rowIndex: number) => {
|
isColumnCellEditable = (column: ColumnProperties, rowIndex: number) => {
|
||||||
return (
|
return (
|
||||||
column.alias === this.props.editableCell.column &&
|
column.alias === this.props.editableCell?.column &&
|
||||||
rowIndex === this.props.editableCell.index
|
rowIndex === this.props.editableCell?.index
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user