@5minds/node-red-contrib-processcube 1.1.4-feature-cf47e1-m0h7fe3x → 1.1.4-feature-e7d879-m0jyro4t
Sign up to get free protection for your applications and to get access to all the features.
- package/externaltask-event-listener.js +13 -17
- package/package.json +1 -1
- package/usertask-event-listener.js +14 -22
@@ -16,14 +16,14 @@ module.exports = function (RED) {
|
|
16
16
|
|
17
17
|
let subscription;
|
18
18
|
|
19
|
-
function externalTaskCallback(
|
19
|
+
function externalTaskCallback() {
|
20
20
|
return (externalTaskNotification) => {
|
21
21
|
if (config.externaltask != '' && config.externaltask != externalTaskNotification.flowNodeId) return;
|
22
22
|
node.send({
|
23
23
|
payload: {
|
24
24
|
flowNodeInstanceId: externalTaskNotification.flowNodeInstanceId,
|
25
25
|
externalTaskEvent: externalTaskNotification,
|
26
|
-
action:
|
26
|
+
action: config.eventtype,
|
27
27
|
type: 'externaltask',
|
28
28
|
},
|
29
29
|
});
|
@@ -31,21 +31,17 @@ module.exports = function (RED) {
|
|
31
31
|
}
|
32
32
|
|
33
33
|
async function subscribe() {
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
identity: currentIdentity,
|
46
|
-
});
|
47
|
-
default:
|
48
|
-
console.error('no such event: ' + config.eventtype);
|
34
|
+
const eventHandlers = {
|
35
|
+
created: client.notification.onExternalTaskCreated,
|
36
|
+
locked: client.notification.onExternalTaskLocked,
|
37
|
+
unlocked: client.notification.onExternalTaskUnlocked,
|
38
|
+
};
|
39
|
+
|
40
|
+
const handler = eventHandlers[config.eventtype];
|
41
|
+
if (handler) {
|
42
|
+
return await handler(externalTaskCallback(), { identity: currentIdentity });
|
43
|
+
} else {
|
44
|
+
console.error('no such event: ' + config.eventtype);
|
49
45
|
}
|
50
46
|
}
|
51
47
|
|
package/package.json
CHANGED
@@ -17,7 +17,7 @@ module.exports = function (RED) {
|
|
17
17
|
let subscription;
|
18
18
|
const query = RED.util.evaluateNodeProperty(config.query, config.query_type, node);
|
19
19
|
|
20
|
-
function userTaskCallback(
|
20
|
+
function userTaskCallback() {
|
21
21
|
return async (userTaskNotification) => {
|
22
22
|
if (config.usertask != '' && config.usertask != userTaskNotification.flowNodeId) return;
|
23
23
|
const newQuery = {
|
@@ -37,7 +37,7 @@ module.exports = function (RED) {
|
|
37
37
|
flowNodeInstanceId: userTaskNotification.flowNodeInstanceId,
|
38
38
|
userTaskEvent: userTaskNotification,
|
39
39
|
userTask: userTask,
|
40
|
-
action:
|
40
|
+
action: config.eventtype,
|
41
41
|
type: 'usertask',
|
42
42
|
},
|
43
43
|
});
|
@@ -46,26 +46,18 @@ module.exports = function (RED) {
|
|
46
46
|
}
|
47
47
|
|
48
48
|
async function subscribe() {
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
});
|
62
|
-
case 'reservation-canceled':
|
63
|
-
return await client.userTasks.onUserTaskReservationCanceled(
|
64
|
-
userTaskCallback('reservation-canceled'),
|
65
|
-
{ identity: currentIdentity }
|
66
|
-
);
|
67
|
-
default:
|
68
|
-
console.error('no such event: ' + config.eventtype);
|
49
|
+
const eventHandlers = {
|
50
|
+
new: client.userTasks.onUserTaskWaiting,
|
51
|
+
finished: client.userTasks.onUserTaskFinished,
|
52
|
+
reserved: client.userTasks.onUserTaskReserved,
|
53
|
+
'reservation-canceled': client.userTasks.onUserTaskReservationCanceled,
|
54
|
+
};
|
55
|
+
|
56
|
+
const handler = eventHandlers[config.eventtype];
|
57
|
+
if (handler) {
|
58
|
+
return await handler(userTaskCallback(), { identity: currentIdentity });
|
59
|
+
} else {
|
60
|
+
console.error('no such event: ' + config.eventtype);
|
69
61
|
}
|
70
62
|
}
|
71
63
|
|