From 0ba77c3966ae50d47e40a6310bf8eced16c99ecc 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 | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/projects/v3/src/app/services/activity.service.ts b/projects/v3/src/app/services/activity.service.ts index e68208b33..da94f31bd 100644 --- a/projects/v3/src/app/services/activity.service.ts +++ b/projects/v3/src/app/services/activity.service.ts @@ -209,6 +209,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; @@ -245,13 +250,16 @@ 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 765877066abe0b40c048d50d91bd87b5c9a286b6 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 da94f31bd..c30a0d70f 100644 --- a/projects/v3/src/app/services/activity.service.ts +++ b/projects/v3/src/app/services/activity.service.ts @@ -126,9 +126,9 @@ export class ActivityService { } return this.getActivityBase(id).pipe( map(res => this._normaliseActivity(res.data, goToNextTask, afterTask)) - ).subscribe(_res => { + ).subscribe(res => { if (callback instanceof Function) { - return callback(_res); + return callback(res); } return; });