aswathitv commented on code in PR #3162:
URL:
https://github.com/apache/incubator-kie-tools/pull/3162#discussion_r2116208940
##########
packages/dmn-editor/src/diagram/Diagram.tsx:
##########
@@ -813,6 +813,119 @@ export const Diagram = React.forwardRef<DiagramRef, {
container: React.RefObject
}
}
}
+ if (node.type === NODE_TYPES.decisionService) {
+ const drds =
state.dmn.model.definitions["dmndi:DMNDI"]?.["dmndi:DMNDiagram"] ?? [];
+ const drgElements =
state.dmn.model.definitions.drgElement!;
+ for (let i = 0; i < drds.length; i++) {
+ if (i === state.computed(state).getDrdIndex()) {
+ continue;
+ }
+ const _indexedDrd = computeIndexedDrd(
+ state.dmn.model.definitions["@_namespace"],
+ state.dmn.model.definitions,
+ i
+ );
+ const dsShape =
_indexedDrd.dmnShapesByHref.get(node.id);
+ if (dsShape && dsShape["dc:Bounds"] &&
!node.data.shape["@_isCollapsed"]) {
+ dsShape["dc:Bounds"]["@_width"] =
change.dimensions?.width ?? 0;
+ dsShape["dc:Bounds"]["@_height"] =
change.dimensions?.height ?? 0;
+ }
+
+ // Apply delta shift to neighbouring nodes in other DRD
+ const decisionService = node.data.dmnObject as
Normalized<DMN15__tDecisionService>;
+ const { containedDecisionHrefsRelativeToThisDmn } =
+ getDecisionServicePropertiesRelativeToThisDmn({
+ thisDmnsNamespace:
state.dmn.model.definitions["@_namespace"],
+ decisionService,
+ decisionServiceNamespace:
+ node.data.dmnObjectNamespace ??
state.dmn.model.definitions["@_namespace"],
+ });
+
+ const decisionsInDecisionServiceInDrd: string[] = [];
+ for (const elem of drgElements) {
+ if (elem.__$$element === "decisionService") {
+ decisionsInDecisionServiceInDrd.push(
+ ...(elem.outputDecision ?? []).map((od) =>
od["@_href"]),
+ ...(elem.encapsulatedDecision ?? []).map((od) =>
od["@_href"])
+ );
+ }
+ }
+
+ for (const [key] of
_indexedDrd.dmnShapesByHref.entries()) {
+ if (key !== node.id &&
!containedDecisionHrefsRelativeToThisDmn.includes(key)) {
+ const nodeShape =
_indexedDrd.dmnShapesByHref.get(key);
+ if (nodeShape && nodeShape["dc:Bounds"] && dsShape
&& !node.data.shape["@_isCollapsed"]) {
+ const nodeShapeWidth =
+ nodeShape["dc:Bounds"]!["@_x"] +
nodeShape["dc:Bounds"]!["@_width"];
+ const nodeShapeHeight =
+ nodeShape["dc:Bounds"]!["@_y"] +
nodeShape["dc:Bounds"]!["@_height"];
+ const dsShapeWidth =
+ dsShape["dc:Bounds"]!["@_x"] +
dsShape["dc:Bounds"]!["@_width"] - deltaWidth;
+ const dsShapeHeight =
+ dsShape["dc:Bounds"]!["@_y"] +
dsShape["dc:Bounds"]!["@_height"] - deltaHeight;
+
+ const drgElem = drgElements.filter(
+ (item) => item["@_id"] ===
nodeShape["@_dmnElementRef"]
+ );
+
+ const shiftXPosition =
+ nodeShape["dc:Bounds"]["@_x"] >= dsShapeWidth
&&
+ (nodeShapeHeight >=
dsShape["dc:Bounds"]!["@_y"] ||
+ nodeShape["dc:Bounds"]["@_y"] <=
dsShapeHeight);
+
+ const shiftYPosition =
+ nodeShape["dc:Bounds"]["@_y"] >= dsShapeHeight
&&
+ (dsShapeWidth <= nodeShapeWidth ||
nodeShape["dc:Bounds"]!["@_x"] <= nodeShapeWidth);
+
+ const bounds = nodeShape["dc:Bounds"];
+
+ if (drgElem[0].__$$element ===
"decisionService") {
+ const containedDecisions = [
+ ...(drgElem[0].outputDecision ??
[]).map((od) => od["@_href"]),
+ ...(drgElem[0].encapsulatedDecision ??
[]).map((od) => od["@_href"]),
+ ];
+
+ if (shiftXPosition || shiftYPosition) {
+ const divider =
nodeShape["dmndi:DMNDecisionServiceDividerLine"];
+ const waypoints = divider?.["di:waypoint"];
+ // Handles position shift of decision service
+ if (shiftXPosition) {
+ bounds["@_x"] += deltaWidth;
+ waypoints![0]["@_x"] += deltaWidth;
+ waypoints![1]["@_x"] += bounds["@_width"]
+ deltaWidth;
Review Comment:
Removed
--
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]