ruoyi-vue-nocode/ruoyi-ui/ruoyi-bpmnjs/resources/properties-panel/factory/LabelFactory.js

39 lines
1.2 KiB
JavaScript
Raw Normal View History

2022-08-11 16:10:41 +08:00
'use strict';
/**
* The label factory provides a label entry. For the label text
* it expects either a string provided by the options.labelText
* parameter or it could be generated programmatically using a
* function passed as the options.get parameter.
*
* @param {Object} options
* @param {string} options.id
* @param {string} [options.labelText]
* @param {Function} [options.get]
* @param {Function} [options.showLabel]
* @param {Boolean} [options.divider] adds a divider at the top of the label if true; default: false
*/
var label = function(options) {
return {
id: options.id,
html: '<label data-value="label" ' +
'data-show="showLabel" ' +
'class="entry-label' + (options.divider ? ' divider' : '') + '">' +
'</label>',
get: function(element, node) {
if (typeof options.get === 'function') {
return options.get(element, node);
}
return { label: options.labelText };
},
showLabel: function(element, node) {
if (typeof options.showLabel === 'function') {
return options.showLabel(element, node);
}
return true;
}
};
};
module.exports = label;