From 527e23cab319ca94b1e5ed8f08e88a402de0f4c9 Mon Sep 17 00:00:00 2001 From: Hiroki Terashima Date: Mon, 13 May 2024 17:39:08 -0700 Subject: [PATCH] refactor(NavItemComponent): Convert to standalone (#1795) --- src/app/student/vle/student-vle.module.ts | 2 +- .../vle/nav-item/nav-item.component.html | 6 +- .../wise5/vle/nav-item/nav-item.component.ts | 103 ++++++++++-------- 3 files changed, 62 insertions(+), 49 deletions(-) diff --git a/src/app/student/vle/student-vle.module.ts b/src/app/student/vle/student-vle.module.ts index 6be029ee21a..07214d01fd8 100644 --- a/src/app/student/vle/student-vle.module.ts +++ b/src/app/student/vle/student-vle.module.ts @@ -42,7 +42,6 @@ import { NodeStatusIconComponent } from '../../../assets/wise5/themes/default/th GenerateImageDialogComponent, GroupTabsComponent, NavigationComponent, - NavItemComponent, NodeNavigationComponent, RunEndedAndLockedMessageComponent, SafeUrl, @@ -55,6 +54,7 @@ import { NodeStatusIconComponent } from '../../../assets/wise5/themes/default/th CommonModule, ComponentStudentModule, MatDialogModule, + NavItemComponent, NodeModule, NodeStatusIconComponent, SimpleDialogModule, diff --git a/src/assets/wise5/vle/nav-item/nav-item.component.html b/src/assets/wise5/vle/nav-item/nav-item.component.html index 8620d1fe62f..de2f70763a3 100644 --- a/src/assets/wise5/vle/nav-item/nav-item.component.html +++ b/src/assets/wise5/vle/nav-item/nav-item.component.html @@ -1,8 +1,8 @@ { + this.dataService.navItemIsExpanded$.subscribe(({ nodeId, isExpanded }) => { if (nodeId === this.nodeId) { this.expanded = isExpanded; } }) ); this.subscriptions.add( - this.StudentDataService.currentNodeChanged$.subscribe( + this.dataService.currentNodeChanged$.subscribe( ({ previousNode: oldNode, currentNode: newNode }) => { this.currentNode = newNode; this.isCurrentNode = this.nodeId === newNode.id; let isPrev = false; - if (this.ProjectService.isApplicationNode(newNode.id)) { + if (this.projectService.isApplicationNode(newNode.id)) { return; } if (oldNode) { isPrev = this.nodeId === oldNode.id; - if (this.StudentDataService.previousStep) { - this.isPrevStep = this.nodeId === this.StudentDataService.previousStep.id; + if (this.dataService.previousStep) { + this.isPrevStep = this.nodeId === this.dataService.previousStep.id; } } if (this.isGroup) { - let prevNodeisGroup = !oldNode || this.ProjectService.isGroupNode(oldNode.id); - let prevNodeIsDescendant = this.ProjectService.isNodeDescendentOfGroup( + let prevNodeisGroup = !oldNode || this.projectService.isGroupNode(oldNode.id); + let prevNodeIsDescendant = this.projectService.isNodeDescendentOfGroup( oldNode, this.item ); @@ -93,7 +106,7 @@ export class NavItemComponent { } } } else { - if (isPrev && this.ProjectService.isNodeDescendentOfGroup(this.item, newNode)) { + if (isPrev && this.projectService.isNodeDescendentOfGroup(this.item, newNode)) { this.zoomToElement(); } } @@ -102,20 +115,20 @@ export class NavItemComponent { ); } - ngOnDestroy() { + ngOnDestroy(): void { this.subscriptions.unsubscribe(); } - setExpanded(): void { + private setExpanded(): void { this.expanded = true; - this.StudentDataService.setNavItemExpanded(this.nodeId, this.expanded); + this.dataService.setNavItemExpanded(this.nodeId, this.expanded); } - zoomToElement() { + private zoomToElement(): void { // TODO: implement me } - itemClicked(event) { + protected itemClicked(): void { if (this.isGroup) { this.expanded = !this.expanded; if (this.expanded) { @@ -125,7 +138,7 @@ export class NavItemComponent { this.nodeService.setCurrentNode(this.nodeId); } } - this.StudentDataService.setNavItemExpanded(this.nodeId, this.expanded); + this.dataService.setNavItemExpanded(this.nodeId, this.expanded); } else { this.nodeService.setCurrentNode(this.nodeId); }