fix: table button migration issues (#7825)

This commit is contained in:
Aswath K 2021-09-27 10:45:51 +05:30 committed by GitHub
parent 90fda1ccae
commit 20c1b56932
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 51 additions and 5 deletions

View File

@ -1023,6 +1023,17 @@ export const revertButtonStyleToButtonColor = (
delete currentDSL.prevMenuStyle;
}
}
if (currentDSL.type === "TABLE_WIDGET") {
if (currentDSL.hasOwnProperty("primaryColumns")) {
Object.keys(currentDSL.primaryColumns).forEach((column) => {
if (currentDSL.primaryColumns[column].columnType === "button") {
currentDSL.primaryColumns[column].buttonColor =
currentDSL.primaryColumns[column].buttonStyle;
delete currentDSL.primaryColumns[column].buttonStyle;
}
});
}
}
if (currentDSL.children && currentDSL.children.length) {
currentDSL.children = currentDSL.children.map((child) =>
revertButtonStyleToButtonColor(child),

View File

@ -1607,6 +1607,24 @@ describe("Table Widget selectedRow bindings update", () => {
computedValue:
"{{Table1.sanitizedTableData.map((currentRow) => ( currentRow.action))}}",
},
customColumn1: {
index: 4,
width: 150,
id: "customColumn1",
horizontalAlignment: "LEFT",
verticalAlignment: "CENTER",
columnType: "button",
textSize: "PARAGRAPH",
enableFilter: true,
enableSort: true,
isVisible: true,
isCellVisible: true,
isDisabled: false,
isDerived: true,
label: "Delete",
onClick: "{{showAlert('Hello')}}",
computedValue: "",
},
},
delimiter: ",",
derivedColumns: {},
@ -1759,6 +1777,24 @@ describe("Table Widget selectedRow bindings update", () => {
computedValue:
"{{Table1.sanitizedTableData.map((currentRow) => ( currentRow.action))}}",
},
customColumn1: {
index: 4,
width: 150,
id: "customColumn1",
horizontalAlignment: "LEFT",
verticalAlignment: "CENTER",
columnType: "button",
textSize: "PARAGRAPH",
enableFilter: true,
enableSort: true,
isVisible: true,
isCellVisible: true,
isDisabled: false,
isDerived: true,
label: "Delete",
onClick: "{{showAlert('Hello')}}",
computedValue: "",
},
},
delimiter: ",",
derivedColumns: {},
@ -1797,6 +1833,6 @@ describe("Table Widget selectedRow bindings update", () => {
},
],
};
expect(JSON.stringify(newDsl) === JSON.stringify(outputDsl));
expect(newDsl).toStrictEqual(outputDsl);
});
});

View File

@ -325,10 +325,9 @@ const getUpdatedColumns = (
"currentRow",
);
}
updatedColumns[sanitizedColumnId] = {
...columnProps,
onClick: newOnClickBindingValue,
};
updatedColumns[sanitizedColumnId] = columnProps;
if (newOnClickBindingValue)
updatedColumns[sanitizedColumnId].onClick = newOnClickBindingValue;
}
}
return updatedColumns;