Skip to content

Commit 4822795

Browse files
committed
fix(widgets): signal access fix in direction card, specs group positioning, lesson guard
- project-direction-card: access about() as signal call instead of direct property, inject ChangeDetectorRef and call markForCheck after goal update - specializations-group: position open state as absolute (top-right) to overlay content, remove unused legacy Input/Output/EventEmitter imports - lesson guard: add LessonGuard implementation (used in course-detail.routes)
1 parent 441b369 commit 4822795

4 files changed

Lines changed: 44 additions & 8 deletions

File tree

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { inject } from "@angular/core";
2+
import { ActivatedRouteSnapshot, Router } from "@angular/router";
3+
import { CoursesRepositoryPort } from "@domain/courses/ports/courses.repository.port";
4+
import { catchError, map, Observable, of } from "rxjs";
5+
6+
export const LessonGuard = (route: ActivatedRouteSnapshot): Observable<boolean> => {
7+
const coursesRepository = inject(CoursesRepositoryPort);
8+
const router = inject(Router);
9+
10+
const courseId = route.parent?.paramMap.get("courseId");
11+
const lessonId = Number(route.firstChild?.paramMap.get("lessonId"));
12+
13+
const redirect = (): boolean => {
14+
router.navigateByUrl(`/office/courses/${courseId ?? ""}`);
15+
return false;
16+
};
17+
18+
if (isNaN(lessonId) || !courseId) {
19+
return of(redirect());
20+
}
21+
22+
return coursesRepository.getCourseLesson(lessonId).pipe(
23+
map(lesson => {
24+
if (lesson.progressStatus === "blocked") {
25+
return redirect();
26+
}
27+
return true;
28+
}),
29+
catchError(() => of(redirect())),
30+
);
31+
};

projects/social_platform/src/app/ui/widgets/project-direction-card/project-direction-card.component.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import { CommonModule } from "@angular/common";
44
import {
55
ChangeDetectionStrategy,
6+
ChangeDetectorRef,
67
Component,
78
inject,
89
input,
@@ -57,6 +58,7 @@ export class ProjectDirectionCard implements OnInit, OnDestroy {
5758
private readonly router = inject(Router);
5859
private readonly updateGoalUseCase = inject(UpdateGoalUseCase);
5960
private readonly logger = inject(LoggerService);
61+
private readonly cdr = inject(ChangeDetectorRef);
6062

6163
private subscriptions: Subscription[] = [];
6264

@@ -125,9 +127,10 @@ export class ProjectDirectionCard implements OnInit, OnDestroy {
125127
const projectId = this.route.snapshot.params["projectId"];
126128
const goalId = +this.route.snapshot.queryParams["goalId"];
127129

128-
if (!goalId || !Array.isArray(this.about)) return;
130+
const goals = this.about() as Goal[];
131+
if (!goalId || !Array.isArray(goals)) return;
129132

130-
const goal = this.about.find((g: Goal) => g.id === goalId);
133+
const goal = goals.find((g: Goal) => g.id === goalId);
131134

132135
if (!goal) return;
133136

@@ -147,16 +150,18 @@ export class ProjectDirectionCard implements OnInit, OnDestroy {
147150
}
148151

149152
const response = result.value;
150-
if (Array.isArray(this.about)) {
151-
const index = this.about.findIndex((g: Goal) => g.id === goalId);
153+
const goals = this.about() as Goal[];
154+
if (Array.isArray(goals)) {
155+
const index = goals.findIndex((g: Goal) => g.id === goalId);
152156
if (index !== -1) {
153-
this.about[index] = response;
157+
goals[index] = response;
154158
}
155159
}
156160

157161
this.isShowsConfirmGoal = false;
158162
this.goalCompleteHoverId = null;
159163
this.selectedGoal = null;
164+
this.cdr.markForCheck();
160165

161166
this.router.navigate([], {
162167
queryParams: {},

projects/social_platform/src/app/ui/widgets/specializations-group/specializations-group.component.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@
5858
gap: 5px;
5959

6060
&--open {
61+
position: absolute;
62+
top: 2%;
63+
right: 0%;
6164
z-index: 1000;
6265
width: 40%;
6366
}

projects/social_platform/src/app/ui/widgets/specializations-group/specializations-group.component.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,8 @@ import { CommonModule } from "@angular/common";
44
import {
55
ChangeDetectionStrategy,
66
Component,
7-
EventEmitter,
87
input,
9-
Input,
108
output,
11-
Output,
129
signal,
1310
} from "@angular/core";
1411
import { IconComponent } from "@ui/primitives";

0 commit comments

Comments
 (0)