Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(NodeService): Clean up getPrevNodeId() for AT/CM modes #1496

Merged
merged 1 commit into from
Oct 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 8 additions & 23 deletions src/assets/wise5/services/nodeService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,33 +88,18 @@ export class NodeService {
* Get the previous node in the project sequence
* @param currentId (optional)
*/
getPrevNodeId(currentId?) {
getPrevNodeId(currentId?: string): string {
let prevNodeId = null;
let currentNodeId = null;
const mode = this.ConfigService.getMode();
if (currentId) {
currentNodeId = currentId;
} else {
let currentNode = null;
currentNode = this.DataService.getCurrentNode();
if (currentNode) {
currentNodeId = currentNode.id;
}
}
const currentNodeId = currentId ?? this.DataService.getCurrentNodeId();
if (currentNodeId) {
if (['classroomMonitor', 'author'].includes(mode)) {
let currentNodeOrder = this.ProjectService.getNodeOrderById(currentNodeId);
if (['author', 'classroomMonitor'].includes(this.ConfigService.getMode())) {
const currentNodeOrder = this.ProjectService.getNodeOrderById(currentNodeId);
if (currentNodeOrder) {
let prevNodeOrder = currentNodeOrder - 1;
let prevId = this.ProjectService.getNodeIdByOrder(prevNodeOrder);
const prevId = this.ProjectService.getNodeIdByOrder(currentNodeOrder - 1);
if (prevId) {
if (this.ProjectService.isApplicationNode(prevId)) {
// node is a step, so set it as the next node
prevNodeId = prevId;
} else if (this.ProjectService.isGroupNode(prevId)) {
// node is an activity, so get next nodeId
prevNodeId = this.getPrevNodeId(prevId);
}
prevNodeId = this.ProjectService.isApplicationNode(prevId)
? prevId
: this.getPrevNodeId(prevId);
}
}
} else {
Expand Down
Loading