bpmn-js/lib/features/label-editing/LabelUtil.js

31 lines
663 B
JavaScript

function getLabelAttr(semantic) {
if (semantic.$instanceOf('bpmn:FlowElement') ||
semantic.$instanceOf('bpmn:Participant') ||
semantic.$instanceOf('bpmn:Lane') ||
semantic.$instanceOf('bpmn:SequenceFlow') ||
semantic.$instanceOf('bpmn:MessageFlow')) {
return 'name';
}
if (semantic.$instanceOf('bpmn:TextAnnotation')) {
return 'text';
}
}
module.exports.getLabel = function(semantic) {
var attr = getLabelAttr(semantic);
if (attr) {
return semantic[attr] || '';
}
};
module.exports.setLabel = function(semantic, label) {
var attr = getLabelAttr(semantic);
if (attr) {
semantic[attr] = label;
}
};