Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
distanceTo: function(shape) {
var shapeTrbl = asTRBL(shape);
return sourceTrbl.left - shapeTrbl.right;
}
};
};
}
// we create a list of nodes to take into consideration
// for calculating the optimal flow node distance
//
// * weight existing target nodes higher than source nodes
// * only take into account individual nodes once
//
var nodes = reduce([].concat(
getTargets(source, isReference).map(toTargetNode(5)),
getSources(source, isReference).map(toSourceNode(1))
), function(nodes, node) {
// filter out shapes connected twice via source or target
nodes[node.shape.id + '__weight_' + node.weight] = node;
return nodes;
}, {});
// compute distances between source and incoming nodes;
// group at the same time by distance and expose the
// favourite distance as { fav: { count, value } }.
var distancesGrouped = reduce(nodes, function(result, node) {
var shape = node.shape,
this.addRule('elements.move', HIGH_PRIORITY, function(context) {
let target = context.target,
shapes = context.shapes;
let type;
// do not allow mixed movements of custom / BPMN shapes
// if any shape cannot be moved, the group cannot be moved, too
let allowed = reduce(shapes, function(result, s) {
if (type === undefined) {
type = isDomainStory(s);
}
if (type !== isDomainStory(s) || result === false) {
return false;
}
return canCreate(s, target);
}, undefined);
// reject, if we have at least one
// custom element that cannot be moved
return allowed;
});
updateProperties(bo, newProps) {
const ids = this._moddle.ids;
// Reduce over all new properties and return
//
// {
// changed,
// oldProperties
// }
return reduce(newProps, (result, value, key) => {
const propertyValue = bo.get(key);
// handle nested update
if (isContainer(value)) {
if (!isContainer(propertyValue)) {
throw new Error(
`non-existing property <${key}>: cannot update values`
);
}
let {
changed,
oldProperties
} = this.updateProperties(propertyValue, value);
GraphicsFactory.prototype.updateContainments = function(elements) {
var self = this,
elementRegistry = this._elementRegistry,
parents;
parents = reduce(elements, function(map, e) {
if (e.parent) {
map[e.parent.id] = e.parent;
}
return map;
}, {});
// update all parents of changed and reorganized their children
// in the correct order (as indicated in our model)
forEach(parents, function(parent) {
var children = parent.children;
if (!children) {
return;
function getProperties(businessObject, properties) {
var propertyNames = keys(properties);
return reduce(propertyNames, function(result, key) {
// handle DI separately
if (key !== DI) {
result[key] = businessObject.get(key);
} else {
result[key] = getDiProperties(businessObject.di, keys(properties.di));
}
return result;
}, {});
}
setDirty(tab, dirty = true) {
const { tabs } = this.state;
const newDirtyTabs = reduce(tabs, (dirtyTabs, t) => {
if (t === tab) {
return dirtyTabs;
}
return {
...dirtyTabs,
[ t.id ]: this.isDirty(t)
};
}, {
[ tab.id ]: dirty
});
return {
dirtyTabs: newDirtyTabs
};
}
function getProperties(businessObject, propertyNames) {
return reduce(propertyNames, function(result, key) {
result[key] = businessObject.get(key);
return result;
}, {});
}
function evaluateReviveHooks(entry, element, hooks, reviveCache) {
function revive(entry, reviveCache) {
return reviveDescriptor(entry, reviveCache, hooks);
}
return reduce(hooks, function(result, hook) {
return hook(
entry,
result.root,
result.reviveCache,
revive
);
}, {
root: element,
reviveCache: reviveCache
});
}
function getDiProperties(di, propertyNames) {
return reduce(propertyNames, function(result, key) {
result[key] = di.get(key);
return result;
}, {});
}