Skip to content
Snippets Groups Projects
Commit 49c07372 authored by Jonas Blatt's avatar Jonas Blatt :ant:
Browse files

Random place for input data

parent 4a6dbb4f
No related branches found
No related tags found
No related merge requests found
...@@ -13,6 +13,30 @@ function getSheetElementWithId(id) { ...@@ -13,6 +13,30 @@ function getSheetElementWithId(id) {
return getCurrentModeler()._sheet._elementRegistry.get(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 * @param {VerificationEntry} verificationEntry
...@@ -35,7 +59,7 @@ function performVerificationFix(verificationEntry, fix, id, $callerButton) { ...@@ -35,7 +59,7 @@ function performVerificationFix(verificationEntry, fix, id, $callerButton) {
break; break;
case 'CREATE': case 'CREATE':
performVerificationFixCREATE(verificationEntry, fix.actions[i]); performVerificationFixCREATE(verificationEntry, fix.actions[i]);
$callerButton.css('display', 'none'); //$callerButton.css('display', 'none');
break; break;
case 'DELETE': case 'DELETE':
performVerificationFixDELETE(verificationEntry, fix.actions[i]); performVerificationFixDELETE(verificationEntry, fix.actions[i]);
...@@ -208,7 +232,6 @@ function createRule(verificationEntry, fixAction) { ...@@ -208,7 +232,6 @@ function createRule(verificationEntry, fixAction) {
* @param {Action} fixAction * @param {Action} fixAction
*/ */
function createInputData(verificationEntry, 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']); openViewWithId(verificationEntry.elements[0].identifier['definitionId']);
let decision = getShapeWithId( let decision = getShapeWithId(
verificationEntry.elements[0].identifier['decisionId']); verificationEntry.elements[0].identifier['decisionId']);
...@@ -216,9 +239,11 @@ function createInputData(verificationEntry, fixAction) { ...@@ -216,9 +239,11 @@ function createInputData(verificationEntry, fixAction) {
const shape = modeler._elementFactory.createDrdElement('shape', const shape = modeler._elementFactory.createDrdElement('shape',
{type: 'dmn:InputData'}); {type: 'dmn:InputData'});
let inputData = modeler.appendShape(decision, shape, 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']), getShapeWithId(verificationEntry.elements[0].identifier['definitionId']),
{attach: false, connection: {type: "dmn:InformationRequirement"}}); {attach: false, connection: {type: "dmn:InformationRequirement"}}
);
inputData.businessObject.name = fixAction.actionValues['name']; inputData.businessObject.name = fixAction.actionValues['name'];
openViewWithId(verificationEntry.elements[0].identifier['definitionId']); openViewWithId(verificationEntry.elements[0].identifier['definitionId']);
} }
......
...@@ -109,6 +109,10 @@ function toggleFullscreen() { ...@@ -109,6 +109,10 @@ function toggleFullscreen() {
} }
} }
/**
*
* @param id
*/
function openViewWithId(id) { function openViewWithId(id) {
var views = dmnModeler.getViews(); var views = dmnModeler.getViews();
views.forEach(function (view) { views.forEach(function (view) {
...@@ -135,12 +139,20 @@ function cleanHighlightFunction() { ...@@ -135,12 +139,20 @@ function cleanHighlightFunction() {
renderHighlightFunction = []; renderHighlightFunction = [];
} }
/**
*
* @param {Array<VerificationEntryElement>} elements
*/
function highlightMultipleDecisions(elements) { function highlightMultipleDecisions(elements) {
elements.forEach(function (el) { elements.forEach(function (el) {
highlightSingleDecision(el.identifier['decisionId']); highlightSingleDecision(el.identifier['decisionId']);
}); });
} }
/**
*
* @param decisionId
*/
function highlightSingleDecision(decisionId) { function highlightSingleDecision(decisionId) {
// node // node
let $decisionNode = $( let $decisionNode = $(
...@@ -150,12 +162,20 @@ function highlightSingleDecision(decisionId) { ...@@ -150,12 +162,20 @@ function highlightSingleDecision(decisionId) {
$('#tab-dec-' + decisionId).addClass('highlight'); $('#tab-dec-' + decisionId).addClass('highlight');
} }
/**
*
* @param {Array<VerificationEntryElement>} elements
*/
function cleanMultipleDecisions(elements) { function cleanMultipleDecisions(elements) {
elements.forEach(function (el) { elements.forEach(function (el) {
cleanSingleDecision(el.identifier['decisionId']); cleanSingleDecision(el.identifier['decisionId']);
}); });
} }
/**
*
* @param decisionId
*/
function cleanSingleDecision(decisionId) { function cleanSingleDecision(decisionId) {
// node // node
let $decisionNode = $( let $decisionNode = $(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment