chore(project): es6ify source code

* use ES6 import / export
* UTILS: export individual utilities
* TESTS: localize TestHelper includes

BREAKING CHANGE:

* all utilities export independent functions
* library sources got ported to ES6. You must now use
  a ES module bundler such as Browserify + babelify or
  Webpack to consume this library (or parts of it).
This commit is contained in:
Nico Rehwaldt
2018-04-02 21:01:53 +02:00
parent 56a644177d
commit d3449ca87c
224 changed files with 2635 additions and 1932 deletions

View File

@ -1,28 +1,37 @@
'use strict';
var collectLanes = require('../util/LaneUtil').collectLanes;
import {
collectLanes,
getLanesRoot
} from '../util/LaneUtil';
var getLanesRoot = require('../util/LaneUtil').getLanesRoot;
import {
is
} from '../../../util/ModelUtil';
var is = require('../../../util/ModelUtil').is;
import {
add as collectionAdd,
remove as collectionRemove
} from 'diagram-js/lib/util/Collections';
var Collections = require('diagram-js/lib/util/Collections');
var asTRBL = require('diagram-js/lib/layout/LayoutUtil').asTRBL;
import {
asTRBL
} from 'diagram-js/lib/layout/LayoutUtil';
var FLOW_NODE_REFS_ATTR = 'flowNodeRef',
LANES_ATTR = 'lanes';
/**
* A handler that updates lane refs on changed elements
*/
function UpdateFlowNodeRefsHandler(elementRegistry) {
export default function UpdateFlowNodeRefsHandler(elementRegistry) {
this._elementRegistry = elementRegistry;
}
UpdateFlowNodeRefsHandler.$inject = [ 'elementRegistry' ];
module.exports = UpdateFlowNodeRefsHandler;
UpdateFlowNodeRefsHandler.$inject = [
'elementRegistry'
];
UpdateFlowNodeRefsHandler.prototype.computeUpdates = function(flowNodeShapes, laneShapes) {
@ -143,14 +152,14 @@ UpdateFlowNodeRefsHandler.prototype.execute = function(context) {
// unwire old
update.remove.forEach(function(oldLane) {
Collections.remove(lanes, oldLane);
Collections.remove(oldLane.get(FLOW_NODE_REFS_ATTR), flowNode);
collectionRemove(lanes, oldLane);
collectionRemove(oldLane.get(FLOW_NODE_REFS_ATTR), flowNode);
});
// wire new
update.add.forEach(function(newLane) {
Collections.add(lanes, newLane);
Collections.add(newLane.get(FLOW_NODE_REFS_ATTR), flowNode);
collectionAdd(lanes, newLane);
collectionAdd(newLane.get(FLOW_NODE_REFS_ATTR), flowNode);
});
});
@ -170,14 +179,14 @@ UpdateFlowNodeRefsHandler.prototype.revert = function(context) {
// unwire new
update.add.forEach(function(newLane) {
Collections.remove(lanes, newLane);
Collections.remove(newLane.get(FLOW_NODE_REFS_ATTR), flowNode);
collectionRemove(lanes, newLane);
collectionRemove(newLane.get(FLOW_NODE_REFS_ATTR), flowNode);
});
// wire old
update.remove.forEach(function(oldLane) {
Collections.add(lanes, oldLane);
Collections.add(oldLane.get(FLOW_NODE_REFS_ATTR), flowNode);
collectionAdd(lanes, oldLane);
collectionAdd(oldLane.get(FLOW_NODE_REFS_ATTR), flowNode);
});
});