From c6ecce6c6bb86241af23e1823f50d284271e9e70 Mon Sep 17 00:00:00 2001 From: Hiroki Terashima Date: Sat, 7 Oct 2023 19:21:00 -0700 Subject: [PATCH] refactor(NodeAuthoringComponent): Extract NodeAuthoringParentComponent (#1454) --- src/app/teacher/authoring-routing.module.ts | 32 +- src/app/teacher/authoring-tool.module.ts | 2 + ...ode-advanced-branch-authoring.component.ts | 2 +- ...ced-constraint-authoring.component.spec.ts | 2 +- ...advanced-constraint-authoring.component.ts | 2 +- ...de-advanced-general-authoring.component.ts | 2 +- .../node-advanced-json-authoring.component.ts | 2 +- .../node-advanced-authoring.component.html | 2 +- ...-advanced-path-authoring.component.spec.ts | 2 +- .../node-advanced-path-authoring.component.ts | 2 +- .../edit-node-rubric.component.spec.ts | 2 +- .../editRubric/edit-node-rubric.component.ts | 2 +- .../node-authoring-parent.component.html | 1 + .../node-authoring-parent.component.ts | 6 + .../node-authoring.component.html | 463 +++++++++--------- .../node-authoring.component.ts | 20 +- src/messages.xlf | 50 +- 17 files changed, 294 insertions(+), 300 deletions(-) create mode 100644 src/assets/wise5/authoringTool/node/node-authoring-parent/node-authoring-parent.component.html create mode 100644 src/assets/wise5/authoringTool/node/node-authoring-parent/node-authoring-parent.component.ts diff --git a/src/app/teacher/authoring-routing.module.ts b/src/app/teacher/authoring-routing.module.ts index 7260d1f48d4..860caaca2f2 100644 --- a/src/app/teacher/authoring-routing.module.ts +++ b/src/app/teacher/authoring-routing.module.ts @@ -36,6 +36,7 @@ import { ChooseMoveNodeLocationComponent } from '../../assets/wise5/authoringToo import { ChooseCopyNodeLocationComponent } from '../../assets/wise5/authoringTool/choose-node-location/choose-copy-node-location/choose-copy-node-location.component'; import { ProjectAuthoringParentComponent } from '../../assets/wise5/authoringTool/project-authoring-parent/project-authoring-parent.component'; import { ChooseImportUnitComponent } from '../authoring-tool/import-step/choose-import-unit/choose-import-unit.component'; +import { NodeAuthoringParentComponent } from '../../assets/wise5/authoringTool/node/node-authoring-parent/node-authoring-parent.component'; const routes: Routes = [ { @@ -124,8 +125,24 @@ const routes: Routes = [ { path: 'milestones', component: MilestonesAuthoringComponent }, { path: 'node/:nodeId', - component: NodeAuthoringComponent, + component: NodeAuthoringParentComponent, children: [ + { + path: '', + component: NodeAuthoringComponent + }, + { + path: 'advanced', + component: NodeAdvancedAuthoringComponent, + children: [ + { path: 'branch', component: NodeAdvancedBranchAuthoringComponent }, + { path: 'constraint', component: NodeAdvancedConstraintAuthoringComponent }, + { path: 'general', component: NodeAdvancedGeneralAuthoringComponent }, + { path: 'json', component: NodeAdvancedJsonAuthoringComponent }, + { path: 'path', component: NodeAdvancedPathAuthoringComponent }, + { path: 'rubric', component: EditNodeRubricComponent } + ] + }, { path: 'choose-component-location', component: ChooseComponentLocationComponent @@ -136,19 +153,6 @@ const routes: Routes = [ } ] }, - - { - path: 'node/:nodeId/advanced', - component: NodeAdvancedAuthoringComponent, - children: [ - { path: 'branch', component: NodeAdvancedBranchAuthoringComponent }, - { path: 'constraint', component: NodeAdvancedConstraintAuthoringComponent }, - { path: 'general', component: NodeAdvancedGeneralAuthoringComponent }, - { path: 'json', component: NodeAdvancedJsonAuthoringComponent }, - { path: 'path', component: NodeAdvancedPathAuthoringComponent }, - { path: 'rubric', component: EditNodeRubricComponent } - ] - }, { path: 'notebook', component: NotebookAuthoringComponent }, { path: 'recovery', component: RecoveryAuthoringComponent }, { diff --git a/src/app/teacher/authoring-tool.module.ts b/src/app/teacher/authoring-tool.module.ts index bbdf33f7d3e..0bcbb700b54 100644 --- a/src/app/teacher/authoring-tool.module.ts +++ b/src/app/teacher/authoring-tool.module.ts @@ -50,6 +50,7 @@ import { NodeIconAndTitleComponent } from '../../assets/wise5/authoringTool/choo import { NodeWithMoveAfterButtonComponent } from '../../assets/wise5/authoringTool/choose-node-location/node-with-move-after-button/node-with-move-after-button.component'; import { ProjectAuthoringParentComponent } from '../../assets/wise5/authoringTool/project-authoring-parent/project-authoring-parent.component'; import { ChooseImportUnitComponent } from '../authoring-tool/import-step/choose-import-unit/choose-import-unit.component'; +import { NodeAuthoringParentComponent } from '../../assets/wise5/authoringTool/node/node-authoring-parent/node-authoring-parent.component'; @NgModule({ declarations: [ @@ -78,6 +79,7 @@ import { ChooseImportUnitComponent } from '../authoring-tool/import-step/choose- InsertNodeInsideButtonComponent, MilestonesAuthoringComponent, NodeAuthoringComponent, + NodeAuthoringParentComponent, NodeIconChooserDialog, NodeIconAndTitleComponent, NodeWithMoveAfterButtonComponent, diff --git a/src/assets/wise5/authoringTool/node/advanced/branch/node-advanced-branch-authoring.component.ts b/src/assets/wise5/authoringTool/node/advanced/branch/node-advanced-branch-authoring.component.ts index 6a2a38c3595..3f714220e23 100644 --- a/src/assets/wise5/authoringTool/node/advanced/branch/node-advanced-branch-authoring.component.ts +++ b/src/assets/wise5/authoringTool/node/advanced/branch/node-advanced-branch-authoring.component.ts @@ -53,7 +53,7 @@ export class NodeAdvancedBranchAuthoringComponent implements OnInit { ) {} ngOnInit() { - this.route.parent.params.subscribe((params) => { + this.route.parent.parent.params.subscribe((params) => { this.nodeId = params.nodeId; this.node = this.projectService.getNodeById(this.nodeId); this.nodeIds = this.projectService.getFlattenedProjectAsNodeIds(true); diff --git a/src/assets/wise5/authoringTool/node/advanced/constraint/node-advanced-constraint-authoring.component.spec.ts b/src/assets/wise5/authoringTool/node/advanced/constraint/node-advanced-constraint-authoring.component.spec.ts index 534c56a6fb2..cf48d212a40 100644 --- a/src/assets/wise5/authoringTool/node/advanced/constraint/node-advanced-constraint-authoring.component.spec.ts +++ b/src/assets/wise5/authoringTool/node/advanced/constraint/node-advanced-constraint-authoring.component.spec.ts @@ -38,7 +38,7 @@ describe('NodeAdvancedConstraintAuthoringComponent', () => { { provide: ActivatedRoute, useValue: { - parent: { params: of({ nodeId: 'node1' }) } + parent: { parent: { params: of({ nodeId: 'node1' }) } } } } ] diff --git a/src/assets/wise5/authoringTool/node/advanced/constraint/node-advanced-constraint-authoring.component.ts b/src/assets/wise5/authoringTool/node/advanced/constraint/node-advanced-constraint-authoring.component.ts index 9cc14a32de7..b037ceff475 100644 --- a/src/assets/wise5/authoringTool/node/advanced/constraint/node-advanced-constraint-authoring.component.ts +++ b/src/assets/wise5/authoringTool/node/advanced/constraint/node-advanced-constraint-authoring.component.ts @@ -16,7 +16,7 @@ export class NodeAdvancedConstraintAuthoringComponent extends ConstraintsAuthori } ngOnInit() { - this.route.parent.params.subscribe((params) => { + this.route.parent.parent.params.subscribe((params) => { const node = this.projectService.getNodeById(params.nodeId); if (node.constraints == null) { node.constraints = []; diff --git a/src/assets/wise5/authoringTool/node/advanced/general/node-advanced-general-authoring.component.ts b/src/assets/wise5/authoringTool/node/advanced/general/node-advanced-general-authoring.component.ts index 73b08771849..2d32eb85907 100644 --- a/src/assets/wise5/authoringTool/node/advanced/general/node-advanced-general-authoring.component.ts +++ b/src/assets/wise5/authoringTool/node/advanced/general/node-advanced-general-authoring.component.ts @@ -12,7 +12,7 @@ export class NodeAdvancedGeneralAuthoringComponent implements OnInit { constructor(private projectService: TeacherProjectService, private route: ActivatedRoute) {} ngOnInit() { - this.route.parent.params.subscribe((params) => { + this.route.parent.parent.params.subscribe((params) => { this.node = this.projectService.getNodeById(params.nodeId); }); } diff --git a/src/assets/wise5/authoringTool/node/advanced/json/node-advanced-json-authoring.component.ts b/src/assets/wise5/authoringTool/node/advanced/json/node-advanced-json-authoring.component.ts index 85c07e7db17..e5ac7652b4a 100644 --- a/src/assets/wise5/authoringTool/node/advanced/json/node-advanced-json-authoring.component.ts +++ b/src/assets/wise5/authoringTool/node/advanced/json/node-advanced-json-authoring.component.ts @@ -23,7 +23,7 @@ export class NodeAdvancedJsonAuthoringComponent implements OnInit { ) {} ngOnInit() { - this.route.parent.params.subscribe((params) => { + this.route.parent.parent.params.subscribe((params) => { this.nodeId = params.nodeId; this.node = this.projectService.getNodeById(this.nodeId); this.nodeContentJSONString = JSON.stringify(this.node, null, 4); diff --git a/src/assets/wise5/authoringTool/node/advanced/node-advanced-authoring/node-advanced-authoring.component.html b/src/assets/wise5/authoringTool/node/advanced/node-advanced-authoring/node-advanced-authoring.component.html index c574e21dfd5..19514995cf2 100644 --- a/src/assets/wise5/authoringTool/node/advanced/node-advanced-authoring/node-advanced-authoring.component.html +++ b/src/assets/wise5/authoringTool/node/advanced/node-advanced-authoring/node-advanced-authoring.component.html @@ -2,7 +2,7 @@ - - - +
+
+ + + Step Title {{ nodePosition }}: + Activity Title {{ nodePosition }}: + + +
+
- + + +
+ + + +
+
Components
+ +
+ + +
+ +
+ + - +
+
+
+
+ This step does not have any components. Click the + button to add a component. +
+
+
-
Components
- -
- - - -
- -
- - -
-
-
-
- This step does not have any components. Click the + button to add a component. -
-
-
-
-
-
-
- drag_indicator - - {{ i + 1 }}. {{ getComponentTypeLabel(component.type) }} - -
- -
- - - - -
-
-
- expand_more -
-
- expand_less -
-
+
-
- +
+ +
-
-
- + [componentId]="component.id" + > + + + +
+
+ expand_more +
+
+ expand_less +
+
+ +
+
+ +
diff --git a/src/assets/wise5/authoringTool/node/node-authoring/node-authoring.component.ts b/src/assets/wise5/authoringTool/node/node-authoring/node-authoring.component.ts index 6979023abcf..0e7ad700ecb 100644 --- a/src/assets/wise5/authoringTool/node/node-authoring/node-authoring.component.ts +++ b/src/assets/wise5/authoringTool/node/node-authoring/node-authoring.component.ts @@ -14,7 +14,7 @@ import { EditComponentAdvancedComponent } from '../../../../../app/authoring-too import { Component as WiseComponent } from '../../../common/Component'; import { ChooseNewComponent } from '../../../../../app/authoring-tool/add-component/choose-new-component/choose-new-component.component'; import { CdkDragDrop, moveItemInArray } from '@angular/cdk/drag-drop'; -import { ActivatedRoute, NavigationEnd, Router } from '@angular/router'; +import { ActivatedRoute, Router } from '@angular/router'; @Component({ selector: 'node-authoring', @@ -32,7 +32,6 @@ export class NodeAuthoringComponent implements OnInit { nodeId: string; nodePosition: any; projectId: number; - showNodeView: boolean = true; subscriptions: Subscription = new Subscription(); constructor( @@ -45,14 +44,9 @@ export class NodeAuthoringComponent implements OnInit { private dataService: TeacherDataService, private route: ActivatedRoute, private router: Router - ) { - this.router.events - .pipe(filter((event) => event instanceof NavigationEnd)) - .subscribe(() => this.updateShowNodeView()); - } + ) {} ngOnInit(): void { - this.updateShowNodeView(); this.nodeId = this.route.snapshot.paramMap.get('nodeId'); this.route.parent.params.subscribe((params) => { this.projectId = Number(params.unitId); @@ -82,12 +76,6 @@ export class NodeAuthoringComponent implements OnInit { } } - private updateShowNodeView(): void { - this.showNodeView = /\/teacher\/edit\/unit\/(\d*)\/node\/(node|group)(\d*)$/.test( - this.router.url - ); - } - ngOnDestroy(): void { this.subscriptions.unsubscribe(); } @@ -189,10 +177,6 @@ export class NodeAuthoringComponent implements OnInit { return this.projectService.saveProject(); } - protected showAdvancedView(): void { - this.router.navigate([`/teacher/edit/unit/${this.projectId}/node/${this.nodeId}/advanced`]); - } - protected getSelectedComponents(): ComponentContent[] { return this.components.filter( (component: ComponentContent) => this.componentsToChecked[component.id] diff --git a/src/messages.xlf b/src/messages.xlf index aa83700b406..c19dd018668 100644 --- a/src/messages.xlf +++ b/src/messages.xlf @@ -1150,7 +1150,7 @@ Click "Cancel" to keep the invalid JSON open so you can fix it. src/assets/wise5/authoringTool/node/node-authoring/node-authoring.component.html - 163 + 161 src/assets/wise5/components/common/feedbackRule/edit-feedback-rules/edit-feedback-rules.component.html @@ -1474,7 +1474,7 @@ Click "Cancel" to keep the invalid JSON open so you can fix it. src/assets/wise5/authoringTool/node/node-authoring/node-authoring.component.html - 36 + 34 @@ -11425,21 +11425,21 @@ Click "Cancel" to keep the invalid JSON open so you can fix it.Step Title : src/assets/wise5/authoringTool/node/node-authoring/node-authoring.component.html - 7 + 5 Activity Title : src/assets/wise5/authoringTool/node/node-authoring/node-authoring.component.html - 8 + 6 Title src/assets/wise5/authoringTool/node/node-authoring/node-authoring.component.html - 14 + 12 src/assets/wise5/authoringTool/notebook-authoring/notebook-authoring.component.html @@ -11466,11 +11466,11 @@ Click "Cancel" to keep the invalid JSON open so you can fix it.Advanced src/assets/wise5/authoringTool/node/node-authoring/node-authoring.component.html - 23 + 21 src/assets/wise5/authoringTool/node/node-authoring/node-authoring.component.html - 192 + 190 src/assets/wise5/authoringTool/project-authoring/project-authoring.component.html @@ -11481,98 +11481,98 @@ Click "Cancel" to keep the invalid JSON open so you can fix it.Back to unit src/assets/wise5/authoringTool/node/node-authoring/node-authoring.component.html - 47 + 45 Add a new component src/assets/wise5/authoringTool/node/node-authoring/node-authoring.component.html - 58 + 56 Components src/assets/wise5/authoringTool/node/node-authoring/node-authoring.component.html - 73 + 71 Move Components src/assets/wise5/authoringTool/node/node-authoring/node-authoring.component.html - 82 + 80 Copy Components src/assets/wise5/authoringTool/node/node-authoring/node-authoring.component.html - 92 + 90 Delete Components src/assets/wise5/authoringTool/node/node-authoring/node-authoring.component.html - 102 + 100 - + + Expand All src/assets/wise5/authoringTool/node/node-authoring/node-authoring.component.html - 117,119 + 115,117 - + - Collapse All src/assets/wise5/authoringTool/node/node-authoring/node-authoring.component.html - 126,128 + 124,126 This step does not have any components. Click the + button to add a component. src/assets/wise5/authoringTool/node/node-authoring/node-authoring.component.html - 133 + 131 Toggle component authoring src/assets/wise5/authoringTool/node/node-authoring/node-authoring.component.html - 155 + 153 Select component src/assets/wise5/authoringTool/node/node-authoring/node-authoring.component.html - 172 + 170 Click to expand/collapse src/assets/wise5/authoringTool/node/node-authoring/node-authoring.component.html - 183 + 181 Copy Component src/assets/wise5/authoringTool/node/node-authoring/node-authoring.component.html - 214 + 212 Delete Component src/assets/wise5/authoringTool/node/node-authoring/node-authoring.component.html - 228 + 226 @@ -11580,7 +11580,7 @@ Click "Cancel" to keep the invalid JSON open so you can fix it. src/assets/wise5/authoringTool/node/node-authoring/node-authoring.component.ts - 274 + 258 @@ -11588,7 +11588,7 @@ Click "Cancel" to keep the invalid JSON open so you can fix it. src/assets/wise5/authoringTool/node/node-authoring/node-authoring.component.ts - 275 + 259