IdClaimHandler.js 685 B

123456789101112131415161718192021222324252627282930313233343536
  1. export default function IdClaimHandler(moddle) {
  2. this._moddle = moddle;
  3. }
  4. IdClaimHandler.$inject = [ 'moddle' ];
  5. IdClaimHandler.prototype.execute = function(context) {
  6. var ids = this._moddle.ids,
  7. id = context.id,
  8. element = context.element,
  9. claiming = context.claiming;
  10. if (claiming) {
  11. ids.claim(id, element);
  12. } else {
  13. ids.unclaim(id);
  14. }
  15. };
  16. /**
  17. * Command revert implementation.
  18. */
  19. IdClaimHandler.prototype.revert = function(context) {
  20. var ids = this._moddle.ids,
  21. id = context.id,
  22. element = context.element,
  23. claiming = context.claiming;
  24. if (claiming) {
  25. ids.unclaim(id);
  26. } else {
  27. ids.claim(id, element);
  28. }
  29. };