jomarko commented on code in PR #2834:
URL:
https://github.com/apache/incubator-kie-tools/pull/2834#discussion_r1908347711
##########
packages/boxed-expression-component/src/expressions/DecisionTableExpression/DecisionTableExpression.tsx:
##########
@@ -895,11 +902,19 @@ export function DecisionTableExpression({
case DecisionTableColumnType.OutputClause:
const newOutputs = [...(prev.output ?? [])];
newOutputs.splice(localIndexInsideGroup, 1);
-
+ const updatedOutputColumns = [
+ ...(newOutputs ?? []).map((outputColumn) => {
+ const outputCopy = { ...outputColumn };
+ if (newOutputs.length == 1) {
+ outputCopy["@_name"] = undefined;
+ }
+ return outputCopy;
+ }),
+ ];
Review Comment:
Also, I think we should bring more information. The variable name
`updatedOutputColumns` will be difficult to understand in the future. From the
variable, it is difficult to understand why we do update and what we update.
Could we try to bring more meaningful variable name? Or at least add comment
that we explain update is done because of kie-issues#1466 ?
##########
packages/boxed-expression-component/src/expressions/DecisionTableExpression/DecisionTableExpression.tsx:
##########
@@ -777,7 +776,15 @@ export function DecisionTableExpression({
});
}
- const nextOutputColumns = [...(prev.output ?? [])];
+ const nextOutputColumns = [
+ ...(prev.output ?? []).map((outputColumn, index) => {
+ const outputCopy = { ...outputColumn };
+ if (outputCopy["@_name"] == null) {
Review Comment:
```suggestion
if (outputCopy["@_name"] === null) {
```
##########
packages/boxed-expression-component/src/expressions/DecisionTableExpression/DecisionTableExpression.tsx:
##########
@@ -895,11 +902,19 @@ export function DecisionTableExpression({
case DecisionTableColumnType.OutputClause:
const newOutputs = [...(prev.output ?? [])];
newOutputs.splice(localIndexInsideGroup, 1);
-
+ const updatedOutputColumns = [
+ ...(newOutputs ?? []).map((outputColumn) => {
+ const outputCopy = { ...outputColumn };
+ if (newOutputs.length == 1) {
+ outputCopy["@_name"] = undefined;
+ }
+ return outputCopy;
+ }),
+ ];
Review Comment:
I am not an expert in the `splice`, however, can it cause `newOutputs` to be
again undefined? Can not we remove one ` ?? []` ? Also I think we should use
`===` instead of `==` in typescript code.
```suggestion
const updatedOutputColumns = [
...(newOutputs).map((outputColumn) => {
const outputCopy = { ...outputColumn };
if (newOutputs.length === 1) {
outputCopy["@_name"] = undefined;
}
return outputCopy;
}),
];
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]