Skip to content

Commit

Permalink
refactor(NodeAuthoringComponent): Extract NodeAuthoringParentComponent (
Browse files Browse the repository at this point in the history
  • Loading branch information
hirokiterashima authored Oct 8, 2023
1 parent 44a0995 commit c6ecce6
Show file tree
Hide file tree
Showing 17 changed files with 294 additions and 300 deletions.
32 changes: 18 additions & 14 deletions src/app/teacher/authoring-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
{
Expand Down Expand Up @@ -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
Expand All @@ -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 },
{
Expand Down
2 changes: 2 additions & 0 deletions src/app/teacher/authoring-tool.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand Down Expand Up @@ -78,6 +79,7 @@ import { ChooseImportUnitComponent } from '../authoring-tool/import-step/choose-
InsertNodeInsideButtonComponent,
MilestonesAuthoringComponent,
NodeAuthoringComponent,
NodeAuthoringParentComponent,
NodeIconChooserDialog,
NodeIconAndTitleComponent,
NodeWithMoveAfterButtonComponent,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ describe('NodeAdvancedConstraintAuthoringComponent', () => {
{
provide: ActivatedRoute,
useValue: {
parent: { params: of({ nodeId: 'node1' }) }
parent: { parent: { params: of({ nodeId: 'node1' }) } }
}
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<button
mat-raised-button
color="primary"
[routerLink]="['/teacher/edit/unit', projectId, 'node', nodeId]"
routerLink=".."
matTooltip="Back"
matTooltipPosition="above"
i18n-matTooltip
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe('NodeAdvancedPathAuthoringComponent', () => {
{
provide: ActivatedRoute,
useValue: {
parent: { params: of({ nodeId: 'node1' }) }
parent: { parent: { params: of({ nodeId: 'node1' }) } }
}
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export class NodeAdvancedPathAuthoringComponent 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);
this.nodeIds = this.projectService.getFlattenedProjectAsNodeIds(true);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ describe('EditNodeRubricComponent', () => {
{
provide: ActivatedRoute,
useValue: {
parent: { params: of({ nodeId: 'node1' }) }
parent: { parent: { params: of({ nodeId: 'node1' }) } }
}
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class EditNodeRubricComponent implements OnInit {
) {}

ngOnInit(): void {
this.route.parent.params.subscribe((params) => {
this.route.parent.parent.params.subscribe((params) => {
this.node = this.projectService.getNodeById(params.nodeId);
this.rubric = this.projectService.replaceAssetPaths(replaceWiseLinks(this.node.rubric));
});
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<router-outlet></router-outlet>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { Component } from '@angular/core';

@Component({
templateUrl: './node-authoring-parent.component.html'
})
export class NodeAuthoringParentComponent {}
Loading

0 comments on commit c6ecce6

Please sign in to comment.