diff --git a/dmnverifierfrontend/src/main/resources/META-INF/resources/js/dmnVerifierActions.js b/dmnverifierfrontend/src/main/resources/META-INF/resources/js/dmnVerifierActions.js index 05764793f5483b015450bfa2ba778220ae1eb149..b2b0570f72c073f4bcfb83a763e190d40ede8e95 100644 --- a/dmnverifierfrontend/src/main/resources/META-INF/resources/js/dmnVerifierActions.js +++ b/dmnverifierfrontend/src/main/resources/META-INF/resources/js/dmnVerifierActions.js @@ -13,6 +13,30 @@ function getSheetElementWithId(id) { return getCurrentModeler()._sheet._elementRegistry.get(id); } +/** + * + * @param sourceX + * @param sourceY + * @param w + * @param offsetX + * @param offsetY + * @returns {{x: *, y: *}} + */ +function getRandomNewPointInCycle(sourceX, sourceY, w, offsetX, offsetY) { + let dx = Math.floor(Math.random() * Math.floor(2 * w)) - w; + let dy = Math.sqrt(w * w - dx * dx); + if (offsetX) { + dx += offsetX; + } + if (offsetY) { + dy += offsetY; + } + if (Math.random() > 0.5) { + dy *= -1; + } + return {x: sourceX + dx, y: sourceY + dy}; +} + /** * * @param {VerificationEntry} verificationEntry @@ -35,7 +59,7 @@ function performVerificationFix(verificationEntry, fix, id, $callerButton) { break; case 'CREATE': performVerificationFixCREATE(verificationEntry, fix.actions[i]); - $callerButton.css('display', 'none'); + //$callerButton.css('display', 'none'); break; case 'DELETE': performVerificationFixDELETE(verificationEntry, fix.actions[i]); @@ -208,7 +232,6 @@ function createRule(verificationEntry, fixAction) { * @param {Action} fixAction */ function createInputData(verificationEntry, fixAction) { - // getCurrentModeler().createShape(getCurrentModeler()._elementFactory.createDrdElement('shape', {type:'dmn:InputData'}), {x:0,y:0}, dmnModeler._definitions) openViewWithId(verificationEntry.elements[0].identifier['definitionId']); let decision = getShapeWithId( verificationEntry.elements[0].identifier['decisionId']); @@ -216,9 +239,11 @@ function createInputData(verificationEntry, fixAction) { const shape = modeler._elementFactory.createDrdElement('shape', {type: 'dmn:InputData'}); let inputData = modeler.appendShape(decision, shape, - {x: decision.x - 150, y: decision.y + 40}, + getRandomNewPointInCycle(decision.x, decision.y, 250, decision.width / 2, + decision.height / 2), getShapeWithId(verificationEntry.elements[0].identifier['definitionId']), - {attach: false, connection: {type: "dmn:InformationRequirement"}}); + {attach: false, connection: {type: "dmn:InformationRequirement"}} + ); inputData.businessObject.name = fixAction.actionValues['name']; openViewWithId(verificationEntry.elements[0].identifier['definitionId']); } diff --git a/dmnverifierfrontend/src/main/resources/META-INF/resources/js/dmnViewer.js b/dmnverifierfrontend/src/main/resources/META-INF/resources/js/dmnViewer.js index 78d7169d3afaa1898c76825de0c88ab782a651a5..a1927e652a1de5be7d6d4750f9a987130207f12a 100644 --- a/dmnverifierfrontend/src/main/resources/META-INF/resources/js/dmnViewer.js +++ b/dmnverifierfrontend/src/main/resources/META-INF/resources/js/dmnViewer.js @@ -109,6 +109,10 @@ function toggleFullscreen() { } } +/** + * + * @param id + */ function openViewWithId(id) { var views = dmnModeler.getViews(); views.forEach(function (view) { @@ -135,12 +139,20 @@ function cleanHighlightFunction() { renderHighlightFunction = []; } +/** + * + * @param {Array<VerificationEntryElement>} elements + */ function highlightMultipleDecisions(elements) { elements.forEach(function (el) { highlightSingleDecision(el.identifier['decisionId']); }); } +/** + * + * @param decisionId + */ function highlightSingleDecision(decisionId) { // node let $decisionNode = $( @@ -150,12 +162,20 @@ function highlightSingleDecision(decisionId) { $('#tab-dec-' + decisionId).addClass('highlight'); } +/** + * + * @param {Array<VerificationEntryElement>} elements + */ function cleanMultipleDecisions(elements) { elements.forEach(function (el) { cleanSingleDecision(el.identifier['decisionId']); }); } +/** + * + * @param decisionId + */ function cleanSingleDecision(decisionId) { // node let $decisionNode = $(