aboutsummaryrefslogtreecommitdiffstats
path: root/workflow-designer-ui/src/main/frontend/src/features/version/composition/custom-properties-provider/provider/camunda/parts/implementation/ResultVariable.js
blob: a0b425fec35b5f143b2a6438d7c2773259857f5b (plain)
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
'use strict';

import { is } from 'bpmn-js/lib/util/ModelUtil';

import assign from 'lodash.assign';

var entryFactory = require('bpmn-js-properties-panel/lib/factory/EntryFactory'),
    cmdHelper = require('bpmn-js-properties-panel/lib/helper/CmdHelper');

export default function(element, bpmnFactory, options, translate) {
    var getBusinessObject = options.getBusinessObject,
        hideResultVariable = options.hideResultVariable,
        id = options.id || 'resultVariable';

    var resultVariableEntry = entryFactory.textField({
        id: id,
        label: translate('Result Variable'),
        modelProperty: 'resultVariable',

        get: function(element) {
            var bo = getBusinessObject(element);
            return { resultVariable: bo.get('camunda:resultVariable') };
        },

        set: function(element, values) {
            var bo = getBusinessObject(element);

            var resultVariable = values.resultVariable || undefined;

            var props = {
                'camunda:resultVariable': resultVariable
            };

            if (is(bo, 'camunda:DmnCapable') && !resultVariable) {
                props = assign(
                    { 'camunda:mapDecisionResult': 'resultList' },
                    props
                );
            }

            return cmdHelper.updateBusinessObject(element, bo, props);
        },

        hidden: function() {
            if (typeof hideResultVariable === 'function') {
                return hideResultVariable.apply(resultVariableEntry, arguments);
            }
        }
    });

    return [resultVariableEntry];
}