MultiCommandHandler.js 822 B

1234567891011121314151617181920212223242526272829303132
  1. 'use strict';
  2. var forEach = require('lodash/forEach');
  3. /**
  4. * A handler that combines and executes multiple commands.
  5. *
  6. * All updates are bundled on the command stack and executed in one step.
  7. * This also makes it possible to revert the changes in one step.
  8. *
  9. * Example use case: remove the camunda:formKey attribute and in addition
  10. * add all form fields needed for the camunda:formData property.
  11. *
  12. * @class
  13. * @constructor
  14. */
  15. function MultiCommandHandler(commandStack) {
  16. this._commandStack = commandStack;
  17. }
  18. MultiCommandHandler.$inject = [ 'commandStack' ];
  19. module.exports = MultiCommandHandler;
  20. MultiCommandHandler.prototype.preExecute = function(context) {
  21. var commandStack = this._commandStack;
  22. forEach(context, function(command) {
  23. commandStack.execute(command.cmd, command.context);
  24. });
  25. };