From 84edcf157ba1d9ebecde0eee95f6747f90879879 Mon Sep 17 00:00:00 2001 From: chaw Date: Thu, 11 May 2023 07:42:51 +0800 Subject: [PATCH 1/2] [AV2-1380] empty tasks handling --- projects/v3/src/app/services/activity.service.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/projects/v3/src/app/services/activity.service.ts b/projects/v3/src/app/services/activity.service.ts index d9e3cd50b..b37bc60ca 100644 --- a/projects/v3/src/app/services/activity.service.ts +++ b/projects/v3/src/app/services/activity.service.ts @@ -182,6 +182,11 @@ export class ActivityService { if (!tasks) { tasks = this.activity.tasks; } + + if (this.utils.isEmpty(tasks) || tasks.length === 0) { + tasks = []; + } + // find the first task that is not done or pending review // and is allowed to access for this user let skipTask = !!afterTask; @@ -216,14 +221,18 @@ export class ActivityService { } } } + // if there is no next task - if (!nextTask) { + if (this.utils.isEmpty(nextTask)) { if (afterTask) { return this._activityCompleted(hasUnfinishedTask); } nextTask = tasks[0]; } - this.goToTask(nextTask); + + if (!this.utils.isEmpty(nextTask)) { + return this.goToTask(nextTask); + } } private _activityCompleted(showPopup: boolean) { From a6a3d2472c9cc50bc1617ba8d2d7093f21e90d65 Mon Sep 17 00:00:00 2001 From: chaw Date: Thu, 11 May 2023 08:08:54 +0800 Subject: [PATCH 2/2] [AV2-1380] "no tasks" indicator --- .../activity/activity.component.html | 18 ++++++++++++++++-- .../v3/src/app/services/activity.service.ts | 4 ++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/projects/v3/src/app/components/activity/activity.component.html b/projects/v3/src/app/components/activity/activity.component.html index efa3d4ca5..78edd78c1 100644 --- a/projects/v3/src/app/components/activity/activity.component.html +++ b/projects/v3/src/app/components/activity/activity.component.html @@ -3,7 +3,7 @@

{{ activity.name }}

- +
@@ -20,7 +20,10 @@

{activity.tasks.length, plural, =1 {Task} other {Tasks}} - + +

+ + +
+ +
+
diff --git a/projects/v3/src/app/services/activity.service.ts b/projects/v3/src/app/services/activity.service.ts index b37bc60ca..2f2e61658 100644 --- a/projects/v3/src/app/services/activity.service.ts +++ b/projects/v3/src/app/services/activity.service.ts @@ -99,9 +99,9 @@ export class ActivityService { } ).pipe( map(res => this._normaliseActivity(res.data, goToNextTask, afterTask)) - ).subscribe(_res => { + ).subscribe(res => { if (callback instanceof Function) { - return callback(_res); + return callback(res); } return; });