Skip to content

Commit 0ae01b0

Browse files
committed
add switching between complted tasks from result/other pages
1 parent 07cc6ea commit 0ae01b0

3 files changed

Lines changed: 27 additions & 3 deletions

File tree

projects/social_platform/src/app/office/courses/lesson/lesson.component.html

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@
1111
@for (task of tasks(); track task.id) {
1212
<div
1313
class="progress__task"
14+
(click)="onSelectTask(task)"
1415
[ngClass]="{
1516
'progress__task--done': isDone(task),
16-
'progress__task--current': isCurrent(task.id)
17+
'progress__task--current': isCurrent(task.id),
18+
'progress__task--clickable': isDone(task)
1719
}"
1820
>
1921
<p class="text-body-12">{{ task.order }}</p>
@@ -82,8 +84,8 @@
8284

8385
<app-button
8486
[loader]="loader()"
85-
[disabled]="isSubmitDisabled()"
86-
[style.opacity]="isSubmitDisabled() ? 0.5 : 1"
87+
[disabled]="isSubmitDisabled() || isViewingCompleted()"
88+
[style.opacity]="isSubmitDisabled() || isViewingCompleted() ? 0.5 : 1"
8789
size="big"
8890
customTypographyClass="text-body-12"
8991
class="action__button"

projects/social_platform/src/app/office/courses/lesson/lesson.component.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@
7373
border: 0 !important;
7474
}
7575

76+
&--clickable {
77+
cursor: pointer;
78+
}
79+
7680
&--current {
7781
border: 0.5px solid var(--accent);
7882
}

projects/social_platform/src/app/office/courses/lesson/lesson.component.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,24 @@ export class LessonComponent implements OnInit {
157157
return task.isCompleted || this.completedTaskIds().has(task.id);
158158
}
159159

160+
protected readonly isViewingCompleted = computed(() => {
161+
const task = this.currentTask();
162+
return task ? this.isDone(task) : false;
163+
});
164+
165+
onSelectTask(task: Task) {
166+
if (!this.isDone(task)) return;
167+
168+
this.currentTaskId.set(task.id);
169+
this.answerBody.set(null);
170+
this.success.set(false);
171+
this.hasError.set(false);
172+
173+
if (this.isComplete()) {
174+
this.router.navigate(["./"], { relativeTo: this.route });
175+
}
176+
}
177+
160178
onSubmitAnswer() {
161179
const task = this.currentTask();
162180
if (!task) return;

0 commit comments

Comments
 (0)