shikeying
2023-03-17 8c1a723d62a6aa5d6266ca613ae4eb77c789db06
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
export default class CustomContextPad {
  constructor(config, contextPad, create, elementFactory, injector, translate) {
    this.create = create;
    this.elementFactory = elementFactory;
    this.translate = translate;
    //自动摆放位置
    if (config.autoPlace !== false) {
      this.autoPlace = injector.get('autoPlace', false);
    }
    //注册工具
    contextPad.registerProvider(this);
  }
  getContextPadEntries(element) {
    const {
      autoPlace,
      create,
      elementFactory,
      translate
    } = this;
 
    function appendUserTask(event, element) {
      if (autoPlace) {
        const shape = elementFactory.createShape({ type: 'bpmn:UserTask' });
        autoPlace.append(element, shape);
      } else {
        appendUserTaskStart(event, element);
      }
    }
 
    function appendUserTaskStart(event) {
          const shape = elementFactory.createShape({ type: 'bpmn:UserTask' });
          create.start(event, shape, element);
    }
    function appendCallActivityStart(event) {
      const shape = elementFactory.createShape({ type: 'bpmn:CallActivity' });
      create.start(event, shape, element);
    }
 
    function appendCallActivity(event, element) {
        if (autoPlace) {
            const shape = elementFactory.createShape({ type: 'bpmn:CallActivity' });
            autoPlace.append(element, shape);
        } else {
            appendCallActivityStart(event, element);
        }
    }
    return {
      'append.user-task': {
        group: 'model',
        className: 'bpmn-icon-user-task',
        title: translate('Append ServiceTask'),
        action: {
          click: appendUserTask,
          dragstart: appendUserTaskStart
        }
      },
      'append.call-activity':{
          group: 'model',
          className: 'bpmn-icon-call-activity',
          title: translate('Append CallActivity'),
          action: {
              click: appendCallActivity,
              dragstart: appendCallActivityStart
          }
      }
    };
  }
}
CustomContextPad.$inject = [
  'config',
  'contextPad',
  'create',
  'elementFactory',
  'injector',
  'translate'
];