44 lines
763 B
JavaScript
44 lines
763 B
JavaScript
'use strict';
|
|
|
|
var LabelUtil = require('../LabelUtil');
|
|
|
|
|
|
/**
|
|
* A handler that updates the text a BPMN element.
|
|
*
|
|
* @param {EventBus} eventBus
|
|
*/
|
|
function UpdateTextHandler(eventBus) {
|
|
|
|
function setText(element, text) {
|
|
var label = LabelUtil.setLabel(element, text);
|
|
|
|
eventBus.fire('element.changed', { element: label });
|
|
}
|
|
|
|
function execute(ctx) {
|
|
ctx.oldLabel = LabelUtil.getLabel(ctx.element);
|
|
setText(ctx.element, ctx.newLabel);
|
|
}
|
|
|
|
function revert(ctx) {
|
|
setText(ctx.element, ctx.oldLabel);
|
|
}
|
|
|
|
|
|
function canExecute(ctx) {
|
|
return true;
|
|
}
|
|
|
|
// API
|
|
|
|
this.execute = execute;
|
|
this.revert = revert;
|
|
|
|
this.canExecute = canExecute;
|
|
}
|
|
|
|
|
|
UpdateTextHandler.$inject = [ 'eventBus' ];
|
|
|
|
module.exports = UpdateTextHandler; |