Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions projects/v3/src/app/components/activity/activity.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<h1 id="activity-name" *ngIf="activity.name" class="headline-2 activity-name">
{{ activity.name }}
</h1>
<ion-skeleton-text *ngIf="!activity.name" animated style="width: 50%;" aria-hidden="true"></ion-skeleton-text>
<ion-skeleton-text *ngIf="!activity.tasks" animated style="width: 50%;" aria-hidden="true"></ion-skeleton-text>

<div class="task-count">
<ion-text *ngIf="activity.tasks" class="subtitle-3" color="grey-75" i18n>
Expand All @@ -20,7 +20,10 @@ <h1 id="activity-name" *ngIf="activity.name" class="headline-2 activity-name">

<ion-item class="headline-4 task-header" lines="none" i18n>{activity.tasks.length, plural, =1 {Task} other {Tasks}}</ion-item>

<app-list-item class="focusable"
<ng-container *ngTemplateOutlet="noTasks"></ng-container>

<app-list-item
class="focusable"
role="button"
tabindex="0"
*ngFor="let task of (activity?.tasks || []); let i = index"
Expand Down Expand Up @@ -49,3 +52,14 @@ <h1 id="activity-name" *ngIf="activity.name" class="headline-2 activity-name">
<ion-skeleton-text animated style="width: 90%"></ion-skeleton-text>
</div>
</ng-template>

<ng-template #noTasks>
<div *ngIf="activity?.tasks?.length === 0" class="ion-padding" aria-live="polite" aria-label="no tasks available">
<app-list-item
lines="none"
subtitle1Color="grey-50"
title="No tasks available."
i18n-title
></app-list-item>
</div>
</ng-template>
17 changes: 13 additions & 4 deletions projects/v3/src/app/services/activity.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down