mirror of
https://github.com/bpmn-io/bpmn-js.git
synced 2025-08-14 19:25:06 +08:00

* use ES6 import / export * UTILS: export individual utilities * TESTS: localize TestHelper includes BREAKING CHANGE: * all utilities export independent functions * library sources got ported to ES6. You must now use a ES module bundler such as Browserify + babelify or Webpack to consume this library (or parts of it).
44 lines
852 B
JavaScript
44 lines
852 B
JavaScript
'use strict';
|
|
|
|
import { is } from '../../util/ModelUtil';
|
|
|
|
function getLabelAttr(semantic) {
|
|
if (is(semantic, 'bpmn:FlowElement') ||
|
|
is(semantic, 'bpmn:Participant') ||
|
|
is(semantic, 'bpmn:Lane') ||
|
|
is(semantic, 'bpmn:SequenceFlow') ||
|
|
is(semantic, 'bpmn:MessageFlow')) {
|
|
|
|
return 'name';
|
|
}
|
|
|
|
if (is(semantic, 'bpmn:TextAnnotation')) {
|
|
return 'text';
|
|
}
|
|
}
|
|
|
|
export function getLabel(element) {
|
|
var semantic = element.businessObject,
|
|
attr = getLabelAttr(semantic);
|
|
|
|
if (attr) {
|
|
return semantic[attr] || '';
|
|
}
|
|
}
|
|
|
|
|
|
export function setLabel(element, text, isExternal) {
|
|
var semantic = element.businessObject,
|
|
attr = getLabelAttr(semantic);
|
|
|
|
if (attr) {
|
|
semantic[attr] = text;
|
|
}
|
|
|
|
// show external label if not empty
|
|
if (isExternal) {
|
|
element.hidden = !text;
|
|
}
|
|
|
|
return element;
|
|
} |