Skip to content

Commit

Permalink
feat(Authoring): Only allow certain add options for branch steps
Browse files Browse the repository at this point in the history
  • Loading branch information
geoffreykwan committed Jun 12, 2024
1 parent 9b8ca71 commit 9b789f6
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,17 @@
<mat-icon>add_circle</mat-icon>
</button>
<mat-menu #step="matMenu">
@if(!branchMergePoint) {
<button mat-menu-item (click)="addStepBefore()">
<mat-icon>add_circle</mat-icon><span i18n>Add step before</span>
</button>
} @if(!branchPoint) {
<button mat-menu-item (click)="goToAddStepViewForAfter(nodeId)">
<mat-icon>add_circle</mat-icon><span i18n>Add step after</span>
</button>
} @if(!branchPoint && !branchPathStep) {
<button mat-menu-item (click)="goToAddBranchView()">
<mat-icon>add_circle</mat-icon><span i18n>Branch off this step</span>
</button>
}
</mat-menu>
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ import { AddStepTarget } from '../../../../app/domain/addStepTarget';
imports: [CommonModule, MatButtonModule, MatIconModule, MatMenuModule, MatTooltipModule]
})
export class AddStepButtonComponent {
protected branchMergePoint: boolean;
protected branchPathStep: boolean;
protected branchPoint: boolean;
@Input() nodeId: string;

constructor(
Expand All @@ -23,6 +26,12 @@ export class AddStepButtonComponent {
private router: Router
) {}

ngOnInit(): void {
this.branchPoint = this.projectService.isBranchPoint(this.nodeId);
this.branchPathStep = this.projectService.isNodeInAnyBranchPath(this.nodeId);
this.branchMergePoint = this.projectService.isBranchMergePoint(this.nodeId);
}

protected addStepBefore(): void {
const previousNodes = this.projectService.getNodesByToNodeId(this.nodeId);
if (previousNodes.length === 0) {
Expand Down
2 changes: 1 addition & 1 deletion src/assets/wise5/services/projectService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1422,7 +1422,7 @@ export class ProjectService {
* @param nodeId look for a branch with this end node id
* @return whether the node is a branch end point
*/
private isBranchMergePoint(nodeId: string): boolean {
isBranchMergePoint(nodeId: string): boolean {
return this.getBranches().some((branch) => branch.endPoint === nodeId);
}

Expand Down
6 changes: 3 additions & 3 deletions src/messages.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -9295,21 +9295,21 @@ Click &quot;Cancel&quot; to keep the invalid JSON open so you can fix it.</sourc
<source>Add step before</source>
<context-group purpose="location">
<context context-type="sourcefile">src/assets/wise5/authoringTool/add-step-button/add-step-button.component.html</context>
<context context-type="linenumber">14</context>
<context context-type="linenumber">15</context>
</context-group>
</trans-unit>
<trans-unit id="d59263511cd8dbe0a1eb9bd829aac8d827d8fd83" datatype="html">
<source>Add step after</source>
<context-group purpose="location">
<context context-type="sourcefile">src/assets/wise5/authoringTool/add-step-button/add-step-button.component.html</context>
<context context-type="linenumber">17</context>
<context context-type="linenumber">19</context>
</context-group>
</trans-unit>
<trans-unit id="66a796ca959149529fa803f5ffa9cad29b5c5c5a" datatype="html">
<source>Branch off this step</source>
<context-group purpose="location">
<context context-type="sourcefile">src/assets/wise5/authoringTool/add-step-button/add-step-button.component.html</context>
<context context-type="linenumber">20</context>
<context context-type="linenumber">23</context>
</context-group>
</trans-unit>
<trans-unit id="8608bcf1ea8ff554000e0ac4337e7afd3cf5c3f3" datatype="html">
Expand Down

0 comments on commit 9b789f6

Please sign in to comment.