Skip to content

Commit

Permalink
fix(BpmnFactory): fix JSDoc
Browse files Browse the repository at this point in the history
  • Loading branch information
philippfromme committed Apr 4, 2023
1 parent 95f9d22 commit 7ae67c5
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 9 deletions.
2 changes: 1 addition & 1 deletion lib/BaseModeler.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import BaseViewer from './BaseViewer';
* @typedef {import('./BaseViewer').ModdleElement} ModdleElement
* @typedef {import('./BaseViewer').ModdleElementsById} ModdleElementsById
*
* @typedef {import('.').Moddle} Moddle
* @typedef {any} Moddle
*/

/**
Expand Down
65 changes: 57 additions & 8 deletions lib/features/modeling/BpmnFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,27 @@ import {
is
} from '../../util/ModelUtil';


/**
* @typedef {import('../../BaseModeler').Moddle} Moddle
* @typedef {import('../../BaseViewer').ModdleElement} ModdleElement
*
* @typedef {import('diagram-js/lib/util/Types').Point} Point
*/

/**
* @param {Moddle} moddle
*/
export default function BpmnFactory(moddle) {
this._model = moddle;
}

BpmnFactory.$inject = [ 'moddle' ];


/**
* @param {ModdleElement} element
*
* @returns {boolean}
*/
BpmnFactory.prototype._needsId = function(element) {
return isAny(element, [
'bpmn:RootElement',
Expand All @@ -41,6 +54,9 @@ BpmnFactory.prototype._needsId = function(element) {
]);
};

/**
* @param {ModdleElement} element
*/
BpmnFactory.prototype._ensureId = function(element) {
if (element.id) {
this._model.ids.claim(element.id, element);
Expand Down Expand Up @@ -70,7 +86,14 @@ BpmnFactory.prototype._ensureId = function(element) {
}
};


/**
* Create BPMN element.
*
* @param {string} type
* @param {Object} [attrs]
*
* @returns {ModdleElement}
*/
BpmnFactory.prototype.create = function(type, attrs) {
var element = this._model.create(type, attrs || {});

Expand All @@ -79,27 +102,37 @@ BpmnFactory.prototype.create = function(type, attrs) {
return element;
};


/**
* @returns {ModdleElement}
*/
BpmnFactory.prototype.createDiLabel = function() {
return this.create('bpmndi:BPMNLabel', {
bounds: this.createDiBounds()
});
};


/**
* @returns {ModdleElement}
*/
BpmnFactory.prototype.createDiShape = function(semantic, attrs) {
return this.create('bpmndi:BPMNShape', assign({
bpmnElement: semantic,
bounds: this.createDiBounds()
}, attrs));
};


/**
* @returns {ModdleElement}
*/
BpmnFactory.prototype.createDiBounds = function(bounds) {
return this.create('dc:Bounds', bounds);
};


/**
* @param {Point[]} waypoints
*
* @returns {ModdleElement[]}
*/
BpmnFactory.prototype.createDiWaypoints = function(waypoints) {
var self = this;

Expand All @@ -108,18 +141,34 @@ BpmnFactory.prototype.createDiWaypoints = function(waypoints) {
});
};

/**
* @param {Point} point
*
* @returns {ModdleElement}
*/
BpmnFactory.prototype.createDiWaypoint = function(point) {
return this.create('dc:Point', pick(point, [ 'x', 'y' ]));
};


/**
* @param {ModdleElement} semantic
* @param {Object} attrs
*
* @returns {ModdleElement}
*/
BpmnFactory.prototype.createDiEdge = function(semantic, attrs) {
return this.create('bpmndi:BPMNEdge', assign({
bpmnElement: semantic,
waypoint: this.createDiWaypoints([])
}, attrs));
};

/**
* @param {ModdleElement} semantic
* @param {Object} attrs
*
* @returns {ModdleElement}
*/
BpmnFactory.prototype.createDiPlane = function(semantic, attrs) {
return this.create('bpmndi:BPMNPlane', assign({
bpmnElement: semantic
Expand Down

0 comments on commit 7ae67c5

Please sign in to comment.