Skip to content

Commit

Permalink
Merge pull request #69 from camunda-community-hub/fix-user-tasks
Browse files Browse the repository at this point in the history
feat: load user tasks of process instance
  • Loading branch information
saig0 authored Dec 21, 2022
2 parents 0b780ae + 40ba9aa commit 37523cc
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 0 deletions.
57 changes: 57 additions & 0 deletions src/main/resources/public/js/view-process-instance.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ function loadProcessInstanceDetailsViews() {

loadElementInstancesOfProcessInstance();
loadJobsOfProcessInstance();
loadUserTasksOfProcessInstance();
loadIncidentsOfProcessInstance();
loadMessageSubscriptionsOfProcessInstance();
loadTimersOfProcessInstance();
Expand Down Expand Up @@ -569,6 +570,62 @@ function removeTaskPlayableMarkersOfJobs(jobs) {
});
}

function loadUserTasksOfProcessInstance() {

const processInstanceKey = getProcessInstanceKey();

queryUserTasksByProcessInstance(processInstanceKey)
.done(function (response) {

let processInstance = response.data.processInstance;
let userTasks = processInstance.userTasks;

let totalCount = userTasks.totalCount;
let nodes = userTasks.nodes;

// TODO (#67): show user tasks in tab

nodes.forEach((userTask, index) => {

const bpmnElement = userTask.elementInstance.element;
const elementId = bpmnElement.elementId;

const isActiveTask = userTask.state === "CREATED";
if (isActiveTask) {
makeTaskPlayable(elementId, userTask.key);
}
});

removeUserTaskMarkers(nodes);
});
}

function removeUserTaskMarkers(userTasks) {
let elementIdsOfActiveTasks = userTasks
.filter(function (userTask) {
return userTask.state === "CREATED";
})
.map(function (userTask) {
return userTask.elementInstance.element.elementId
});

let elementIdsOfNotActiveTasks = userTasks
.filter(function (userTask) {
return userTask.state !== "CREATED";
})
.map(function (userTask) {
return userTask.elementInstance.element.elementId
})

elementIdsOfNotActiveTasks
.filter(function (elementId) {
return !elementIdsOfActiveTasks.includes(elementId);
})
.forEach(function (elementId) {
removeTaskPlayableMarker(elementId);
});
}

function loadIncidentsOfProcessInstance() {

const processInstanceKey = getProcessInstanceKey();
Expand Down
35 changes: 35 additions & 0 deletions src/main/resources/public/js/zeeqs-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,34 @@ const jobsByProcessInstanceQuery = `query JobsOfProcessInstance($key: ID!, $zone
}
}`;

const userTasksByProcessInstanceQuery = `query UserTasksOfProcessInstance($key: ID!) {
processInstance(key: $key) {
userTasks(perPage: 100) {
totalCount
nodes {
key
state
assignee
candidateGroups
form {
resource
}
elementInstance {
key
element {
elementId
elementName
bpmnElementType
}
}
}
}
}
}`;

const incidentsByProcessInstanceQuery = `query IncidentsOfProcessInstance($key: ID!, $zoneId: String!) {
processInstance(key: $key) {
incidents {
Expand Down Expand Up @@ -640,6 +668,13 @@ function queryJobsByProcessInstance(processInstanceKey) {
});
}

function queryUserTasksByProcessInstance(processInstanceKey) {

return fetchData(userTasksByProcessInstanceQuery, {
key: processInstanceKey
});
}

function queryIncidentsByProcessInstance(processInstanceKey) {

return fetchData(incidentsByProcessInstanceQuery, {
Expand Down

0 comments on commit 37523cc

Please sign in to comment.