all files / lib/features/global-connect/ BpmnGlobalConnect.js

100% Statements 8/8
100% Branches 4/4
100% Functions 3/3
100% Lines 8/8
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48                          64×                                                      
import {
  isAny
} from '../modeling/util/ModelingUtil';
 
import {
  isLabel
} from '../../util/LabelUtil';
 
/**
 * Extention of GlobalConnect tool that implements BPMN specific rules about
 * connection start elements.
 */
export default function BpmnGlobalConnect(globalConnect) {
  globalConnect.registerProvider(this);
}
 
BpmnGlobalConnect.$inject = [ 'globalConnect' ];
 
 
/**
 * Checks if given element can be used for starting connection.
 *
 * @param  {Element} source
 * @return {Boolean}
 */
BpmnGlobalConnect.prototype.canStartConnect = function(source) {
 
  if (nonExistantOrLabel(source)) {
    return null;
  }
 
  var businessObject = source.businessObject;
 
  return isAny(businessObject, [
    'bpmn:FlowNode',
    'bpmn:InteractionNode',
    'bpmn:DataObjectReference',
    'bpmn:DataStoreReference'
  ]);
};
 
 
function nonExistantOrLabel(element) {
  return !element || isLabel(element);
}