Skip to content

Commit 76aa224

Browse files
refactor(TeacherProjectService): Move doesAnyComponentHaveWork to NodeAuthoringComponent (#1904)
1 parent b610a42 commit 76aa224

File tree

2 files changed

+7
-17
lines changed

2 files changed

+7
-17
lines changed

src/assets/wise5/authoringTool/node/node-authoring/node-authoring.component.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ export class NodeAuthoringComponent implements OnInit {
212212

213213
private checkIfNeedToShowNodeSaveOrNodeSubmitButtons(): void {
214214
if (!this.projectService.doesAnyComponentInNodeShowSubmitButton(this.nodeId)) {
215-
if (this.projectService.doesAnyComponentHaveWork(this.nodeId)) {
215+
if (this.hasComponentsWithWork()) {
216216
this.nodeJson.showSaveButton = true;
217217
this.nodeJson.showSubmitButton = false;
218218
this.hideAllComponentSaveButtons();
@@ -223,6 +223,12 @@ export class NodeAuthoringComponent implements OnInit {
223223
}
224224
}
225225

226+
private hasComponentsWithWork(): boolean {
227+
return this.node.components.some((component) =>
228+
this.componentServiceLookupService.getService(component.type).componentHasWork(component)
229+
);
230+
}
231+
226232
/**
227233
* Temporarily highlight the specified components and show the component
228234
* authoring views. Used to bring user's attention to new changes.

src/assets/wise5/services/teacherProjectService.ts

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1509,22 +1509,6 @@ export class TeacherProjectService extends ProjectService {
15091509
return component;
15101510
}
15111511

1512-
/**
1513-
* Returns true iff any component in the step generates work
1514-
* @param nodeId the node id
1515-
* @return whether any components in the step generates work
1516-
*/
1517-
doesAnyComponentHaveWork(nodeId) {
1518-
const node = this.getNodeById(nodeId);
1519-
for (const component of node.components) {
1520-
const service = this.componentServiceLookupService.getService(component.type);
1521-
if (service != null && service.componentHasWork(component)) {
1522-
return true;
1523-
}
1524-
}
1525-
return false;
1526-
}
1527-
15281512
/**
15291513
* Check if any of the components in the node are showing their submit button.
15301514
* @param nodeId {string} The node id to check.

0 commit comments

Comments
 (0)