@hmcts/ccd-case-ui-toolkit 7.0.29-task-comp → 7.0.29-task-comp-2

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.
@@ -8514,6 +8514,7 @@ class WorkAllocationService {
8514
8514
  if (!this.isWAEnabled()) {
8515
8515
  return of(null);
8516
8516
  }
8517
+ console.log(`completeTask: completing ${taskId}`);
8517
8518
  const url = `${this.appConfig.getWorkAllocationApiUrl()}/task/${taskId}/complete`;
8518
8519
  return this.http
8519
8520
  .post(url, {})
@@ -32148,10 +32149,12 @@ class EventStartGuard {
32148
32149
  return of(false);
32149
32150
  }
32150
32151
  checkTaskInEventNotRequired(payload, caseId, taskId) {
32152
+ console.log('checkTaskInEventNotRequired: start');
32151
32153
  if (!payload || !payload.tasks) {
32152
32154
  return true;
32153
32155
  }
32154
32156
  const taskNumber = payload.tasks.length;
32157
+ console.log(`checkTaskInEventNotRequired: found ${taskNumber} tasks`);
32155
32158
  if (taskNumber === 0) {
32156
32159
  // if there are no tasks just carry on
32157
32160
  return true;
@@ -32160,11 +32163,13 @@ class EventStartGuard {
32160
32163
  const userInfoStr = this.sessionStorageService.getItem('userDetails');
32161
32164
  const userInfo = JSON.parse(userInfoStr);
32162
32165
  const tasksAssignedToUser = payload.tasks.filter(x => x.task_state !== 'unassigned' && x.assignee === userInfo.id || x.assignee === userInfo.uid);
32166
+ console.log(`checkTaskInEventNotRequired: ${tasksAssignedToUser} tasks assigned to user`);
32163
32167
  if (tasksAssignedToUser.length === 0) {
32164
32168
  // if no tasks assigned to user carry on
32165
32169
  return true;
32166
32170
  }
32167
32171
  else if (tasksAssignedToUser.length > 1 && !taskId) {
32172
+ console.log(`checkTaskInEventNotRequired: more than one task assigned, taskId: ${taskId}`);
32168
32173
  // if more than one task assigned to the user then give multiple tasks error
32169
32174
  this.router.navigate([`/cases/case-details/${caseId}/multiple-tasks-exist`]);
32170
32175
  return false;
@@ -32177,26 +32182,30 @@ class EventStartGuard {
32177
32182
  else {
32178
32183
  task = tasksAssignedToUser[0];
32179
32184
  }
32185
+ console.log(`checkTaskInEventNotRequired: storing task ${task} in session`);
32180
32186
  // if one task assigned to user, allow user to complete event
32181
32187
  this.sessionStorageService.setItem('taskToComplete', JSON.stringify(task));
32182
32188
  return true;
32183
32189
  }
32184
32190
  }
32185
32191
  checkForTasks(payload, caseId, eventId, taskId) {
32186
- // Clear taskToComplete from session as we will be starting the process for new task
32187
- this.sessionStorageService.removeItem('taskToComplete');
32188
32192
  if (payload.task_required_for_event) {
32189
32193
  // There are some issues in EventTriggerResolver/CaseService and/or CCD for some events
32190
32194
  // which triggers the CanActivate guard again.
32191
32195
  // If event start is initiated again, then we do not need to perform state machine processing again.
32192
32196
  // https://tools.hmcts.net/jira/browse/EUI-5489
32193
32197
  if (this.router && this.router.url && this.router.url.includes('event-start')) {
32198
+ console.log(`checkForTasks: event-start again check is true: ${this.router.url} : taskId = ${taskId}`);
32194
32199
  return of(true);
32195
32200
  }
32196
32201
  this.router.navigate([`/cases/case-details/${caseId}/event-start`], { queryParams: { caseId, eventId, taskId } });
32197
32202
  return of(false);
32198
32203
  }
32199
32204
  else {
32205
+ // Clear taskToComplete from session as we will be starting the process for new task
32206
+ console.log(`Removing taskToComplete from session storage for case:event:task ${caseId}:${eventId}:${taskId}`);
32207
+ this.sessionStorageService.removeItem('taskToComplete');
32208
+ console.log("checkForTasks: no task required for event");
32200
32209
  return of(this.checkTaskInEventNotRequired(payload, caseId, taskId));
32201
32210
  }
32202
32211
  }
@@ -32337,8 +32346,10 @@ class EventStartStateMachineService {
32337
32346
  if (!task) {
32338
32347
  task = context.tasks[0];
32339
32348
  }
32349
+ const taskStr = JSON.stringify(task);
32350
+ console.log('entryActionForStateOneTaskAssignedToUser: setting taskToComplete to ' + taskStr);
32340
32351
  // Store task to session
32341
- context.sessionStorageService.setItem('taskToComplete', JSON.stringify(task));
32352
+ context.sessionStorageService.setItem('taskToComplete', taskStr);
32342
32353
  // Allow user to perform the event
32343
32354
  context.router.navigate([`/cases/case-details/${context.caseId}/trigger/${context.eventId}`], { relativeTo: context.route });
32344
32355
  }