Skip to content

Commit

Permalink
fix: fix behaviors JSDocs
Browse files Browse the repository at this point in the history
  • Loading branch information
philippfromme committed Apr 11, 2023
1 parent ea90da7 commit 5589cd4
Show file tree
Hide file tree
Showing 44 changed files with 511 additions and 125 deletions.
24 changes: 17 additions & 7 deletions lib/features/modeling/behavior/AdaptiveLabelPositioningBehavior.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@ import {

import CommandInterceptor from 'diagram-js/lib/command/CommandInterceptor';

/**
* @typedef {import('diagram-js/lib/core/EventBus').default} EventBus
* @typedef {import('../Modeling').default} Modeling
*
* @typedef {import('../../../model/Types').BpmnElement} BpmnElement
* @typedef {import('../../../model/Types').BpmnShape} BpmnShape
*
* @typedef {import('diagram-js/lib/util/Types').DirectionTRBL} DirectionTRBL
*/

var ALIGNMENTS = [
'top',
'bottom',
Expand Down Expand Up @@ -171,9 +181,9 @@ AdaptiveLabelPositioningBehavior.$inject = [
/**
* Return alignments which are taken by a boundary's host element
*
* @param {Shape} element
* @param {BpmnShape} element
*
* @return {Array<string>}
* @return {DirectionTRBL[]}
*/
function getTakenHostAlignments(element) {

Expand Down Expand Up @@ -202,9 +212,9 @@ function getTakenHostAlignments(element) {
/**
* Return alignments which are taken by related connections
*
* @param {Shape} element
* @param {BpmnElement} element
*
* @return {Array<string>}
* @return {DirectionTRBL[]}
*/
function getTakenConnectionAlignments(element) {

Expand All @@ -226,11 +236,11 @@ function getTakenConnectionAlignments(element) {

/**
* Return the optimal label position around an element
* or _undefined_, if none was found.
* or `undefined`, if none was found.
*
* @param {Shape} element
* @param {BpmnElement} element
*
* @return {string} positioning identifier
* @return {DirectionTRBL|undefined}
*/
function getOptimalPosition(element) {

Expand Down
11 changes: 6 additions & 5 deletions lib/features/modeling/behavior/AppendBehavior.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ import { is } from '../../../util/ModelUtil';

import CommandInterceptor from 'diagram-js/lib/command/CommandInterceptor';

/**
* @typedef {import('diagram-js/lib/core/EventBus').default} EventBus
*/

export default function AppendBehavior(eventBus, elementFactory, bpmnRules) {
export default function AppendBehavior(eventBus) {

CommandInterceptor.call(this, eventBus);

Expand All @@ -21,7 +24,7 @@ export default function AppendBehavior(eventBus, elementFactory, bpmnRules) {
if (is(shape, 'bpmn:TextAnnotation')) {
context.position = {
x: source.x + source.width / 2 + 75,
y: source.y - (50) - shape.height / 2
y: source.y - 50 - shape.height / 2
};
} else {
context.position = {
Expand All @@ -36,7 +39,5 @@ export default function AppendBehavior(eventBus, elementFactory, bpmnRules) {
inherits(AppendBehavior, CommandInterceptor);

AppendBehavior.$inject = [
'eventBus',
'elementFactory',
'bpmnRules'
'eventBus'
];
10 changes: 9 additions & 1 deletion lib/features/modeling/behavior/AssociationBehavior.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,15 @@ import {
forEach
} from 'min-dash';


/**
* @typedef {import('didi').Injector} Injector
* @typedef {import('../Modeling').default} Modeling
*/

/**
* @param {Injector} injector
* @param {Modeling} modeling
*/
export default function AssociationBehavior(injector, modeling) {
injector.invoke(CommandInterceptor, this);

Expand Down
14 changes: 11 additions & 3 deletions lib/features/modeling/behavior/AttachEventBehavior.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,19 @@ import { isAny } from '../util/ModelingUtil';

import { isLabel } from '../../../util/LabelUtil';

/**
* @typedef {import('../../replace/BpmnReplace').default} BpmnReplace
* @typedef {import('didi').Injector} Injector
*/

var LOW_PRIORITY = 500;


/**
* Replace intermediate event with boundary event when creating or moving results in attached event.
*
* @param {BpmnReplace} bpmnReplace
* @param {Injector} injector
*/
export default function AttachEventBehavior(bpmnReplace, injector) {
injector.invoke(CommandInterceptor, this);
Expand All @@ -39,7 +47,7 @@ export default function AttachEventBehavior(bpmnReplace, injector) {
}).forEach(function(index) {
var host = elements[ index ];

context.elements[ index ] = self.replaceShape(elements[ index ], host);
context.elements[ index ] = self._replaceShape(elements[ index ], host);
});
}, true);

Expand All @@ -55,7 +63,7 @@ export default function AttachEventBehavior(bpmnReplace, injector) {
var shape = shapes[0];

if (shouldReplace(shape, host)) {
context.shapes = [ self.replaceShape(shape, host) ];
context.shapes = [ self._replaceShape(shape, host) ];
}
}, true);
}
Expand All @@ -67,7 +75,7 @@ AttachEventBehavior.$inject = [

inherits(AttachEventBehavior, CommandInterceptor);

AttachEventBehavior.prototype.replaceShape = function(shape, host) {
AttachEventBehavior.prototype._replaceShape = function(shape, host) {
var eventDefinition = getEventDefinition(shape);

var boundaryEvent = {
Expand Down
9 changes: 8 additions & 1 deletion lib/features/modeling/behavior/BoundaryEventBehavior.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,16 @@ import {
forEach
} from 'min-dash';

/**
* @typedef {import('diagram-js/lib/core/EventBus').default} EventBus
* @typedef {import('../Modeling').default} Modeling
*/

/**
* BPMN specific boundary event behavior
* BPMN specific boundary event behavior.
*
* @param {EventBus} eventBus
* @param {Modeling} modeling
*/
export default function BoundaryEventBehavior(eventBus, modeling) {

Expand Down
6 changes: 6 additions & 0 deletions lib/features/modeling/behavior/CreateBehavior.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@ import CommandInterceptor from 'diagram-js/lib/command/CommandInterceptor';

import { getParent } from '../util/ModelingUtil';

/**
* @typedef {import('didi').Injector} Injector
*/

/**
* @param {Injector} injector
*/
export default function CreateBehavior(injector) {
injector.invoke(CommandInterceptor, this);

Expand Down
14 changes: 10 additions & 4 deletions lib/features/modeling/behavior/CreateDataObjectBehavior.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,18 @@ import CommandInterceptor from 'diagram-js/lib/command/CommandInterceptor';

import { is } from '../../../util/ModelUtil';

/**
* @typedef {import('diagram-js/lib/core/EventBus').default} EventBus
* @typedef {import('../BpmnFactory').default} BpmnFactory
*/

/**
* BPMN specific create data object behavior
* BPMN specific create data object behavior.
*
* @param {EventBus} eventBus
* @param {BpmnFactory} bpmnFactory
*/
export default function CreateDataObjectBehavior(eventBus, bpmnFactory, moddle) {
export default function CreateDataObjectBehavior(eventBus, bpmnFactory) {

CommandInterceptor.call(this, eventBus);

Expand All @@ -31,8 +38,7 @@ export default function CreateDataObjectBehavior(eventBus, bpmnFactory, moddle)

CreateDataObjectBehavior.$inject = [
'eventBus',
'bpmnFactory',
'moddle'
'bpmnFactory'
];

inherits(CreateDataObjectBehavior, CommandInterceptor);
10 changes: 10 additions & 0 deletions lib/features/modeling/behavior/CreateParticipantBehavior.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ import {

import { asTRBL } from 'diagram-js/lib/layout/LayoutUtil';

/**
* @typedef {import('diagram-js/lib/core/Canvas').default} Canvas
* @typedef {import('diagram-js/lib/core/EventBus').default} EventBus
* @typedef {import('../Modeling').default} Modeling
*/

var HORIZONTAL_PARTICIPANT_PADDING = 20,
VERTICAL_PARTICIPANT_PADDING = 20;

Expand All @@ -25,6 +31,10 @@ var HIGH_PRIORITY = 2000;

/**
* BPMN-specific behavior for creating participants.
*
* @param {Canvas} canvas
* @param {EventBus} eventBus
* @param {Modeling} modeling
*/
export default function CreateParticipantBehavior(canvas, eventBus, modeling) {
CommandInterceptor.call(this, eventBus);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ import {
is
} from '../../../util/ModelUtil';

/**
* @typedef {import('diagram-js/lib/core/EventBus').default} EventBus
* @typedef {import('../BpmnFactory').default} BpmnFactory
*/

var TARGET_REF_PLACEHOLDER_NAME = '__targetRef_placeholder';


Expand Down
13 changes: 12 additions & 1 deletion lib/features/modeling/behavior/DataStoreBehavior.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,20 @@ import { isAny } from '../util/ModelingUtil';

import UpdateSemanticParentHandler from '../cmd/UpdateSemanticParentHandler';

/**
* @typedef {import('diagram-js/lib/core/Canvas').default} Canvas
* @typedef {import('diagram-js/lib/command/CommandStack').default} CommandStack
* @typedef {import('diagram-js/lib/core/ElementRegistry').default} ElementRegistry
* @typedef {import('diagram-js/lib/core/EventBus').default} EventBus
*/

/**
* BPMN specific data store behavior
* BPMN specific data store behavior.
*
* @param {Canvas} canvas
* @param {CommandStack} commandStack
* @param {ElementRegistry} elementRegistry
* @param {EventBus} eventBus
*/
export default function DataStoreBehavior(
canvas, commandStack, elementRegistry,
Expand Down
12 changes: 9 additions & 3 deletions lib/features/modeling/behavior/DeleteLaneBehavior.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,21 @@ import {
eachElement
} from 'diagram-js/lib/util/Elements';

/**
* @typedef {import('diagram-js/lib/core/EventBus').default} EventBus
* @typedef {import('../../space-tool/BpmnSpaceTool').default} SpaceTool
*/

var LOW_PRIORITY = 500;


/**
* BPMN specific delete lane behavior
* BPMN specific delete lane behavior.
*
* @param {EventBus} eventBus
* @param {SpaceTool} spaceTool
*/
export default function DeleteLaneBehavior(eventBus, modeling, spaceTool) {
export default function DeleteLaneBehavior(eventBus, spaceTool) {

CommandInterceptor.call(this, eventBus);

Expand Down Expand Up @@ -105,7 +112,6 @@ export default function DeleteLaneBehavior(eventBus, modeling, spaceTool) {

DeleteLaneBehavior.$inject = [
'eventBus',
'modeling',
'spaceTool'
];

Expand Down
14 changes: 11 additions & 3 deletions lib/features/modeling/behavior/DetachEventBehavior.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,19 @@ import {

import { isLabel } from '../../../util/LabelUtil';

/**
* @typedef {import('../../replace/BpmnReplace').default} BpmnReplace
* @typedef {import('didi').Injector} Injector
*/

var LOW_PRIORITY = 500;


/**
* Replace boundary event with intermediate event when creating or moving results in detached event.
*
* @param {BpmnReplace} bpmnReplace
* @param {Injector} injector
*/
export default function DetachEventBehavior(bpmnReplace, injector) {
injector.invoke(CommandInterceptor, this);
Expand All @@ -32,7 +40,7 @@ export default function DetachEventBehavior(bpmnReplace, injector) {
}).map(function(shape) {
return elements.indexOf(shape);
}).forEach(function(index) {
context.elements[ index ] = self.replaceShape(elements[ index ]);
context.elements[ index ] = self._replaceShape(elements[ index ]);
});
}, true);

Expand All @@ -44,7 +52,7 @@ export default function DetachEventBehavior(bpmnReplace, injector) {
var host = shape.host;

if (shouldReplace(shape, includes(shapes, host) ? host : newHost)) {
shapes[ index ] = self.replaceShape(shape);
shapes[ index ] = self._replaceShape(shape);
}
});
}, true);
Expand All @@ -57,7 +65,7 @@ DetachEventBehavior.$inject = [

inherits(DetachEventBehavior, CommandInterceptor);

DetachEventBehavior.prototype.replaceShape = function(shape) {
DetachEventBehavior.prototype._replaceShape = function(shape) {
var eventDefinition = getEventDefinition(shape),
intermediateEvent;

Expand Down
12 changes: 11 additions & 1 deletion lib/features/modeling/behavior/DropOnFlowBehavior.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,17 @@ import {
getApproxIntersection
} from 'diagram-js/lib/util/LineIntersection';


/**
* @typedef {import('diagram-js/lib/core/EventBus').default} EventBus
* @typedef {import('../../rules/BpmnRules').default} BpmnRules
* @typedef {import('../../modeling/Modeling').default} Modeling
*/

/**
* @param {EventBus} eventBus
* @param {BpmnRules} bpmnRules
* @param {Modeling} modeling
*/
export default function DropOnFlowBehavior(eventBus, bpmnRules, modeling) {

CommandInterceptor.call(this, eventBus);
Expand Down
9 changes: 9 additions & 0 deletions lib/features/modeling/behavior/EventBasedGatewayBehavior.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@ import CommandInterceptor from 'diagram-js/lib/command/CommandInterceptor';

import { is } from '../../../util/ModelUtil';

/**
* @typedef {import('diagram-js/lib/core/EventBus').default} EventBus
* @typedef {import('../Modeling').default} Modeling
*/

/**
* @param {EventBus} eventBus
* @param {Modeling} modeling
*/
export default function EventBasedGatewayBehavior(eventBus, modeling) {

CommandInterceptor.call(this, eventBus);
Expand Down

0 comments on commit 5589cd4

Please sign in to comment.