You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kie.apache.org by "Kusuma04-dev (via GitHub)" <gi...@apache.org> on 2025/02/19 07:11:59 UTC
[PR] kie-issues#2548: Cannot add a new record within an empty decision table [incubator-kie-tools]
Kusuma04-dev opened a new pull request, #2912:
URL: https://github.com/apache/incubator-kie-tools/pull/2912
closes https://github.com/apache/incubator-kie-tools/issues/2548 Cannot add a new record within an empty decision table
Before fix:
When user added empty decision table without any row , + icon is not visible to add rows.
After fix:
If user added an empty decision table then row is displayed, if user added something in that row then only it is updated otherwise row is just for display purpose and here if user tries to add another row , he can able to add after updating something in the displayed row.
--
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: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] kie-issues#2548: Cannot add a new record within an empty Decision Table [incubator-kie-tools]
Posted by "Kusuma04-dev (via GitHub)" <gi...@apache.org>.
Kusuma04-dev commented on code in PR #2912:
URL: https://github.com/apache/incubator-kie-tools/pull/2912#discussion_r1974876529
##########
packages/boxed-expression-component/src/expressions/DecisionTableExpression/DecisionTableExpression.tsx:
##########
@@ -416,35 +416,60 @@ export function DecisionTableExpression({
widths,
]);
- const beeTableRows = useMemo(
- () =>
- (decisionTableExpression.rule ?? []).map((rule) => {
- const ruleRow = [
- ...(rule.inputEntry ?? []),
- ...(rule.outputEntry ?? new Array(decisionTableExpression.output.length)),
- ...(rule.annotationEntry ?? []),
- ];
-
- return getColumnsAtLastLevel(beeTableColumns).reduce(
- (tableRow: ROWTYPE, column, columnIndex) => {
- tableRow[column.accessor] = {
- id: (ruleRow[columnIndex] as DMN15__tUnaryTests & DMN15__tLiteralExpression)?.["@_id"] ?? "",
- content: ruleRow[columnIndex]?.text?.__$$text ?? "",
- };
- return tableRow;
- },
- { id: rule["@_id"] }
- );
- }),
- [beeTableColumns, decisionTableExpression.output.length, decisionTableExpression.rule]
- );
+ const createDefaultRule = () => {
+ const defaultRowToAdd: Normalized<DMN15__tDecisionRule> = {
+ "@_id": generateUuid(),
+ inputEntry: [
+ {
+ "@_id": generateUuid(),
+ text: { __$$text: DECISION_TABLE_INPUT_DEFAULT_VALUE },
+ },
+ ],
+ outputEntry: [
+ {
+ "@_id": generateUuid(),
+ text: { __$$text: DECISION_TABLE_OUTPUT_DEFAULT_VALUE },
+ },
+ ],
+ annotationEntry: [{ text: { __$$text: "// Your annotations here" } }],
+ };
+ return defaultRowToAdd;
+ };
Review Comment:
Thanks Tiago for pointing out , Will do.
--
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: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] kie-issues#2548: Cannot add a new record within an empty Decision Table [incubator-kie-tools]
Posted by "ljmotta (via GitHub)" <gi...@apache.org>.
ljmotta commented on code in PR #2912:
URL: https://github.com/apache/incubator-kie-tools/pull/2912#discussion_r1987923774
##########
packages/boxed-expression-component/src/expressions/ExpressionDefinitionRoot/ExpressionDefinitionLogicTypeSelector.tsx:
##########
@@ -147,7 +148,14 @@ export function ExpressionDefinitionLogicTypeSelector({
case "context":
return <ContextExpression expression={expression} isNested={isNested} parentElementId={parentElementId} />;
case "decisionTable":
- return <DecisionTableExpression expression={expression} isNested={isNested} />;
+ const newExpression =
+ !expression?.rule || expression?.rule?.length === 0
+ ? {
+ ...expression,
+ rule: [createDefaultRule()],
+ }
+ : expression;
Review Comment:
The change on the "DecisionTableExpression" isn't enough? I mean, you're already tweaking the "beeTableRows".
--
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: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] kie-issues#2548: Cannot add a new record within an empty Decision Table [incubator-kie-tools]
Posted by "ljmotta (via GitHub)" <gi...@apache.org>.
ljmotta commented on code in PR #2912:
URL: https://github.com/apache/incubator-kie-tools/pull/2912#discussion_r1987923774
##########
packages/boxed-expression-component/src/expressions/ExpressionDefinitionRoot/ExpressionDefinitionLogicTypeSelector.tsx:
##########
@@ -147,7 +148,14 @@ export function ExpressionDefinitionLogicTypeSelector({
case "context":
return <ContextExpression expression={expression} isNested={isNested} parentElementId={parentElementId} />;
case "decisionTable":
- return <DecisionTableExpression expression={expression} isNested={isNested} />;
+ const newExpression =
+ !expression?.rule || expression?.rule?.length === 0
+ ? {
+ ...expression,
+ rule: [createDefaultRule()],
+ }
+ : expression;
Review Comment:
The change on the "DecisionTableExpression" isn't enough? I mean, you're already tweaking the "beeTableRows".
--
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: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] kie-issues#2548: Cannot add a new record within an empty decision table [incubator-kie-tools]
Posted by "tiagobento (via GitHub)" <gi...@apache.org>.
tiagobento commented on PR #2912:
URL: https://github.com/apache/incubator-kie-tools/pull/2912#issuecomment-2668862380
IDK I think it's weird to have to click on the `+` sign to add a row that is already there. If we always show at lest one row (even if the DMN XML says the Decision Table has 0 rows), users will be able to use normally...
--
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: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] kie-issues#2548: Cannot add a new record within an empty Decision Table [incubator-kie-tools]
Posted by "tiagobento (via GitHub)" <gi...@apache.org>.
tiagobento commented on code in PR #2912:
URL: https://github.com/apache/incubator-kie-tools/pull/2912#discussion_r1985405235
##########
packages/boxed-expression-component/src/expressions/ExpressionDefinitionRoot/ExpressionContainer.tsx:
##########
@@ -107,10 +108,18 @@ export const ExpressionContainer: React.FunctionComponent<ExpressionContainerPro
const getPlacementRef = useCallback(() => containerRef.current!, []);
+ const newExpression =
+ expression?.__$$element === "decisionTable"
+ ? {
+ ...expression,
+ rule: expression?.rule?.length === 0 ? [createDefaultRule()] : expression?.rule,
+ }
+ : expression;
Review Comment:
ExpressionContainer is a generic component. We need to solve this problem for Decision Tables exclusively. Adding an `if` here makes this behavior obscure and couples this component with Decision Tables in particular. Please re-iterate.
--
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: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] kie-issues#2548: Cannot add a new record within an empty Decision Table [incubator-kie-tools]
Posted by "ljmotta (via GitHub)" <gi...@apache.org>.
ljmotta commented on PR #2912:
URL: https://github.com/apache/incubator-kie-tools/pull/2912#issuecomment-2718651412
@Kusuma04-dev I made a confusion with the branches, it's working!
--
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: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] kie-issues#2548: Cannot add a new record within an empty Decision Table [incubator-kie-tools]
Posted by "Kusuma04-dev (via GitHub)" <gi...@apache.org>.
Kusuma04-dev commented on code in PR #2912:
URL: https://github.com/apache/incubator-kie-tools/pull/2912#discussion_r1988598509
##########
packages/boxed-expression-component/src/expressions/ExpressionDefinitionRoot/ExpressionDefinitionLogicTypeSelector.tsx:
##########
@@ -147,7 +148,14 @@ export function ExpressionDefinitionLogicTypeSelector({
case "context":
return <ContextExpression expression={expression} isNested={isNested} parentElementId={parentElementId} />;
case "decisionTable":
- return <DecisionTableExpression expression={expression} isNested={isNested} />;
+ const newExpression =
+ !expression?.rule || expression?.rule?.length === 0
+ ? {
+ ...expression,
+ rule: [createDefaultRule()],
+ }
+ : expression;
Review Comment:
Yeah @tiagobento @ljmotta , Previously i thought as we are not adding rule to the xml and we are taking the expression from the xml, it is causing an issue . But now i found the exact issue and changed it accordingly.Thank you.
--
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: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] kie-issues#2548: Cannot add a new record within an empty Decision Table [incubator-kie-tools]
Posted by "Kusuma04-dev (via GitHub)" <gi...@apache.org>.
Kusuma04-dev commented on PR #2912:
URL: https://github.com/apache/incubator-kie-tools/pull/2912#issuecomment-2718624066
> This PR is working fine for top level Decision Tables, but for nested ones I'm still seeing the max depth error.
>
> Example of dmn file:
>
> ```
> <?xml version="1.0" encoding="UTF-8" ?>
> <definitions xmlns="https://www.omg.org/spec/DMN/20230324/MODEL/" xmlns:dmndi="https://www.omg.org/spec/DMN/20230324/DMNDI/" xmlns:dc="http://www.omg.org/spec/DMN/20180521/DC/" xmlns:di="http://www.omg.org/spec/DMN/20180521/DI/" xmlns:kie="https://kie.org/dmn/extensions/1.0" expressionLanguage="https://www.omg.org/spec/DMN/20230324/FEEL/" namespace="https://kie.org/dmn/_3CBBEBAE-E08B-4813-8DF1-A6D04202C724" id="_47D65C59-0E73-453E-94C7-63D70C4F0BAB" name="DMN_45B6311A-EA35-4C07-9F38-E369F3A36875">
> <decision name="New Decision" id="_FF8D870E-601C-4798-B412-80C0AA1A9812">
> <variable name="New Decision" id="_B2949544-4E8A-4394-89AF-D39D3940E9E8" />
> <context id="_52DAA31C-A12E-42EB-8802-9A75D5DF3384" label="New Decision">
> <contextEntry id="_C316F005-2CFF-4BF3-AF4F-BE727AE1E5A6">
> <variable id="_F2CD345B-A880-4842-BDF9-DD657747BA2D" name="ContextEntry-1" />
> <decisionTable id="_530092D8-8FCA-483A-B099-FA882F341475" hitPolicy="UNIQUE" label="ContextEntry-1">
> <input id="_A6D91C4D-744B-4DA3-8255-CA70FDCC0090">
> <inputExpression id="_25EDEB88-DB4B-475B-8575-F81D6CB5A4B5">
> <text>Input-1</text>
> </inputExpression>
> </input>
> <output id="_2A2BD858-8B87-42BD-836F-2C1625E25DA1" />
> <annotation name="Annotations" />
> </decisionTable>
> </contextEntry>
> <contextEntry id="_EEAF5A81-E14E-4F30-A7C3-B47D37ED6751" />
> </context>
> </decision>
> <dmndi:DMNDI>
> <dmndi:DMNDiagram id="_D4883DFF-3B17-4F6B-937D-58DF840FE1AF" name="Default DRD" useAlternativeInputDataShape="false">
> <di:extension>
> <kie:ComponentsWidthsExtension>
> <kie:ComponentWidths />
> </kie:ComponentsWidthsExtension>
> </di:extension>
> <dmndi:DMNShape id="_C238E488-A5C9-4FB7-AAF8-85D3D2BB07D0" dmnElementRef="_FF8D870E-601C-4798-B412-80C0AA1A9812">
> <dc:Bounds x="112" y="112" width="160" height="80" />
> </dmndi:DMNShape>
> </dmndi:DMNDiagram>
> </dmndi:DMNDI>
> </definitions>
> ```
Hi @ljmotta , Here is the dmn for nested decisionTable: ```
<?xml version="1.0" encoding="UTF-8" ?>
<definitions xmlns="https://www.omg.org/spec/DMN/20230324/MODEL/" expressionLanguage="https://www.omg.org/spec/DMN/20230324/FEEL/" namespace="https://kie.org/dmn/_7B4C6599-2C53-4033-B406-54C2C80F40E8" id="_E414676D-186F-4D8D-8F16-3018EE361689" name="DMN_6F0CCA2F-99EC-45CA-A5CD-4A7254A716F9" xmlns:dmndi="https://www.omg.org/spec/DMN/20230324/DMNDI/" xmlns:dc="http://www.omg.org/spec/DMN/20180521/DC/" xmlns:di="http://www.omg.org/spec/DMN/20180521/DI/" xmlns:kie="https://kie.org/dmn/extensions/1.0">
<decision name="New Decision" id="_C8C0389F-4A8E-4FD3-9852-49C254B2E936">
<variable name="New Decision" id="_292443FE-7900-4A43-9A66-438E7DBFDDD1" />
<context id="_FD3EB91E-9C23-479F-9B81-C9319A62E4FB" label="New Decision">
<contextEntry id="_0C74EA3B-226D-4ED8-93B9-2261F0CFA6B9">
<variable id="_B675BAD8-5314-4D7B-8875-3FE51A0F389E" name="ContextEntry-1" />
<decisionTable id="_B7C1B35B-1431-4074-9963-2DD9DF82EB40" hitPolicy="UNIQUE" label="ContextEntry-1">
<input id="_1F043F16-F68B-4583-BE9C-3AD0D23E5F0C">
<inputExpression id="_6AA1DECE-CE3E-49E6-B748-2DD900E78C77">
<text>Input-1</text>
</inputExpression>
</input>
<output id="_C03C7E03-5A66-4163-B8B7-50CE0471DC8A" name="Output-1" />
<annotation name="Annotations" />
</decisionTable>
</contextEntry>
<contextEntry id="_A6537197-2819-4387-814F-4C0A0067AC79" />
</context>
</decision>
<dmndi:DMNDI>
<dmndi:DMNDiagram id="_874D0C4C-1F02-43F9-9259-C334247717AC" name="Default DRD" useAlternativeInputDataShape="false">
<di:extension>
<kie:ComponentsWidthsExtension>
<kie:ComponentWidths dmnElementRef="_FD3EB91E-9C23-479F-9B81-C9319A62E4FB">
<kie:width>120</kie:width>
</kie:ComponentWidths>
<kie:ComponentWidths dmnElementRef="_B7C1B35B-1431-4074-9963-2DD9DF82EB40">
<kie:width>60</kie:width>
<kie:width>118</kie:width>
<kie:width>118</kie:width>
<kie:width>240</kie:width>
</kie:ComponentWidths>
</kie:ComponentsWidthsExtension>
</di:extension>
<dmndi:DMNShape id="_22ABE629-FB9E-42A5-8F74-1273AE0B1193" dmnElementRef="_C8C0389F-4A8E-4FD3-9852-49C254B2E936" isCollapsed="false" isListedInputData="false">
<dc:Bounds x="80" y="60" width="160" height="80" />
</dmndi:DMNShape>
</dmndi:DMNDiagram>
</dmndi:DMNDI>
</definitions>
```
--
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: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] kie-issues#2548: Cannot add a new record within an empty Decision Table [incubator-kie-tools]
Posted by "Kusuma04-dev (via GitHub)" <gi...@apache.org>.
Kusuma04-dev commented on PR #2912:
URL: https://github.com/apache/incubator-kie-tools/pull/2912#issuecomment-2671250789
Hi @tiagobento @jomarko , I have made the changes to make it work as normal decisiontable, Please review and suggest if anything is missing.
--
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: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] kie-issues#2548: Cannot add a new record within an empty decision table [incubator-kie-tools]
Posted by "Kusuma04-dev (via GitHub)" <gi...@apache.org>.
Kusuma04-dev commented on PR #2912:
URL: https://github.com/apache/incubator-kie-tools/pull/2912#issuecomment-2668544592
> @Kusuma04-dev Hi, thank you for the PR. I think from now one users will be able to add rows even to a table, that has zero rows/rules in the xml.
>
> However, I would like to share one idea/proposal, that from my point of view would make more clear difference between no data state vs some data state.
>
> ### Currently we have
> #### 0 rows just opened
> 
>
> #### 0 rows transformed to one row
> 
>
> ### Proposal
> #### 0 rows just opened
> 
>
> #### 0 rows transformed to one row
> 
Thanks Jozef for the review and the proposal. I agree with you ,with these changes user can distinguish between dummy row and actual row.
--
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: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] kie-issues#2548: Cannot add a new record within an empty Decision Table [incubator-kie-tools]
Posted by "tiagobento (via GitHub)" <gi...@apache.org>.
tiagobento merged PR #2912:
URL: https://github.com/apache/incubator-kie-tools/pull/2912
--
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: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] kie-issues#2548: Cannot add a new record within an empty Decision Table [incubator-kie-tools]
Posted by "Kusuma04-dev (via GitHub)" <gi...@apache.org>.
Kusuma04-dev commented on PR #2912:
URL: https://github.com/apache/incubator-kie-tools/pull/2912#issuecomment-2717386221
> I am not sure, why on my machine, the built PR does not work. Could you maybe provide VSIX file for me for testing?
>
>  
Hi @jomarko , Can you please check in branch: **kie-issues##2548**
--
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: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] kie-issues#2548: Cannot add a new record within an empty Decision Table [incubator-kie-tools]
Posted by "tiagobento (via GitHub)" <gi...@apache.org>.
tiagobento commented on code in PR #2912:
URL: https://github.com/apache/incubator-kie-tools/pull/2912#discussion_r1974377299
##########
packages/boxed-expression-component/src/expressions/DecisionTableExpression/DecisionTableExpression.tsx:
##########
@@ -416,35 +416,60 @@ export function DecisionTableExpression({
widths,
]);
- const beeTableRows = useMemo(
- () =>
- (decisionTableExpression.rule ?? []).map((rule) => {
- const ruleRow = [
- ...(rule.inputEntry ?? []),
- ...(rule.outputEntry ?? new Array(decisionTableExpression.output.length)),
- ...(rule.annotationEntry ?? []),
- ];
-
- return getColumnsAtLastLevel(beeTableColumns).reduce(
- (tableRow: ROWTYPE, column, columnIndex) => {
- tableRow[column.accessor] = {
- id: (ruleRow[columnIndex] as DMN15__tUnaryTests & DMN15__tLiteralExpression)?.["@_id"] ?? "",
- content: ruleRow[columnIndex]?.text?.__$$text ?? "",
- };
- return tableRow;
- },
- { id: rule["@_id"] }
- );
- }),
- [beeTableColumns, decisionTableExpression.output.length, decisionTableExpression.rule]
- );
+ const createDefaultRule = () => {
+ const defaultRowToAdd: Normalized<DMN15__tDecisionRule> = {
+ "@_id": generateUuid(),
+ inputEntry: [
+ {
+ "@_id": generateUuid(),
+ text: { __$$text: DECISION_TABLE_INPUT_DEFAULT_VALUE },
+ },
+ ],
+ outputEntry: [
+ {
+ "@_id": generateUuid(),
+ text: { __$$text: DECISION_TABLE_OUTPUT_DEFAULT_VALUE },
+ },
+ ],
+ annotationEntry: [{ text: { __$$text: "// Your annotations here" } }],
+ };
+ return defaultRowToAdd;
+ };
+
+ const beeTableRows = useMemo(() => {
+ const mapRuleToRow = (rule: Normalized<DMN15__tDecisionRule>) => {
+ const ruleRow = [
+ ...(rule.inputEntry ?? []),
+ ...(rule.outputEntry ?? new Array(decisionTableExpression.output.length)),
+ ...(rule.annotationEntry ?? []),
+ ];
+
+ return getColumnsAtLastLevel(beeTableColumns).reduce(
+ (tableRow: ROWTYPE, column, columnIndex) => {
+ tableRow[column.accessor] = {
+ id: (ruleRow[columnIndex] as DMN15__tUnaryTests & DMN15__tLiteralExpression)?.["@_id"] ?? "",
+ content: ruleRow[columnIndex]?.text?.__$$text ?? "",
+ };
+ return tableRow;
+ },
+ { id: rule["@_id"] }
+ );
+ };
+ const prevRules = decisionTableExpression.rule ?? [];
+ if (prevRules.length === 0) {
+ return [mapRuleToRow(createDefaultRule())];
+ }
+ return prevRules.map(mapRuleToRow);
+ }, [decisionTableExpression.rule, decisionTableExpression.output.length, beeTableColumns]);
const onCellUpdates = useCallback(
(cellUpdates: BeeTableCellUpdate<ROWTYPE>[]) => {
setExpression({
setExpressionAction: (prev: Normalized<BoxedDecisionTable>) => {
let previousExpression: Normalized<BoxedDecisionTable> = { ...prev };
-
+ if (!previousExpression.rule) {
+ previousExpression.rule = [createDefaultRule()];
+ }
Review Comment:
```suggestion
if (!previousExpression.rule || previousExpression.rule.length === 0) {
previousExpression.rule = [createDefaultRule()];
}
```
##########
packages/boxed-expression-component/src/expressions/DecisionTableExpression/DecisionTableExpression.tsx:
##########
@@ -719,9 +744,11 @@ export function DecisionTableExpression({
(args: { beforeIndex: number; rowsCount: number }) => {
setExpression({
setExpressionAction: (prev: Normalized<BoxedDecisionTable>) => {
+ if (!prev.rule) {
+ prev.rule = [createDefaultRule()];
+ }
Review Comment:
```suggestion
if (!prev.rule || prev.rule.length === 0)) {
prev.rule = [createDefaultRule()];
}
```
##########
packages/boxed-expression-component/src/expressions/DecisionTableExpression/DecisionTableExpression.tsx:
##########
@@ -416,35 +416,60 @@ export function DecisionTableExpression({
widths,
]);
- const beeTableRows = useMemo(
- () =>
- (decisionTableExpression.rule ?? []).map((rule) => {
- const ruleRow = [
- ...(rule.inputEntry ?? []),
- ...(rule.outputEntry ?? new Array(decisionTableExpression.output.length)),
- ...(rule.annotationEntry ?? []),
- ];
-
- return getColumnsAtLastLevel(beeTableColumns).reduce(
- (tableRow: ROWTYPE, column, columnIndex) => {
- tableRow[column.accessor] = {
- id: (ruleRow[columnIndex] as DMN15__tUnaryTests & DMN15__tLiteralExpression)?.["@_id"] ?? "",
- content: ruleRow[columnIndex]?.text?.__$$text ?? "",
- };
- return tableRow;
- },
- { id: rule["@_id"] }
- );
- }),
- [beeTableColumns, decisionTableExpression.output.length, decisionTableExpression.rule]
- );
+ const createDefaultRule = () => {
+ const defaultRowToAdd: Normalized<DMN15__tDecisionRule> = {
+ "@_id": generateUuid(),
+ inputEntry: [
+ {
+ "@_id": generateUuid(),
+ text: { __$$text: DECISION_TABLE_INPUT_DEFAULT_VALUE },
+ },
+ ],
+ outputEntry: [
+ {
+ "@_id": generateUuid(),
+ text: { __$$text: DECISION_TABLE_OUTPUT_DEFAULT_VALUE },
+ },
+ ],
+ annotationEntry: [{ text: { __$$text: "// Your annotations here" } }],
+ };
+ return defaultRowToAdd;
+ };
+
+ const beeTableRows = useMemo(() => {
+ const mapRuleToRow = (rule: Normalized<DMN15__tDecisionRule>) => {
+ const ruleRow = [
+ ...(rule.inputEntry ?? []),
+ ...(rule.outputEntry ?? new Array(decisionTableExpression.output.length)),
+ ...(rule.annotationEntry ?? []),
+ ];
+
+ return getColumnsAtLastLevel(beeTableColumns).reduce(
+ (tableRow: ROWTYPE, column, columnIndex) => {
+ tableRow[column.accessor] = {
+ id: (ruleRow[columnIndex] as DMN15__tUnaryTests & DMN15__tLiteralExpression)?.["@_id"] ?? "",
+ content: ruleRow[columnIndex]?.text?.__$$text ?? "",
+ };
+ return tableRow;
+ },
+ { id: rule["@_id"] }
+ );
+ };
+ const prevRules = decisionTableExpression.rule ?? [];
+ if (prevRules.length === 0) {
+ return [mapRuleToRow(createDefaultRule())];
+ }
+ return prevRules.map(mapRuleToRow);
Review Comment:
Please be attentive with negative spacing for improved readability. Nice function extraction!
##########
packages/boxed-expression-component/src/expressions/DecisionTableExpression/DecisionTableExpression.tsx:
##########
@@ -416,35 +416,60 @@ export function DecisionTableExpression({
widths,
]);
- const beeTableRows = useMemo(
- () =>
- (decisionTableExpression.rule ?? []).map((rule) => {
- const ruleRow = [
- ...(rule.inputEntry ?? []),
- ...(rule.outputEntry ?? new Array(decisionTableExpression.output.length)),
- ...(rule.annotationEntry ?? []),
- ];
-
- return getColumnsAtLastLevel(beeTableColumns).reduce(
- (tableRow: ROWTYPE, column, columnIndex) => {
- tableRow[column.accessor] = {
- id: (ruleRow[columnIndex] as DMN15__tUnaryTests & DMN15__tLiteralExpression)?.["@_id"] ?? "",
- content: ruleRow[columnIndex]?.text?.__$$text ?? "",
- };
- return tableRow;
- },
- { id: rule["@_id"] }
- );
- }),
- [beeTableColumns, decisionTableExpression.output.length, decisionTableExpression.rule]
- );
+ const createDefaultRule = () => {
+ const defaultRowToAdd: Normalized<DMN15__tDecisionRule> = {
+ "@_id": generateUuid(),
+ inputEntry: [
+ {
+ "@_id": generateUuid(),
+ text: { __$$text: DECISION_TABLE_INPUT_DEFAULT_VALUE },
+ },
+ ],
+ outputEntry: [
+ {
+ "@_id": generateUuid(),
+ text: { __$$text: DECISION_TABLE_OUTPUT_DEFAULT_VALUE },
+ },
+ ],
+ annotationEntry: [{ text: { __$$text: "// Your annotations here" } }],
+ };
+ return defaultRowToAdd;
+ };
+
+ const beeTableRows = useMemo(() => {
+ const mapRuleToRow = (rule: Normalized<DMN15__tDecisionRule>) => {
+ const ruleRow = [
+ ...(rule.inputEntry ?? []),
+ ...(rule.outputEntry ?? new Array(decisionTableExpression.output.length)),
+ ...(rule.annotationEntry ?? []),
+ ];
+
+ return getColumnsAtLastLevel(beeTableColumns).reduce(
+ (tableRow: ROWTYPE, column, columnIndex) => {
+ tableRow[column.accessor] = {
+ id: (ruleRow[columnIndex] as DMN15__tUnaryTests & DMN15__tLiteralExpression)?.["@_id"] ?? "",
+ content: ruleRow[columnIndex]?.text?.__$$text ?? "",
+ };
+ return tableRow;
+ },
+ { id: rule["@_id"] }
+ );
+ };
+ const prevRules = decisionTableExpression.rule ?? [];
+ if (prevRules.length === 0) {
+ return [mapRuleToRow(createDefaultRule())];
+ }
+ return prevRules.map(mapRuleToRow);
Review Comment:
I also removed the temporary variable in my suggestion.
##########
packages/boxed-expression-component/src/expressions/DecisionTableExpression/DecisionTableExpression.tsx:
##########
@@ -416,35 +416,60 @@ export function DecisionTableExpression({
widths,
]);
- const beeTableRows = useMemo(
- () =>
- (decisionTableExpression.rule ?? []).map((rule) => {
- const ruleRow = [
- ...(rule.inputEntry ?? []),
- ...(rule.outputEntry ?? new Array(decisionTableExpression.output.length)),
- ...(rule.annotationEntry ?? []),
- ];
-
- return getColumnsAtLastLevel(beeTableColumns).reduce(
- (tableRow: ROWTYPE, column, columnIndex) => {
- tableRow[column.accessor] = {
- id: (ruleRow[columnIndex] as DMN15__tUnaryTests & DMN15__tLiteralExpression)?.["@_id"] ?? "",
- content: ruleRow[columnIndex]?.text?.__$$text ?? "",
- };
- return tableRow;
- },
- { id: rule["@_id"] }
- );
- }),
- [beeTableColumns, decisionTableExpression.output.length, decisionTableExpression.rule]
- );
+ const createDefaultRule = () => {
+ const defaultRowToAdd: Normalized<DMN15__tDecisionRule> = {
+ "@_id": generateUuid(),
+ inputEntry: [
+ {
+ "@_id": generateUuid(),
+ text: { __$$text: DECISION_TABLE_INPUT_DEFAULT_VALUE },
+ },
+ ],
+ outputEntry: [
+ {
+ "@_id": generateUuid(),
+ text: { __$$text: DECISION_TABLE_OUTPUT_DEFAULT_VALUE },
+ },
+ ],
+ annotationEntry: [{ text: { __$$text: "// Your annotations here" } }],
+ };
+ return defaultRowToAdd;
+ };
+
+ const beeTableRows = useMemo(() => {
+ const mapRuleToRow = (rule: Normalized<DMN15__tDecisionRule>) => {
+ const ruleRow = [
+ ...(rule.inputEntry ?? []),
+ ...(rule.outputEntry ?? new Array(decisionTableExpression.output.length)),
+ ...(rule.annotationEntry ?? []),
+ ];
+
+ return getColumnsAtLastLevel(beeTableColumns).reduce(
+ (tableRow: ROWTYPE, column, columnIndex) => {
+ tableRow[column.accessor] = {
+ id: (ruleRow[columnIndex] as DMN15__tUnaryTests & DMN15__tLiteralExpression)?.["@_id"] ?? "",
+ content: ruleRow[columnIndex]?.text?.__$$text ?? "",
+ };
+ return tableRow;
+ },
+ { id: rule["@_id"] }
+ );
+ };
+ const prevRules = decisionTableExpression.rule ?? [];
+ if (prevRules.length === 0) {
+ return [mapRuleToRow(createDefaultRule())];
+ }
+ return prevRules.map(mapRuleToRow);
Review Comment:
```suggestion
};
if (!decisionTableExpression.rule || decisionTableExpression.rule.length === 0) {
return [mapRuleToRow(createDefaultRule())];
}
return prevRules.map(mapRuleToRow);
```
##########
packages/boxed-expression-component/src/expressions/DecisionTableExpression/DecisionTableExpression.tsx:
##########
@@ -416,35 +416,60 @@ export function DecisionTableExpression({
widths,
]);
- const beeTableRows = useMemo(
- () =>
- (decisionTableExpression.rule ?? []).map((rule) => {
- const ruleRow = [
- ...(rule.inputEntry ?? []),
- ...(rule.outputEntry ?? new Array(decisionTableExpression.output.length)),
- ...(rule.annotationEntry ?? []),
- ];
-
- return getColumnsAtLastLevel(beeTableColumns).reduce(
- (tableRow: ROWTYPE, column, columnIndex) => {
- tableRow[column.accessor] = {
- id: (ruleRow[columnIndex] as DMN15__tUnaryTests & DMN15__tLiteralExpression)?.["@_id"] ?? "",
- content: ruleRow[columnIndex]?.text?.__$$text ?? "",
- };
- return tableRow;
- },
- { id: rule["@_id"] }
- );
- }),
- [beeTableColumns, decisionTableExpression.output.length, decisionTableExpression.rule]
- );
+ const createDefaultRule = () => {
+ const defaultRowToAdd: Normalized<DMN15__tDecisionRule> = {
+ "@_id": generateUuid(),
+ inputEntry: [
+ {
+ "@_id": generateUuid(),
+ text: { __$$text: DECISION_TABLE_INPUT_DEFAULT_VALUE },
+ },
+ ],
+ outputEntry: [
+ {
+ "@_id": generateUuid(),
+ text: { __$$text: DECISION_TABLE_OUTPUT_DEFAULT_VALUE },
+ },
+ ],
+ annotationEntry: [{ text: { __$$text: "// Your annotations here" } }],
+ };
+ return defaultRowToAdd;
+ };
Review Comment:
Not memoized. Unnecessary local variable. Could be outside of the React component in the global scope as a named function.
--
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: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] kie-issues#2548: Cannot add a new record within an empty Decision Table [incubator-kie-tools]
Posted by "Kusuma04-dev (via GitHub)" <gi...@apache.org>.
Kusuma04-dev commented on PR #2912:
URL: https://github.com/apache/incubator-kie-tools/pull/2912#issuecomment-2669324073
> IDK I think it's weird to have to click on the `+` sign to add a row that is already there. If we always show at lest one row (even if the DMN XML says the Decision Table has 0 rows), users will be able to use normally...
@tiagobento ,Thanks for your suggestion , Yeah user can use normally ,here 1st row which is displayed is not actual rule , it becomes active only when user added something then they can use normally but if user didn't add anything then clicked on + icon then it will add 1st row(considering no rule present before). Please share your view on this if this is fine or we need to modify anything?
--
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: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] kie-issues#2548: Cannot add a new record within an empty decision table [incubator-kie-tools]
Posted by "Kusuma04-dev (via GitHub)" <gi...@apache.org>.
Kusuma04-dev commented on PR #2912:
URL: https://github.com/apache/incubator-kie-tools/pull/2912#issuecomment-2668557492
@tiagobento , Can you please share your thoughts on this:
Can we do like this as jozef mentioned:
Uploading Screen Recording 2025-02-19 at 6.16.31 PM.mov…
--
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: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] kie-issues#2548: Cannot add a new record within an empty Decision Table [incubator-kie-tools]
Posted by "jomarko (via GitHub)" <gi...@apache.org>.
jomarko commented on PR #2912:
URL: https://github.com/apache/incubator-kie-tools/pull/2912#issuecomment-2717352980
I am not sure, why on my machine, the built PR does not work. Could you maybe provide VSIX file for me for testing?


--
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: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] kie-issues#2548: Cannot add a new record within an empty Decision Table [incubator-kie-tools]
Posted by "ljmotta (via GitHub)" <gi...@apache.org>.
ljmotta commented on code in PR #2912:
URL: https://github.com/apache/incubator-kie-tools/pull/2912#discussion_r1987927601
##########
packages/boxed-expression-component/src/expressions/ExpressionDefinitionRoot/ExpressionDefinitionLogicTypeSelector.tsx:
##########
@@ -147,7 +148,14 @@ export function ExpressionDefinitionLogicTypeSelector({
case "context":
return <ContextExpression expression={expression} isNested={isNested} parentElementId={parentElementId} />;
case "decisionTable":
- return <DecisionTableExpression expression={expression} isNested={isNested} />;
+ const newExpression =
+ !expression?.rule || expression?.rule?.length === 0
+ ? {
+ ...expression,
+ rule: [createDefaultRule()],
+ }
+ : expression;
Review Comment:
Following @tiagobento comment, the change on the "DecisionTableExpression" isn't enough? I mean, you're already tweaking the "beeTableRows".
--
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: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] kie-issues#2548: Cannot add a new record within an empty Decision Table [incubator-kie-tools]
Posted by "ljmotta (via GitHub)" <gi...@apache.org>.
ljmotta commented on PR #2912:
URL: https://github.com/apache/incubator-kie-tools/pull/2912#issuecomment-2718489950
This PR is working fine for top level Decision Tables, but for nested ones I'm still seeing the max depth error.
Example of dmn file:
```xml
<?xml version="1.0" encoding="UTF-8" ?>
<definitions xmlns="https://www.omg.org/spec/DMN/20230324/MODEL/" xmlns:dmndi="https://www.omg.org/spec/DMN/20230324/DMNDI/" xmlns:dc="http://www.omg.org/spec/DMN/20180521/DC/" xmlns:di="http://www.omg.org/spec/DMN/20180521/DI/" xmlns:kie="https://kie.org/dmn/extensions/1.0" expressionLanguage="https://www.omg.org/spec/DMN/20230324/FEEL/" namespace="https://kie.org/dmn/_3CBBEBAE-E08B-4813-8DF1-A6D04202C724" id="_47D65C59-0E73-453E-94C7-63D70C4F0BAB" name="DMN_45B6311A-EA35-4C07-9F38-E369F3A36875">
<decision name="New Decision" id="_FF8D870E-601C-4798-B412-80C0AA1A9812">
<variable name="New Decision" id="_B2949544-4E8A-4394-89AF-D39D3940E9E8" />
<context id="_52DAA31C-A12E-42EB-8802-9A75D5DF3384" label="New Decision">
<contextEntry id="_C316F005-2CFF-4BF3-AF4F-BE727AE1E5A6">
<variable id="_F2CD345B-A880-4842-BDF9-DD657747BA2D" name="ContextEntry-1" />
<decisionTable id="_530092D8-8FCA-483A-B099-FA882F341475" hitPolicy="UNIQUE" label="ContextEntry-1">
<input id="_A6D91C4D-744B-4DA3-8255-CA70FDCC0090">
<inputExpression id="_25EDEB88-DB4B-475B-8575-F81D6CB5A4B5">
<text>Input-1</text>
</inputExpression>
</input>
<output id="_2A2BD858-8B87-42BD-836F-2C1625E25DA1" />
<annotation name="Annotations" />
</decisionTable>
</contextEntry>
<contextEntry id="_EEAF5A81-E14E-4F30-A7C3-B47D37ED6751" />
</context>
</decision>
<dmndi:DMNDI>
<dmndi:DMNDiagram id="_D4883DFF-3B17-4F6B-937D-58DF840FE1AF" name="Default DRD" useAlternativeInputDataShape="false">
<di:extension>
<kie:ComponentsWidthsExtension>
<kie:ComponentWidths />
</kie:ComponentsWidthsExtension>
</di:extension>
<dmndi:DMNShape id="_C238E488-A5C9-4FB7-AAF8-85D3D2BB07D0" dmnElementRef="_FF8D870E-601C-4798-B412-80C0AA1A9812">
<dc:Bounds x="112" y="112" width="160" height="80" />
</dmndi:DMNShape>
</dmndi:DMNDiagram>
</dmndi:DMNDI>
</definitions>
```
--
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: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] kie-issues#2548: Cannot add a new record within an empty Decision Table [incubator-kie-tools]
Posted by "tiagobento (via GitHub)" <gi...@apache.org>.
tiagobento commented on PR #2912:
URL: https://github.com/apache/incubator-kie-tools/pull/2912#issuecomment-2689201222
@Kusuma04-dev I also tested the case @jomarko described with nested Decision Tables. It does indeed happen on `main` too, so this PR did not introduce it. As this PR's goal is to ensure Decision Tables without any rules work well in the DMN Editor's Boxed Expression Editor (BEE), I'd suggest we continue the investigation on this PR until we find a solution for it too, if that's okay with you. Thanks!
--
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: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org