2022-01-21 13:47:14 +00:00
|
|
|
import { getDi, is } from './ModelUtil';
|
2021-12-15 10:45:45 +00:00
|
|
|
|
|
|
|
|
2022-01-25 12:54:32 +00:00
|
|
|
export var planeSuffix = '_plane';
|
2021-12-15 10:45:45 +00:00
|
|
|
|
|
|
|
/**
|
2022-01-30 15:46:44 +00:00
|
|
|
* Get primary shape ID for a plane.
|
2021-12-15 10:45:45 +00:00
|
|
|
*
|
|
|
|
* @param {djs.model.Base|ModdleElement} element
|
2022-01-30 15:46:44 +00:00
|
|
|
*
|
|
|
|
* @returns {String}
|
|
|
|
*/
|
|
|
|
export function getShapeIdFromPlane(element) {
|
|
|
|
var id = element.id;
|
|
|
|
|
|
|
|
return removePlaneSuffix(id);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get plane ID for a primary shape.
|
|
|
|
*
|
|
|
|
* @param {djs.model.Base|ModdleElement} element
|
|
|
|
*
|
|
|
|
* @returns {String}
|
2021-12-15 10:45:45 +00:00
|
|
|
*/
|
2022-01-30 15:46:44 +00:00
|
|
|
export function getPlaneIdFromShape(element) {
|
|
|
|
var id = element.id;
|
|
|
|
|
2021-12-15 10:45:45 +00:00
|
|
|
if (is(element, 'bpmn:SubProcess')) {
|
2022-01-30 15:46:44 +00:00
|
|
|
return addPlaneSuffix(id);
|
2021-12-15 10:45:45 +00:00
|
|
|
}
|
|
|
|
|
2022-01-30 15:46:44 +00:00
|
|
|
return id;
|
2021-12-15 10:45:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2022-01-30 15:46:44 +00:00
|
|
|
* Get plane ID for primary shape ID.
|
2021-12-15 10:45:45 +00:00
|
|
|
*
|
2022-01-30 15:46:44 +00:00
|
|
|
* @param {String} id
|
|
|
|
*
|
|
|
|
* @returns {String}
|
2021-12-15 10:45:45 +00:00
|
|
|
*/
|
2022-01-30 15:46:44 +00:00
|
|
|
export function toPlaneId(id) {
|
|
|
|
return addPlaneSuffix(id);
|
2022-01-21 13:47:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2022-01-30 15:46:44 +00:00
|
|
|
* Check wether element is plane.
|
2022-01-21 13:47:14 +00:00
|
|
|
*
|
|
|
|
* @param {djs.model.Base|ModdleElement} element
|
2022-01-30 15:46:44 +00:00
|
|
|
*
|
2022-01-21 13:47:14 +00:00
|
|
|
* @returns {Boolean}
|
|
|
|
*/
|
|
|
|
export function isPlane(element) {
|
|
|
|
var di = getDi(element);
|
2022-01-30 15:46:44 +00:00
|
|
|
|
2022-01-21 13:47:14 +00:00
|
|
|
return is(di, 'bpmndi:BPMNPlane');
|
|
|
|
}
|
|
|
|
|
2022-01-30 15:46:44 +00:00
|
|
|
function addPlaneSuffix(id) {
|
|
|
|
return id + planeSuffix;
|
|
|
|
}
|
|
|
|
|
|
|
|
function removePlaneSuffix(id) {
|
|
|
|
return id.replace(new RegExp(planeSuffix + '$'), '');
|
2021-12-15 10:45:45 +00:00
|
|
|
}
|