mirror of
https://github.com/bpmn-io/bpmn-js.git
synced 2025-08-26 12:40:20 +08:00
fix(ElementFactory): fix JSDoc
This commit is contained in:
@ -33,36 +33,52 @@ import {
|
|||||||
} from '../../util/CompatibilityUtil';
|
} from '../../util/CompatibilityUtil';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {import('diagram-js/lib/model').Base} Base
|
* @typedef {import('diagram-js/lib/model').Element} Element
|
||||||
* @typedef {import('diagram-js/lib/model').Connection} Connection
|
* @typedef {import('diagram-js/lib/model').Connection} Connection
|
||||||
|
* @typedef {import('diagram-js/lib/model').Label} Label
|
||||||
* @typedef {import('diagram-js/lib/model').Root} Root
|
* @typedef {import('diagram-js/lib/model').Root} Root
|
||||||
* @typedef {import('diagram-js/lib/model').Shape} Shape
|
* @typedef {import('diagram-js/lib/model').Shape} Shape
|
||||||
* @typedef {import('diagram-js/lib/model').ModelAttrs} ModelAttrs
|
|
||||||
* @typedef {import('diagram-js/lib/model').ModelAttrsConnection} ModelAttrsConnection
|
|
||||||
* @typedef {import('diagram-js/lib/model').ModelAttrsRoot} ModelAttrsRoot
|
|
||||||
* @typedef {import('diagram-js/lib/model').ModelAttrsShape} ModelAttrsShape
|
|
||||||
* @typedef {import('diagram-js/lib/model').ModelType} ModelType
|
|
||||||
* @typedef {import('diagram-js/lib/model').ModelTypeConnection} ModelTypeConnection
|
|
||||||
* @typedef {import('diagram-js/lib/model').ModelTypeRoot} ModelTypeRoot
|
|
||||||
* @typedef {import('diagram-js/lib/model').ModelTypeShape} ModelTypeShape
|
|
||||||
*
|
*
|
||||||
* @typedef {import('diagram-js/lib/i18n/translate/translate').TranslateFunction} TranslateFunction
|
* @typedef {import('diagram-js/lib/i18n/translate/translate').default} Translate
|
||||||
*
|
*
|
||||||
* @typedef {import('diagram-js/lib/util/Types').Dimensions} Dimensions
|
* @typedef {import('diagram-js/lib/util/Types').Dimensions} Dimensions
|
||||||
*
|
*
|
||||||
* @typedef {import('./BpmnFactory').default} BpmnFactory
|
* @typedef {import('./BpmnFactory').default} BpmnFactory
|
||||||
* @typedef {import('./ElementFactory').ModelAttrsBPMN} ModelAttrsBPMN
|
|
||||||
*
|
*
|
||||||
* @typedef {import('../../BaseModeler').Moddle} Moddle
|
* @typedef {import('../../BaseModeler').Moddle} Moddle
|
||||||
* @typedef {import('../../BaseViewer').ModdleElement} ModdleElement
|
* @typedef {import('../../BaseViewer').ModdleElement} ModdleElement
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef { {
|
||||||
|
* businessObject: any;
|
||||||
|
* di: any;
|
||||||
|
* type: string;
|
||||||
|
* } & Element } BpmnElement
|
||||||
|
*
|
||||||
|
* @typedef { {
|
||||||
|
* associationDirection: 'None' | 'One' | 'Both';
|
||||||
|
* cancelActivity: boolean;
|
||||||
|
* eventDefinitionType: string;
|
||||||
|
* isExpanded: boolean;
|
||||||
|
* isForCompensation: boolean;
|
||||||
|
* isInterrupting: boolean;
|
||||||
|
* processRef: ModdleElement;
|
||||||
|
* triggeredByEvent: boolean;
|
||||||
|
* } } BpmnAttributes
|
||||||
|
*
|
||||||
|
* @typedef {Connection & BpmnElement} BpmnConnection
|
||||||
|
* @typedef {Label & BpmnElement} BpmnLabel
|
||||||
|
* @typedef {Root & BpmnElement} BpmnRoot
|
||||||
|
* @typedef {Shape & BpmnElement} BpmnShape
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A BPMN-aware factory for diagram elements.
|
* A BPMN-aware factory for diagram elements.
|
||||||
*
|
*
|
||||||
* @param {BpmnFactory} bpmnFactory
|
* @param {BpmnFactory} bpmnFactory
|
||||||
* @param {Moddle} moddle
|
* @param {Moddle} moddle
|
||||||
* @param {TranslateFunction} translate
|
* @param {Translate} translate
|
||||||
*/
|
*/
|
||||||
export default function ElementFactory(bpmnFactory, moddle, translate) {
|
export default function ElementFactory(bpmnFactory, moddle, translate) {
|
||||||
BaseElementFactory.call(this);
|
BaseElementFactory.call(this);
|
||||||
@ -80,15 +96,41 @@ ElementFactory.$inject = [
|
|||||||
'translate'
|
'translate'
|
||||||
];
|
];
|
||||||
|
|
||||||
ElementFactory.prototype.baseCreate = BaseElementFactory.prototype.create;
|
ElementFactory.prototype._baseCreate = BaseElementFactory.prototype.create;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create an element.
|
* Create a root element.
|
||||||
*
|
*
|
||||||
* @param {ModelType} elementType The type of the element to be created.
|
* @overlord
|
||||||
* @param {ModelAttrs} attrs The attributes to create the element with.
|
* @param {'root'} type
|
||||||
|
* @param {Partial<BpmnRoot> & Partial<BpmnAttributes>} [attrs]
|
||||||
|
* @return {BpmnRoot}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a shape.
|
||||||
*
|
*
|
||||||
* @returns {Base} The created diagram element.
|
* @overlord
|
||||||
|
* @param {'shape'} type
|
||||||
|
* @param {Partial<BpmnShape> & Partial<BpmnAttributes>} [attrs]
|
||||||
|
* @return {BpmnShape}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a connection.
|
||||||
|
*
|
||||||
|
* @overlord
|
||||||
|
* @param {'connection'} type
|
||||||
|
* @param {Partial<BpmnConnection> & Partial<BpmnAttributes>} [attrs]
|
||||||
|
* @return {BpmnConnection}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a label.
|
||||||
|
*
|
||||||
|
* @param {'label'} type
|
||||||
|
* @param {Partial<BpmnLabel> & Partial<BpmnAttributes>} [attrs]
|
||||||
|
* @return {BpmnLabel}
|
||||||
*/
|
*/
|
||||||
ElementFactory.prototype.create = function(elementType, attrs) {
|
ElementFactory.prototype.create = function(elementType, attrs) {
|
||||||
|
|
||||||
@ -97,19 +139,36 @@ ElementFactory.prototype.create = function(elementType, attrs) {
|
|||||||
// and wired via attrs
|
// and wired via attrs
|
||||||
if (elementType === 'label') {
|
if (elementType === 'label') {
|
||||||
var di = attrs.di || this._bpmnFactory.createDiLabel();
|
var di = attrs.di || this._bpmnFactory.createDiLabel();
|
||||||
return this.baseCreate(elementType, assign({ type: 'label', di: di }, DEFAULT_LABEL_SIZE, attrs));
|
return this._baseCreate(elementType, assign({ type: 'label', di: di }, DEFAULT_LABEL_SIZE, attrs));
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.createBpmnElement(elementType, attrs);
|
return this.createBpmnElement(elementType, attrs);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a BPMN-specific element.
|
* Create a BPMN root element.
|
||||||
*
|
*
|
||||||
* @param {ModelTypeConnection|ModelTypeRoot|ModelTypeShape} elementType The type of the element to be created.
|
* @overlord
|
||||||
* @param {ModelAttrsConnection|ModelAttrsRoot|ModelAttrsShape} attrs The attributes to create the element with.
|
* @param {'root'} elementType
|
||||||
|
* @param {Partial<BpmnRoot> & Partial<BpmnAttributes>} [attrs]
|
||||||
|
* @return {BpmnRoot}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a BPMN shape.
|
||||||
*
|
*
|
||||||
* @returns {Connection|Root|Shape} The created diagram element.
|
* @overlord
|
||||||
|
* @param {'shape'} elementType
|
||||||
|
* @param {Partial<BpmnShape> & Partial<BpmnAttributes>} [attrs]
|
||||||
|
* @return {BpmnShape}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a BPMN connection.
|
||||||
|
*
|
||||||
|
* @param {'connection'} elementType
|
||||||
|
* @param {Partial<BpmnConnection> & Partial<BpmnAttributes>} [attrs]
|
||||||
|
* @return {BpmnConnection}
|
||||||
*/
|
*/
|
||||||
ElementFactory.prototype.createBpmnElement = function(elementType, attrs) {
|
ElementFactory.prototype.createBpmnElement = function(elementType, attrs) {
|
||||||
var size,
|
var size,
|
||||||
@ -210,13 +269,13 @@ ElementFactory.prototype.createBpmnElement = function(elementType, attrs) {
|
|||||||
di: di
|
di: di
|
||||||
});
|
});
|
||||||
|
|
||||||
return this.baseCreate(elementType, attrs);
|
return this._baseCreate(elementType, attrs);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the default size of a diagram element.
|
* Get the default size of a diagram element.
|
||||||
*
|
*
|
||||||
* @param {Base} element The element.
|
* @param {BpmnElement} element The element.
|
||||||
* @param {ModdleElement} di The DI.
|
* @param {ModdleElement} di The DI.
|
||||||
*
|
*
|
||||||
* @returns {Dimensions} Default width and height of the element.
|
* @returns {Dimensions} Default width and height of the element.
|
||||||
@ -281,10 +340,10 @@ ElementFactory.prototype.getDefaultSize = function(element, di) {
|
|||||||
/**
|
/**
|
||||||
* Create participant.
|
* Create participant.
|
||||||
*
|
*
|
||||||
* @param {boolean|Object} [attrs] Attributes or whether the participant is
|
* @param {boolean|Partial<BpmnShape> & Partial<BpmnAttributes>} [attrs] Attributes or whether the participant is
|
||||||
* expanded.
|
* expanded.
|
||||||
*
|
*
|
||||||
* @returns {Shape} The created participant.
|
* @returns {BpmnShape} The created participant.
|
||||||
*/
|
*/
|
||||||
ElementFactory.prototype.createParticipantShape = function(attrs) {
|
ElementFactory.prototype.createParticipantShape = function(attrs) {
|
||||||
|
|
||||||
@ -309,7 +368,7 @@ ElementFactory.prototype.createParticipantShape = function(attrs) {
|
|||||||
* Apply attributes from a map to the given element,
|
* Apply attributes from a map to the given element,
|
||||||
* remove attribute from the map on application.
|
* remove attribute from the map on application.
|
||||||
*
|
*
|
||||||
* @param {Base} element
|
* @param {Element} element
|
||||||
* @param {Object} attrs (in/out map of attributes)
|
* @param {Object} attrs (in/out map of attributes)
|
||||||
* @param {Array<string>} attributeNames name of attributes to apply
|
* @param {Array<string>} attributeNames name of attributes to apply
|
||||||
*
|
*
|
||||||
@ -328,7 +387,7 @@ function applyAttributes(element, attrs, attributeNames) {
|
|||||||
* Apply named property to element and drain it from the attrs
|
* Apply named property to element and drain it from the attrs
|
||||||
* collection.
|
* collection.
|
||||||
*
|
*
|
||||||
* @param {Base} element
|
* @param {Element} element
|
||||||
* @param {Object} attrs (in/out map of attributes)
|
* @param {Object} attrs (in/out map of attributes)
|
||||||
* @param {string} attributeName to apply
|
* @param {string} attributeName to apply
|
||||||
*
|
*
|
||||||
|
@ -58,6 +58,32 @@ elementFactory.create('label', {
|
|||||||
type: 'bpmn:Task'
|
type: 'bpmn:Task'
|
||||||
});
|
});
|
||||||
|
|
||||||
|
elementFactory.create('connection', {
|
||||||
|
type: 'bpmn:Association',
|
||||||
|
associationDirection: 'One'
|
||||||
|
});
|
||||||
|
|
||||||
|
elementFactory.create('shape', {
|
||||||
|
type: 'bpmn:BoundaryEvent',
|
||||||
|
cancelActivity: true,
|
||||||
|
eventDefinitionType: 'bpmn:ErrorEventDefinition'
|
||||||
|
});
|
||||||
|
|
||||||
|
elementFactory.create('shape', {
|
||||||
|
type: 'bpmn:Task',
|
||||||
|
isForCompensation: false
|
||||||
|
});
|
||||||
|
|
||||||
|
elementFactory.create('shape', {
|
||||||
|
type: 'bpmn:Participant',
|
||||||
|
processRef: {}
|
||||||
|
});
|
||||||
|
|
||||||
|
elementFactory.create('shape', {
|
||||||
|
type: 'bpmn:SubProcess',
|
||||||
|
triggeredByEvent: true
|
||||||
|
});
|
||||||
|
|
||||||
elementFactory.createBpmnElement('connection', {
|
elementFactory.createBpmnElement('connection', {
|
||||||
type: 'bpmn:SequenceFlow'
|
type: 'bpmn:SequenceFlow'
|
||||||
});
|
});
|
||||||
|
@ -22,7 +22,7 @@ export default function CustomElementFactory(injector) {
|
|||||||
size;
|
size;
|
||||||
|
|
||||||
if (elementType === 'label') {
|
if (elementType === 'label') {
|
||||||
return self.baseCreate(elementType, assign({ type: 'label' }, DEFAULT_LABEL_SIZE, attrs));
|
return self._baseCreate(elementType, assign({ type: 'label' }, DEFAULT_LABEL_SIZE, attrs));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (/^custom:/.test(type)) {
|
if (/^custom:/.test(type)) {
|
||||||
@ -32,7 +32,7 @@ export default function CustomElementFactory(injector) {
|
|||||||
|
|
||||||
size = self._getCustomElementSize(type);
|
size = self._getCustomElementSize(type);
|
||||||
|
|
||||||
return self.baseCreate(elementType,
|
return self._baseCreate(elementType,
|
||||||
assign({ type: elementType, businessObject: businessObject }, attrs, size));
|
assign({ type: elementType, businessObject: businessObject }, attrs, size));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user