cmmn-js-properties-panel-flowable 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +112 -0
- package/dist/assets/cmmn-js-properties-panel.css +495 -0
- package/index.js +1 -0
- package/lib/PropertiesActivator.js +67 -0
- package/lib/PropertiesPanel.js +1264 -0
- package/lib/Utils.js +126 -0
- package/lib/cmd/MultiCommandHandler.js +32 -0
- package/lib/cmd/UpdateBusinessObjectHandler.js +100 -0
- package/lib/cmd/UpdateBusinessObjectListHandler.js +108 -0
- package/lib/cmd/index.js +25 -0
- package/lib/factory/CheckboxEntryFactory.js +68 -0
- package/lib/factory/EntryFactory.js +199 -0
- package/lib/factory/EntryFieldDescription.js +73 -0
- package/lib/factory/LabelFactory.js +38 -0
- package/lib/factory/SelectEntryFactory.js +75 -0
- package/lib/factory/TextBoxEntryFactory.js +42 -0
- package/lib/factory/TextInputEntryFactory.js +73 -0
- package/lib/factory/ValidationAwareTextInput.js +66 -0
- package/lib/helper/CmdHelper.js +76 -0
- package/lib/helper/CmmnElementHelper.js +232 -0
- package/lib/helper/ElementHelper.js +23 -0
- package/lib/helper/ExtensionElementsHelper.js +39 -0
- package/lib/helper/ListenerHelper.js +28 -0
- package/lib/index.js +13 -0
- package/lib/provider/cmmn/CmmnPropertiesProvider.js +183 -0
- package/lib/provider/cmmn/index.js +7 -0
- package/lib/provider/cmmn/parts/CallableProps.js +169 -0
- package/lib/provider/cmmn/parts/CaseProps.js +66 -0
- package/lib/provider/cmmn/parts/DefinitionDocumentationProps.js +24 -0
- package/lib/provider/cmmn/parts/DefinitionIdProps.js +22 -0
- package/lib/provider/cmmn/parts/DefinitionNameProps.js +43 -0
- package/lib/provider/cmmn/parts/DocumentationProps.js +21 -0
- package/lib/provider/cmmn/parts/IdProps.js +14 -0
- package/lib/provider/cmmn/parts/IfPartProps.js +110 -0
- package/lib/provider/cmmn/parts/NameProps.js +90 -0
- package/lib/provider/cmmn/parts/OnPartProps.js +61 -0
- package/lib/provider/cmmn/parts/PlanItemControlProps.js +214 -0
- package/lib/provider/cmmn/parts/implementation/ConditionProp.js +81 -0
- package/lib/provider/cmmn/parts/implementation/DocumentationProp.js +91 -0
- package/lib/provider/cmmn/parts/implementation/IdProp.js +42 -0
- package/lib/provider/cmmn/parts/implementation/NameProp.js +38 -0
- package/lib/provider/cmmn/parts/implementation/RuleProp.js +96 -0
- package/lib/provider/cmmn/parts/implementation/TransitionProp.js +81 -0
- package/lib/provider/flowable/FlowablePropertiesProvider.js +393 -0
- package/lib/provider/flowable/index.js +7 -0
- package/lib/provider/flowable/parts/CallableExtensionProps.js +250 -0
- package/lib/provider/flowable/parts/CaseExecutionListenerProps.js +31 -0
- package/lib/provider/flowable/parts/HistoryTimeToLiveProps.js +19 -0
- package/lib/provider/flowable/parts/HumanTaskProps.js +76 -0
- package/lib/provider/flowable/parts/ListenerDetailProps.js +32 -0
- package/lib/provider/flowable/parts/ListenerFieldInjectionProps.js +13 -0
- package/lib/provider/flowable/parts/RepeatOnStandardEventProps.js +144 -0
- package/lib/provider/flowable/parts/TaskListenerProps.js +27 -0
- package/lib/provider/flowable/parts/VariableListenerProps.js +27 -0
- package/lib/provider/flowable/parts/VariableMappingProps.js +361 -0
- package/lib/provider/flowable/parts/implementation/BusinessKeyProp.js +109 -0
- package/lib/provider/flowable/parts/implementation/ExtensionElements.js +248 -0
- package/lib/provider/flowable/parts/implementation/FieldInjection.js +281 -0
- package/lib/provider/flowable/parts/implementation/HistoryTimeToLiveProp.js +37 -0
- package/lib/provider/flowable/parts/implementation/ListenerDelegateProp.js +159 -0
- package/lib/provider/flowable/parts/implementation/ListenerElements.js +132 -0
- package/lib/provider/flowable/parts/implementation/ListenerEventTypeProp.js +118 -0
- package/lib/provider/flowable/parts/implementation/ScriptProp.js +161 -0
- package/package.json +72 -0
- package/styles/_mixins.less +79 -0
- package/styles/_variables.less +19 -0
- package/styles/config.json +46 -0
- package/styles/groups.less +71 -0
- package/styles/header.less +35 -0
- package/styles/properties.less +328 -0
- package/styles/tabs.less +90 -0
package/lib/Utils.js
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var Ids = require('ids');
|
|
4
|
+
|
|
5
|
+
var SPACE_REGEX = /\s/;
|
|
6
|
+
|
|
7
|
+
// for QName validation as per http://www.w3.org/TR/REC-xml/#NT-NameChar
|
|
8
|
+
var QNAME_REGEX = /^([a-z][\w-.]*:)?[a-z_][\w-.]*$/i;
|
|
9
|
+
|
|
10
|
+
// for ID validation as per CMMN Schema (QName - Namespace)
|
|
11
|
+
var ID_REGEX = /^[a-z_][\w-.]*$/i;
|
|
12
|
+
|
|
13
|
+
var HTML_ESCAPE_MAP = {
|
|
14
|
+
'&': '&',
|
|
15
|
+
'<': '<',
|
|
16
|
+
'>': '>',
|
|
17
|
+
'"': '"',
|
|
18
|
+
'\'': '''
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* adds an empty option to the list
|
|
23
|
+
*/
|
|
24
|
+
function addEmptyParameter(list) {
|
|
25
|
+
return list.push({ 'label': '', 'value': '', 'name': '' });
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
module.exports.addEmptyParameter = addEmptyParameter;
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* checks whether the id value is valid
|
|
33
|
+
*
|
|
34
|
+
* @param {ModdleElement} bo
|
|
35
|
+
* @param {String} idValue
|
|
36
|
+
* @param {Function} translate
|
|
37
|
+
*
|
|
38
|
+
* @return {String} error message
|
|
39
|
+
*/
|
|
40
|
+
function isIdValid(bo, idValue, translate) {
|
|
41
|
+
var assigned = bo.$model.ids.assigned(idValue);
|
|
42
|
+
|
|
43
|
+
var idExists = assigned && assigned !== bo;
|
|
44
|
+
|
|
45
|
+
if (!idValue || idExists) {
|
|
46
|
+
return translate('Element must have an unique id.');
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return validateId(idValue, translate);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
module.exports.isIdValid = isIdValid;
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
function validateId(idValue, translate) {
|
|
56
|
+
|
|
57
|
+
if (containsSpace(idValue)) {
|
|
58
|
+
return translate('Id must not contain spaces.');
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (!ID_REGEX.test(idValue)) {
|
|
62
|
+
|
|
63
|
+
if (QNAME_REGEX.test(idValue)) {
|
|
64
|
+
return translate('Id must not contain prefix.');
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return translate('Id must be a valid QName.');
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
module.exports.validateId = validateId;
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
function containsSpace(value) {
|
|
75
|
+
return SPACE_REGEX.test(value);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
module.exports.containsSpace = containsSpace;
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* generate a semantic id with given prefix
|
|
82
|
+
*/
|
|
83
|
+
function nextId(prefix) {
|
|
84
|
+
var ids = new Ids([32,32,1]);
|
|
85
|
+
|
|
86
|
+
return ids.nextPrefixed(prefix);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
module.exports.nextId = nextId;
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
function triggerClickEvent(element) {
|
|
93
|
+
var evt;
|
|
94
|
+
var eventType = 'click';
|
|
95
|
+
|
|
96
|
+
if (document.createEvent) {
|
|
97
|
+
try {
|
|
98
|
+
// Chrome, Safari, Firefox
|
|
99
|
+
evt = new MouseEvent((eventType), { view: window, bubbles: true, cancelable: true });
|
|
100
|
+
} catch (e) {
|
|
101
|
+
// IE 11, PhantomJS (wat!)
|
|
102
|
+
evt = document.createEvent('MouseEvent');
|
|
103
|
+
|
|
104
|
+
evt.initEvent((eventType), true, true);
|
|
105
|
+
}
|
|
106
|
+
return element.dispatchEvent(evt);
|
|
107
|
+
} else {
|
|
108
|
+
// Welcome IE
|
|
109
|
+
evt = document.createEventObject();
|
|
110
|
+
|
|
111
|
+
return element.fireEvent('on' + eventType, evt);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
module.exports.triggerClickEvent = triggerClickEvent;
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
function escapeHTML(str) {
|
|
119
|
+
str = '' + str;
|
|
120
|
+
|
|
121
|
+
return str && str.replace(/[&<>"']/g, function(match) {
|
|
122
|
+
return HTML_ESCAPE_MAP[match];
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
module.exports.escapeHTML = escapeHTML;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var forEach = require('lodash/forEach');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* A handler that combines and executes multiple commands.
|
|
7
|
+
*
|
|
8
|
+
* All updates are bundled on the command stack and executed in one step.
|
|
9
|
+
* This also makes it possible to revert the changes in one step.
|
|
10
|
+
*
|
|
11
|
+
* Example use case: remove the camunda:formKey attribute and in addition
|
|
12
|
+
* add all form fields needed for the camunda:formData property.
|
|
13
|
+
*
|
|
14
|
+
* @class
|
|
15
|
+
* @constructor
|
|
16
|
+
*/
|
|
17
|
+
function MultiCommandHandler(commandStack) {
|
|
18
|
+
this._commandStack = commandStack;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
MultiCommandHandler.$inject = [ 'commandStack' ];
|
|
22
|
+
|
|
23
|
+
module.exports = MultiCommandHandler;
|
|
24
|
+
|
|
25
|
+
MultiCommandHandler.prototype.preExecute = function(context) {
|
|
26
|
+
|
|
27
|
+
var commandStack = this._commandStack;
|
|
28
|
+
|
|
29
|
+
forEach(context, function(command) {
|
|
30
|
+
commandStack.execute(command.cmd, command.context);
|
|
31
|
+
});
|
|
32
|
+
};
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var reduce = require('lodash/transform'),
|
|
4
|
+
keys = require('lodash/keys'),
|
|
5
|
+
forEach = require('lodash/forEach');
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* A handler that implements a CMMN 1.1 property update
|
|
9
|
+
* for business objects which are not represented in the
|
|
10
|
+
* diagram.
|
|
11
|
+
*
|
|
12
|
+
* This is useful in the context of the properties panel in
|
|
13
|
+
* order to update child elements of elements visible in
|
|
14
|
+
* the diagram.
|
|
15
|
+
*
|
|
16
|
+
* @class
|
|
17
|
+
* @constructor
|
|
18
|
+
*/
|
|
19
|
+
function UpdateBusinessObjectHandler() { }
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
module.exports = UpdateBusinessObjectHandler;
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
function getProperties(businessObject, propertyNames) {
|
|
26
|
+
return reduce(propertyNames, function(result, key) {
|
|
27
|
+
result[key] = businessObject.get(key);
|
|
28
|
+
return result;
|
|
29
|
+
}, {});
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
function setProperties(businessObject, properties) {
|
|
34
|
+
forEach(properties, function(value, key) {
|
|
35
|
+
businessObject.set(key, value);
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
// api /////////////////////////////////////////////
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Updates a business object with a list of new properties
|
|
44
|
+
*
|
|
45
|
+
* @method UpdateBusinessObjectHandler#execute
|
|
46
|
+
*
|
|
47
|
+
* @param {Object} context
|
|
48
|
+
* @param {djs.model.Base} context.element the element which has a child business object updated
|
|
49
|
+
* @param {moddle.businessObject} context.businessObject the businessObject to update
|
|
50
|
+
* @param {Object} context.properties a list of properties to set on the businessObject
|
|
51
|
+
*
|
|
52
|
+
* @return {Array<djs.mode.Base>} the updated element
|
|
53
|
+
*/
|
|
54
|
+
UpdateBusinessObjectHandler.prototype.execute = function(context) {
|
|
55
|
+
|
|
56
|
+
var element = context.element,
|
|
57
|
+
businessObject = context.businessObject,
|
|
58
|
+
changed = [ element ]; // this will not change any diagram-js elements
|
|
59
|
+
|
|
60
|
+
if (!element) {
|
|
61
|
+
throw new Error('element required');
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (!businessObject) {
|
|
65
|
+
throw new Error('businessObject required');
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
var properties = context.properties,
|
|
69
|
+
oldProperties = context.oldProperties || getProperties(businessObject, keys(properties));
|
|
70
|
+
|
|
71
|
+
// update properties
|
|
72
|
+
setProperties(businessObject, properties);
|
|
73
|
+
|
|
74
|
+
// store old values
|
|
75
|
+
context.oldProperties = oldProperties;
|
|
76
|
+
context.changed = changed;
|
|
77
|
+
|
|
78
|
+
// indicate changed on objects affected by the update
|
|
79
|
+
return changed;
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Reverts the update
|
|
84
|
+
*
|
|
85
|
+
* @method UpdateBusinessObjectHandler#revert
|
|
86
|
+
*
|
|
87
|
+
* @param {Object} context
|
|
88
|
+
*
|
|
89
|
+
* @return {djs.mode.Base} the updated element
|
|
90
|
+
*/
|
|
91
|
+
UpdateBusinessObjectHandler.prototype.revert = function(context) {
|
|
92
|
+
|
|
93
|
+
var oldProperties = context.oldProperties,
|
|
94
|
+
businessObject = context.businessObject;
|
|
95
|
+
|
|
96
|
+
// update properties
|
|
97
|
+
setProperties(businessObject, oldProperties);
|
|
98
|
+
|
|
99
|
+
return context.changed;
|
|
100
|
+
};
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var forEach = require('lodash/forEach');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* A handler that implements a CMMN 1.1 property update
|
|
7
|
+
* for business object lists which are not represented in the
|
|
8
|
+
* diagram.
|
|
9
|
+
*
|
|
10
|
+
* This is useful in the context of the properties panel in
|
|
11
|
+
* order to update child elements of elements visible in
|
|
12
|
+
* the diagram.
|
|
13
|
+
*
|
|
14
|
+
* @class
|
|
15
|
+
* @constructor
|
|
16
|
+
*/
|
|
17
|
+
function UpdateBusinessObjectListHandler() { }
|
|
18
|
+
|
|
19
|
+
module.exports = UpdateBusinessObjectListHandler;
|
|
20
|
+
|
|
21
|
+
function ensureNotNull(prop, name) {
|
|
22
|
+
if (!prop) {
|
|
23
|
+
throw new Error(name + 'required');
|
|
24
|
+
}
|
|
25
|
+
return prop;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// api /////////////////////////////////////////////
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Updates a element under a provided parent.
|
|
32
|
+
*/
|
|
33
|
+
UpdateBusinessObjectListHandler.prototype.execute = function(context) {
|
|
34
|
+
|
|
35
|
+
var currentObject = ensureNotNull(context.currentObject, 'currentObject'),
|
|
36
|
+
propertyName = ensureNotNull(context.propertyName, 'propertyName'),
|
|
37
|
+
updatedObjectList = context.updatedObjectList,
|
|
38
|
+
objectsToRemove = context.objectsToRemove || [],
|
|
39
|
+
objectsToAdd = context.objectsToAdd || [],
|
|
40
|
+
changed = [ context.element], // this will not change any diagram-js elements
|
|
41
|
+
referencePropertyName;
|
|
42
|
+
|
|
43
|
+
if (context.referencePropertyName) {
|
|
44
|
+
referencePropertyName = context.referencePropertyName;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
var objectList = currentObject[propertyName];
|
|
48
|
+
// adjust array reference in the parent business object
|
|
49
|
+
context.previousList = currentObject[propertyName];
|
|
50
|
+
|
|
51
|
+
if (updatedObjectList) {
|
|
52
|
+
currentObject[propertyName] = updatedObjectList;
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
var listCopy = [];
|
|
56
|
+
// remove all objects which should be removed
|
|
57
|
+
forEach(objectList, function(object) {
|
|
58
|
+
if (objectsToRemove.indexOf(object) == -1) {
|
|
59
|
+
listCopy.push(object);
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
// add all objects which should be added
|
|
63
|
+
listCopy = listCopy.concat(objectsToAdd);
|
|
64
|
+
|
|
65
|
+
// set property to new list
|
|
66
|
+
if (listCopy.length > 0 || !referencePropertyName) {
|
|
67
|
+
|
|
68
|
+
// as long as there are elements in the list update the list
|
|
69
|
+
currentObject[propertyName] = listCopy;
|
|
70
|
+
} else if (referencePropertyName) {
|
|
71
|
+
|
|
72
|
+
// remove the list when it is empty
|
|
73
|
+
var parentObject = currentObject.$parent;
|
|
74
|
+
parentObject.set(referencePropertyName, undefined);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
context.changed = changed;
|
|
79
|
+
|
|
80
|
+
// indicate changed on objects affected by the update
|
|
81
|
+
return changed;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Reverts the update
|
|
86
|
+
*
|
|
87
|
+
* @method CreateBusinessObjectListHandler#revert
|
|
88
|
+
*
|
|
89
|
+
* @param {Object} context
|
|
90
|
+
*
|
|
91
|
+
* @return {djs.mode.Base} the updated element
|
|
92
|
+
*/
|
|
93
|
+
UpdateBusinessObjectListHandler.prototype.revert = function(context) {
|
|
94
|
+
|
|
95
|
+
var currentObject = context.currentObject,
|
|
96
|
+
propertyName = context.propertyName,
|
|
97
|
+
previousList = context.previousList,
|
|
98
|
+
parentObject = currentObject.$parent;
|
|
99
|
+
|
|
100
|
+
if (context.referencePropertyName) {
|
|
101
|
+
parentObject.set(context.referencePropertyName, currentObject);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// remove new element
|
|
105
|
+
currentObject.set(propertyName, previousList);
|
|
106
|
+
|
|
107
|
+
return context.changed;
|
|
108
|
+
};
|
package/lib/cmd/index.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var forEach = require('lodash/forEach');
|
|
4
|
+
|
|
5
|
+
var HANDLERS = {
|
|
6
|
+
'properties-panel.update-businessobject': require('./UpdateBusinessObjectHandler'),
|
|
7
|
+
'properties-panel.update-businessobject-list': require('./UpdateBusinessObjectListHandler'),
|
|
8
|
+
'properties-panel.multi-command-executor': require('./MultiCommandHandler')
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
function CommandInitializer(eventBus, commandStack) {
|
|
13
|
+
|
|
14
|
+
eventBus.on('diagram.init', function() {
|
|
15
|
+
forEach(HANDLERS, function(handler, id) {
|
|
16
|
+
commandStack.registerHandler(id, handler);
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
CommandInitializer.$inject = [ 'eventBus', 'commandStack' ];
|
|
22
|
+
|
|
23
|
+
module.exports = {
|
|
24
|
+
__init__: [ CommandInitializer ]
|
|
25
|
+
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var escapeHTML = require('../Utils').escapeHTML;
|
|
4
|
+
|
|
5
|
+
var getBusinessObject = require('cmmn-js/lib/util/ModelUtil').getBusinessObject,
|
|
6
|
+
cmdHelper = require('../helper/CmdHelper');
|
|
7
|
+
|
|
8
|
+
var entryFieldDescription = require('./EntryFieldDescription');
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
var checkbox = function(options, defaultParameters) {
|
|
12
|
+
var resource = defaultParameters,
|
|
13
|
+
label = options.label || resource.id,
|
|
14
|
+
canBeDisabled = !!options.disabled && typeof options.disabled === 'function',
|
|
15
|
+
description = options.description;
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
resource.html =
|
|
19
|
+
'<input id="flowable-' + escapeHTML(resource.id) + '" ' +
|
|
20
|
+
'type="checkbox" ' +
|
|
21
|
+
'name="' + escapeHTML(options.modelProperty) + '" ' +
|
|
22
|
+
(canBeDisabled ? 'data-show="isDisabled"' : '') +
|
|
23
|
+
' />' +
|
|
24
|
+
'<label for="flowable-' + escapeHTML(resource.id) + '" ' +
|
|
25
|
+
(canBeDisabled ? 'data-show="isDisabled"' : '') +
|
|
26
|
+
'>' + escapeHTML(label) + '</label>';
|
|
27
|
+
|
|
28
|
+
// add description below checkbox entry field
|
|
29
|
+
if (description) {
|
|
30
|
+
resource.html += entryFieldDescription(description);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
resource.get = function(element) {
|
|
34
|
+
var bo = getBusinessObject(element),
|
|
35
|
+
res = {};
|
|
36
|
+
|
|
37
|
+
res[options.modelProperty] = bo.get(options.modelProperty);
|
|
38
|
+
|
|
39
|
+
return res;
|
|
40
|
+
};
|
|
41
|
+
resource.set = function(element, values) {
|
|
42
|
+
var res = {};
|
|
43
|
+
|
|
44
|
+
res[options.modelProperty] = !!values[options.modelProperty];
|
|
45
|
+
|
|
46
|
+
return cmdHelper.updateProperties(element, res);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
if (typeof options.set === 'function') {
|
|
50
|
+
resource.set = options.set;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (typeof options.get === 'function') {
|
|
54
|
+
resource.get = options.get;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (canBeDisabled) {
|
|
58
|
+
resource.isDisabled = function() {
|
|
59
|
+
return !options.disabled.apply(resource, arguments);
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
resource.cssClasses = ['cpp-checkbox'];
|
|
64
|
+
|
|
65
|
+
return resource;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
module.exports = checkbox;
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var getBusinessObject = require('cmmn-js/lib/util/ModelUtil').getBusinessObject;
|
|
4
|
+
|
|
5
|
+
// input entities
|
|
6
|
+
var textInputField = require('./TextInputEntryFactory'),
|
|
7
|
+
checkboxField = require('./CheckboxEntryFactory'),
|
|
8
|
+
selectBoxField = require('./SelectEntryFactory'),
|
|
9
|
+
textBoxField = require('./TextBoxEntryFactory'),
|
|
10
|
+
validationAwareTextInputField = require('./ValidationAwareTextInput'),
|
|
11
|
+
labelEntry = require('./LabelFactory');
|
|
12
|
+
|
|
13
|
+
var cmdHelper = require('../helper/CmdHelper');
|
|
14
|
+
|
|
15
|
+
// helpers ////////////////////////////////////////
|
|
16
|
+
|
|
17
|
+
function ensureNotNull(prop) {
|
|
18
|
+
if (!prop) {
|
|
19
|
+
throw new Error(prop + ' must be set.');
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return prop;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* sets the default parameters which are needed to create an entry
|
|
27
|
+
*
|
|
28
|
+
* @param options
|
|
29
|
+
* @returns {{id: *, description: (*|string), get: (*|Function), set: (*|Function),
|
|
30
|
+
* validate: (*|Function), html: string}}
|
|
31
|
+
*/
|
|
32
|
+
var setDefaultParameters = function(options) {
|
|
33
|
+
|
|
34
|
+
function getReferencedObject(element, reference) {
|
|
35
|
+
var bo = getBusinessObject(element);
|
|
36
|
+
|
|
37
|
+
if (reference) {
|
|
38
|
+
return bo && bo.get(reference);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return bo;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
// default /////////////////////////////////////////////////////////
|
|
46
|
+
|
|
47
|
+
// default method to fetch the current value of the input field
|
|
48
|
+
var defaultGet = function(element, node, bo) {
|
|
49
|
+
var res = {},
|
|
50
|
+
prop = ensureNotNull(options.modelProperty);
|
|
51
|
+
|
|
52
|
+
bo = bo || getBusinessObject(element);
|
|
53
|
+
res[prop] = bo && bo.get(prop);
|
|
54
|
+
|
|
55
|
+
return res;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
// default method to set a new value to the input field
|
|
59
|
+
var defaultSet = function(element, values, node, bo) {
|
|
60
|
+
var res = {},
|
|
61
|
+
prop = ensureNotNull(options.modelProperty);
|
|
62
|
+
|
|
63
|
+
if (values[prop] !== '') {
|
|
64
|
+
res[prop] = values[prop];
|
|
65
|
+
} else {
|
|
66
|
+
res[prop] = undefined;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
bo = bo || getBusinessObject(element);
|
|
70
|
+
|
|
71
|
+
return cmdHelper.updateProperties(bo, res, element);
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
// default validation method
|
|
75
|
+
var defaultValidate = function() {
|
|
76
|
+
return {};
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
// wrapper ////////////////////////////////////////
|
|
81
|
+
|
|
82
|
+
var wrapperGet = function(element, node) {
|
|
83
|
+
|
|
84
|
+
var reference = options.reference,
|
|
85
|
+
getter = options.get || defaultGet;
|
|
86
|
+
|
|
87
|
+
return getter(element, node, getReferencedObject(element, reference));
|
|
88
|
+
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
var wrapperSet = function(element, values, node) {
|
|
92
|
+
|
|
93
|
+
var reference = options.reference,
|
|
94
|
+
setter = options.set || defaultSet;
|
|
95
|
+
|
|
96
|
+
return setter(element, values, node, getReferencedObject(element, reference));
|
|
97
|
+
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
var wrapperValidate = function(element, values, node) {
|
|
101
|
+
|
|
102
|
+
var reference = options.reference,
|
|
103
|
+
validator = options.validate || defaultValidate;
|
|
104
|
+
|
|
105
|
+
return validator(element, values, node, getReferencedObject(element, reference));
|
|
106
|
+
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
return {
|
|
112
|
+
id : options.id,
|
|
113
|
+
description : (options.description || ''),
|
|
114
|
+
get : wrapperGet,
|
|
115
|
+
set : wrapperSet,
|
|
116
|
+
validate : wrapperValidate,
|
|
117
|
+
html: '',
|
|
118
|
+
reference: options.reference,
|
|
119
|
+
hideEntry: options.hideEntry
|
|
120
|
+
};
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
function EntryFactory() {
|
|
124
|
+
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Generates an text input entry object for a property panel.
|
|
129
|
+
* options are:
|
|
130
|
+
* - id: id of the entry - String
|
|
131
|
+
*
|
|
132
|
+
* - description: description of the property - String
|
|
133
|
+
*
|
|
134
|
+
* - label: label for the input field - String
|
|
135
|
+
*
|
|
136
|
+
* - set: setter method - Function
|
|
137
|
+
*
|
|
138
|
+
* - get: getter method - Function
|
|
139
|
+
*
|
|
140
|
+
* - validate: validation mehtod - Function
|
|
141
|
+
*
|
|
142
|
+
* - modelProperty: name of the model property - String
|
|
143
|
+
*
|
|
144
|
+
* - buttonAction: Object which contains the following properties: - Object
|
|
145
|
+
* ---- name: name of the [data-action] callback - String
|
|
146
|
+
* ---- method: callback function for [data-action] - Function
|
|
147
|
+
*
|
|
148
|
+
* - buttonShow: Object which contains the following properties: - Object
|
|
149
|
+
* ---- name: name of the [data-show] callback - String
|
|
150
|
+
* ---- method: callback function for [data-show] - Function
|
|
151
|
+
*
|
|
152
|
+
* @param options
|
|
153
|
+
* @returns the propertyPanel entry resource object
|
|
154
|
+
*/
|
|
155
|
+
EntryFactory.textField = function(options) {
|
|
156
|
+
return textInputField(options, setDefaultParameters(options));
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
EntryFactory.validationAwareTextField = function(options) {
|
|
160
|
+
return validationAwareTextInputField(options, setDefaultParameters(options));
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Generates a checkbox input entry object for a property panel.
|
|
165
|
+
* options are:
|
|
166
|
+
* - id: id of the entry - String
|
|
167
|
+
*
|
|
168
|
+
* - description: description of the property - String
|
|
169
|
+
*
|
|
170
|
+
* - label: label for the input field - String
|
|
171
|
+
*
|
|
172
|
+
* - set: setter method - Function
|
|
173
|
+
*
|
|
174
|
+
* - get: getter method - Function
|
|
175
|
+
*
|
|
176
|
+
* - validate: validation mehtod - Function
|
|
177
|
+
*
|
|
178
|
+
* - modelProperty: name of the model property - String
|
|
179
|
+
*
|
|
180
|
+
* @param options
|
|
181
|
+
* @returns the propertyPanel entry resource object
|
|
182
|
+
*/
|
|
183
|
+
EntryFactory.checkbox = function(options) {
|
|
184
|
+
return checkboxField(options, setDefaultParameters(options));
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
EntryFactory.textBox = function(options) {
|
|
188
|
+
return textBoxField(options, setDefaultParameters(options));
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
EntryFactory.selectBox = function(options) {
|
|
192
|
+
return selectBoxField(options, setDefaultParameters(options));
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
EntryFactory.label = function(options) {
|
|
196
|
+
return labelEntry(options);
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
module.exports = EntryFactory;
|